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"
948 local mdts=$(get_facets MDS)
954 for mds in ${mdts//,/ }; do
957 dev=$(basename $(do_facet $mds "lctl get_param -n \
958 osd*.${!varsvc}.mntdev | xargs readlink -f"))
959 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
960 2>/dev/null | head -n1")
967 # commit on sharing tests
969 remote_mds_nodsh && skip "remote MDS with nodsh" && return
971 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
972 [ $CLIENTCOUNT -lt 2 ] &&
973 skip "Need two or more clients, have $CLIENTCOUNT"
975 local nfiles=${TEST33_NFILES:-10000}
976 local param_file=$TMP/$tfile-params
982 save_lustre_params $(get_facets MDS) \
983 "mdt.*.commit_on_sharing" > $param_file
986 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
990 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
992 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
993 echo "=== START createmany old: $jbdold transaction"
994 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")
995 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
996 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
997 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
998 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
999 avgtime=$(( avgtime + elapsed ))
1001 eval cos${COS}_jbd=$((avgjbd / 3))
1002 eval cos${COS}_time=$((avgtime / 3))
1005 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1006 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1007 [ "$cos0_jbd" != 0 ] &&
1008 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1009 [ "$cos0_time" != 0 ] &&
1010 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1012 restore_lustre_params < $param_file
1016 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1018 # commit on sharing tests
1020 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1022 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1023 [ $CLIENTCOUNT -ge 2 ] ||
1024 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1026 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1028 local nfiles=${TEST33_NFILES:-10000}
1029 local param_file=$TMP/$tfile-params
1031 save_lustre_params $(get_facets MDS) \
1032 "mdt.*.commit_on_sharing" > $param_file
1041 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1045 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1046 $DIR1/$tdir-\\\$(hostname)-$i"
1048 jbdold=$(print_jbd_stat)
1049 echo "=== START createmany old: $jbdold transaction"
1050 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1051 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1052 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1054 jbdnew=$(print_jbd_stat)
1055 jbd=$(( jbdnew - jbdold ))
1056 echo "=== END createmany new: $jbdnew transaction : \
1057 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1058 avgjbd=$(( avgjbd + jbd ))
1059 avgtime=$(( avgtime + elapsed ))
1061 eval cos${COS}_jbd=$((avgjbd / 3))
1062 eval cos${COS}_time=$((avgtime / 3))
1065 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1066 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1067 [ "$cos0_jbd" != 0 ] &&
1068 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1069 [ "$cos0_time" != 0 ] &&
1070 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1072 restore_lustre_params < $param_file
1076 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1079 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1080 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1081 skip "DNE CoS not supported"
1085 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1089 mkdir_on_mdt0 $DIR/$tdir
1091 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1092 # do twice in case transaction is committed before unlock, see LU-8200
1094 # remote dir is created on MDT1, which enqueued lock of $tdir on
1096 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1097 mkdir $DIR/$tdir/local.$i
1099 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1100 echo "sync_count $sync_count"
1101 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1104 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1105 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1106 # during sleep remote mkdir should have been committed and canceled
1107 # remote lock spontaneously, which shouldn't trigger sync
1109 mkdir $DIR/$tdir/local.3
1110 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1111 echo "sync_count $sync_count"
1112 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1114 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1116 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1120 local nodes=$(comma_list $(mdts_nodes))
1124 # trigger CoS twice in case transaction commit before unlock
1127 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1129 commit_nr=$(do_nodes $nodes \
1130 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1131 total=$((total + commit_nr));
1136 echo "CoS count $total"
1137 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1141 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1142 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1143 skip "DNE CoS not supported"
1145 # remote directory create
1146 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1147 # remote directory unlink
1148 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1149 # striped directory create
1150 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1151 # striped directory setattr
1152 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1153 "chmod 713 $DIR/$tdir"
1154 # striped directory unlink
1155 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1158 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1159 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1160 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1161 touch $DIR/$tdir/d1/tgt" \
1162 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1164 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1165 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1166 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1167 touch $DIR/$tdir/d1/src" \
1168 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1170 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1171 "$LFS migrate -m 1 $DIR/$tdir"
1175 run_test 33d "DNE distributed operation should trigger COS"
1178 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1179 [ $CLIENTCOUNT -ge 2 ] ||
1180 skip "Need two or more clients, have $CLIENTCOUNT"
1181 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1182 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1183 skip "DNE CoS not supported"
1185 local client2=${CLIENT2:-$(hostname)}
1189 local nodes=$(comma_list $(mdts_nodes))
1190 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1192 $LFS mkdir -c 2 $DIR/$tdir
1193 mkdir $DIR/$tdir/subdir
1194 echo abc > $DIR/$tdir/$tfile
1195 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1196 do_node $client2 touch $DIR/$tdir/subdir
1198 local async_commit_count=$(do_nodes $nodes \
1199 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1200 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1204 run_test 33e "DNE local operation shouldn't trigger COS"
1206 # End commit on sharing tests
1208 get_ost_lock_timeouts() {
1209 local nodes=${1:-$(comma_list $(osts_nodes))}
1211 local locks=$(do_nodes $nodes \
1212 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1220 do_nodes $(comma_list $(osts_nodes)) \
1221 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1222 for i in $(seq $OSTCOUNT); do
1223 wait_osc_import_ready client ost$i
1228 remote_ost_nodsh && skip "remote OST with nodsh" && return
1232 trap cleanup_34 EXIT RETURN
1233 for OPER in notimeout timeout ; do
1234 rm $DIR1/$tfile 2>/dev/null
1235 lock_in=$(get_ost_lock_timeouts)
1236 if [ $OPER == "timeout" ] ; then
1237 for j in `seq $OSTCOUNT`; do
1238 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1239 do_facet ost$j lctl set_param fail_loc=0x511
1241 echo lock should expire
1243 for j in `seq $OSTCOUNT`; do
1244 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1245 do_facet ost$j lctl set_param fail_loc=0x512
1247 echo lock should not expire
1249 echo writing on client1
1250 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1252 echo reading on client2
1253 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1254 # wait for a lock timeout
1256 lock_out=$(get_ost_lock_timeouts)
1257 if [ $OPER == "timeout" ] ; then
1258 if [ $lock_in == $lock_out ]; then
1259 error "no lock timeout happened"
1264 if [ $lock_in != $lock_out ]; then
1265 error "lock timeout happened"
1273 run_test 34 "no lock timeout under IO"
1275 test_35() { # bug 17645
1278 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1279 awk '/generation/{print $2}')
1281 generation[count]=$g
1285 test_mkdir $MOUNT1/$tdir
1286 cancel_lru_locks mdc
1288 # Let's initiate -EINTR situation by setting fail_loc and take
1289 # write lock on same file from same client. This will not cause
1290 # bl_ast yet as lock is already in local cache.
1291 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1292 do_facet client "lctl set_param fail_loc=0x80000317"
1293 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1294 let timeout=timeout*3
1296 while test $nr -lt 10; do
1297 log "Race attempt $nr"
1298 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1299 awk '/ldlm_bl_callback/ { print $2 }')
1300 test "x$blk1" = "x" && blk1=0
1301 createmany -o $MOUNT2/$tdir/a 4000 &
1305 # Let's make conflict and bl_ast
1306 ls -la $MOUNT1/$tdir > /dev/null &
1309 log "Wait for $pid1 $pid2 for $timeout sec..."
1311 kill -9 $pid1 $pid2 > /dev/null 2>&1
1313 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1314 awk '/ldlm_bl_callback/ { print $2 }')
1315 test "x$blk2" = "x" && blk2=0
1316 test $blk2 -gt $blk1 && break
1317 rm -fr $MOUNT1/$tdir
1318 cancel_lru_locks mdc
1321 do_facet client "lctl set_param fail_loc=0x0"
1322 df -h $MOUNT1 $MOUNT2
1324 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1325 awk '/generation/{print $2}')
1327 if ! test "$g" -eq "${generation[count]}"; then
1328 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1330 for imp in $list; do
1331 if [ $c = $count ]; then
1336 imp=$(echo "$imp" | awk -F"." '{print $2}')
1337 error "Eviction happened on import $imp"
1342 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1344 test_36() { #bug 16417
1349 test_mkdir $DIR1/$tdir
1350 $LFS setstripe -c -1 $DIR1/$tdir
1353 let SIZE_B=SIZE*1024*1024
1354 sync; sleep 2; sync # wait for delete thread
1355 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1356 wait_destroy_complete || error "wait_destroy_complete failed"
1358 while [ $i -le 10 ]; do
1359 lctl mark "start test - cycle ($i)"
1360 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1361 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1362 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1363 sync # sync data from client cache
1364 sync_all_data # sync data from server cache (delayed allocation)
1366 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1367 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1369 rm -f $DIR1/$tdir/$tfile
1370 kill -USR1 $read_pid
1372 sync; sleep 2; sync # Ensure new statfs
1373 wait_delete_completed
1374 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1375 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1377 # this free space! not used
1378 (( $after_dd <= $after)) ||
1379 error "space leaked after_dd:$after_dd > after:$after"
1383 run_test 36 "handle ESTALE/open-unlink correctly"
1385 test_37() { # bug 18695
1386 test_mkdir $DIR1/$tdir
1387 multiop_bg_pause $DIR1/$tdir D_c || return 1
1389 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1390 createmany -m $DIR2/$tdir/f 10000
1391 # set mtime/atime backward
1392 touch -t 198001010000 $DIR2/$tdir
1393 kill -USR1 $MULTIPID
1394 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1395 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1398 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1400 # this should be set to past
1401 TEST_39_MTIME=`date -d "1 year ago" +%s`
1405 local client1=${CLIENT1:-`hostname`}
1406 local client2=${CLIENT2:-`hostname`}
1408 do_node $client1 "touch $DIR1/$tfile"
1410 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1411 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1412 [ "$mtime1" = $TEST_39_MTIME ] || \
1413 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1415 local d1=`do_node $client1 date +%s`
1416 do_node $client1 'echo hello >> '$DIR1/$tfile
1417 local d2=`do_node $client1 date +%s`
1419 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1420 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1421 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1423 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1425 for (( i=0; i < 2; i++ )) ; do
1426 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1427 [ "$mtime2" = "$mtime3" ] || \
1428 error "mtime ($mtime2) changed (to $mtime3) on rename"
1430 cancel_lru_locks osc
1431 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1434 run_test 39a "test from 11063 =================================="
1437 local client1=${CLIENT1:-`hostname`}
1438 local client2=${CLIENT2:-`hostname`}
1442 local mtime1=`stat -c %Y $DIR1/$tfile`
1443 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1446 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1448 for (( i=0; i < 2; i++ )) ; do
1449 local mtime3=`stat -c %Y $DIR1/$tfile`
1450 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1452 [ "$mtime3" = "$mtime4" ] || \
1453 error "different mtime on clients: $mtime3, $mtime4"
1454 [ "$mtime3" = $TEST_39_MTIME ] || \
1455 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1457 cancel_lru_locks osc
1458 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1461 run_test 39b "11063 problem 1 =================================="
1464 local client1=${CLIENT1:-`hostname`}
1465 local client2=${CLIENT2:-`hostname`}
1467 echo hello > $DIR1/$tfile
1469 local mtime1=`stat -c %Y $DIR1/$tfile`
1470 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1471 [ "$mtime1" = "$mtime2" ] || \
1472 error "create: different mtime on clients: $mtime1, $mtime2"
1475 $TRUNCATE $DIR1/$tfile 1
1477 for (( i=0; i < 2; i++ )) ; do
1478 local mtime3=`stat -c %Y $DIR1/$tfile`
1479 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1481 [ "$mtime3" = "$mtime4" ] || \
1482 error "different mtime on clients: $mtime3, $mtime4"
1483 [ "$mtime3" -gt $mtime2 ] || \
1484 error "truncate did not update mtime: $mtime2, $mtime3"
1486 cancel_lru_locks osc
1487 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1490 run_test 39c "check truncate mtime update ======================"
1492 test_39d() { # LU-7310
1494 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1496 local mtime1=$(stat -c %Y $DIR2/$tfile)
1497 [ "$mtime1" = $TEST_39_MTIME ] ||
1498 error "mtime: $mtime1, should be $TEST_39_MTIME"
1501 # define OBD_FAIL_OSC_NO_GRANT 0x411
1502 $LCTL set_param fail_loc=0x411
1504 local d1=$(date +%s)
1505 echo hello >> $DIR1/$tfile
1506 local d2=$(date +%s)
1508 $LCTL set_param fail_loc=0
1510 cancel_lru_locks $OSC
1512 local mtime2=$(stat -c %Y $DIR2/$tfile)
1513 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1514 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1516 run_test 39d "sync write should update mtime"
1519 # how long 40-47 take with specific delay
1526 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1527 # avoid unexpected delays due to previous tests
1529 cancel_lru_locks mdc
1530 do_nodes $(comma_list $(mdts_nodes)) \
1531 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1532 do_nodes $(comma_list $(mdts_nodes)) \
1533 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1534 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1537 # check that pid exists hence second operation wasn't blocked by first one
1538 # if it is so then there is no conflict, return 0
1539 # else second operation is conflicting with first one, return 1
1540 check_pdo_conflict() {
1543 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1544 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1554 # test 40: check non-blocking operations
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1558 mkdir_on_mdt0 $DIR2/$tdir
1560 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1561 do_nodes $(comma_list $(mdts_nodes)) \
1562 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1563 mkdir $DIR1/$tdir/$tfile &
1565 touch $DIR2/$tdir/$tfile-2
1566 check_pdo_conflict $PID1 || error "create is blocked"
1567 mkdir $DIR2/$tdir/$tfile-3
1568 check_pdo_conflict $PID1 || error "mkdir is blocked"
1569 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1570 check_pdo_conflict $PID1 || error "link is blocked"
1571 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1572 check_pdo_conflict $PID1 || error "rename is blocked"
1573 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1574 check_pdo_conflict $PID1 || error "getattr is blocked"
1575 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1576 rmdir $DIR2/$tdir/$tfile-3
1577 check_pdo_conflict $PID1 || error "unlink is blocked"
1579 # all operations above shouldn't wait the first one
1580 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1581 do_nodes $(comma_list $(mdts_nodes)) \
1582 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1587 run_test 40a "pdirops: create vs others =============="
1590 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1592 mkdir_on_mdt0 $DIR2/$tdir
1594 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1595 do_nodes $(comma_list $(mdts_nodes)) \
1596 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1597 touch $DIR1/$tdir/$tfile &
1600 touch $DIR2/$tdir/$tfile-2
1601 check_pdo_conflict $PID1 || error "create is blocked"
1602 mkdir $DIR2/$tdir/$tfile-3
1603 check_pdo_conflict $PID1 || error "mkdir is blocked"
1604 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1605 check_pdo_conflict $PID1 || error "link is blocked"
1606 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1607 check_pdo_conflict $PID1 || error "rename is blocked"
1608 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1609 check_pdo_conflict $PID1 || error "getattr is blocked"
1610 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1611 rmdir $DIR2/$tdir/$tfile-3
1612 check_pdo_conflict $PID1 || error "unlink is blocked"
1613 # all operations above shouldn't wait the first one
1615 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1616 do_nodes $(comma_list $(mdts_nodes)) \
1617 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1622 run_test 40b "pdirops: open|create and others =============="
1625 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1627 mkdir_on_mdt0 $DIR2/$tdir
1629 touch $DIR1/$tdir/$tfile
1630 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1631 do_nodes $(comma_list $(mdts_nodes)) \
1632 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1633 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1636 touch $DIR2/$tdir/$tfile-2
1637 check_pdo_conflict $PID1 || error "create is blocked"
1638 mkdir $DIR2/$tdir/$tfile-3
1639 check_pdo_conflict $PID1 || error "mkdir is blocked"
1640 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1641 check_pdo_conflict $PID1 || error "link is blocked"
1642 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1643 check_pdo_conflict $PID1 || error "rename is blocked"
1644 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1645 check_pdo_conflict $PID1 || error "getattr is blocked"
1646 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1647 rmdir $DIR2/$tdir/$tfile-3
1648 check_pdo_conflict $PID1 || error "unlink is blocked"
1650 # all operations above shouldn't wait the first one
1651 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1652 do_nodes $(comma_list $(mdts_nodes)) \
1653 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1658 run_test 40c "pdirops: link and others =============="
1661 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1663 mkdir_on_mdt0 $DIR2/$tdir
1665 touch $DIR1/$tdir/$tfile
1666 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1667 do_nodes $(comma_list $(mdts_nodes)) \
1668 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1669 rm $DIR1/$tdir/$tfile &
1672 touch $DIR2/$tdir/$tfile-2
1673 check_pdo_conflict $PID1 || error "create is blocked"
1674 mkdir $DIR2/$tdir/$tfile-3
1675 check_pdo_conflict $PID1 || error "mkdir is blocked"
1676 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1677 check_pdo_conflict $PID1 || error "link is blocked"
1678 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1679 check_pdo_conflict $PID1 || error "rename is blocked"
1680 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1681 check_pdo_conflict $PID1 || error "getattr is blocked"
1682 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1683 rmdir $DIR2/$tdir/$tfile-3
1684 check_pdo_conflict $PID1 || error "unlink is blocked"
1686 # all operations above shouldn't wait the first one
1687 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1688 do_nodes $(comma_list $(mdts_nodes)) \
1689 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1693 run_test 40d "pdirops: unlink and others =============="
1696 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1698 mkdir_on_mdt0 $DIR2/$tdir
1700 touch $DIR1/$tdir/$tfile
1701 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1702 do_nodes $(comma_list $(mdts_nodes)) \
1703 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1704 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1707 touch $DIR2/$tdir/$tfile-2
1708 check_pdo_conflict $PID1 || error "create is blocked"
1709 mkdir $DIR2/$tdir/$tfile-3
1710 check_pdo_conflict $PID1 || error "mkdir is blocked"
1711 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1712 check_pdo_conflict $PID1 || error "link is blocked"
1713 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1714 check_pdo_conflict $PID1 || error "getattr is blocked"
1715 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1716 rmdir $DIR2/$tdir/$tfile-3
1717 check_pdo_conflict $PID1 || error "unlink is blocked"
1719 # all operations above shouldn't wait the first one
1720 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1721 do_nodes $(comma_list $(mdts_nodes)) \
1722 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1727 run_test 40e "pdirops: rename and others =============="
1729 # test 41: create blocking operations
1732 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1733 do_nodes $(comma_list $(mdts_nodes)) \
1734 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1735 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1737 mkdir $DIR2/$tfile &
1739 do_nodes $(comma_list $(mdts_nodes)) \
1740 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1741 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1742 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1746 run_test 41a "pdirops: create vs mkdir =============="
1750 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1751 do_nodes $(comma_list $(mdts_nodes)) \
1752 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1753 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1755 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1757 do_nodes $(comma_list $(mdts_nodes)) \
1758 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1760 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1764 run_test 41b "pdirops: create vs create =============="
1768 touch $DIR1/$tfile-2
1769 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1770 do_nodes $(comma_list $(mdts_nodes)) \
1771 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1772 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1774 link $DIR2/$tfile-2 $DIR2/$tfile &
1776 do_nodes $(comma_list $(mdts_nodes)) \
1777 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1778 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1779 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1783 run_test 41c "pdirops: create vs link =============="
1787 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1788 do_nodes $(comma_list $(mdts_nodes)) \
1789 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1790 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1794 do_nodes $(comma_list $(mdts_nodes)) \
1795 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1796 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1797 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1801 run_test 41d "pdirops: create vs unlink =============="
1805 touch $DIR1/$tfile-2
1806 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1807 do_nodes $(comma_list $(mdts_nodes)) \
1808 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1809 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1811 mv $DIR2/$tfile-2 $DIR2/$tfile &
1813 do_nodes $(comma_list $(mdts_nodes)) \
1814 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1815 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1816 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1820 run_test 41e "pdirops: create and rename (tgt) =============="
1824 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1825 do_nodes $(comma_list $(mdts_nodes)) \
1826 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1827 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1829 mv $DIR2/$tfile $DIR2/$tfile-2 &
1831 do_nodes $(comma_list $(mdts_nodes)) \
1832 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1833 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1834 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1838 run_test 41f "pdirops: create and rename (src) =============="
1842 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1843 do_nodes $(comma_list $(mdts_nodes)) \
1844 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1845 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1847 stat $DIR2/$tfile > /dev/null &
1849 do_nodes $(comma_list $(mdts_nodes)) \
1850 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1851 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1852 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1856 run_test 41g "pdirops: create vs getattr =============="
1860 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1861 do_nodes $(comma_list $(mdts_nodes)) \
1862 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1863 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1865 ls -lia $DIR2/ > /dev/null &
1867 do_nodes $(comma_list $(mdts_nodes)) \
1868 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1869 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1874 run_test 41h "pdirops: create vs readdir =============="
1881 do_nodes $(comma_list $(mdts_nodes)) \
1882 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1884 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1887 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1890 if ! wait $PID1 && ! wait $PID2; then
1891 echo "Both creates failed (1 should fail, 1 should succeed)"
1893 elif wait $PID1 && wait $PID2; then
1894 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1899 do_nodes $(comma_list $(mdts_nodes)) \
1900 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1907 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1908 skip "Need MDS version newer than 2.13.56"
1911 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1912 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1913 for fail_loc in "0x80000169" "0x8000016a"; do
1914 echo "Begin 100 tests with fail_loc=$fail_loc"
1916 for i in {1..100}; do
1918 msg=$(sub_test_41i "$fail_loc") ||
1919 { echo; error "iter=$i : $msg"; }
1924 run_test 41i "reint_open: create vs create"
1927 # test 42: unlink and blocking operations
1930 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1931 do_nodes $(comma_list $(mdts_nodes)) \
1932 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1933 mkdir $DIR1/$tfile &
1935 mkdir $DIR2/$tfile &
1937 do_nodes $(comma_list $(mdts_nodes)) \
1938 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1939 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1940 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1944 run_test 42a "pdirops: mkdir vs mkdir =============="
1948 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1949 do_nodes $(comma_list $(mdts_nodes)) \
1950 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1951 mkdir $DIR1/$tfile &
1953 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1955 do_nodes $(comma_list $(mdts_nodes)) \
1956 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1957 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1958 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1962 run_test 42b "pdirops: mkdir vs create =============="
1966 touch $DIR1/$tfile-2
1967 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1968 do_nodes $(comma_list $(mdts_nodes)) \
1969 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1970 mkdir $DIR1/$tfile &
1972 link $DIR2/$tfile-2 $DIR2/$tfile &
1974 do_nodes $(comma_list $(mdts_nodes)) \
1975 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1976 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1977 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1981 run_test 42c "pdirops: mkdir vs link =============="
1985 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1986 do_nodes $(comma_list $(mdts_nodes)) \
1987 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1988 mkdir $DIR1/$tfile &
1990 rmdir $DIR2/$tfile &
1992 do_nodes $(comma_list $(mdts_nodes)) \
1993 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1994 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1995 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1999 run_test 42d "pdirops: mkdir vs unlink =============="
2003 touch $DIR1/$tfile-2
2004 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2005 do_nodes $(comma_list $(mdts_nodes)) \
2006 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2007 mkdir $DIR1/$tfile &
2009 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2011 do_nodes $(comma_list $(mdts_nodes)) \
2012 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2013 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2014 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2018 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2022 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2023 do_nodes $(comma_list $(mdts_nodes)) \
2024 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2025 mkdir $DIR1/$tfile &
2027 mv $DIR2/$tfile $DIR2/$tfile-2 &
2029 do_nodes $(comma_list $(mdts_nodes)) \
2030 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2031 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2032 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2036 run_test 42f "pdirops: mkdir and rename (src) =============="
2039 mkdir_on_mdt0 $DIR1/$tdir
2041 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2042 do_nodes $(comma_list $(mdts_nodes)) \
2043 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2044 mkdir $DIR1/$tdir/$tfile &
2046 stat $DIR2/$tdir/$tfile > /dev/null &
2048 do_nodes $(comma_list $(mdts_nodes)) \
2049 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2050 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2051 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2054 run_test 42g "pdirops: mkdir vs getattr =============="
2058 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2059 do_nodes $(comma_list $(mdts_nodes)) \
2060 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2061 mkdir $DIR1/$tfile &
2063 ls -lia $DIR2/ > /dev/null &
2065 do_nodes $(comma_list $(mdts_nodes)) \
2066 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2067 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2072 run_test 42h "pdirops: mkdir vs readdir =============="
2074 # test 43: rmdir,mkdir won't return -EEXIST
2076 for i in {1..1000}; do
2077 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2078 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2082 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2087 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2088 do_nodes $(comma_list $(mdts_nodes)) \
2089 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2092 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2094 do_nodes $(comma_list $(mdts_nodes)) \
2095 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2096 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2097 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2101 run_test 43b "pdirops: unlink vs create =============="
2106 touch $DIR1/$tfile-2
2107 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2108 do_nodes $(comma_list $(mdts_nodes)) \
2109 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2112 link $DIR2/$tfile-2 $DIR2/$tfile &
2114 do_nodes $(comma_list $(mdts_nodes)) \
2115 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2116 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2117 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2121 run_test 43c "pdirops: unlink vs link =============="
2126 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2127 do_nodes $(comma_list $(mdts_nodes)) \
2128 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2133 do_nodes $(comma_list $(mdts_nodes)) \
2134 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2135 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2136 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2140 run_test 43d "pdirops: unlink vs unlink =============="
2145 touch $DIR1/$tfile-2
2146 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2147 do_nodes $(comma_list $(mdts_nodes)) \
2148 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2151 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2153 do_nodes $(comma_list $(mdts_nodes)) \
2154 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2155 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2156 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2160 run_test 43e "pdirops: unlink and rename (tgt) =============="
2165 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2166 do_nodes $(comma_list $(mdts_nodes)) \
2167 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2170 mv $DIR2/$tfile $DIR2/$tfile-2 &
2172 do_nodes $(comma_list $(mdts_nodes)) \
2173 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2174 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2175 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2179 run_test 43f "pdirops: unlink and rename (src) =============="
2184 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2185 do_nodes $(comma_list $(mdts_nodes)) \
2186 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2189 stat $DIR2/$tfile > /dev/null &
2191 do_nodes $(comma_list $(mdts_nodes)) \
2192 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2193 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2194 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2198 run_test 43g "pdirops: unlink vs getattr =============="
2203 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2204 do_nodes $(comma_list $(mdts_nodes)) \
2205 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2208 ls -lia $DIR2/ > /dev/null &
2210 do_nodes $(comma_list $(mdts_nodes)) \
2211 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2212 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2217 run_test 43h "pdirops: unlink vs readdir =============="
2220 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2223 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2224 do_nodes $(comma_list $(mdts_nodes)) \
2225 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2228 $LFS mkdir -i 1 $DIR2/$tfile &
2230 do_nodes $(comma_list $(mdts_nodes)) \
2231 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2232 check_pdo_conflict $PID1 &&
2233 { wait $PID1; error "remote mkdir isn't blocked"; }
2234 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2238 run_test 43i "pdirops: unlink vs remote mkdir"
2241 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2242 skip "Need MDS version newer than 2.13.52"
2244 mkdir_on_mdt0 $DIR1/$tdir
2245 for i in {1..100}; do
2246 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2247 do_nodes $(comma_list $(mdts_nodes)) \
2248 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2251 mkdir $DIR1/$tdir/sub &
2253 mkdir $DIR2/$tdir/sub && ((OK++))
2254 wait $PID1 && ((OK++))
2255 (( OK == 1 )) || error "exactly one mkdir should succeed"
2257 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2261 run_test 43j "racy mkdir return EEXIST =============="
2268 # We test in a separate directory to be able to unblock server thread in
2269 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2270 test_mkdir $DIR2/$tdir
2271 touch $DIR2/$tdir/$tfile
2273 do_nodes $(comma_list $(mdts_nodes)) \
2274 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2275 echo content > $DIR1/$tdir/$tfile & PID1=$!
2277 multiop $DIR2/$tdir/$tfile u & PID2=$!
2281 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2284 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2287 do_nodes $(comma_list $(mdts_nodes)) \
2288 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2295 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2296 skip "Need MDS version newer than 2.13.56"
2299 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2300 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2301 for fail_loc in "0x80000169" "0x8000016a"; do
2302 echo "Begin 100 tests with fail_loc=$fail_loc"
2304 for i in {1..100}; do
2306 msg=$(sub_test_43k "$fail_loc") ||
2307 { echo; error "iter=$i : $msg"; }
2317 run_test 43k "unlink vs create"
2319 # test 44: rename tgt and blocking operations
2322 touch $DIR1/$tfile-2
2323 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2324 do_nodes $(comma_list $(mdts_nodes)) \
2325 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2326 mv $DIR1/$tfile-2 $DIR1/$tfile &
2328 mkdir $DIR2/$tfile &
2330 do_nodes $(comma_list $(mdts_nodes)) \
2331 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2332 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2333 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2338 run_test 44a "pdirops: rename tgt vs mkdir =============="
2342 touch $DIR1/$tfile-2
2343 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2344 do_nodes $(comma_list $(mdts_nodes)) \
2345 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2346 mv $DIR1/$tfile-2 $DIR1/$tfile &
2348 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2350 do_nodes $(comma_list $(mdts_nodes)) \
2351 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2352 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2353 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2357 run_test 44b "pdirops: rename tgt vs create =============="
2361 touch $DIR1/$tfile-2
2362 touch $DIR1/$tfile-3
2363 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2364 do_nodes $(comma_list $(mdts_nodes)) \
2365 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2366 mv $DIR1/$tfile-2 $DIR1/$tfile &
2368 link $DIR2/$tfile-3 $DIR2/$tfile &
2370 do_nodes $(comma_list $(mdts_nodes)) \
2371 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2372 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2373 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2377 run_test 44c "pdirops: rename tgt vs link =============="
2381 touch $DIR1/$tfile-2
2382 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2383 do_nodes $(comma_list $(mdts_nodes)) \
2384 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2385 mv $DIR1/$tfile-2 $DIR1/$tfile &
2389 do_nodes $(comma_list $(mdts_nodes)) \
2390 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2391 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2392 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2396 run_test 44d "pdirops: rename tgt vs unlink =============="
2401 touch $DIR1/$tfile-2
2402 touch $DIR1/$tfile-3
2403 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2404 do_nodes $(comma_list $(mdts_nodes)) \
2405 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2406 mv $DIR1/$tfile-2 $DIR1/$tfile &
2408 mv $DIR2/$tfile-3 $DIR2/$tfile &
2410 do_nodes $(comma_list $(mdts_nodes)) \
2411 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2412 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2413 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2417 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2421 touch $DIR1/$tfile-2
2422 touch $DIR1/$tfile-3
2423 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2424 do_nodes $(comma_list $(mdts_nodes)) \
2425 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2426 mv $DIR1/$tfile-2 $DIR1/$tfile &
2428 mv $DIR2/$tfile $DIR2/$tfile-3 &
2430 do_nodes $(comma_list $(mdts_nodes)) \
2431 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2432 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2433 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2437 run_test 44f "pdirops: rename tgt and rename (src) =============="
2441 touch $DIR1/$tfile-2
2442 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2443 do_nodes $(comma_list $(mdts_nodes)) \
2444 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2445 mv $DIR1/$tfile-2 $DIR1/$tfile &
2447 stat $DIR2/$tfile > /dev/null &
2449 do_nodes $(comma_list $(mdts_nodes)) \
2450 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2451 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2452 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2456 run_test 44g "pdirops: rename tgt vs getattr =============="
2460 touch $DIR1/$tfile-2
2461 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2462 do_nodes $(comma_list $(mdts_nodes)) \
2463 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2464 mv $DIR1/$tfile-2 $DIR1/$tfile &
2466 ls -lia $DIR2/ > /dev/null &
2468 do_nodes $(comma_list $(mdts_nodes)) \
2469 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2470 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2475 run_test 44h "pdirops: rename tgt vs readdir =============="
2477 # test 44: rename tgt and blocking operations
2479 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2481 touch $DIR1/$tfile-2
2482 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2483 do_nodes $(comma_list $(mdts_nodes)) \
2484 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2485 mv $DIR1/$tfile-2 $DIR1/$tfile &
2487 $LFS mkdir -i 1 $DIR2/$tfile &
2489 do_nodes $(comma_list $(mdts_nodes)) \
2490 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2491 check_pdo_conflict $PID1 && { wait $PID1;
2492 error "remote mkdir isn't blocked"; }
2493 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2497 run_test 44i "pdirops: rename tgt vs remote mkdir"
2499 # test 45: rename,mkdir doesn't fail with -EEXIST
2501 for i in {1..1000}; do
2502 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2503 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2504 error "mrename to $tdir.$i failed"
2509 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2514 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2515 do_nodes $(comma_list $(mdts_nodes)) \
2516 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2517 mv $DIR1/$tfile $DIR1/$tfile-2 &
2519 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2521 do_nodes $(comma_list $(mdts_nodes)) \
2522 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2523 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2524 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2528 run_test 45b "pdirops: rename src vs create =============="
2533 touch $DIR1/$tfile-3
2534 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2535 do_nodes $(comma_list $(mdts_nodes)) \
2536 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2537 mv $DIR1/$tfile $DIR1/$tfile-2 &
2539 link $DIR2/$tfile-3 $DIR2/$tfile &
2541 do_nodes $(comma_list $(mdts_nodes)) \
2542 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2543 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2544 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2548 run_test 45c "pdirops: rename src vs link =============="
2553 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2554 do_nodes $(comma_list $(mdts_nodes)) \
2555 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2556 mv $DIR1/$tfile $DIR1/$tfile-2 &
2560 do_nodes $(comma_list $(mdts_nodes)) \
2561 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2562 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2563 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2567 run_test 45d "pdirops: rename src vs unlink =============="
2572 touch $DIR1/$tfile-3
2573 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2574 do_nodes $(comma_list $(mdts_nodes)) \
2575 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2576 mv $DIR1/$tfile $DIR1/$tfile-2 &
2578 mv $DIR2/$tfile-3 $DIR2/$tfile &
2580 do_nodes $(comma_list $(mdts_nodes)) \
2581 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2582 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2583 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2587 run_test 45e "pdirops: rename src and rename (tgt) =============="
2592 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2593 do_nodes $(comma_list $(mdts_nodes)) \
2594 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2595 mv $DIR1/$tfile $DIR1/$tfile-2 &
2597 mv $DIR2/$tfile $DIR2/$tfile-3 &
2599 do_nodes $(comma_list $(mdts_nodes)) \
2600 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2601 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2602 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2606 run_test 45f "pdirops: rename src and rename (src) =============="
2611 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2612 do_nodes $(comma_list $(mdts_nodes)) \
2613 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2614 mv $DIR1/$tfile $DIR1/$tfile-2 &
2616 stat $DIR2/$tfile > /dev/null &
2618 do_nodes $(comma_list $(mdts_nodes)) \
2619 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2620 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2621 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2625 run_test 45g "pdirops: rename src vs getattr =============="
2630 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2631 do_nodes $(comma_list $(mdts_nodes)) \
2632 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2633 mv $DIR1/$tfile $DIR1/$tfile-2 &
2635 ls -lia $DIR2/ > /dev/null &
2636 do_nodes $(comma_list $(mdts_nodes)) \
2637 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2638 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2643 run_test 45h "pdirops: unlink vs readdir =============="
2646 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2649 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2650 do_nodes $(comma_list $(mdts_nodes)) \
2651 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2652 mv $DIR1/$tfile $DIR1/$tfile-2 &
2654 $LFS mkdir -i 1 $DIR2/$tfile &
2656 do_nodes $(comma_list $(mdts_nodes)) \
2657 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2658 check_pdo_conflict $PID1 && { wait $PID1;
2659 error "create remote dir isn't blocked"; }
2660 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2664 run_test 45i "pdirops: rename src vs remote mkdir"
2671 # We test in a sparate directory to be able to unblock server thread in
2672 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2673 test_mkdir $DIR2/$tdir
2674 echo file1 > $DIR2/$tdir/$tfile
2675 echo file2 > $DIR2/$tdir/$tfile-2
2677 do_nodes $(comma_list $(mdts_nodes)) \
2678 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2680 cat $DIR1/$tdir/$tfile >/dev/null &
2683 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2687 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2690 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2693 do_nodes $(comma_list $(mdts_nodes)) \
2694 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2701 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2702 skip "Need MDS version newer than 2.13.56"
2705 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2706 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2707 for fail_loc in "0x80000169" "0x8000016a"; do
2708 echo "Begin 100 tests with fail_loc=$fail_loc"
2710 for i in {1..100}; do
2712 msg=$(sub_test_45j "$fail_loc") ||
2713 { echo; error "iter=$i : $msg"; }
2718 run_test 45j "read vs rename =============="
2720 # test 46: link and blocking operations
2723 touch $DIR1/$tfile-2
2724 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2725 do_nodes $(comma_list $(mdts_nodes)) \
2726 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2727 link $DIR1/$tfile-2 $DIR1/$tfile &
2729 mkdir $DIR2/$tfile &
2731 do_nodes $(comma_list $(mdts_nodes)) \
2732 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2733 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2734 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2738 run_test 46a "pdirops: link vs mkdir =============="
2742 touch $DIR1/$tfile-2
2743 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2744 do_nodes $(comma_list $(mdts_nodes)) \
2745 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2746 link $DIR1/$tfile-2 $DIR1/$tfile &
2748 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2750 do_nodes $(comma_list $(mdts_nodes)) \
2751 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2752 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2753 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2757 run_test 46b "pdirops: link vs create =============="
2761 touch $DIR1/$tfile-2
2762 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2763 do_nodes $(comma_list $(mdts_nodes)) \
2764 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2765 link $DIR1/$tfile-2 $DIR1/$tfile &
2767 link $DIR2/$tfile $DIR2/$tfile &
2769 do_nodes $(comma_list $(mdts_nodes)) \
2770 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2771 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2772 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2776 run_test 46c "pdirops: link vs link =============="
2780 touch $DIR1/$tfile-2
2781 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2782 do_nodes $(comma_list $(mdts_nodes)) \
2783 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2784 link $DIR1/$tfile-2 $DIR1/$tfile &
2788 do_nodes $(comma_list $(mdts_nodes)) \
2789 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2790 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2791 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2795 run_test 46d "pdirops: link vs unlink =============="
2799 touch $DIR1/$tfile-2
2800 touch $DIR1/$tfile-3
2801 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2802 do_nodes $(comma_list $(mdts_nodes)) \
2803 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2804 link $DIR1/$tfile-2 $DIR1/$tfile &
2806 mv $DIR2/$tfile-3 $DIR2/$tfile &
2808 do_nodes $(comma_list $(mdts_nodes)) \
2809 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2810 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2811 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2815 run_test 46e "pdirops: link and rename (tgt) =============="
2819 touch $DIR1/$tfile-2
2820 touch $DIR1/$tfile-3
2821 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2822 do_nodes $(comma_list $(mdts_nodes)) \
2823 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2824 link $DIR1/$tfile-2 $DIR1/$tfile &
2826 mv $DIR2/$tfile $DIR2/$tfile-3 &
2828 do_nodes $(comma_list $(mdts_nodes)) \
2829 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2830 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2831 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2835 run_test 46f "pdirops: link and rename (src) =============="
2839 touch $DIR1/$tfile-2
2840 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2841 do_nodes $(comma_list $(mdts_nodes)) \
2842 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2843 link $DIR1/$tfile-2 $DIR1/$tfile &
2845 stat $DIR2/$tfile > /dev/null &
2847 do_nodes $(comma_list $(mdts_nodes)) \
2848 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2849 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2850 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2854 run_test 46g "pdirops: link vs getattr =============="
2858 touch $DIR1/$tfile-2
2859 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2860 do_nodes $(comma_list $(mdts_nodes)) \
2861 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2862 link $DIR1/$tfile-2 $DIR1/$tfile &
2864 ls -lia $DIR2/ > /dev/null &
2866 do_nodes $(comma_list $(mdts_nodes)) \
2867 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2868 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2873 run_test 46h "pdirops: link vs readdir =============="
2876 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2878 touch $DIR1/$tfile-2
2879 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2880 do_nodes $(comma_list $(mdts_nodes)) \
2881 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2882 link $DIR1/$tfile-2 $DIR1/$tfile &
2884 $LFS mkdir -i 1 $DIR2/$tfile &
2886 do_nodes $(comma_list $(mdts_nodes)) \
2887 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2888 check_pdo_conflict $PID1 && { wait $PID1;
2889 error "remote mkdir isn't blocked"; }
2890 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2894 run_test 46i "pdirops: link vs remote mkdir"
2896 # test 47: remote mkdir and blocking operations
2898 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2899 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2901 do_nodes $(comma_list $(mdts_nodes)) \
2902 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2903 $LFS mkdir -i 1 $DIR1/$tfile &
2905 mkdir $DIR2/$tfile &
2907 do_nodes $(comma_list $(mdts_nodes)) \
2908 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2909 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2910 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2914 run_test 47a "pdirops: remote mkdir vs mkdir"
2917 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2918 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2920 do_nodes $(comma_list $(mdts_nodes)) \
2921 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2922 $LFS mkdir -i 1 $DIR1/$tfile &
2924 sleep 1 # please do not remove this sleep, see LU-10754
2925 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2927 do_nodes $(comma_list $(mdts_nodes)) \
2928 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2929 check_pdo_conflict $PID1 && { wait $PID1;
2930 error "create isn't blocked"; }
2931 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2935 run_test 47b "pdirops: remote mkdir vs create"
2938 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2940 touch $DIR1/$tfile-2
2941 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2942 do_nodes $(comma_list $(mdts_nodes)) \
2943 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2944 $LFS mkdir -i 1 $DIR1/$tfile &
2946 link $DIR2/$tfile-2 $DIR2/$tfile &
2948 do_nodes $(comma_list $(mdts_nodes)) \
2949 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2950 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2951 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2955 run_test 47c "pdirops: remote mkdir vs link"
2958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2960 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2961 do_nodes $(comma_list $(mdts_nodes)) \
2962 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2963 $LFS mkdir -i 1 $DIR1/$tfile &
2965 rmdir $DIR2/$tfile &
2967 do_nodes $(comma_list $(mdts_nodes)) \
2968 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2969 check_pdo_conflict $PID1 && { wait $PID1;
2970 error "unlink isn't blocked"; }
2971 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2975 run_test 47d "pdirops: remote mkdir vs unlink"
2978 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2980 touch $DIR1/$tfile-2
2981 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2982 do_nodes $(comma_list $(mdts_nodes)) \
2983 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2984 $LFS mkdir -i 1 $DIR1/$tfile &
2986 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2988 do_nodes $(comma_list $(mdts_nodes)) \
2989 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2990 check_pdo_conflict $PID1 && { wait $PID1;
2991 error "rename isn't blocked"; }
2992 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2996 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3001 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3002 do_nodes $(comma_list $(mdts_nodes)) \
3003 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3004 $LFS mkdir -i 1 $DIR1/$tfile &
3006 mv $DIR2/$tfile $DIR2/$tfile-2 &
3008 do_nodes $(comma_list $(mdts_nodes)) \
3009 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3010 check_pdo_conflict $PID1 && { wait $PID1;
3011 error "rename isn't blocked"; }
3012 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3016 run_test 47f "pdirops: remote mkdir and rename (src)"
3019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3023 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3024 do_nodes $(comma_list $(mdts_nodes)) \
3025 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3026 $LFS mkdir -i 1 $DIR1/$tfile &
3028 stat $DIR2/$tfile > /dev/null &
3030 do_nodes $(comma_list $(mdts_nodes)) \
3031 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3032 check_pdo_conflict $PID1 && { wait $PID1;
3033 error "getattr isn't blocked"; }
3034 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3038 run_test 47g "pdirops: remote mkdir vs getattr"
3042 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3043 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3044 do_facet client "lctl set_param fail_loc=0x410"
3045 $TRUNCATE $DIR2/$tfile $trunc_size
3046 do_facet client "lctl set_param fail_loc=0x0"
3048 size=`stat -c %s $DIR2/$tfile`
3049 [ $size -eq $trunc_size ] || error "wrong size"
3051 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3055 local origfile=/etc/hosts
3057 filesize=$(stat -c %s $origfile)
3059 # create an empty file
3060 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3061 # cache layout lock on both mount point
3062 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3063 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3065 # open and sleep 2 seconds then read
3066 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3070 # create the layout of testing file
3071 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3072 error "dd $DIR1/$tfile failed"
3074 # MULTIOP proc should be able to read enough bytes and exit
3075 for ((i = 0; i < 6; i++)); do
3077 kill -0 $pid || break
3079 kill -0 $pid 2> /dev/null && error "multiop is still there"
3080 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3084 run_test 51a "layout lock: refresh layout should work"
3087 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3088 skip "Need MDS version at least 2.3.59"
3090 local tmpfile=`mktemp`
3092 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3093 error "Create $DIR1/$tfile failed"
3095 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3096 error "dd $DIR1/$tfile failed"
3098 # delay glimpse so that layout has changed when glimpse finish
3099 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3100 $LCTL set_param fail_loc=0x1404 fail_val=4
3101 stat -c %s $DIR2/$tfile |tee $tmpfile &
3105 # extend layout of testing file
3106 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3107 error "dd $DIR1/$tfile failed"
3110 local fsize=$(cat $tmpfile)
3112 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3114 rm -f $DIR1/$tfile $tmpfile
3116 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3119 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3121 # set default layout to have 1 stripe
3123 $LFS setstripe -c 1 $DIR1/$tdir
3125 # create a file with empty layout
3126 $MCREATE $DIR1/$tdir/$tfile ||
3127 error "$MCREATE $DIR1/$tdir/$tfile failed"
3129 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3130 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3132 # change the layout of testing file
3133 echo "Setting layout to have $OSTCOUNT stripes ..."
3134 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3138 # write something to the file, it should be blocked on fetching layout
3139 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3140 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3143 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3144 # count to succeed with only 3/4 of the number of stripes (rounded up),
3145 # so creating striped files does not fail if an OST is offline or full
3146 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3147 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3151 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3154 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3155 cancel_lru_locks mdc
3157 # open should grant LAYOUT lock, mmap and read will install pages
3158 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3162 # rss before revoking
3163 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3164 echo "Before revoking layout lock: $br KB mapped"
3166 # cancel layout lock manually
3167 cancel_lru_locks mdc
3169 # rss after revoking
3170 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3173 wait $PID || error "wait PID $PID failed"
3175 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3177 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3180 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3181 skip "MDS version must be at least 2.13.54.148"
3185 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3189 $LFS getstripe $DIR2/$tfile
3191 wait $pid || error "multiop failed"
3193 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3197 $LFS getstripe $DIR2/$tfile
3199 wait $pid || error "multiop failed"
3201 run_test 51e "lfs getstripe does not break leases, part 2"
3205 echo "==> rename vs getattr vs setxattr should not deadlock"
3206 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3208 do_facet mds1 $LCTL set_param fail_loc=$1
3210 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3218 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3219 wait $PID1 || error "(3) mv failed"
3220 wait $PID2 || error "(4) stat failed"
3227 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3228 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3230 do_facet mds1 $LCTL set_param fail_loc=$1
3232 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3240 $MULTIOP $DIR2/d1/d2 Oc &
3244 stat $DIR/d1 || error "(2) stat failed"
3246 wait $PID1 || error "(3) mv failed"
3247 wait $PID2 || error "(4) stat failed"
3248 wait $PID3 && error "(5) multiop failed"
3254 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3255 save_lustre_params client "llite.*.xattr_cache" > $p
3256 lctl set_param llite.*.xattr_cache 1 ||
3257 { skip "xattr cache is not supported"; return 0; }
3259 #define OBD_FAIL_MDS_RENAME 0x153
3260 #define OBD_FAIL_MDS_RENAME2 0x154
3261 test_54_part1 0x80000153 || error 10
3262 test_54_part1 0x80000154 || error 11
3263 test_54_part2 0x80000153 || error 12
3264 test_54_part2 0x80000154 || error 13
3266 restore_lustre_params < $p
3269 run_test 54 "rename locking"
3272 mkdir_on_mdt0 $DIR/$tdir
3273 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3275 #define OBD_FAIL_MDS_RENAME4 0x156
3276 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3278 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3282 rm -r $DIR2/$tdir/d3
3283 wait $PID1 && error "(2) mv succeeded"
3287 run_test 55a "rename vs unlink target dir"
3291 mkdir_on_mdt0 $DIR/$tdir
3292 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3294 #define OBD_FAIL_MDS_RENAME4 0x156
3295 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3297 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3301 rm -r $DIR2/$tdir/d1
3302 wait $PID1 && error "(2) mv succeeded"
3306 run_test 55b "rename vs unlink source dir"
3310 mkdir_on_mdt0 $DIR/$tdir
3311 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3313 #define OBD_FAIL_MDS_RENAME4 0x156
3314 do_facet mds1 $LCTL set_param fail_loc=0x156
3316 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3320 # while rename is sleeping, open and remove d3
3321 $MULTIOP $DIR2/$tdir/d3 D_c &
3324 rm -rf $DIR2/$tdir/d3
3327 # while rename is sleeping 2nd time, close d3
3329 wait $PID2 || error "(3) multiop failed"
3331 wait $PID1 && error "(2) mv succeeded"
3335 run_test 55c "rename vs unlink orphan target dir"
3339 mkdir_on_mdt0 $DIR/$tdir
3343 #define OBD_FAIL_MDS_RENAME3 0x155
3344 do_facet mds1 $LCTL set_param fail_loc=0x155
3345 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3349 # while rename is sleeping, create $tdir, but as a directory
3350 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3352 # link in reverse locking order
3353 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3355 wait $PID1 && error "(2) mv succeeded"
3358 run_test 55d "rename file vs link"
3361 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3362 skip "MDS version must be >= 2.3.0"
3365 test_mkdir $DIR1/$tdir
3366 file1=$DIR1/$tdir/file
3367 file2=$DIR2/$tdir/file
3369 echo orig > $file2 || error "Could not create $file2"
3370 version=$($LFS data_version $file1)
3373 echo append >> $file2 || error "Could not append to $file2"
3374 version2=$($LFS data_version $file1)
3375 [ "$version" != "$version2" ] ||
3376 error "append did not change data version: $version"
3379 echo overwrite > $file2 || error "Could not overwrite $file2"
3380 version3=$($LFS data_version $file1)
3381 [ "$version2" != "$version3" ] ||
3382 error "overwrite did not change data version: $version2"
3384 # Truncate before EOF
3385 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3386 version4=$($LFS data_version $file1)
3387 [ "$version3" != "$version4" ] ||
3388 error "truncate did not change data version: $version3"
3390 # Truncate after EOF
3391 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3392 version5=$($LFS data_version $file1)
3393 [ "$version4" != "$version5" ] ||
3394 error "truncate did not change data version: $version4"
3396 # Chmod do not change version
3397 chmod 400 $file2 || error "Could not chmod 400 $file2"
3398 version6=$($LFS data_version $file1)
3399 [ "$version5" == "$version6" ] ||
3400 error "chmod should not change data version: $version5 != $version6"
3402 # Chown do not change version
3403 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3404 version7=$($LFS data_version $file1)
3405 [ "$version5" == "$version7" ] ||
3406 error "chown should not change data version: $version5 != $version7"
3408 run_test 60 "Verify data_version behaviour"
3411 local test_dir=$tdir/test_dir
3413 mkdir -p $DIR1/$tdir
3414 if [ $MDSCOUNT -ge 2 ]; then
3416 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3417 error "Create remote directory failed"
3419 mkdir -p $DIR1/$test_dir
3421 cd $DIR2/$test_dir || error "cd directory failed"
3422 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3424 cd $DIR2/$tdir || error "exit directory"
3426 run_test 70a "cd directory && rm directory"
3428 test_70b() { # LU-2781
3430 mkdir -p $DIR1/$tdir
3432 touch $DIR1/$tdir/file
3433 for ((i = 0; i < 32; i++)); do
3434 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3436 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3438 touch $DIR1/$tdir/file
3439 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3440 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3441 rm -rf $DIR1/$tdir/test_dir ||
3442 error "cannot remove directory after rm_entry"
3443 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3445 run_test 70b "remove files after calling rm_entry"
3448 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3449 skip "Need MDS version at least 2.1.6"
3451 # Patch not applied to 2.2 and 2.3 branches
3452 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3453 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3454 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3456 checkfiemap --test ||
3457 skip "checkfiemap not runnable: $?"
3458 # write data this way: hole - data - hole - data
3459 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3460 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3462 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3463 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3464 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3466 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3468 checkfiemap $DIR2/$tfile 81920 ||
3469 error "data is not flushed from client"
3470 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3473 # common case of "create file, copy file" on a single node
3474 # should not flush data from ost
3475 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3476 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3478 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3480 checkfiemap $DIR1/$tfile 81920 ||
3482 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3484 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3486 run_test 71a "correct file map just after write operation is finished"
3489 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3490 skip "Need MDS version at least 2.1.6"
3492 # Patch not applied to 2.2 and 2.3 branches
3493 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3494 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3495 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3496 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3498 checkfiemap --test ||
3499 skip "error $?: checkfiemap failed"
3501 mkdir -p $DIR1/$tdir
3503 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3504 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3505 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3507 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3508 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3510 run_test 71b "check fiemap support for stripecount > 1"
3513 local p="$TMP/sanityN-$TESTNAME.parameters"
3516 save_lustre_params client "llite.*.xattr_cache" > $p
3517 lctl set_param llite.*.xattr_cache 1 ||
3518 { skip "xattr cache is not supported"; return 0; }
3521 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3522 error "setfattr1 failed"
3523 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3524 error "getfattr1 failed"
3525 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3526 error "setfattr2 failed"
3527 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3528 error "getfattr2 failed"
3530 # check that trusted.link is consistent
3531 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3532 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3533 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3534 echo "$tlink1 $tlink2"
3535 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3539 restore_lustre_params < $p
3542 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3545 local p="$TMP/sanityN-$TESTNAME.parameters"
3546 save_lustre_params client "llite.*.xattr_cache" > $p
3547 lctl set_param llite.*.xattr_cache 1 ||
3548 { skip "xattr cache is not supported"; return 0; }
3551 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3552 error "setfattr1 failed"
3553 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3554 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3555 clear_stats llite.*.stats
3556 # PR lock should be cached by now on both clients
3557 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3558 # 2 hits for getfattr(0)+getfattr(size)
3559 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3560 error "not cached in $DIR1"
3561 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3562 # 4 hits for more getfattr(0)+getfattr(size)
3563 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3564 error "not cached in $DIR2"
3567 restore_lustre_params < $p
3570 run_test 73 "getxattr should not cause xattr lock cancellation"
3573 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3574 skip "Need MDS version at least 2.4.93"
3576 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3577 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3578 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3580 run_test 74 "flock deadlock: different mounts =============="
3584 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3585 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3586 cancel_lru_locks osc
3588 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3591 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3592 $LCTL set_param fail_loc=0x31d
3593 stat -c %s $DIR1/$tfile &
3598 # For bad lock error handler we should ASSERT and got kernel panic here
3600 $LCTL set_param fail_loc=0
3602 run_test 75 "osc: upcall after unuse lock==================="
3605 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3606 skip "Need MDS version at least 2.5.53"
3608 remote_mds_nodsh && skip "remote MDS with nodsh"
3609 local fcount=$((MDSCOUNT * 256))
3614 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3620 test_mkdir $DIR/$tdir
3622 # drop all open locks and close any cached "open" files on the client
3623 cancel_lru_locks mdc
3625 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3626 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3627 local already=${#fid_list[@]}
3628 for (( i = 0; i < $already; i++ )) ; do
3629 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3632 echo -n "opening files: "
3633 ulimit -n $((fcount + 50))
3634 for ((i = 0; i < $fcount; i++)); do
3635 touch $DIR/$tdir/f_$i
3636 local fd=$(free_fd ${fd_list[i]})
3637 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3642 (( $i % 32 == 0 )) && echo -n "."
3646 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3648 # Possible errors in openfiles FID list.
3649 # 1. Missing FIDs. Check 1
3650 # 2. Extra FIDs. Check 1
3651 # 3. Duplicated FID. Check 2
3652 # 4. Invalid FIDs. Check 2
3653 # 5. Valid FID, points to some other file. Check 3
3656 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3657 error "${#fid_list[@]} != $fcount (+$already old) open files"
3659 echo -n "closing files: "
3660 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3661 local close_cmd="exec ${fd_list[fd]}<&-"
3663 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3665 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3666 echo "skip old open file $filename"
3668 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3672 rm --interactive=no $filename
3674 error "Nonexisting fid ${fid_list[fid]} listed."
3675 (( $fd % 32 == 0 )) && echo -n "."
3680 ls_op=$(ls $DIR2/$tdir | wc -l)
3682 error "Some openfiles are missing in lproc output"
3686 run_test 76 "Verify MDT open_files listing"
3690 local dir=$DIR/$tdir
3693 mkdir $dir || error "mkdir $dir failed"
3694 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3697 do_nodes $CLIENTS $myRUNAS \
3698 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3699 error "dd at 0 on client failed (1)"
3701 do_nodes $CLIENTS $myRUNAS \
3703 for ((i = 0; i < $n; i++)); do
3704 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3705 seek=\\\$i count=1 conv=notrunc &
3706 pids_w[\\\$i]=\\\$!;
3709 for ((i = 0; i < $n; i++)); do
3710 wait \\\${pids_w[\\\$i]};
3712 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3716 do_nodes $CLIENTS sync;
3717 cancel_lru_locks osc
3719 do_nodes $CLIENTS $myRUNAS \
3721 for ((i = 0; i < $n; i++)); do
3722 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3723 seek=\\\$i count=1 &
3724 pids_r[\\\$i]=\\\$!;
3727 for ((i = 0; i < $n; i++)); do
3728 wait \\\${pids_r[\\\$i]};
3730 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3734 cancel_lru_locks osc
3736 wait $pid_w || error "dd (write) failed (2)"
3737 wait $pid_r || error "dd (read) failed (3)"
3738 rm -rvf $dir || error "rm -rf $dir failed"
3741 test_77a() { #LU-3266
3744 oss=$(comma_list $(osts_nodes))
3745 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3747 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3748 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3753 run_test 77a "check FIFO NRS policy"
3755 test_77b() { #LU-3266
3758 oss=$(comma_list $(osts_nodes))
3760 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3761 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3762 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3763 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3765 echo "policy: crr-n, crrn_quantum 1"
3768 do_nodes $oss lctl set_param \
3769 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3770 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3772 echo "policy: crr-n, crrn_quantum 64"
3776 do_nodes $oss lctl set_param \
3777 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3778 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3781 run_test 77b "check CRR-N NRS policy"
3786 oss=$(comma_list $(osts_nodes))
3788 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3789 ost.OSS.*.nrs_"$policy"_quantum=1 \
3790 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3791 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3793 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3794 "physical, ${policy}_supported reads"
3797 do_nodes $oss lctl set_param \
3798 ost.OSS.*.nrs_${policy}_supported="writes" \
3799 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3801 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3802 "physical, ${policy}_supported writes"
3805 do_nodes $oss lctl set_param \
3806 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3807 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3808 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3809 "logical, ${policy}_supported reads_and_writes"
3813 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3818 test_77c() { #LU-3266
3820 orr_trr "orr" || rc=$?
3821 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3822 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3825 run_test 77c "check ORR NRS policy"
3827 test_77d() { #LU-3266
3829 orr_trr "trr" || rc=$?
3830 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3831 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3834 run_test 77d "check TRR nrs policy"
3841 do_facet $facet lctl set_param \
3842 ost.OSS.ost_io.nrs_tbf_rule="$*"
3844 error "failed to run operate '$*' on TBF rules"
3847 cleanup_tbf_verify()
3851 echo "cleanup_tbf $DIR/$tdir"
3854 wait_delete_completed
3859 local dir=$DIR/$tdir
3860 local client1=${CLIENT1:-$(hostname)}
3863 local np=$(check_cpt_number ost1)
3864 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3865 echo "cpu_npartitions on ost1 is $np"
3867 mkdir $dir || error "mkdir $dir failed"
3868 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3871 trap cleanup_tbf_verify EXIT
3872 echo "Limited write rate: $1, read rate: $2"
3873 echo "Verify the write rate is under TBF control"
3874 local start=$SECONDS
3875 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3876 bs=1M count=100 oflag=direct 2>&1
3877 local runtime=$((SECONDS - start + 1))
3878 local rate=$(bc <<< "scale=6; 100 / $runtime")
3879 echo "Write runtime is $runtime s, speed is $rate IOPS"
3881 # verify the write rate does not exceed TBF rate limit
3882 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3883 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3885 cancel_lru_locks osc
3887 echo "Verify the read rate is under TBF control"
3889 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3890 bs=1M count=100 iflag=direct 2>&1
3891 runtime=$((SECONDS - start + 1))
3892 rate=$(bc <<< "scale=6; 100 / $runtime")
3893 echo "Read runtime is $runtime s, speed is $rate IOPS"
3895 # verify the read rate does not exceed TBF rate limit
3896 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3897 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3899 cancel_lru_locks osc
3900 cleanup_tbf_verify || error "rm -rf $dir failed"
3906 oss=$(comma_list $(osts_nodes))
3908 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3910 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3911 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3915 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3920 # Only operate rules on ost1 since OSTs might run on the same OSS
3922 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3923 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3924 local client_nids=$(nids_list $address "\\")
3925 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3926 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3930 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3931 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3932 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3936 tbf_rule_operate ost1 "stop\ localhost"
3937 tbf_rule_operate ost1 "stop\ clients"
3938 tbf_rule_operate ost1 "stop\ others"
3941 # Cleanup the TBF policy
3942 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3943 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3947 run_test 77e "check TBF NID nrs policy"
3952 oss=$(comma_list $(osts_nodes))
3954 do_nodes $oss $LCTL set_param \
3955 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3956 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3957 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3959 # Configure jobid_var
3960 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3962 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3963 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3964 if [ $saved_jobid_var != procname_uid ]; then
3965 set_persistent_param_and_check client \
3966 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3971 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3976 # Only operate rules on ost1 since OSTs might run on the same OSS
3978 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3979 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3980 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3981 nrs_write_read "$RUNAS"
3984 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3985 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3986 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3987 nrs_write_read "$RUNAS"
3990 tbf_rule_operate ost1 "stop\ runas"
3991 tbf_rule_operate ost1 "stop\ iozone_runas"
3992 tbf_rule_operate ost1 "stop\ dd_runas"
3993 nrs_write_read "$RUNAS"
3995 # Cleanup the TBF policy
3996 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3997 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3998 nrs_write_read "$RUNAS"
4000 local current_jobid_var=$($LCTL get_param -n jobid_var)
4001 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4002 if [ $saved_jobid_var != $current_jobid_var ]; then
4003 set_persistent_param_and_check client \
4004 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4008 run_test 77f "check TBF JobID nrs policy"
4013 oss=$(comma_list $(osts_nodes))
4015 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4017 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4018 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4020 do_nodes $oss lctl set_param \
4021 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4022 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4026 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4031 # Add a rule that only valid for Jobid TBF. If direct change between
4032 # TBF types is not supported, this operation will fail.
4033 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4035 # Cleanup the TBF policy
4036 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4037 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4040 run_test 77g "Change TBF type directly"
4043 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4044 skip "Need OST version at least 2.8.55"
4046 local old_policy=$(do_facet ost1 \
4047 lctl get_param ost.OSS.ost_io.nrs_policies)
4050 do_facet ost1 lctl set_param \
4051 ost.OSS.ost_io.nrs_policies="abc"
4052 [ $? -eq 0 ] && error "should return error"
4054 do_facet ost1 lctl set_param \
4055 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4056 [ $? -eq 0 ] && error "should return error"
4058 do_facet ost1 lctl set_param \
4059 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4060 [ $? -eq 0 ] && error "should return error"
4062 do_facet ost1 lctl set_param \
4063 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4064 [ $? -eq 0 ] && error "should return error"
4066 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4067 [ $? -eq 0 ] || error "shouldn't LBUG"
4069 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4073 run_test 77h "Wrong policy name should report error, not LBUG"
4079 local error_message=$3
4081 for rule in $expected; do
4082 rule_number=$((rule_number + 1))
4084 local stop_line=$(($rule_number + 3))
4085 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4087 local output=$(do_facet $facet lctl get_param \
4088 ost.OSS.ost_io.nrs_tbf_rule |
4092 if [ "$output" != "$expected" ]; then
4093 error "$error_message, expected '$expected', got '$output'"
4098 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4099 skip "Need OST version at least 2.8.55"
4101 for i in $(seq 1 $OSTCOUNT)
4103 do_facet ost"$i" lctl set_param \
4104 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4106 error "failed to set TBF policy"
4109 tbf_rule_check ost1 "default" "error before inserting any rule"
4111 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4112 tbf_rule_check ost1 "before default" \
4113 "error when inserting rule 'before'"
4115 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4116 tbf_rule_check ost1 "before after default" \
4117 "error when inserting rule 'after'"
4119 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4120 tbf_rule_check ost1 "before target after default" \
4121 "error when inserting rule 'target'"
4123 echo "Move before itself"
4124 tbf_rule_operate ost1 "change\ target\ rank=target"
4125 tbf_rule_check ost1 "before target after default" \
4126 "error when moving before itself"
4128 echo "Move to higher rank"
4129 tbf_rule_operate ost1 "change\ target\ rank=before"
4130 tbf_rule_check ost1 "target before after default" \
4131 "error when moving to higher rank"
4133 echo "Move to lower rank"
4134 tbf_rule_operate ost1 "change\ target\ rank=after"
4135 tbf_rule_check ost1 "before target after default" \
4136 "error when moving to lower rank"
4138 echo "Move before default"
4139 tbf_rule_operate ost1 "change\ target\ rank=default"
4140 tbf_rule_check ost1 "before after target default" \
4141 error "error when moving before default"
4143 # Cleanup the TBF policy
4144 do_nodes $(comma_list $(osts_nodes)) \
4145 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4148 run_test 77i "Change rank of TBF rule"
4154 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4155 skip "Need OST version at least 2.9.53"
4156 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4161 do_nodes $(comma_list $(osts_nodes)) \
4162 lctl set_param jobid_var=procname_uid \
4163 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4164 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4165 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4166 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4171 do_nodes $(comma_list $(osts_nodes)) \
4172 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4173 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4174 ost.OSS.ost_io.nrs_policies="fifo"
4176 # sleep 3 seconds to wait the tbf policy stop completely,
4177 # or the next test case is possible get -EAGAIN when
4178 # setting the tbf policy
4181 run_test 77j "check TBF-OPCode NRS policy"
4184 local idstr="${1}id"
4185 local policy="${idstr}={$2}"
4186 local rate="rate=$3"
4188 do_nodes $(comma_list $(osts_nodes)) \
4189 lctl set_param jobid_var=procname_uid \
4190 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4191 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4192 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4194 nrs_write_read "runas $4"
4195 tbf_verify $3 $3 "runas $4"
4197 do_nodes $(comma_list $(osts_nodes)) \
4198 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4199 ost.OSS.ost_io.nrs_policies="fifo"
4201 # sleep 3 seconds to wait the tbf policy stop completely,
4202 # or the next test case is possible get -eagain when
4203 # setting the tbf policy
4208 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4209 skip "Need OST version at least 2.11.50"
4212 test_id "u" "500" "5" "-u 500"
4213 test_id "g" "500" "5" "-u 500 -g 500"
4215 run_test 77ja "check TBF-UID/GID NRS policy"
4223 for rule in $rule_lists; do
4224 do_nodes $(comma_list $(osts_nodes)) \
4225 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4228 do_nodes $(comma_list $(osts_nodes)) \
4229 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4235 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4236 skip "Need OST version at least 2.9.53"
4238 do_nodes $(comma_list $(osts_nodes)) \
4239 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4240 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4241 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4243 nrs_write_read "$RUNAS"
4244 tbf_verify 20 10 "$RUNAS"
4246 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4247 local client_nids=$(nids_list $address "\\")
4248 do_nodes $(comma_list $(osts_nodes)) \
4249 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4250 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4251 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4252 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4257 do_nodes $(comma_list $(osts_nodes)) \
4258 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4259 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4260 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4262 nrs_write_read "$RUNAS"
4263 tbf_verify 20 20 "$RUNAS"
4265 do_nodes $(comma_list $(osts_nodes)) \
4266 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4267 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4268 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4270 nrs_write_read "$RUNAS"
4271 # with parameter "RUNAS", it will match the latest rule
4272 # "ext_b" first, so the limited write rate is 10.
4273 tbf_verify 10 10 "$RUNAS"
4276 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4278 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4279 skip "Need OST version at least 2.10.58"
4281 do_nodes $(comma_list $(osts_nodes)) \
4282 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4283 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4284 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4285 nrs_write_read "runas -u 500 -g 1000"
4286 tbf_verify 5 5 "runas -u 500 -g 1000"
4288 do_nodes $(comma_list $(osts_nodes)) \
4289 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4290 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4291 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4293 nrs_write_read "runas -u 500"
4294 tbf_verify 20 10 "runas -u 500"
4296 do_nodes $(comma_list $(osts_nodes)) \
4297 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4298 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4299 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4300 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4301 nrs_write_read "runas -u 500"
4302 tbf_verify 10 10 "runas -u 500"
4303 tbf_verify 20 10 "runas -u 500"
4304 cleanup_77k "ext_a ext_b" "fifo"
4306 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4309 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4310 skip "Need OST version at least 2.10.56"
4312 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4313 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4315 local output=$(do_facet ost1 lctl get_param \
4316 ost.OSS.ost_io.nrs_policies | \
4317 awk '/name: tbf/ {print;exit}' | \
4318 awk -F ': ' '{print $2}')
4320 if [ "$output" != "tbf" ]; then
4321 error "The generic TBF output is '$output', not 'tbf'"
4324 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4326 run_test 77l "check the output of NRS policies for generic TBF"
4329 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4330 skip "Need OST version at least 2.9.54"
4333 local dir=$DIR/$tdir
4335 mkdir $dir || error "mkdir $dir failed"
4336 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4339 local nodes=$(comma_list $(osts_nodes))
4340 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4341 ost.OSS.ost_io.nrs_delay_min=4 \
4342 ost.OSS.ost_io.nrs_delay_max=4 \
4343 ost.OSS.ost_io.nrs_delay_pct=100
4344 [ $? -ne 0 ] && error "Failed to set delay policy"
4346 local start=$SECONDS
4347 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4348 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4349 oflag=direct conv=fdatasync ||
4350 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4351 error "dd on client failed (1)"; }
4352 local elapsed=$((SECONDS - start))
4354 # NRS delay doesn't do sub-second timing, so a request enqueued at
4355 # 0.9 seconds can be dequeued at 4.0
4356 [ $elapsed -lt 3 ] &&
4357 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4358 error "Single 1M write should take at least 3 seconds"; }
4361 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4362 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4363 oflag=direct conv=fdatasync ||
4364 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4365 error "dd on client failed (2)"; }
4366 elapsed=$((SECONDS - start))
4368 [ $elapsed -lt 30 ] &&
4369 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4370 error "Ten 1M writes should take at least 30 seconds"; }
4372 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4373 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4377 run_test 77m "check NRS Delay slows write RPC processing"
4379 test_77n() { #LU-10802
4380 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4381 skip "Need OST version at least 2.10.58"
4384 # Configure jobid_var
4385 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4386 if [ $saved_jobid_var != procname_uid ]; then
4387 set_persistent_param_and_check client \
4388 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4391 do_nodes $(comma_list $(osts_nodes)) \
4392 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4393 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4394 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4397 tbf_verify 20 20 "$RUNAS"
4399 do_nodes $(comma_list $(osts_nodes)) \
4400 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4401 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4406 do_nodes $(comma_list $(osts_nodes)) \
4407 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4408 ost.OSS.ost_io.nrs_policies="fifo"
4412 local current_jobid_var=$($LCTL get_param -n jobid_var)
4413 if [ $saved_jobid_var != $current_jobid_var ]; then
4414 set_persistent_param_and_check client \
4415 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4418 run_test 77n "check wildcard support for TBF JobID NRS policy"
4421 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
4422 skip "need OST > 2.14.54"
4424 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
4425 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
4426 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
4427 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
4428 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
4429 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
4431 run_test 77o "Changing rank should not panic"
4436 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4437 skip "need MDS >= 2.14.54"
4439 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4440 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4442 for i in {1..50}; do
4445 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={500}&gid={500} rate=100'" &
4447 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
4449 wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
4450 wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
4452 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
4454 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
4456 wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
4457 wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
4460 run_test 77q "Parallel TBF rule definitions should not panic"
4462 test_78() { #LU-6673
4465 oss=$(comma_list $(osts_nodes))
4466 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4467 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4469 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4470 # Valid return codes are:
4471 # 0: Tuning succeeded
4472 # ENODEV: Policy is still stopped
4473 # EAGAIN: Policy is being initialized
4474 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4475 error "Expected set_param to return 0|ENODEV|EAGAIN"
4477 # Cleanup the ORR policy
4478 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4479 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4482 run_test 78 "Enable policy and specify tunings right away"
4485 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4486 test_mkdir $DIR/$tdir
4488 # Prevent interference from layout intent RPCs due to
4489 # asynchronous writeback. These will be tested in 130c below.
4490 do_nodes ${CLIENTS:-$HOSTNAME} sync
4492 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4493 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4495 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4496 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4497 local facet=mds$((mdtidx + 1))
4499 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4500 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4504 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4505 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4510 run_test 79 "xattr: intent error"
4513 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4520 mkdir_on_mdt0 $DIR1/$tdir
4521 mkdir -p $DIR1/$tdir/dir
4522 createmany -o $DIR1/$tdir/dir/f 10 ||
4523 error "create files under remote dir failed $i"
4525 cp /etc/passwd $DIR1/$tdir/$tfile
4527 #migrate open file should fails
4528 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4530 # give multiop a chance to open
4533 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4534 error "migrate open files should failed with open files"
4538 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4539 error "migrate remote dir error"
4541 echo "Finish migration, then checking.."
4542 for file in $(find $DIR1/$tdir); do
4543 mdt_index=$($LFS getstripe -m $file)
4544 [ $mdt_index == $MDTIDX ] ||
4545 error "$file is not on MDT${MDTIDX}"
4548 diff /etc/passwd $DIR1/$tdir/$tfile ||
4549 error "file different after migration"
4551 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4553 run_test 80a "migrate directory when some children is being opened"
4557 kill -9 $migrate_pid
4561 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4562 local migrate_dir1=$DIR1/$tdir/migrate_dir
4563 local migrate_dir2=$DIR2/$tdir/migrate_dir
4564 local migrate_run=$LUSTRE/tests/migrate.sh
4572 trap cleanup_80b EXIT
4573 #prepare migrate directory
4574 mkdir -p $migrate_dir1
4575 for F in {1,2,3,4,5}; do
4576 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4577 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4580 #migrate the directories among MDTs
4583 mdt_idx=$((RANDOM % MDSCOUNT))
4584 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4586 [ $rc -ne 0 -o $rc -ne 16 ] || break
4591 echo "start migration thread $migrate_pid"
4592 #Access the files at the same time
4593 start_time=$(date +%s)
4594 echo "accessing the migrating directory for 5 minutes..."
4596 ls $migrate_dir2 > /dev/null || {
4597 echo "read dir fails"
4600 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4601 echo "access file1 fails"
4605 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4606 echo "access file2/3 fails"
4610 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4611 echo "access file4 fails"
4615 stat $migrate_dir2/file5 > /dev/null || {
4616 echo "stat file5 fails"
4620 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4621 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4622 echo "touch file failed with $rc1"
4626 if [ -e $migrate_dir2/source_file ]; then
4627 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4628 &>/dev/null || rc1=$?
4629 if [ -e $migrate_dir2/link_file ]; then
4630 rm -rf $migrate_dir2/link_file
4633 mrename $migrate_dir2/source_file \
4634 $migrate_dir2/target_file &>/dev/null || rc1=$?
4635 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4636 echo "rename failed with $rc1"
4640 if [ -e $migrate_dir2/target_file ]; then
4641 rm -rf $migrate_dir2/target_file &>/dev/null ||
4644 rm -rf $migrate_dir2/source_file &>/dev/null ||
4647 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4648 echo "unlink failed with $rc1"
4653 end_time=$(date +%s)
4654 duration=$((end_time - start_time))
4655 if [ $((duration % 10)) -eq 0 ]; then
4656 if [ $show_time -eq 1 ]; then
4657 echo "...$duration seconds"
4664 kill -0 $migrate_pid || {
4665 echo "migration stopped 1"
4669 [ $duration -ge 300 ] && break
4672 #check migration are still there
4673 kill -0 $migrate_pid || error "migration stopped 2"
4676 run_test 80b "Accessing directory during migration"
4679 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4683 mkdir -p $DIR1/$tdir
4685 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4686 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4689 touch d0/0 || error "create 0 failed"
4690 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4691 stat d0/0 && error "stat mv filed succeed"
4692 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4693 stat d0/0 || error "stat failed"
4695 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4697 if [ $t -ne 3 ]; then
4698 ls -ai $DIR1/$tdir/d0
4699 error "expect 3 get $t"
4704 run_test 81a "rename and stat under striped directory"
4707 [ $MDSCOUNT -lt 2 ] &&
4708 skip "We need at least 2 MDTs for this test"
4715 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4716 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4725 for i in $(seq $total); do
4726 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4730 kill -9 $setattr_pid
4732 run_test 81b "rename under striped directory doesn't deadlock"
4735 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4736 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4737 skip "Need MDS version at least 2.13.52"
4739 # source is local, source parent is remote
4740 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4741 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4742 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4743 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4744 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4745 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4746 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4747 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4749 # source is remote, source parent is local
4750 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4751 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4752 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4753 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4754 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4755 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4756 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4757 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4759 # source and source parent are remote
4760 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4761 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4762 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4763 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4764 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4765 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4766 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4767 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4769 # source and source parent are remote, and source is remote object
4770 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4771 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4772 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4773 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4774 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4775 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4776 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4778 run_test 81c "rename revoke LOOKUP lock for remote object"
4781 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4782 skip "Need MDS version at least 2.6.92"
4784 # Client 1 creates a file.
4785 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4787 # Client 2 opens the file.
4788 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4790 # Client 1 makes the file an orphan.
4791 rm $DIR1/$tfile || error "rm"
4792 # Client 2 sets EA "user.multiop".
4794 wait $pid2 || error "multiop 2"
4795 # Client 1 gets EA "user.multiop". This used to fail because the EA
4796 # cache refill would get "trusted.link" from mdd_xattr_list() but
4797 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4800 wait $pid1 || error "multiop 1"
4802 run_test 82 "fsetxattr and fgetxattr on orphan files"
4805 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4812 $LFS mkdir -i1 -c2 $tdir
4817 echo "start pid $pid1 to create/unlink striped directory"
4819 # Access the directory at the same time
4823 stat $tdir > /dev/null 2>&1
4827 echo "start pid $pid2 to stat striped directory"
4835 run_test 83 "access striped directory while it is being created/unlinked"
4838 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4839 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4843 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4844 error "create $tfile failed"
4845 mtime=$(stat -c%Y $DIR/$tfile)
4846 mtime=$((mtime + 200))
4848 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4849 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4851 touch -c -m $mtime $DIR/$tfile &
4853 # sleep a while to let 'touch' run first
4855 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4858 wait $setattr_pid || true
4860 run_test 84 "0-nlink race in lu_object_find()"
4863 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4868 [ "$SLOW" = "yes" ] && duration=600
4869 # Open/Create under striped directory
4873 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4874 touch $tdir/f{0..3} > /dev/null 2>&1
4878 echo "start pid $pid1 to open/create under striped directory"
4880 # unlink the striped directory at the same time
4884 rm -rf $tdir > /dev/null 2>&1
4888 echo "start pid $pid2 to unlink striped directory"
4897 run_test 90 "open/create and unlink striped directory"
4900 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4905 [ "$SLOW" = "yes" ] && duration=600
4906 # chmod striped directory
4910 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4911 chmod go+w $tdir > /dev/null 2>&1
4915 echo "start pid $pid1 to chmod striped directory"
4917 # unlink the striped directory at the same time
4921 rm -rf $tdir > /dev/null 2>&1
4925 echo "start pid $pid2 to unlink striped directory"
4934 run_test 91 "chmod and unlink striped directory"
4937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4940 local cmd="exec $fd<$DIR1/$tdir"
4941 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4944 trap "eval $cmd" EXIT
4945 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4946 rmdir ../$tdir || error "rmdir ../$tdir fails"
4948 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4949 $LCTL set_param fail_loc=0x1408
4950 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4951 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4952 error "create remote dir succeeds"
4953 $LCTL set_param fail_loc=0
4957 run_test 92 "create remote directory under orphan directory"
4964 mkdir -p $DIR1/$tfile-1/
4965 mkdir -p $DIR2/$tfile-2/
4966 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4967 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4968 do_facet $SINGLEMDS "$LCTL set_param -n \
4969 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4970 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4971 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4973 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4976 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4980 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4981 do_facet $SINGLEMDS "$LCTL set_param -n \
4982 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4984 $LFS getstripe $DIR1/$tfile-1/file1
4985 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4986 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4987 $LFS getstripe $DIR2/$tfile-2/file2
4988 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4989 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4990 echo "rc1=$rc1 and rc2=$rc2 "
4991 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4992 error "object allocate on same ost detected"
4994 run_test 93 "alloc_rr should not allocate on same ost"
4997 $LCTL set_param osc.*.idle_timeout=0
4998 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
5000 local before=$(date +%s)
5004 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
5005 $LCTL set_param fail_val=5 fail_loc=0x80000312
5006 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
5010 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
5011 $LCTL set_param fail_val=6 fail_loc=0x80000329
5012 $LCTL mark kill $pid
5015 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
5018 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
5020 evict=$(do_facet client $LCTL get_param \
5021 osc.$FSNAME-OST*-osc-*/state |
5022 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
5024 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5025 (do_facet client $LCTL get_param \
5026 osc.$FSNAME-OST*-osc-*/state;
5027 error "eviction happened: $evict before:$before")
5028 $LCTL set_param osc.*.idle_timeout=debug
5030 run_test 94 "signal vs CP callback race"
5034 skip "Reserved for glimpse-ahead" && return
5035 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5036 skip "Need MDS version at least 2.10.55"
5040 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5042 lctl set_param -n mdc.*.stats=clear
5043 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5045 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5046 # first stat from server should return size data and save glimpse
5047 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5048 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5049 # second stat to check size is NOT cached on client without IO lock
5050 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5052 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5053 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5056 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5059 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5060 skip "Need MDS version at least 2.10.55"
5064 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5066 lctl set_param -n mdc.*.stats=clear
5067 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5068 cancel_lru_locks mdc
5069 # first stat data from server should have size
5070 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5071 # second stat to check size is cached on client
5072 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5074 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5075 # both stats should cause no glimpse requests
5076 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5079 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5082 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5083 skip "Need MDS version at least 2.10.55"
5087 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5089 lctl set_param -n mdc.*.stats=clear
5090 lctl set_param -n osc.*.stats=clear
5091 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5093 # check that size is merged from MDT and OST correctly
5094 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5095 error "Wrong size from stat #1"
5097 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5098 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5102 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5105 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5106 skip "Need MDS version at least 2.10.55"
5110 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5113 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5114 lctl set_param -n mdc.*.stats=clear
5115 $TRUNCATE $DIR2/$tdir/dom 4096
5117 # check that reported size is valid after file grows to OST and
5118 # is truncated back to MDT stripe size
5119 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5120 error "Wrong size from stat #1"
5122 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5123 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5127 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5130 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5131 skip "Need MDS version at least 2.11.50"
5133 local dom=$DIR/$tdir/dom
5134 local dom2=$DIR2/$tdir/dom
5137 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5139 cancel_lru_locks mdc
5140 dd if=/dev/urandom of=$dom bs=12000 count=1
5141 $TRUNCATE $dom2 6000
5142 cancel_lru_locks mdc
5143 lctl set_param -n mdc.*.stats=clear
5144 # expect read-on-open to return all data before write
5145 cat /etc/hosts >> $dom
5146 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5147 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5149 run_test 100e "DoM: read on open and file size"
5152 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5153 skip "Need MDS version at least 2.10.55"
5155 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5157 $CHECKSTAT -t file $DIR1/$tfile
5159 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5160 sysctl -wq vm.dirty_writeback_centisecs=0
5162 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5165 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5166 error_noexit "Write fails"
5167 # must discard pages
5168 lctl set_param -n mdc.*.stats=clear
5169 rm $DIR2/$tfile || error "Unlink fails"
5171 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5172 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5174 run_test 101a "Discard DoM data on unlink"
5177 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5178 skip "Need MDS version at least 2.10.55"
5180 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5181 touch $DIR1/${tfile}_2
5183 $CHECKSTAT -t file $DIR1/$tfile
5185 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5186 sysctl -wq vm.dirty_writeback_centisecs=0
5188 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5191 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5192 # must discard pages
5193 lctl set_param -n mdc.*.stats=clear
5194 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5196 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5197 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5199 run_test 101b "Discard DoM data on rename"
5202 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5203 skip "Need MDS version at least 2.10.55"
5205 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5207 $CHECKSTAT -t file $DIR1/$tfile
5209 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5210 sysctl -wq vm.dirty_writeback_centisecs=0
5212 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5215 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5216 $MULTIOP $DIR1/$tfile O_c &
5219 lctl set_param -n mdc.*.stats=clear
5220 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5221 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5223 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5224 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5226 run_test 101c "Discard DoM data on close-unlink"
5228 # test to verify file handle related system calls
5229 # (name_to_handle_at/open_by_handle_at)
5230 # The new system calls are supported in glibc >= 2.14.
5232 # test to verify we can open by handle an unlinked file from > 1 client
5233 # This test opens the file normally on $DIR1, which is on one mount, and then
5234 # opens it by handle on $DIR2, which is on a different mount.
5236 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
5237 skip "Needs MDS version 2.11.57 or later"
5239 echo "Test file_handle syscalls" > $DIR/$tfile ||
5240 error "write failed"
5241 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5242 error "check_fhandle_syscalls $tfile failed"
5244 # test this is working on DNE directories also
5245 if (( MDSCOUNT > 1 MDS1_VERSION >= $(version_code 2.14.52) )); then
5246 $LFS mkdir -i 1 $DIR/$tdir.remote
5247 cancel_lru_locks mdc
5248 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5249 error "check_fhandle_syscalls $tdir.remote failed"
5250 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5251 cancel_lru_locks mdc
5252 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5253 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5255 $LFS mkdir -c -1 $DIR/$tdir.stripe
5256 cancel_lru_locks mdc
5257 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5258 error "check_fhandle_syscalls $tdir.stripe failed"
5259 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5260 cancel_lru_locks mdc
5261 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5262 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5265 run_test 102 "Test open by handle of unlinked file"
5267 # Compare file size between first & second mount, ensuring the client correctly
5268 # glimpses even with unused speculative locks - LU-11670
5270 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5271 skip "Lockahead needs OST version at least 2.10.50"
5275 test_mkdir -p $DIR/$tdir
5277 # Force file on to OST0
5278 $LFS setstripe -i 0 $DIR/$tdir
5280 # Do not check multiple locks on glimpse
5281 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5282 $LCTL set_param fail_loc=0x415
5284 # Delay write commit by 2 seconds to guarantee glimpse wins race
5285 # The same fail_loc is used on client & server so it can work in the
5286 # single node sanity setup
5287 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5289 echo "Incorrect size expected (no glimpse fix):"
5290 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5292 if [ $rc -eq 0 ]; then
5293 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5296 # guarantee write commit timeout has expired
5299 # Clear fail_loc on client
5300 $LCTL set_param fail_loc=0
5302 # Delay write commit by 2 seconds to guarantee glimpse wins race
5303 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5304 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5306 # Write commit is still delayed by 2 seconds
5307 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5309 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5311 # guarantee write commit timeout has expired
5314 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5316 run_test 103 "Test size correctness with lockahead"
5322 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5333 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5334 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5335 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5336 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5344 local xtimes=($(get_stat_xtimes))
5345 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5347 echo "STAT a|m|ctime ${xtimes[*]}"
5348 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5349 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5350 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5351 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5352 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5353 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5354 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5358 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5359 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5360 skip "Need MDS version at least 2.12.4"
5363 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5364 local atime_diff=$(do_facet $SINGLEMDS \
5365 lctl get_param -n mdd.*MDT0000*.atime_diff)
5367 do_facet $SINGLEMDS \
5368 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5370 stack_trap "do_facet $SINGLEMDS \
5371 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5373 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5374 check_mdt_xtimes $mdtdev
5377 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5378 check_mdt_xtimes $mdtdev
5380 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5383 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5385 kill -USR1 $pid && wait $pid || error "multiop failure"
5386 check_mdt_xtimes $mdtdev
5391 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5392 # on the client side
5393 xtimes=($(get_stat_xtimes))
5394 $MULTIOP $DIR/$tfile O_c &
5397 kill -USR1 $pid && wait $pid || error "multiop failure"
5398 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5399 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5400 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5401 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5402 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5403 check_mdt_xtimes $mdtdev
5406 # Change ctime via chmod
5407 $MULTIOP $DIR/$tfile o_tc &
5410 kill -USR1 $pid && wait $pid || error "multiop failure"
5411 check_mdt_xtimes $mdtdev
5413 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5416 test_mkdir -p $DIR/$tdir
5417 echo test > $DIR/$tdir/$tfile
5418 $LCTL set_param fail_loc=0x416
5419 cancel_lru_locks osc & sleep 1
5420 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5422 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5424 run_test 105 "Glimpse and lock cancel race"
5427 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5428 skip_env "Test only for ldiskfs and statx() supported"
5433 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5435 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5436 btime=$($STATX -c %W $DIR/$tfile)
5437 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5439 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5440 [[ $btime == $mdt_btime ]] ||
5441 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5444 run_test 106a "Verify the btime via statx()"
5447 statx_supported || skip_env "statx() only test"
5452 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5453 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5454 cancel_lru_locks $OSC
5455 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5457 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5458 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5459 error "$STATX should send 1 glimpse RPC to $OSC"
5461 cancel_lru_locks $OSC
5462 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5463 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5464 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5466 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5467 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5468 [ $rpcs_after -eq $rpcs_before ] ||
5469 error "$STATX should not send glimpse RPCs to $OSC"
5471 cancel_lru_locks $OSC
5472 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5473 $STATX --cached=always $DIR/$tfile
5474 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5475 [ $rpcs_after -eq $rpcs_before ] ||
5476 error "$STATX should not send glimpse RPCs to $OSC"
5478 cancel_lru_locks $OSC
5479 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5480 $STATX -c %Y $DIR/$tfile
5481 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5482 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5483 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5485 cancel_lru_locks $OSC
5486 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5487 $STATX -c %s $DIR/$tfile
5488 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5489 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5490 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5492 cancel_lru_locks $OSC
5493 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5494 $STATX -c %b $DIR/$tfile
5495 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5496 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5497 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5499 run_test 106b "Glimpse RPCs test for statx"
5502 statx_supported || skip_env "statx() only test"
5507 # Mask supported in stx_attributes by Lustre is
5508 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5509 mask=$($STATX -c %p $DIR/$tfile)
5510 [[ $mask == "30" ]] ||
5511 error "supported stx_attributes: got '$mask', expected '30'"
5512 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5513 mask=$($STATX -c %r $DIR/$tfile)
5514 [[ $mask == "10" ]] ||
5515 error "got immutable flags '$mask', expected '10'"
5516 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5517 mask=$($STATX -c %r $DIR/$tfile)
5518 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5519 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5520 mask=$($STATX -c %r $DIR/$tfile)
5521 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5522 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5523 mask=$($STATX -c %r $DIR/$tfile)
5524 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5525 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5526 mask=$($STATX -c %r $DIR/$tfile)
5527 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5528 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5529 mask=$($STATX -c %r $DIR/$tfile)
5530 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5532 run_test 106c "Verify statx attributes mask"
5534 test_107a() { # LU-1031
5535 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5539 $LFS getstripe $DIR1/$tfile
5541 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5543 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5545 kill -USR1 $MULTIPID2
5547 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5548 error "First grouplock does not block second one"
5550 echo "First grouplock blocks second one"
5552 kill -USR1 $MULTIPID1
5556 run_test 107a "Basic grouplock conflict"
5559 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5563 $LFS getstripe $DIR1/$tfile
5565 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5567 multiop $DIR2/$tfile Or10c &
5571 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5572 error "Grouplock does not block IO"
5574 echo "Grouplock blocks IO"
5577 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5580 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5581 error "First grouplock does not block second one"
5583 echo "First grouplock blocks second one"
5586 kill -USR1 $MULTIPID1
5589 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5590 error "Second grouplock thread disappeared"
5593 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5594 error "Second grouplock does not block IO"
5596 echo "Second grouplock blocks IO"
5599 kill -USR1 $MULTIPID3
5604 run_test 107b "Grouplock is added to the head of waiting list"
5609 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5610 error "Create $DIR1/$tfile failed"
5612 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5613 error "dd $DIR1/$tfile failed"
5614 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5615 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5617 $TRUNCATE $DIR1/$tfile 2000
5618 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5619 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5621 #define OBD_FAIL_OSC_DELAY_IO 0x414
5622 $LCTL set_param fail_val=4 fail_loc=0x80000414
5623 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5627 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5629 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5631 run_test 108a "lseek: parallel updates"
5639 skip "Clients need to be on different nodes than the servers"
5641 umount_client $MOUNT
5642 umount_client $MOUNT2
5644 echo "Starting race between client mount instances (50 iterations):"
5645 for i in {1..50}; do
5648 #define OBD_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
5649 $LCTL set_param -n fail_loc=0x80001417
5651 mount_client $MOUNT & pid1=$!
5652 mount_client $MOUNT2 & pid2=$!
5653 wait $pid1 || error "Mount $MOUNT fails with $?"
5654 wait $pid2 || error "Mount $MOUNT2 fails with $?"
5656 umount_client $MOUNT & pid1=$!
5657 umount_client $MOUNT2 & pid2=$!
5658 wait $pid1 || error "Umount $MOUNT fails with $?"
5659 wait $pid2 || error "Umount $MOUNT2 fails with $?"
5661 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
5667 mount_client $MOUNT2
5670 run_test 109 "Race with several mount instances on 1 node"
5673 local before=$(date +%s)
5680 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
5681 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
5683 # disable last_xid logic by dropping link reply
5684 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
5687 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
5688 do_facet mds1 lctl set_param fail_loc=0x534
5690 # RPC will race with its Resend and the Resend will sleep to let
5691 # the original lock to get granted & cancelled.
5693 # AST_SENT is set artificially, so an explicit conflict is not needed
5695 # The woken up Resend gets a new lock, but client does not wait for it
5698 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
5700 # Take a conflict to wait long enough to see the eviction
5703 # let the client reconnect
5705 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
5706 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
5708 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5709 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
5710 error "eviction happened: $evict before:$before")
5712 run_test 110 "do not grant another lock on resend"
5715 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
5716 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
5717 skip "MDT0 and MDT1 should be on the same node"
5720 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
5721 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
5723 mkdir $DIR1/$tdir/mdt0dir/foodir
5724 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
5726 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
5728 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
5730 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
5731 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
5733 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
5736 rm $DIR2/$tdir/mdt1dir/file2
5739 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
5744 rm -r $DIR1/$tdir || error "Removing test dir failed"
5746 run_test 111 "A racy rename/link an open file should not cause fs corruption"
5749 (( MDSCOUNT >= 2 )) ||
5750 skip "We need at least 2 MDTs for this test"
5752 (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
5753 skip "Need server version at least 2.14.54"
5758 rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
5760 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
5762 mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
5763 $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
5764 $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
5765 error "setdirstripe s3 failed"
5766 $LCTL set_param lmv.*.qos_threshold_rr=90
5767 mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
5768 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
5769 (( count == 64 )) || error "only $count subdirs created on MDT0"
5771 $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
5772 error "setdirstripe s3 failed"
5773 mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
5774 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
5775 (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
5777 run_test 112 "update max-inherit in default LMV"
5779 log "cleanup: ======================================================"
5781 # kill and wait in each test only guarentee script finish, but command in script
5782 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5783 # otherwise umount below will fail
5784 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5789 check_and_cleanup_lustre