6 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
7 # bug number for skipped test: LU-7105
9 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 #skip tests for PPC until they are fixed
12 if [[ $(uname -m) = ppc64 ]]; then
13 # bug number: LU-11597 LU-11787
14 ALWAYS_EXCEPT+=" 16a 71a "
18 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
21 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
22 OPENFILE=${OPENFILE:-openfile}
23 OPENUNLINK=${OPENUNLINK:-openunlink}
24 export MULTIOP=${MULTIOP:-multiop}
25 export TMP=${TMP:-/tmp}
26 MOUNT_2=${MOUNT_2:-"yes"}
27 CHECK_GRANT=${CHECK_GRANT:-"yes"}
28 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
32 export NAME=${NAME:-local}
34 LUSTRE=${LUSTRE:-`dirname $0`/..}
35 . $LUSTRE/tests/test-framework.sh
39 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
43 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
44 # bug number for skipped test:
45 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
46 # LU-2829 / LU-2887 - make allowances for ZFS slowness
47 TEST33_NFILES=${TEST33_NFILES:-1000}
50 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
57 check_and_setup_lustre
62 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
64 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
65 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
67 # $RUNAS_ID may get set incorrectly somewhere else
68 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
70 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
76 [ -f $DIR2/$tfile ] || error "Check create"
77 chmod 777 $DIR2/$tfile
78 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
79 error "Check attribute update for 0777"
81 chmod a-x $DIR2/$tfile
82 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
83 error "Check attribute update for 0666"
86 $CHECKSTAT -a $DIR1/$tfile ||
87 error "Check unlink - removes file on other mountpoint"
89 run_test 1 "Check attribute updates on 2 mount points"
95 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
96 error "Either not file type or perms not 0777"
98 run_test 2a "check cached attribute updates on 2 mtpt's ========"
104 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
105 error "Either not file type or perms not 0777"
107 run_test 2b "check cached attribute updates on 2 mtpt's ========"
109 # NEED TO SAVE ROOT DIR MODE
112 $CHECKSTAT -t dir -p 0777 $DIR2 ||
113 error "Either not dir type or perms not 0777"
115 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
119 $CHECKSTAT -t dir -p 0755 $DIR2 ||
120 error "Either not file type or perms not 0775"
122 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
129 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
132 run_test 2e "check chmod on root is propagated to others"
135 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
137 local remote_dir=$tdir/remote_dir
140 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
141 error "Create remote directory failed"
143 touch $DIR1/$remote_dir/$tfile ||
144 error "Create file under remote directory failed"
145 chmod 777 $DIR1/$remote_dir/$tfile ||
146 error "Chmod file under remote directory failed"
148 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
149 error "Check attr of file under remote directory failed"
151 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
152 error "Chown file under remote directory failed"
154 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
155 error "Check owner of file under remote directory failed"
157 cd $DIR2/$remote_dir || error "enter remote dir"
158 rm -rf $DIR1/$remote_dir/$tfile ||
159 error "Unlink remote directory failed"
161 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
162 error "unlink file still exists!"
164 cd $DIR2/$tdir || error "exit remote dir"
165 rm -rf $DIR1/$tdir || error "unlink directory failed"
167 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
170 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
172 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
174 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
175 echo "$DIR1/$tfile has $block1 blocks"
176 echo "$DIR2/$tfile has $block2 blocks"
177 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
179 run_test 2g "check blocks update on sync write"
182 local target="this/is/good"
183 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
184 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
185 error "link $DIR2/$tfile not as expected"
187 run_test 3 "symlink on one mtpt, readlink on another ==========="
190 multifstat $DIR1/f4 $DIR2/f4
192 run_test 4 "fstat validation on multiple mount points =========="
196 $TRUNCATE $DIR2/f5 100
197 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
198 error "Either not file type or size not equal to 100 bytes"
201 run_test 5 "create a file on one mount, truncate it on the other"
204 openunlink $DIR1/$tfile $DIR2/$tfile || \
205 error "openunlink $DIR1/$tfile $DIR2/$tfile"
207 run_test 6 "remove of open file on other node =================="
211 opendirunlink $DIR1/$dir $DIR2/$dir || \
212 error "opendirunlink $DIR1/$dir $DIR2/$dir"
214 run_test 7 "remove of open directory on other node ============="
217 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
218 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
220 run_test 8 "remove of open special file on other node =========="
226 for C in a b c d e f g h i j k l; do
227 dir=`eval echo \\$DIR$MTPT`
228 echo -n $C >> $dir/f9
229 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
231 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
232 error "`od -a $DIR1/f9` != abcdefghijkl"
234 run_test 9a "append of file with sub-page size on multiple mounts"
236 #LU-10681 - tiny writes & appending to sparse striped file
238 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
240 $LFS setstripe -c 2 -S 1M $DIR/$tfile
241 echo "foo" >> $DIR/$tfile
242 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
243 error "sparse dd $DIR2/$tfile failed"
244 echo "foo" >> $DIR/$tfile
246 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
247 echo "Data read (expecting 'foo')": $data
248 [ "$data" = "foo" ] || error "append to sparse striped file failed"
250 run_test 9b "append to striped sparse file"
257 for C in a b c d e f g h i j k l; do
258 dir=`eval echo \\$DIR$MTPT`
259 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
260 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
261 OFFSET=`expr $OFFSET + 1`
263 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
264 error "`od -a $DIR1/f10` != abcdefghijkl"
266 run_test 10a "write of file with sub-page size on multiple mounts "
270 yes "R" | head -c 4000 >$TMP/f10b-seed
271 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
273 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
275 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
277 # create a test file locally to compare
278 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
279 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
280 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
281 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
283 run_test 10b "write of file with sub-page size on multiple mounts "
287 multiop_bg_pause $DIR1/d11/f O_c || return 1
289 cp -p /bin/ls $DIR1/d11/f
293 wait $MULTIPID || error "wait for PID $MULTIPID failed"
294 [ $RC -eq 0 ] && error || true
296 run_test 11 "execution of file opened for write should return error ===="
299 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
301 run_test 12 "test lock ordering (link, stat, unlink)"
303 test_13() { # bug 2451 - directory coherency
305 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
307 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
309 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
310 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
311 # need to run it twice
312 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
314 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
315 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
317 run_test 13 "test directory page revocation"
320 test_mkdir $DIR1/$tdir
321 cp -p /bin/ls $DIR1/$tdir/$tfile
322 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
325 $DIR2/$tdir/$tfile && error || true
328 run_test 14aa "execution of file open for write returns -ETXTBSY"
331 test_mkdir $DIR1/$tdir
332 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
333 $DIR1/$tdir/sleep 60 &
335 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
338 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
340 test_14b() { # bug 3192, 7040
341 test_mkdir $DIR1/$tdir
342 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
343 $DIR1/$tdir/sleep 60 &
345 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
346 error "expected truncate error, got success"
348 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
350 run_test 14b "truncate of executing file returns -ETXTBSY ======"
352 test_14c() { # bug 3430, 7040
353 test_mkdir $DIR1/$tdir
354 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
355 $DIR1/$tdir/sleep 60 &
357 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
359 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
361 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
363 test_14d() { # bug 10921
364 test_mkdir $DIR1/$tdir
365 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
366 $DIR1/$tdir/sleep 60 &
369 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
371 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
373 run_test 14d "chmod of executing file is still possible ========"
375 test_15() { # bug 974 - ENOSPC
377 sh oos2.sh $MOUNT1 $MOUNT2
378 wait_delete_completed
379 grant_error=`dmesg | grep "> available"`
380 [ -z "$grant_error" ] || error "$grant_error"
382 run_test 15 "test out-of-space with multiple writers ==========="
385 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
386 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
387 # pass a 2500 operation dual-mount run within the time limit.
388 if [ "$(facet_fstype ost1)" = "zfs" ]; then
389 FSXNUM=$((COUNT / 5))
391 elif [ "$SLOW" = "yes" ]; then
392 FSXNUM=$((COUNT * 5))
400 local file1=$DIR1/$tfile
401 local file2=$DIR2/$tfile
402 local stripe_size=$(do_facet $SINGLEMDS \
403 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
405 # to allocate grant because it may run out due to test_15.
406 $LFS setstripe -c -1 $file1
407 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
408 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
411 $LFS setstripe -c -1 $file1 # b=10919
412 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
413 || error "fsx failed"
416 # O_DIRECT reads and writes must be aligned to the device block size.
417 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
418 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
420 run_test 16a "$FSXNUM iterations of dual-mount fsx"
422 # Consistency check for tiny writes, LU-9409
424 local file1=$DIR1/$tfile
425 local file2=$DIR2/$tfile
427 # to allocate grant because it may run out due to test_15.
428 lfs setstripe -c -1 $file1
429 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
430 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
433 lfs setstripe -c -1 $file1 # b=10919
434 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
435 # create a mix of tiny writes & normal writes
436 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
439 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
442 local file1=$DIR1/$tfile
443 local file2=$DIR2/$tfile
444 local stripe_size=$(do_facet $SINGLEMDS \
445 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
447 [ $(facet_fstype ost1) != ldiskfs ] && skip "dio on ldiskfs only"
449 # to allocate grant because it may run out due to test_15.
450 $LFS setstripe -c -1 $file1
451 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
452 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
454 wait_delete_completed
456 local list=$(comma_list $(osts_nodes))
457 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
458 skip "not cache-capable obdfilter"
461 set_osd_param $list '' read_cache_enable 0
462 set_osd_param $list '' writethrough_cache_enable 0
464 $LFS setstripe -c -1 $file1 # b=10919
465 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
466 || error "fsx failed"
469 set_osd_param $list '' read_cache_enable 1
470 set_osd_param $list '' writethrough_cache_enable 1
474 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
477 test_17() { # bug 3513, 3667
478 remote_ost_nodsh && skip "remote OST with nodsh" && return
480 lfs setstripe $DIR1/$tfile -i 0 -c 1
481 cp $SAMPLE_FILE $DIR1/$tfile
482 cancel_lru_locks osc > /dev/null
483 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
484 do_facet ost1 lctl set_param fail_loc=0x8000030a
485 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
486 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
488 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
490 run_test 17 "resource creation/LVB creation race ==============="
493 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
496 for idx in {a..z}; do
497 local ptr=EXCEPT_ALWAYS_18$idx
498 [ x${!ptr} = xtrue ] || continue
500 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
503 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
506 run_test 18 "mmap sanity check ================================="
508 test_19() { # bug3811
509 local node=$(facet_active_host ost1)
511 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
513 # check whether obdfilter is cache capable at all
514 get_osd_param $node '' read_cache_enable >/dev/null ||
515 skip "not cache-capable obdfilter"
517 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
518 set_osd_param $node '' readcache_max_filesize 4096
519 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
520 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
521 cp $TMP/$tfile $DIR1/$tfile
522 for i in `seq 1 20`; do
523 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
524 cancel_lru_locks $OSC > /dev/null
525 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
526 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
528 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
529 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
530 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
531 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
533 set_osd_param $node '' readcache_max_filesize $MAX
536 run_test 19 "test concurrent uncached read races ==============="
540 cancel_lru_locks $OSC
541 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
542 $MULTIOP $DIR1/f20 Ow8190c
543 $MULTIOP $DIR2/f20 Oz8194w8190c
544 $MULTIOP $DIR1/f20 Oz0r8190c
545 cancel_lru_locks $OSC
546 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
548 error $CNTD" page left in cache after lock cancel" || true
550 run_test 20 "test extra readahead page left in cache ===="
557 test_21() { # Bug 5907
558 test_mkdir $DIR1/$tdir
559 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
561 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
562 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
563 test -d $DIR1/$tdir || error "Mounted directory disappeared"
565 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
568 run_test 21 " Try to remove mountpoint on another dir ===="
570 test_23() { # Bug 5972
571 local at_diff=$(do_facet $SINGLEMDS \
572 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
573 echo "atime should be updated while another read" > $DIR1/$tfile
575 # clear the lock(mode: LCK_PW) gotten from creating operation
576 cancel_lru_locks $OSC
579 sleep $((at_diff + 1))
581 echo "starting reads"
582 multiop_bg_pause $DIR1/$tfile or20_c || return 1
583 # with SOM and opencache enabled, we need to close a file and cancel
584 # open lock to get atime propogated to MDS
585 kill -USR1 $! || return 2
588 time2=$(stat -c "%X" $DIR/$tfile)
589 echo "new atime is $time2"
591 [ $time2 -gt $time1 ] || error "atime was not updated"
592 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
595 run_test 23 " others should see updated atime while another read===="
599 lfs df || error "lfs df failed"
600 lfs df -ih || error "lfs df -ih failed"
601 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
602 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
603 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
604 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
606 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
607 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
608 lctl --device %osc deactivate
609 lfs df -i || error "lfs df -i with deactivated OSC failed"
610 lctl --device %osc activate
611 lfs df || error "lfs df with reactivated OSC failed"
613 run_test 24a "lfs df [-ih] [path] test ========================="
617 fsnum=$(lfs_df | grep -c "summary")
618 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
620 run_test 24b "lfs df should show both filesystems ==============="
623 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
625 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
628 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
629 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
631 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
632 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
633 error "setfacl $DIR2/$tdir #1"
634 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
635 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
636 error "setfacl $DIR2/$tdir #2"
637 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
638 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
639 error "setfacl $DIR2/$tdir #3"
640 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
641 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
642 error "setfacl $DIR2/$tdir #4"
643 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
647 run_test 25a "change ACL on one mountpoint be seen on another ==="
650 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
652 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
654 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
657 $LFS mkdir -i 1 $DIR1/$tdir
658 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
659 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
661 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
662 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
663 error "setfacl $DIR2/$tdir #1"
664 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
665 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
666 error "setfacl $DIR2/$tdir #2"
667 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
668 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
669 error "setfacl $DIR2/$tdir #3"
670 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
671 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
672 error "setfacl $DIR2/$tdir #4"
673 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
677 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
680 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
682 run_test 26a "allow mtime to get older"
687 echo "aaa" >> $DIR1/$tfile
689 chmod a+x $DIR2/$tfile
690 mt1=`stat -c %Y $DIR1/$tfile`
691 mt2=`stat -c %Y $DIR2/$tfile`
693 if [ x"$mt1" != x"$mt2" ]; then
694 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
697 run_test 26b "sync mtime between ost and mds"
700 cancel_lru_locks $OSC
702 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
707 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
712 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
714 lctl set_param -n ldlm.dump_namespaces ""
715 wait $DD1_PID $DD2_PID
716 [ $? -ne 0 ] && lctl dk $TMP/debug || true
718 run_test 27 "align non-overlapping extent locks from request ==="
720 test_28() { # bug 9977
721 ECHO_UUID="ECHO_osc1_UUID"
722 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
724 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
725 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
726 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
730 attach echo_client ECHO_osc1 $ECHO_UUID
734 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
735 $LCTL --device $tECHOID destroy "${tOBJID}:0"
743 # reading of 1st stripe should pass
744 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
745 # reading of 2nd stripe should fail (this stripe was destroyed)
746 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
748 # now, recreating test file
749 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
750 # reading of 1st stripe should pass
751 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
752 # reading of 2nd stripe should pass
753 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
756 run_test 28 "read/write/truncate file with lost stripes"
758 test_30() { #b=11110, LU-2523
759 test_mkdir $DIR1/$tdir
760 cp -f /bin/bash $DIR1/$tdir/bash
761 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
762 $DIR1/$tdir/bash -c 'sleep 2;
763 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
767 run_test 30 "recreate file race"
770 test_mkdir $DIR1/$tdir
771 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
772 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
773 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
774 lctl set_param fail_loc=0x314
775 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
776 awk 'BEGIN { FS="+" } /in/ {print $1}')
777 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
779 run_test 31a "voluntary cancel / blocking ast race=============="
782 remote_ost || { skip "local OST" && return 0; }
783 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
785 # make sure there is no local locks due to destroy
786 wait_mds_ost_sync || error "wait_mds_ost_sync()"
787 wait_delete_completed || error "wait_delete_completed()"
789 test_mkdir $DIR1/$tdir
790 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
791 cp /etc/hosts $DIR/$tdir/$tfile
792 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
793 lctl set_param fail_loc=0x314
794 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
795 do_facet ost1 lctl set_param fail_loc=0x316
797 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
798 lctl set_param fail_loc=0
799 do_facet ost1 lctl set_param fail_loc=0
800 # cleanup: reconnect the client back
803 run_test 31b "voluntary OST cancel / blocking ast race=============="
805 # enable/disable lockless truncate feature, depending on the arg 0/1
806 enable_lockless_truncate() {
807 lctl set_param -n $OSC.*.lockless_truncate $1
810 test_32a() { # bug 11270
811 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
812 local stripe_size=$(do_facet $SINGLEMDS \
813 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
815 save_lustre_params client "$OSC.*.lockless_truncate" > $p
816 cancel_lru_locks $OSC
817 enable_lockless_truncate 1
819 lfs setstripe -c -1 $DIR1/$tfile
820 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
822 clear_stats $OSC.*.${OSC}_stats
824 log "checking cached lockless truncate"
825 $TRUNCATE $DIR1/$tfile 8000000
826 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
827 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
828 error "cached truncate isn't lockless"
830 log "checking not cached lockless truncate"
831 $TRUNCATE $DIR2/$tfile 5000000
832 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
833 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
834 error "not cached truncate isn't lockless"
836 log "disabled lockless truncate"
837 enable_lockless_truncate 0
838 clear_stats $OSC.*.${OSC}_stats
839 $TRUNCATE $DIR2/$tfile 3000000
840 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
841 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
842 error "lockless truncate disabling failed"
844 # restore lockless_truncate default values
845 restore_lustre_params < $p
848 run_test 32a "lockless truncate"
850 test_32b() { # bug 11270
851 remote_ost_nodsh && skip "remote OST with nodsh" && return
854 local facets=$(get_facets OST)
855 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
857 save_lustre_params client "osc.*.contention_seconds" > $p
858 save_lustre_params $facets \
859 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
860 save_lustre_params $facets \
861 "ldlm.namespaces.filter-*.contended_locks" >> $p
862 save_lustre_params $facets \
863 "ldlm.namespaces.filter-*.contention_seconds" >> $p
864 clear_stats $OSC.*.${OSC}_stats
866 # agressive lockless i/o settings
867 do_nodes $(comma_list $(osts_nodes)) \
868 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
869 ldlm.namespaces.filter-*.contended_locks=0 \
870 ldlm.namespaces.filter-*.contention_seconds=60"
871 lctl set_param -n $OSC.*.contention_seconds=60
873 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
875 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
878 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
879 error "lockless i/o was not triggered"
880 # disable lockless i/o (it is disabled by default)
881 do_nodes $(comma_list $(osts_nodes)) \
882 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
883 ldlm.namespaces.filter-*.contended_locks=32 \
884 ldlm.namespaces.filter-*.contention_seconds=0"
885 # set contention_seconds to 0 at client too, otherwise Lustre still
886 # remembers lock contention
887 lctl set_param -n $OSC.*.contention_seconds=0
888 clear_stats $OSC.*.${OSC}_stats
890 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
892 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
895 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
896 error "lockless i/o works when disabled"
898 restore_lustre_params <$p
901 run_test 32b "lockless i/o"
905 local mdts=$(get_facets MDS)
910 for mds in ${mdts//,/ }; do
912 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
913 xargs readlink -f" ))
914 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
917 stat=$(( stat + val))
922 # commit on sharing tests
924 remote_mds_nodsh && skip "remote MDS with nodsh" && return
926 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
927 [ $CLIENTCOUNT -lt 2 ] &&
928 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
930 local nfiles=${TEST33_NFILES:-10000}
931 local param_file=$TMP/$tfile-params
932 local fstype=$(facet_fstype $SINGLEMDS)
934 save_lustre_params $(get_facets MDS) \
935 "mdt.*.commit_on_sharing" > $param_file
943 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
947 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
949 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
950 echo "=== START createmany old: $jbdold transaction"
951 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")
952 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
953 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
954 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
955 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
956 avgtime=$(( avgtime + elapsed ))
958 eval cos${COS}_jbd=$((avgjbd / 3))
959 eval cos${COS}_time=$((avgtime / 3))
962 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
963 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
964 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
965 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
967 restore_lustre_params < $param_file
971 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
973 # commit on sharing tests
975 remote_mds_nodsh && skip "remote MDS with nodsh" && return
977 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
978 [ $CLIENTCOUNT -ge 2 ] ||
979 { skip "Need two or more clients, have $CLIENTCOUNT" &&
981 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
983 local nfiles=${TEST33_NFILES:-10000}
984 local param_file=$TMP/$tfile-params
986 save_lustre_params $(get_facets MDS) \
987 "mdt.*.commit_on_sharing" > $param_file
996 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1000 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1001 $DIR1/$tdir-\\\$(hostname)-$i"
1003 jbdold=$(print_jbd_stat)
1004 echo "=== START createmany old: $jbdold transaction"
1005 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1006 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1007 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1009 jbdnew=$(print_jbd_stat)
1010 jbd=$(( jbdnew - jbdold ))
1011 echo "=== END createmany new: $jbdnew transaction : \
1012 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1013 avgjbd=$(( avgjbd + jbd ))
1014 avgtime=$(( avgtime + elapsed ))
1016 eval cos${COS}_jbd=$((avgjbd / 3))
1017 eval cos${COS}_time=$((avgtime / 3))
1020 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1021 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1022 [ "$cos0_jbd" != 0 ] &&
1023 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1024 [ "$cos0_time" != 0 ] &&
1025 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1027 restore_lustre_params < $param_file
1031 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1034 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1035 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1036 skip "DNE CoS not supported" && return
1042 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1043 # do twice in case transaction is committed before unlock, see LU-8200
1045 # remote dir is created on MDT1, which enqueued lock of $tdir on
1047 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1048 mkdir $DIR/$tdir/local.$i
1050 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1051 echo "sync_count $sync_count"
1052 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1055 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1056 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1057 # during sleep remote mkdir should have been committed and canceled
1058 # remote lock spontaneously, which shouldn't trigger sync
1060 mkdir $DIR/$tdir/local.3
1061 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1062 echo "sync_count $sync_count"
1063 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1065 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1067 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1071 local nodes=$(comma_list $(mdts_nodes))
1075 # trigger CoS twice in case transaction commit before unlock
1078 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1080 commit_nr=$(do_nodes $nodes \
1081 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1082 total=$((total + commit_nr));
1087 echo "CoS count $total"
1088 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1092 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1093 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1094 skip "DNE CoS not supported" && return
1096 # remote directory create
1097 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1098 # remote directory unlink
1099 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1100 # striped directory create
1101 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1102 # striped directory setattr
1103 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1104 "chmod 713 $DIR/$tdir"
1105 # striped directory unlink
1106 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1109 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1110 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1111 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1112 touch $DIR/$tdir/d1/tgt" \
1113 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1115 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1116 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1117 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1118 touch $DIR/$tdir/d1/src" \
1119 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1121 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1122 "$LFS migrate -m 1 $DIR/$tdir"
1126 run_test 33d "DNE distributed operation should trigger COS"
1129 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1130 [ $CLIENTCOUNT -ge 2 ] ||
1131 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1133 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1134 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1135 skip "DNE CoS not supported" && return
1137 local client2=${CLIENT2:-$(hostname)}
1141 local nodes=$(comma_list $(mdts_nodes))
1142 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1144 $LFS mkdir -c 2 $DIR/$tdir
1145 mkdir $DIR/$tdir/subdir
1146 echo abc > $DIR/$tdir/$tfile
1147 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1148 do_node $client2 touch $DIR/$tdir/subdir
1150 local async_commit_count=$(do_nodes $nodes \
1151 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1152 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1156 run_test 33e "DNE local operation shouldn't trigger COS"
1158 # End commit on sharing tests
1160 get_ost_lock_timeouts() {
1161 local nodes=${1:-$(comma_list $(osts_nodes))}
1163 local locks=$(do_nodes $nodes \
1164 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1172 do_nodes $(comma_list $(osts_nodes)) \
1173 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1174 for i in $(seq $OSTCOUNT); do
1175 wait_osc_import_ready client ost$i
1180 remote_ost_nodsh && skip "remote OST with nodsh" && return
1184 trap cleanup_34 EXIT RETURN
1185 for OPER in notimeout timeout ; do
1186 rm $DIR1/$tfile 2>/dev/null
1187 lock_in=$(get_ost_lock_timeouts)
1188 if [ $OPER == "timeout" ] ; then
1189 for j in `seq $OSTCOUNT`; do
1190 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1191 do_facet ost$j lctl set_param fail_loc=0x511
1193 echo lock should expire
1195 for j in `seq $OSTCOUNT`; do
1196 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1197 do_facet ost$j lctl set_param fail_loc=0x512
1199 echo lock should not expire
1201 echo writing on client1
1202 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1204 echo reading on client2
1205 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1206 # wait for a lock timeout
1208 lock_out=$(get_ost_lock_timeouts)
1209 if [ $OPER == "timeout" ] ; then
1210 if [ $lock_in == $lock_out ]; then
1211 error "no lock timeout happened"
1216 if [ $lock_in != $lock_out ]; then
1217 error "lock timeout happened"
1225 run_test 34 "no lock timeout under IO"
1227 test_35() { # bug 17645
1230 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1231 awk '/generation/{print $2}')
1233 generation[count]=$g
1237 test_mkdir $MOUNT1/$tdir
1238 cancel_lru_locks mdc
1240 # Let's initiate -EINTR situation by setting fail_loc and take
1241 # write lock on same file from same client. This will not cause
1242 # bl_ast yet as lock is already in local cache.
1243 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1244 do_facet client "lctl set_param fail_loc=0x80000317"
1245 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1246 let timeout=timeout*3
1248 while test $nr -lt 10; do
1249 log "Race attempt $nr"
1250 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1251 awk '/ldlm_bl_callback/ { print $2 }')
1252 test "x$blk1" = "x" && blk1=0
1253 createmany -o $MOUNT2/$tdir/a 4000 &
1257 # Let's make conflict and bl_ast
1258 ls -la $MOUNT1/$tdir > /dev/null &
1261 log "Wait for $pid1 $pid2 for $timeout sec..."
1263 kill -9 $pid1 $pid2 > /dev/null 2>&1
1265 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1266 awk '/ldlm_bl_callback/ { print $2 }')
1267 test "x$blk2" = "x" && blk2=0
1268 test $blk2 -gt $blk1 && break
1269 rm -fr $MOUNT1/$tdir
1270 cancel_lru_locks mdc
1273 do_facet client "lctl set_param fail_loc=0x0"
1274 df -h $MOUNT1 $MOUNT2
1276 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1277 awk '/generation/{print $2}')
1279 if ! test "$g" -eq "${generation[count]}"; then
1280 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1282 for imp in $list; do
1283 if [ $c = $count ]; then
1288 imp=$(echo "$imp" | awk -F"." '{print $2}')
1289 error "Eviction happened on import $imp"
1294 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1296 test_36() { #bug 16417
1301 test_mkdir $DIR1/$tdir
1302 $LFS setstripe -c -1 $DIR1/$tdir
1305 let SIZE_B=SIZE*1024*1024
1306 sync; sleep 2; sync # wait for delete thread
1307 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1308 wait_destroy_complete || error "wait_destroy_complete failed"
1310 while [ $i -le 10 ]; do
1311 lctl mark "start test - cycle ($i)"
1312 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1313 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1314 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1315 sync # sync data from client cache
1316 sync_all_data # sync data from server cache (delayed allocation)
1318 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1319 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1321 rm -f $DIR1/$tdir/$tfile
1322 kill -USR1 $read_pid
1324 sync; sleep 2; sync # Ensure new statfs
1325 wait_delete_completed
1326 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1327 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1329 # this free space! not used
1330 (( $after_dd <= $after)) ||
1331 error "space leaked after_dd:$after_dd > after:$after"
1335 run_test 36 "handle ESTALE/open-unlink correctly"
1337 test_37() { # bug 18695
1338 test_mkdir $DIR1/$tdir
1339 multiop_bg_pause $DIR1/$tdir D_c || return 1
1341 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1342 createmany -m $DIR2/$tdir/f 10000
1343 # set mtime/atime backward
1344 touch -t 198001010000 $DIR2/$tdir
1345 kill -USR1 $MULTIPID
1346 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1347 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1350 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1352 # this should be set to past
1353 TEST_39_MTIME=`date -d "1 year ago" +%s`
1357 local client1=${CLIENT1:-`hostname`}
1358 local client2=${CLIENT2:-`hostname`}
1360 do_node $client1 "touch $DIR1/$tfile"
1362 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1363 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1364 [ "$mtime1" = $TEST_39_MTIME ] || \
1365 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1367 local d1=`do_node $client1 date +%s`
1368 do_node $client1 'echo hello >> '$DIR1/$tfile
1369 local d2=`do_node $client1 date +%s`
1371 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1372 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1373 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1375 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1377 for (( i=0; i < 2; i++ )) ; do
1378 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1379 [ "$mtime2" = "$mtime3" ] || \
1380 error "mtime ($mtime2) changed (to $mtime3) on rename"
1382 cancel_lru_locks osc
1383 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1386 run_test 39a "test from 11063 =================================="
1389 local client1=${CLIENT1:-`hostname`}
1390 local client2=${CLIENT2:-`hostname`}
1394 local mtime1=`stat -c %Y $DIR1/$tfile`
1395 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1398 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1400 for (( i=0; i < 2; i++ )) ; do
1401 local mtime3=`stat -c %Y $DIR1/$tfile`
1402 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1404 [ "$mtime3" = "$mtime4" ] || \
1405 error "different mtime on clients: $mtime3, $mtime4"
1406 [ "$mtime3" = $TEST_39_MTIME ] || \
1407 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1409 cancel_lru_locks osc
1410 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1413 run_test 39b "11063 problem 1 =================================="
1416 local client1=${CLIENT1:-`hostname`}
1417 local client2=${CLIENT2:-`hostname`}
1419 echo hello > $DIR1/$tfile
1421 local mtime1=`stat -c %Y $DIR1/$tfile`
1422 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1423 [ "$mtime1" = "$mtime2" ] || \
1424 error "create: different mtime on clients: $mtime1, $mtime2"
1427 $TRUNCATE $DIR1/$tfile 1
1429 for (( i=0; i < 2; i++ )) ; do
1430 local mtime3=`stat -c %Y $DIR1/$tfile`
1431 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1433 [ "$mtime3" = "$mtime4" ] || \
1434 error "different mtime on clients: $mtime3, $mtime4"
1435 [ "$mtime3" -gt $mtime2 ] || \
1436 error "truncate did not update mtime: $mtime2, $mtime3"
1438 cancel_lru_locks osc
1439 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1442 run_test 39c "check truncate mtime update ======================"
1444 test_39d() { # LU-7310
1446 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1448 local mtime1=$(stat -c %Y $DIR2/$tfile)
1449 [ "$mtime1" = $TEST_39_MTIME ] ||
1450 error "mtime: $mtime1, should be $TEST_39_MTIME"
1453 # define OBD_FAIL_OSC_NO_GRANT 0x411
1454 $LCTL set_param fail_loc=0x411
1456 local d1=$(date +%s)
1457 echo hello >> $DIR1/$tfile
1458 local d2=$(date +%s)
1460 $LCTL set_param fail_loc=0
1462 cancel_lru_locks $OSC
1464 local mtime2=$(stat -c %Y $DIR2/$tfile)
1465 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1466 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1468 run_test 39d "sync write should update mtime"
1470 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1471 # avoid unexpected delays due to previous tests
1473 cancel_lru_locks mdc
1474 do_nodes $(comma_list $(mdts_nodes)) \
1475 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1476 do_nodes $(comma_list $(mdts_nodes)) \
1477 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1478 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1481 # check that pid exists hence second operation wasn't blocked by first one
1482 # if it is so then there is no conflict, return 0
1483 # else second operation is conflicting with first one, return 1
1484 check_pdo_conflict() {
1487 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1488 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1498 # test 40: check non-blocking operations
1500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1502 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1503 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1505 mkdir $DIR1/$tfile &
1508 touch $DIR2/$tfile-2
1509 check_pdo_conflict $PID1 || error "create is blocked"
1510 mkdir $DIR2/$tfile-3
1511 check_pdo_conflict $PID1 || error "mkdir is blocked"
1512 link $DIR2/$tfile-2 $DIR2/$tfile-4
1513 check_pdo_conflict $PID1 || error "link is blocked"
1514 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1515 check_pdo_conflict $PID1 || error "rename is blocked"
1516 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1517 check_pdo_conflict $PID1 || error "getattr is blocked"
1518 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1519 rmdir $DIR2/$tfile-3
1520 check_pdo_conflict $PID1 || error "unlink is blocked"
1522 # all operations above shouldn't wait the first one
1523 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1528 run_test 40a "pdirops: create vs others =============="
1531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1534 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1535 touch $DIR1/$tfile &
1539 touch $DIR2/$tfile-2
1540 check_pdo_conflict $PID1 || error "create is blocked"
1541 mkdir $DIR2/$tfile-3
1542 check_pdo_conflict $PID1 || error "mkdir is blocked"
1543 link $DIR2/$tfile-2 $DIR2/$tfile-4
1544 check_pdo_conflict $PID1 || error "link is blocked"
1545 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1546 check_pdo_conflict $PID1 || error "rename is blocked"
1547 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1548 check_pdo_conflict $PID1 || error "getattr is blocked"
1549 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1550 rmdir $DIR2/$tfile-3
1551 check_pdo_conflict $PID1 || error "unlink is blocked"
1552 # all operations above shouldn't wait the first one
1554 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1559 run_test 40b "pdirops: open|create and others =============="
1562 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1565 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1566 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1567 link $DIR1/$tfile $DIR1/$tfile-0 &
1571 touch $DIR2/$tfile-2
1572 check_pdo_conflict $PID1 || error "create is blocked"
1573 mkdir $DIR2/$tfile-3
1574 check_pdo_conflict $PID1 || error "mkdir is blocked"
1575 link $DIR2/$tfile-2 $DIR2/$tfile-4
1576 check_pdo_conflict $PID1 || error "link is blocked"
1577 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1578 check_pdo_conflict $PID1 || error "rename is blocked"
1579 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1580 check_pdo_conflict $PID1 || error "getattr is blocked"
1581 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1582 rmdir $DIR2/$tfile-3
1583 check_pdo_conflict $PID1 || error "unlink is blocked"
1585 # all operations above shouldn't wait the first one
1586 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1591 run_test 40c "pdirops: link and others =============="
1594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1597 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1598 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1603 touch $DIR2/$tfile-2
1604 check_pdo_conflict $PID1 || error "create is blocked"
1605 mkdir $DIR2/$tfile-3
1606 check_pdo_conflict $PID1 || error "mkdir is blocked"
1607 link $DIR2/$tfile-2 $DIR2/$tfile-4
1608 check_pdo_conflict $PID1 || error "link is blocked"
1609 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1610 check_pdo_conflict $PID1 || error "rename is blocked"
1611 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1612 check_pdo_conflict $PID1 || error "getattr is blocked"
1613 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1614 rmdir $DIR2/$tfile-3
1615 check_pdo_conflict $PID1 || error "unlink is blocked"
1617 # all operations above shouldn't wait the first one
1618 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1622 run_test 40d "pdirops: unlink and others =============="
1625 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1628 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1629 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1630 mv $DIR1/$tfile $DIR1/$tfile-0 &
1634 touch $DIR2/$tfile-2
1635 check_pdo_conflict $PID1 || error "create is blocked"
1636 mkdir $DIR2/$tfile-3
1637 check_pdo_conflict $PID1 || error "mkdir is blocked"
1638 link $DIR2/$tfile-2 $DIR2/$tfile-4
1639 check_pdo_conflict $PID1 || error "link is blocked"
1640 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1641 check_pdo_conflict $PID1 || error "getattr is blocked"
1642 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1643 rmdir $DIR2/$tfile-3
1644 check_pdo_conflict $PID1 || error "unlink is blocked"
1646 # all operations above shouldn't wait the first one
1647 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1652 run_test 40e "pdirops: rename and others =============="
1654 # test 41: create blocking operations
1657 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1658 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1659 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1662 mkdir $DIR2/$tfile && error "mkdir must fail"
1663 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1667 run_test 41a "pdirops: create vs mkdir =============="
1671 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1672 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1673 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1676 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1677 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1681 run_test 41b "pdirops: create vs create =============="
1685 touch $DIR1/$tfile-2
1686 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1687 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1688 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1691 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1692 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1696 run_test 41c "pdirops: create vs link =============="
1700 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1701 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1702 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1705 rm $DIR2/$tfile || error "unlink must succeed"
1706 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1710 run_test 41d "pdirops: create vs unlink =============="
1714 touch $DIR1/$tfile-2
1715 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1716 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1717 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1720 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1721 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1725 run_test 41e "pdirops: create and rename (tgt) =============="
1729 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1730 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1731 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1734 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1735 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1739 run_test 41f "pdirops: create and rename (src) =============="
1743 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1744 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1745 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1748 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1749 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1753 run_test 41g "pdirops: create vs getattr =============="
1757 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1758 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1759 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1762 ls -lia $DIR2/ > /dev/null
1763 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1767 run_test 41h "pdirops: create vs readdir =============="
1769 # test 42: unlink and blocking operations
1772 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1773 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1774 mkdir $DIR1/$tfile &
1777 mkdir $DIR2/$tfile && error "mkdir must fail"
1778 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1782 run_test 42a "pdirops: mkdir vs mkdir =============="
1786 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1787 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1788 mkdir $DIR1/$tfile &
1791 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1792 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1796 run_test 42b "pdirops: mkdir vs create =============="
1800 touch $DIR1/$tfile-2
1801 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1802 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1803 mkdir $DIR1/$tfile &
1806 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1807 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1811 run_test 42c "pdirops: mkdir vs link =============="
1815 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1816 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1817 mkdir $DIR1/$tfile &
1820 rmdir $DIR2/$tfile || error "unlink must succeed"
1821 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1825 run_test 42d "pdirops: mkdir vs unlink =============="
1829 touch $DIR1/$tfile-2
1830 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1831 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1832 mkdir $DIR1/$tfile &
1835 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1836 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1840 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1844 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1845 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1846 mkdir $DIR1/$tfile &
1849 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1850 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1854 run_test 42f "pdirops: mkdir and rename (src) =============="
1858 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1859 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1860 mkdir $DIR1/$tfile &
1863 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1864 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1868 run_test 42g "pdirops: mkdir vs getattr =============="
1872 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1873 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1874 mkdir $DIR1/$tfile &
1877 ls -lia $DIR2/ > /dev/null
1878 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1882 run_test 42h "pdirops: mkdir vs readdir =============="
1884 # test 43: unlink and blocking operations
1888 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1889 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1893 mkdir $DIR2/$tfile || error "mkdir must succeed"
1894 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1898 run_test 43a "pdirops: unlink vs mkdir =============="
1903 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1904 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1908 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1909 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1913 run_test 43b "pdirops: unlink vs create =============="
1918 touch $DIR1/$tfile-2
1919 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1920 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1924 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1925 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1929 run_test 43c "pdirops: unlink vs link =============="
1934 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1935 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1939 rm $DIR2/$tfile && error "unlink must fail"
1940 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1944 run_test 43d "pdirops: unlink vs unlink =============="
1949 touch $DIR1/$tfile-2
1950 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1951 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1955 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1956 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1960 run_test 43e "pdirops: unlink and rename (tgt) =============="
1965 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1966 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1970 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1971 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1975 run_test 43f "pdirops: unlink and rename (src) =============="
1980 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1981 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1985 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1986 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1990 run_test 43g "pdirops: unlink vs getattr =============="
1995 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1996 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2000 ls -lia $DIR2/ > /dev/null
2001 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2005 run_test 43h "pdirops: unlink vs readdir =============="
2008 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2011 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2012 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2016 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
2017 check_pdo_conflict $PID1 &&
2018 { wait $PID1; error "remote mkdir isn't blocked"; }
2022 run_test 43i "pdirops: unlink vs remote mkdir"
2024 # test 44: rename tgt and blocking operations
2027 touch $DIR1/$tfile-2
2028 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2029 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2030 mv $DIR1/$tfile-2 $DIR1/$tfile &
2033 mkdir $DIR2/$tfile && error "mkdir must fail"
2034 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2038 run_test 44a "pdirops: rename tgt vs mkdir =============="
2042 touch $DIR1/$tfile-2
2043 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2044 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2045 mv $DIR1/$tfile-2 $DIR1/$tfile &
2048 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2049 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2053 run_test 44b "pdirops: rename tgt vs create =============="
2057 touch $DIR1/$tfile-2
2058 touch $DIR1/$tfile-3
2059 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2060 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2061 mv $DIR1/$tfile-2 $DIR1/$tfile &
2064 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
2065 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2069 run_test 44c "pdirops: rename tgt vs link =============="
2073 touch $DIR1/$tfile-2
2074 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2075 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2076 mv $DIR1/$tfile-2 $DIR1/$tfile &
2079 rm $DIR2/$tfile || error "unlink must succeed"
2080 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2084 run_test 44d "pdirops: rename tgt vs unlink =============="
2089 touch $DIR1/$tfile-2
2090 touch $DIR1/$tfile-3
2091 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2092 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2093 mv $DIR1/$tfile-2 $DIR1/$tfile &
2096 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2097 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2101 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2105 touch $DIR1/$tfile-2
2106 touch $DIR1/$tfile-3
2107 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2108 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2109 mv $DIR1/$tfile-2 $DIR1/$tfile &
2112 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2113 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2117 run_test 44f "pdirops: rename tgt and rename (src) =============="
2121 touch $DIR1/$tfile-2
2122 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2123 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2124 mv $DIR1/$tfile-2 $DIR1/$tfile &
2127 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2128 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2132 run_test 44g "pdirops: rename tgt vs getattr =============="
2136 touch $DIR1/$tfile-2
2137 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2138 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2139 mv $DIR1/$tfile-2 $DIR1/$tfile &
2142 ls -lia $DIR2/ > /dev/null
2143 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2147 run_test 44h "pdirops: rename tgt vs readdir =============="
2149 # test 44: rename tgt and blocking operations
2151 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2153 touch $DIR1/$tfile-2
2154 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2155 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2156 mv $DIR1/$tfile-2 $DIR1/$tfile &
2159 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2160 check_pdo_conflict $PID1 && { wait $PID1;
2161 error "remote mkdir isn't blocked"; }
2165 run_test 44i "pdirops: rename tgt vs remote mkdir"
2167 # test 45: rename src and blocking operations
2171 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2172 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2173 mv $DIR1/$tfile $DIR1/$tfile-2 &
2176 mkdir $DIR2/$tfile || error "mkdir must succeed"
2177 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2181 run_test 45a "pdirops: rename src vs mkdir =============="
2186 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2187 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2188 mv $DIR1/$tfile $DIR1/$tfile-2 &
2191 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2192 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2196 run_test 45b "pdirops: rename src vs create =============="
2201 touch $DIR1/$tfile-3
2202 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2203 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2204 mv $DIR1/$tfile $DIR1/$tfile-2 &
2207 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2208 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2212 run_test 45c "pdirops: rename src vs link =============="
2217 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2218 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2219 mv $DIR1/$tfile $DIR1/$tfile-2 &
2222 rm $DIR2/$tfile && error "unlink must fail"
2223 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2227 run_test 45d "pdirops: rename src vs unlink =============="
2232 touch $DIR1/$tfile-3
2233 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2234 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2235 mv $DIR1/$tfile $DIR1/$tfile-2 &
2238 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2239 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2243 run_test 45e "pdirops: rename src and rename (tgt) =============="
2248 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2249 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2250 mv $DIR1/$tfile $DIR1/$tfile-2 &
2253 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2254 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2258 run_test 45f "pdirops: rename src and rename (src) =============="
2263 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2264 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2265 mv $DIR1/$tfile $DIR1/$tfile-2 &
2268 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2269 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2273 run_test 45g "pdirops: rename src vs getattr =============="
2278 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2279 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2280 mv $DIR1/$tfile $DIR1/$tfile-2 &
2283 ls -lia $DIR2/ > /dev/null
2284 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2288 run_test 45h "pdirops: unlink vs readdir =============="
2291 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2294 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2295 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2296 mv $DIR1/$tfile $DIR1/$tfile-2 &
2299 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2300 check_pdo_conflict $PID1 && { wait $PID1;
2301 error "create remote dir isn't blocked"; }
2305 run_test 45i "pdirops: rename src vs remote mkdir"
2307 # test 46: link and blocking operations
2310 touch $DIR1/$tfile-2
2311 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2312 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2313 link $DIR1/$tfile-2 $DIR1/$tfile &
2316 mkdir $DIR2/$tfile && error "mkdir must fail"
2317 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2321 run_test 46a "pdirops: link vs mkdir =============="
2325 touch $DIR1/$tfile-2
2326 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2327 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2328 link $DIR1/$tfile-2 $DIR1/$tfile &
2331 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2332 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2336 run_test 46b "pdirops: link vs create =============="
2340 touch $DIR1/$tfile-2
2341 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2342 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2343 link $DIR1/$tfile-2 $DIR1/$tfile &
2346 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2347 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2351 run_test 46c "pdirops: link vs link =============="
2355 touch $DIR1/$tfile-2
2356 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2357 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2358 link $DIR1/$tfile-2 $DIR1/$tfile &
2361 rm $DIR2/$tfile || error "unlink must succeed"
2362 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2366 run_test 46d "pdirops: link vs unlink =============="
2370 touch $DIR1/$tfile-2
2371 touch $DIR1/$tfile-3
2372 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2373 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2374 link $DIR1/$tfile-2 $DIR1/$tfile &
2377 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2378 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2382 run_test 46e "pdirops: link and rename (tgt) =============="
2386 touch $DIR1/$tfile-2
2387 touch $DIR1/$tfile-3
2388 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2389 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2390 link $DIR1/$tfile-2 $DIR1/$tfile &
2393 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2394 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2398 run_test 46f "pdirops: link and rename (src) =============="
2402 touch $DIR1/$tfile-2
2403 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2404 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2405 link $DIR1/$tfile-2 $DIR1/$tfile &
2408 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2409 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2413 run_test 46g "pdirops: link vs getattr =============="
2417 touch $DIR1/$tfile-2
2418 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2419 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2420 link $DIR1/$tfile-2 $DIR1/$tfile &
2423 ls -lia $DIR2/ > /dev/null
2424 check_pdo_conflict $PID1 && { wait $PID1;
2425 error "readdir isn't blocked"; }
2429 run_test 46h "pdirops: link vs readdir =============="
2432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2434 touch $DIR1/$tfile-2
2435 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2436 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2437 link $DIR1/$tfile-2 $DIR1/$tfile &
2440 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2441 check_pdo_conflict $PID1 && { wait $PID1;
2442 error "remote mkdir isn't blocked"; }
2446 run_test 46i "pdirops: link vs remote mkdir"
2448 # test 47: remote mkdir and blocking operations
2450 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2451 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2453 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2454 $LFS mkdir -i 1 $DIR1/$tfile &
2457 mkdir $DIR2/$tfile && error "mkdir must fail"
2458 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2462 run_test 47a "pdirops: remote mkdir vs mkdir"
2465 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2466 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2468 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2469 $LFS mkdir -i 1 $DIR1/$tfile &
2472 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2473 check_pdo_conflict $PID1 && { wait $PID1;
2474 error "create isn't blocked"; }
2478 run_test 47b "pdirops: remote mkdir vs create"
2481 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2483 touch $DIR1/$tfile-2
2484 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2485 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2486 $LFS mkdir -i 1 $DIR1/$tfile &
2489 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2490 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2494 run_test 47c "pdirops: remote mkdir vs link"
2497 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2499 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2500 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2501 $LFS mkdir -i 1 $DIR1/$tfile &
2504 rmdir $DIR2/$tfile || error "unlink must succeed"
2505 check_pdo_conflict $PID1 && { wait $PID1;
2506 error "unlink isn't blocked"; }
2510 run_test 47d "pdirops: remote mkdir vs unlink"
2513 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2515 touch $DIR1/$tfile-2
2516 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2517 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2518 $LFS mkdir -i 1 $DIR1/$tfile &
2521 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2522 check_pdo_conflict $PID1 && { wait $PID1;
2523 error "rename isn't blocked"; }
2527 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2530 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2532 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2533 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2534 $LFS mkdir -i 1 $DIR1/$tfile &
2537 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2538 check_pdo_conflict $PID1 && { wait $PID1;
2539 error "rename isn't blocked"; }
2543 run_test 47f "pdirops: remote mkdir and rename (src)"
2546 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2550 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2551 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2552 $LFS mkdir -i 1 $DIR1/$tfile &
2555 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2556 check_pdo_conflict $PID1 && { wait $PID1;
2557 error "getattr isn't blocked"; }
2561 run_test 47g "pdirops: remote mkdir vs getattr"
2565 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2566 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2567 do_facet client "lctl set_param fail_loc=0x410"
2568 $TRUNCATE $DIR2/$tfile $trunc_size
2569 do_facet client "lctl set_param fail_loc=0x0"
2571 size=`stat -c %s $DIR2/$tfile`
2572 [ $size -eq $trunc_size ] || error "wrong size"
2574 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2578 local origfile=/etc/hosts
2580 filesize=$(stat -c %s $origfile)
2582 # create an empty file
2583 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2584 # cache layout lock on both mount point
2585 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2586 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2588 # open and sleep 2 seconds then read
2589 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2593 # create the layout of testing file
2594 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2595 error "dd $DIR1/$tfile failed"
2597 # MULTIOP proc should be able to read enough bytes and exit
2598 for ((i = 0; i < 6; i++)); do
2600 kill -0 $pid || break
2602 kill -0 $pid 2> /dev/null && error "multiop is still there"
2603 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2607 run_test 51a "layout lock: refresh layout should work"
2610 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2611 { skip "Need MDS version at least 2.3.59"; return 0; }
2613 local tmpfile=`mktemp`
2615 # create an empty file
2616 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2618 # delay glimpse so that layout has changed when glimpse finish
2619 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2620 $LCTL set_param fail_loc=0x1404
2621 stat -c %s $DIR2/$tfile |tee $tmpfile &
2625 # create layout of testing file
2626 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2627 error "dd $DIR1/$tfile failed"
2630 local fsize=$(cat $tmpfile)
2632 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2634 rm -f $DIR1/$tfile $tmpfile
2636 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2639 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2641 # set default layout to have 1 stripe
2643 $LFS setstripe -c 1 $DIR1/$tdir
2645 # create a file with empty layout
2646 $MCREATE $DIR1/$tdir/$tfile ||
2647 error "$MCREATE $DIR1/$tdir/$tfile failed"
2649 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2650 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2652 # change the layout of testing file
2653 echo "Setting layout to have $OSTCOUNT stripes ..."
2654 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2658 # write something to the file, it should be blocked on fetching layout
2659 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2660 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2663 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2664 # count to succeed with only 3/4 of the number of stripes (rounded up),
2665 # so creating striped files does not fail if an OST is offline or full
2666 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2667 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2671 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2674 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2675 cancel_lru_locks mdc
2677 # open should grant LAYOUT lock, mmap and read will install pages
2678 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2682 # rss before revoking
2683 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2684 echo "Before revoking layout lock: $br KB mapped"
2686 # cancel layout lock manually
2687 cancel_lru_locks mdc
2689 # rss after revoking
2690 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2693 wait $PID || error "wait PID $PID failed"
2695 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2697 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2701 echo "==> rename vs getattr vs setxattr should not deadlock"
2702 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2704 do_facet mds1 $LCTL set_param fail_loc=$1
2706 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2714 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2715 wait $PID1 || error "(3) mv failed"
2716 wait $PID2 || error "(4) stat failed"
2723 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2724 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2726 do_facet mds1 $LCTL set_param fail_loc=$1
2728 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2736 $MULTIOP $DIR2/d1/d2 Oc &
2740 stat $DIR/d1 || error "(2) stat failed"
2742 wait $PID1 || error "(3) mv failed"
2743 wait $PID2 || error "(4) stat failed"
2744 wait $PID3 && error "(5) multiop failed"
2750 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2751 save_lustre_params client "llite.*.xattr_cache" > $p
2752 lctl set_param llite.*.xattr_cache 1 ||
2753 { skip "xattr cache is not supported"; return 0; }
2755 #define OBD_FAIL_MDS_RENAME 0x153
2756 #define OBD_FAIL_MDS_RENAME2 0x154
2757 test_54_part1 0x80000153 || error 10
2758 test_54_part1 0x80000154 || error 11
2759 test_54_part2 0x80000153 || error 12
2760 test_54_part2 0x80000154 || error 13
2762 restore_lustre_params < $p
2765 run_test 54 "rename locking"
2768 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2770 #define OBD_FAIL_MDS_RENAME4 0x156
2771 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2773 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2778 wait $PID1 && error "(2) mv succeeded"
2782 run_test 55a "rename vs unlink target dir"
2786 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2788 #define OBD_FAIL_MDS_RENAME4 0x156
2789 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2791 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2796 wait $PID1 && error "(2) mv succeeded"
2800 run_test 55b "rename vs unlink source dir"
2804 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2806 #define OBD_FAIL_MDS_RENAME4 0x156
2807 do_facet mds1 $LCTL set_param fail_loc=0x156
2809 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2813 # while rename is sleeping, open and remove d3
2814 $MULTIOP $DIR2/d3 D_c &
2820 # while rename is sleeping 2nd time, close d3
2822 wait $PID2 || error "(3) multiop failed"
2824 wait $PID1 && error "(2) mv succeeded"
2828 run_test 55c "rename vs unlink orphan target dir"
2834 #define OBD_FAIL_MDS_RENAME3 0x155
2835 do_facet mds1 $LCTL set_param fail_loc=0x155
2836 mv $DIR/f1 $DIR/$tdir &
2840 # while rename is sleeping, create $tdir, but as a directory
2841 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2843 # link in reverse locking order
2844 ln $DIR2/f1 $DIR2/$tdir/
2846 wait $PID1 && error "(2) mv succeeded"
2849 run_test 55d "rename file vs link"
2852 local MDSVER=$(lustre_build_version $SINGLEMDS)
2853 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2854 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2857 test_mkdir $DIR1/$tdir
2858 file1=$DIR1/$tdir/file
2859 file2=$DIR2/$tdir/file
2861 echo orig > $file2 || error "Could not create $file2"
2862 version=$($LFS data_version $file1)
2865 echo append >> $file2 || error "Could not append to $file2"
2866 version2=$($LFS data_version $file1)
2867 [ "$version" != "$version2" ] ||
2868 error "append did not change data version: $version"
2871 echo overwrite > $file2 || error "Could not overwrite $file2"
2872 version3=$($LFS data_version $file1)
2873 [ "$version2" != "$version3" ] ||
2874 error "overwrite did not change data version: $version2"
2876 # Truncate before EOF
2877 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2878 version4=$($LFS data_version $file1)
2879 [ "$version3" != "$version4" ] ||
2880 error "truncate did not change data version: $version3"
2882 # Truncate after EOF
2883 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2884 version5=$($LFS data_version $file1)
2885 [ "$version4" != "$version5" ] ||
2886 error "truncate did not change data version: $version4"
2888 # Chmod do not change version
2889 chmod 400 $file2 || error "Could not chmod 400 $file2"
2890 version6=$($LFS data_version $file1)
2891 [ "$version5" == "$version6" ] ||
2892 error "chmod should not change data version: $version5 != $version6"
2894 # Chown do not change version
2895 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2896 version7=$($LFS data_version $file1)
2897 [ "$version5" == "$version7" ] ||
2898 error "chown should not change data version: $version5 != $version7"
2900 run_test 60 "Verify data_version behaviour"
2903 local test_dir=$tdir/test_dir
2905 mkdir -p $DIR1/$tdir
2906 if [ $MDSCOUNT -ge 2 ]; then
2908 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2909 error "Create remote directory failed"
2911 mkdir -p $DIR1/$test_dir
2913 cd $DIR2/$test_dir || error "cd directory failed"
2914 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2916 cd $DIR2/$tdir || error "exit directory"
2918 run_test 70a "cd directory && rm directory"
2920 test_70b() { # LU-2781
2922 mkdir -p $DIR1/$tdir
2924 touch $DIR1/$tdir/file
2925 for ((i = 0; i < 32; i++)); do
2926 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2928 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2930 touch $DIR1/$tdir/file
2931 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2932 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2933 rm -rf $DIR1/$tdir/test_dir ||
2934 error "cannot remove directory after rm_entry"
2935 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2937 run_test 70b "remove files after calling rm_entry"
2940 local server_version=$(lustre_version_code $SINGLEMDS)
2942 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2943 skip "Need MDS version at least 2.1.6" && return
2945 # Patch not applied to 2.2 and 2.3 branches
2946 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2947 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2948 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2951 checkfiemap --test ||
2952 { skip "checkfiemap not runnable: $?" && return; }
2953 # write data this way: hole - data - hole - data
2954 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2955 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2957 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2958 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2959 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2961 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2963 checkfiemap $DIR2/$tfile 81920 ||
2964 error "data is not flushed from client"
2965 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2968 # common case of "create file, copy file" on a single node
2969 # should not flush data from ost
2970 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2971 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2973 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2975 checkfiemap $DIR1/$tfile 81920 ||
2977 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2979 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2981 run_test 71a "correct file map just after write operation is finished"
2984 local server_version=$(lustre_version_code $SINGLEMDS)
2986 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2987 skip "Need MDS version at least 2.1.6" && return
2989 # Patch not applied to 2.2 and 2.3 branches
2990 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2991 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2992 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2994 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2996 checkfiemap --test ||
2997 { skip "error $?: checkfiemap failed" && return; }
2999 mkdir -p $DIR1/$tdir
3001 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3002 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3003 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
3005 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3006 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3008 run_test 71b "check fiemap support for stripecount > 1"
3011 local p="$TMP/sanityN-$TESTNAME.parameters"
3014 save_lustre_params client "llite.*.xattr_cache" > $p
3015 lctl set_param llite.*.xattr_cache 1 ||
3016 { skip "xattr cache is not supported"; return 0; }
3019 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3020 error "setfattr1 failed"
3021 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3022 error "getfattr1 failed"
3023 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3024 error "setfattr2 failed"
3025 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3026 error "getfattr2 failed"
3028 # check that trusted.link is consistent
3029 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3030 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3031 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3032 echo "$tlink1 $tlink2"
3033 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3037 restore_lustre_params < $p
3040 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3043 local p="$TMP/sanityN-$TESTNAME.parameters"
3044 save_lustre_params client "llite.*.xattr_cache" > $p
3045 lctl set_param llite.*.xattr_cache 1 ||
3046 { skip "xattr cache is not supported"; return 0; }
3049 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3050 error "setfattr1 failed"
3051 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3052 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3053 clear_stats llite.*.stats
3054 # PR lock should be cached by now on both clients
3055 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3056 # 2 hits for getfattr(0)+getfattr(size)
3057 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3058 error "not cached in $DIR1"
3059 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3060 # 4 hits for more getfattr(0)+getfattr(size)
3061 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3062 error "not cached in $DIR2"
3065 restore_lustre_params < $p
3068 run_test 73 "getxattr should not cause xattr lock cancellation"
3071 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3072 skip "Need MDS version at least 2.4.93" && return
3074 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3075 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3076 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3078 run_test 74 "flock deadlock: different mounts =============="
3082 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3083 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3084 cancel_lru_locks osc
3086 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3089 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3090 $LCTL set_param fail_loc=0x31d
3091 stat -c %s $DIR1/$tfile &
3096 # For bad lock error handler we should ASSERT and got kernel panic here
3098 $LCTL set_param fail_loc=0
3100 run_test 75 "osc: upcall after unuse lock==================="
3103 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3104 skip "Need MDS version at least 2.5.53" && return
3106 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3107 local fcount=$((MDSCOUNT * 256))
3112 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3118 test_mkdir $DIR/$tdir
3120 # drop all open locks and close any cached "open" files on the client
3121 cancel_lru_locks mdc
3123 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3124 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3125 local already=${#fid_list[@]}
3126 for (( i = 0; i < $already; i++ )) ; do
3127 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3130 echo -n "opening files: "
3131 ulimit -n $((fcount + 50))
3132 for ((i = 0; i < $fcount; i++)); do
3133 touch $DIR/$tdir/f_$i
3134 local fd=$(free_fd ${fd_list[i]})
3135 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3140 (( $i % 32 == 0 )) && echo -n "."
3144 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3146 # Possible errors in openfiles FID list.
3147 # 1. Missing FIDs. Check 1
3148 # 2. Extra FIDs. Check 1
3149 # 3. Duplicated FID. Check 2
3150 # 4. Invalid FIDs. Check 2
3151 # 5. Valid FID, points to some other file. Check 3
3154 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3155 error "${#fid_list[@]} != $fcount (+$already old) open files"
3157 echo -n "closing files: "
3158 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3159 local close_cmd="exec ${fd_list[fd]}<&-"
3161 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3163 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3164 echo "skip old open file $filename"
3166 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3170 rm --interactive=no $filename
3172 error "Nonexisting fid ${fid_list[fid]} listed."
3173 (( $fd % 32 == 0 )) && echo -n "."
3178 ls_op=$(ls $DIR2/$tdir | wc -l)
3180 error "Some openfiles are missing in lproc output"
3184 run_test 76 "Verify MDT open_files listing"
3188 local dir=$DIR/$tdir
3191 mkdir $dir || error "mkdir $dir failed"
3192 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3195 do_nodes $CLIENTS $myRUNAS \
3196 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3197 error "dd at 0 on client failed (1)"
3199 do_nodes $CLIENTS $myRUNAS \
3201 for ((i = 0; i < $n; i++)); do
3202 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3203 seek=\\\$i count=1 conv=notrunc &
3204 pids_w[\\\$i]=\\\$!;
3207 for ((i = 0; i < $n; i++)); do
3208 wait \\\${pids_w[\\\$i]};
3210 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3214 do_nodes $CLIENTS sync;
3215 cancel_lru_locks osc
3217 do_nodes $CLIENTS $myRUNAS \
3219 for ((i = 0; i < $n; i++)); do
3220 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3221 seek=\\\$i count=1 &
3222 pids_r[\\\$i]=\\\$!;
3225 for ((i = 0; i < $n; i++)); do
3226 wait \\\${pids_r[\\\$i]};
3228 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3232 cancel_lru_locks osc
3234 wait $pid_w || error "dd (write) failed (2)"
3235 wait $pid_r || error "dd (read) failed (3)"
3236 rm -rvf $dir || error "rm -rf $dir failed"
3239 test_77a() { #LU-3266
3242 oss=$(comma_list $(osts_nodes))
3243 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3245 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3246 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3251 run_test 77a "check FIFO NRS policy"
3253 test_77b() { #LU-3266
3256 oss=$(comma_list $(osts_nodes))
3258 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3259 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3260 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3261 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3263 echo "policy: crr-n, crrn_quantum 1"
3266 do_nodes $oss lctl set_param \
3267 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3268 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3270 echo "policy: crr-n, crrn_quantum 64"
3274 do_nodes $oss lctl set_param \
3275 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3276 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3279 run_test 77b "check CRR-N NRS policy"
3284 oss=$(comma_list $(osts_nodes))
3286 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3287 ost.OSS.*.nrs_"$policy"_quantum=1 \
3288 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3289 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3291 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3292 "physical, ${policy}_supported reads"
3295 do_nodes $oss lctl set_param \
3296 ost.OSS.*.nrs_${policy}_supported="writes" \
3297 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3299 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3300 "physical, ${policy}_supported writes"
3303 do_nodes $oss lctl set_param \
3304 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3305 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3306 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3307 "logical, ${policy}_supported reads_and_writes"
3311 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3316 test_77c() { #LU-3266
3318 orr_trr "orr" || rc=$?
3319 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3320 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3323 run_test 77c "check ORR NRS policy"
3325 test_77d() { #LU-3266
3327 orr_trr "trr" || rc=$?
3328 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3329 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3332 run_test 77d "check TRR nrs policy"
3339 do_facet $facet lctl set_param \
3340 ost.OSS.ost_io.nrs_tbf_rule="$*"
3342 error "failed to run operate '$*' on TBF rules"
3345 cleanup_tbf_verify()
3349 echo "cleanup_tbf $DIR/$tdir"
3352 wait_delete_completed
3357 local dir=$DIR/$tdir
3358 local client1=${CLIENT1:-$(hostname)}
3361 local np=$(check_cpt_number ost1)
3362 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3363 echo "cpu_npartitions on ost1 is $np"
3365 mkdir $dir || error "mkdir $dir failed"
3366 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3369 trap cleanup_tbf_verify EXIT
3370 echo "Limited write rate: $1, read rate: $2"
3371 echo "Verify the write rate is under TBF control"
3372 local start=$SECONDS
3373 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3374 bs=1M count=100 oflag=direct 2>&1
3375 local runtime=$((SECONDS - start + 1))
3376 local rate=$(bc <<< "scale=6; 100 / $runtime")
3377 echo "Write runtime is $runtime s, speed is $rate IOPS"
3379 # verify the write rate does not exceed TBF rate limit
3380 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3381 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3383 cancel_lru_locks osc
3385 echo "Verify the read rate is under TBF control"
3387 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3388 bs=1M count=100 iflag=direct 2>&1
3389 runtime=$((SECONDS - start + 1))
3390 rate=$(bc <<< "scale=6; 100 / $runtime")
3391 echo "Read runtime is $runtime s, speed is $rate IOPS"
3393 # verify the read rate does not exceed TBF rate limit
3394 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3395 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3397 cancel_lru_locks osc
3398 cleanup_tbf_verify || error "rm -rf $dir failed"
3404 oss=$(comma_list $(osts_nodes))
3406 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3408 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3409 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3413 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3418 # Only operate rules on ost1 since OSTs might run on the same OSS
3420 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3421 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3422 local client_nids=$(nids_list $address "\\")
3423 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3424 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3428 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3429 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3430 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3434 tbf_rule_operate ost1 "stop\ localhost"
3435 tbf_rule_operate ost1 "stop\ clients"
3436 tbf_rule_operate ost1 "stop\ others"
3439 # Cleanup the TBF policy
3440 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3441 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3445 run_test 77e "check TBF NID nrs policy"
3450 oss=$(comma_list $(osts_nodes))
3452 do_nodes $oss $LCTL set_param \
3453 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3454 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3455 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3457 # Configure jobid_var
3458 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3460 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3461 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3462 if [ $saved_jobid_var != procname_uid ]; then
3463 set_persistent_param_and_check client \
3464 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3469 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3474 # Only operate rules on ost1 since OSTs might run on the same OSS
3476 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3477 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3478 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3479 nrs_write_read "$RUNAS"
3482 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3483 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3484 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3485 nrs_write_read "$RUNAS"
3488 tbf_rule_operate ost1 "stop\ runas"
3489 tbf_rule_operate ost1 "stop\ iozone_runas"
3490 tbf_rule_operate ost1 "stop\ dd_runas"
3491 nrs_write_read "$RUNAS"
3493 # Cleanup the TBF policy
3494 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3495 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3496 nrs_write_read "$RUNAS"
3498 local current_jobid_var=$($LCTL get_param -n jobid_var)
3499 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3500 if [ $saved_jobid_var != $current_jobid_var ]; then
3501 set_persistent_param_and_check client \
3502 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3506 run_test 77f "check TBF JobID nrs policy"
3511 oss=$(comma_list $(osts_nodes))
3513 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3515 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3516 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3518 do_nodes $oss lctl set_param \
3519 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3520 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3524 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3529 # Add a rule that only valid for Jobid TBF. If direct change between
3530 # TBF types is not supported, this operation will fail.
3531 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3533 # Cleanup the TBF policy
3534 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3535 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3538 run_test 77g "Change TBF type directly"
3541 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3542 { skip "Need OST version at least 2.8.55"; return 0; }
3544 local old_policy=$(do_facet ost1 \
3545 lctl get_param ost.OSS.ost_io.nrs_policies)
3548 do_facet ost1 lctl set_param \
3549 ost.OSS.ost_io.nrs_policies="abc"
3550 [ $? -eq 0 ] && error "should return error"
3552 do_facet ost1 lctl set_param \
3553 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3554 [ $? -eq 0 ] && error "should return error"
3556 do_facet ost1 lctl set_param \
3557 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3558 [ $? -eq 0 ] && error "should return error"
3560 do_facet ost1 lctl set_param \
3561 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3562 [ $? -eq 0 ] && error "should return error"
3564 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3565 [ $? -eq 0 ] || error "shouldn't LBUG"
3567 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3571 run_test 77h "Wrong policy name should report error, not LBUG"
3577 local error_message=$3
3579 for rule in $expected; do
3580 rule_number=$((rule_number + 1))
3582 local stop_line=$(($rule_number + 3))
3583 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3585 local output=$(do_facet $facet lctl get_param \
3586 ost.OSS.ost_io.nrs_tbf_rule |
3590 if [ "$output" != "$expected" ]; then
3591 error "$error_message, expected '$expected', got '$output'"
3596 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3597 { skip "Need OST version at least 2.8.55"; return 0; }
3599 for i in $(seq 1 $OSTCOUNT)
3601 do_facet ost"$i" lctl set_param \
3602 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3604 error "failed to set TBF policy"
3607 tbf_rule_check ost1 "default" "error before inserting any rule"
3609 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3610 tbf_rule_check ost1 "before default" \
3611 "error when inserting rule 'before'"
3613 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3614 tbf_rule_check ost1 "before after default" \
3615 "error when inserting rule 'after'"
3617 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3618 tbf_rule_check ost1 "before target after default" \
3619 "error when inserting rule 'target'"
3621 echo "Move before itself"
3622 tbf_rule_operate ost1 "change\ target\ rank=target"
3623 tbf_rule_check ost1 "before target after default" \
3624 "error when moving before itself"
3626 echo "Move to higher rank"
3627 tbf_rule_operate ost1 "change\ target\ rank=before"
3628 tbf_rule_check ost1 "target before after default" \
3629 "error when moving to higher rank"
3631 echo "Move to lower rank"
3632 tbf_rule_operate ost1 "change\ target\ rank=after"
3633 tbf_rule_check ost1 "before target after default" \
3634 "error when moving to lower rank"
3636 echo "Move before default"
3637 tbf_rule_operate ost1 "change\ target\ rank=default"
3638 tbf_rule_check ost1 "before after target default" \
3639 error "error when moving before default"
3641 # Cleanup the TBF policy
3642 do_nodes $(comma_list $(osts_nodes)) \
3643 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3646 run_test 77i "Change rank of TBF rule"
3651 local ost_version=$(lustre_version_code ost1)
3653 [ $ost_version -ge $(version_code 2.9.53) ] ||
3654 { skip "Need OST version at least 2.9.53"; return 0; }
3655 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3660 do_nodes $(comma_list $(osts_nodes)) \
3661 lctl set_param jobid_var=procname_uid \
3662 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3663 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3664 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3665 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3670 do_nodes $(comma_list $(osts_nodes)) \
3671 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3672 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3673 ost.OSS.ost_io.nrs_policies="fifo"
3675 # sleep 3 seconds to wait the tbf policy stop completely,
3676 # or the next test case is possible get -EAGAIN when
3677 # setting the tbf policy
3680 run_test 77j "check TBF-OPCode NRS policy"
3683 local idstr="${1}id"
3684 local policy="${idstr}={$2}"
3685 local rate="rate=$3"
3687 do_nodes $(comma_list $(osts_nodes)) \
3688 lctl set_param jobid_var=procname_uid \
3689 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3690 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3691 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3693 nrs_write_read "runas $4"
3694 tbf_verify $3 $3 "runas $4"
3696 do_nodes $(comma_list $(osts_nodes)) \
3697 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3698 ost.OSS.ost_io.nrs_policies="fifo"
3700 # sleep 3 seconds to wait the tbf policy stop completely,
3701 # or the next test case is possible get -eagain when
3702 # setting the tbf policy
3707 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3708 skip "Need OST version at least 2.11.50"
3711 test_id "u" "500" "5" "-u 500"
3712 test_id "g" "500" "5" "-u 500 -g 500"
3714 run_test 77ja "check TBF-UID/GID NRS policy"
3722 for rule in $rule_lists; do
3723 do_nodes $(comma_list $(osts_nodes)) \
3724 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3727 do_nodes $(comma_list $(osts_nodes)) \
3728 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3734 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3735 { skip "Need OST version at least 2.9.53"; return 0; }
3737 do_nodes $(comma_list $(osts_nodes)) \
3738 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3739 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3740 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3742 nrs_write_read "$RUNAS"
3743 tbf_verify 20 10 "$RUNAS"
3745 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3746 local client_nids=$(nids_list $address "\\")
3747 do_nodes $(comma_list $(osts_nodes)) \
3748 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3749 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3750 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3751 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3756 do_nodes $(comma_list $(osts_nodes)) \
3757 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3758 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3759 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3761 nrs_write_read "$RUNAS"
3762 tbf_verify 20 20 "$RUNAS"
3764 do_nodes $(comma_list $(osts_nodes)) \
3765 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3766 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3767 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3769 nrs_write_read "$RUNAS"
3770 # with parameter "RUNAS", it will match the latest rule
3771 # "ext_b" first, so the limited write rate is 10.
3772 tbf_verify 10 10 "$RUNAS"
3775 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3777 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3778 { skip "Need OST version at least 2.10.58"; return 0; }
3780 do_nodes $(comma_list $(osts_nodes)) \
3781 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3782 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3783 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3784 nrs_write_read "runas -u 500 -g 1000"
3785 tbf_verify 5 5 "runas -u 500 -g 1000"
3787 do_nodes $(comma_list $(osts_nodes)) \
3788 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3789 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3790 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3792 nrs_write_read "runas -u 500"
3793 tbf_verify 20 10 "runas -u 500"
3795 do_nodes $(comma_list $(osts_nodes)) \
3796 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3797 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3798 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3799 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3800 nrs_write_read "runas -u 500"
3801 tbf_verify 10 10 "runas -u 500"
3802 tbf_verify 20 10 "runas -u 500"
3803 cleanup_77k "ext_a ext_b" "fifo"
3805 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3808 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3809 { skip "Need OST version at least 2.10.56"; return 0; }
3811 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3812 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3814 local output=$(do_facet ost1 lctl get_param \
3815 ost.OSS.ost_io.nrs_policies | \
3816 awk '/name: tbf/ {print;exit}' | \
3817 awk -F ': ' '{print $2}')
3819 if [ "$output" != "tbf" ]; then
3820 error "The generic TBF output is '$output', not 'tbf'"
3823 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3825 run_test 77l "check the output of NRS policies for generic TBF"
3828 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3829 skip "Need OST version at least 2.9.54"
3833 local dir=$DIR/$tdir
3835 mkdir $dir || error "mkdir $dir failed"
3836 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3839 local nodes=$(comma_list $(osts_nodes))
3840 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3841 ost.OSS.ost_io.nrs_delay_min=4 \
3842 ost.OSS.ost_io.nrs_delay_max=4 \
3843 ost.OSS.ost_io.nrs_delay_pct=100
3844 [ $? -ne 0 ] && error "Failed to set delay policy"
3846 local start=$SECONDS
3847 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3848 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3849 oflag=direct conv=fdatasync ||
3850 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3851 error "dd on client failed (1)"; }
3852 local elapsed=$((SECONDS - start))
3854 # NRS delay doesn't do sub-second timing, so a request enqueued at
3855 # 0.9 seconds can be dequeued at 4.0
3856 [ $elapsed -lt 3 ] &&
3857 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3858 error "Single 1M write should take at least 3 seconds"; }
3861 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3862 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3863 oflag=direct conv=fdatasync ||
3864 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3865 error "dd on client failed (2)"; }
3866 elapsed=$((SECONDS - start))
3868 [ $elapsed -lt 30 ] &&
3869 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3870 error "Ten 1M writes should take at least 30 seconds"; }
3872 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3873 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3877 run_test 77m "check NRS Delay slows write RPC processing"
3879 test_77n() { #LU-10802
3880 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3881 skip "Need OST version at least 2.10.58"
3885 # Configure jobid_var
3886 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3887 if [ $saved_jobid_var != procname_uid ]; then
3888 set_persistent_param_and_check client \
3889 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3892 do_nodes $(comma_list $(osts_nodes)) \
3893 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
3894 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3895 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
3898 tbf_verify 20 20 "$RUNAS"
3900 do_nodes $(comma_list $(osts_nodes)) \
3901 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3902 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
3907 do_nodes $(comma_list $(osts_nodes)) \
3908 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3909 ost.OSS.ost_io.nrs_policies="fifo"
3913 local current_jobid_var=$($LCTL get_param -n jobid_var)
3914 if [ $saved_jobid_var != $current_jobid_var ]; then
3915 set_persistent_param_and_check client \
3916 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3919 run_test 77n "check wildcard support for TBF JobID NRS policy"
3921 test_78() { #LU-6673
3924 oss=$(comma_list $(osts_nodes))
3925 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3926 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3928 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3929 # Valid return codes are:
3930 # 0: Tuning succeeded
3931 # ENODEV: Policy is still stopped
3932 # EAGAIN: Policy is being initialized
3933 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3934 error "Expected set_param to return 0|ENODEV|EAGAIN"
3936 # Cleanup the ORR policy
3937 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3938 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3941 run_test 78 "Enable policy and specify tunings right away"
3944 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3945 test_mkdir $DIR/$tdir
3947 # Prevent interference from layout intent RPCs due to
3948 # asynchronous writeback. These will be tested in 130c below.
3949 do_nodes ${CLIENTS:-$HOSTNAME} sync
3951 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3952 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3954 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3955 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
3956 local facet=mds$((mdtidx + 1))
3958 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3959 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3963 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3964 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3969 run_test 79 "xattr: intent error"
3972 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3979 mkdir -p $DIR1/$tdir/dir
3980 createmany -o $DIR1/$tdir/dir/f 10 ||
3981 error "create files under remote dir failed $i"
3983 cp /etc/passwd $DIR1/$tdir/$tfile
3985 #migrate open file should fails
3986 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3988 # give multiop a chance to open
3991 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3992 error "migrate open files should failed with open files"
3996 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3997 error "migrate remote dir error"
3999 echo "Finish migration, then checking.."
4000 for file in $(find $DIR1/$tdir); do
4001 mdt_index=$($LFS getstripe -m $file)
4002 [ $mdt_index == $MDTIDX ] ||
4003 error "$file is not on MDT${MDTIDX}"
4006 diff /etc/passwd $DIR1/$tdir/$tfile ||
4007 error "file different after migration"
4009 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4011 run_test 80a "migrate directory when some children is being opened"
4015 kill -9 $migrate_pid
4019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4020 local migrate_dir1=$DIR1/$tdir/migrate_dir
4021 local migrate_dir2=$DIR2/$tdir/migrate_dir
4022 local migrate_run=$LUSTRE/tests/migrate.sh
4030 trap cleanup_80b EXIT
4031 #prepare migrate directory
4032 mkdir -p $migrate_dir1
4033 for F in {1,2,3,4,5}; do
4034 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4035 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4038 #migrate the directories among MDTs
4041 mdt_idx=$((RANDOM % MDSCOUNT))
4042 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4044 [ $rc -ne 0 -o $rc -ne 16 ] || break
4049 echo "start migration thread $migrate_pid"
4050 #Access the files at the same time
4051 start_time=$(date +%s)
4052 echo "accessing the migrating directory for 5 minutes..."
4054 ls $migrate_dir2 > /dev/null || {
4055 echo "read dir fails"
4058 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4059 echo "access file1 fails"
4063 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4064 echo "access file2/3 fails"
4068 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4069 echo "access file4 fails"
4073 stat $migrate_dir2/file5 > /dev/null || {
4074 echo "stat file5 fails"
4078 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4079 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4080 echo "touch file failed with $rc1"
4084 if [ -e $migrate_dir2/source_file ]; then
4085 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4086 &>/dev/null || rc1=$?
4087 if [ -e $migrate_dir2/link_file ]; then
4088 rm -rf $migrate_dir2/link_file
4091 mrename $migrate_dir2/source_file \
4092 $migrate_dir2/target_file &>/dev/null || rc1=$?
4093 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4094 echo "rename failed with $rc1"
4098 if [ -e $migrate_dir2/target_file ]; then
4099 rm -rf $migrate_dir2/target_file &>/dev/null ||
4102 rm -rf $migrate_dir2/source_file &>/dev/null ||
4105 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4106 echo "unlink failed with $rc1"
4111 end_time=$(date +%s)
4112 duration=$((end_time - start_time))
4113 if [ $((duration % 10)) -eq 0 ]; then
4114 if [ $show_time -eq 1 ]; then
4115 echo "...$duration seconds"
4122 kill -0 $migrate_pid || {
4123 echo "migration stopped 1"
4127 [ $duration -ge 300 ] && break
4130 #check migration are still there
4131 kill -0 $migrate_pid || error "migration stopped 2"
4134 run_test 80b "Accessing directory during migration"
4137 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4141 mkdir -p $DIR1/$tdir
4143 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4144 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4147 touch d0/0 || error "create 0 failed"
4148 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4149 stat d0/0 && error "stat mv filed succeed"
4150 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4151 stat d0/0 || error "stat failed"
4153 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4155 if [ $t -ne 3 ]; then
4156 ls -ai $DIR1/$tdir/d0
4157 error "expect 3 get $t"
4162 run_test 81a "rename and stat under striped directory"
4165 [ $MDSCOUNT -lt 2 ] &&
4166 skip "We need at least 2 MDTs for this test"
4173 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4174 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4183 for i in $(seq $total); do
4184 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4188 kill -9 $setattr_pid
4190 run_test 81b "rename under striped directory doesn't deadlock"
4193 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4194 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4195 skip "Need MDS version at least 2.13.52"
4197 # source is local, source parent is remote
4198 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4199 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4200 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4201 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4202 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4203 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4204 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4205 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4207 # source is remote, source parent is local
4208 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4209 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4210 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4211 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4212 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4213 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4214 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4215 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4217 # source and source parent are remote
4218 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4219 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4220 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4221 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4222 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4223 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4224 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4225 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4227 # source and source parent are remote, and source is remote object
4228 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4229 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4230 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4231 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4232 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4233 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4234 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4236 run_test 81c "rename revoke LOOKUP lock for remote object"
4239 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4240 { skip "Need MDS version at least 2.6.92"; return 0; }
4242 # Client 1 creates a file.
4243 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4245 # Client 2 opens the file.
4246 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4248 # Client 1 makes the file an orphan.
4249 rm $DIR1/$tfile || error "rm"
4250 # Client 2 sets EA "user.multiop".
4252 wait $pid2 || error "multiop 2"
4253 # Client 1 gets EA "user.multiop". This used to fail because the EA
4254 # cache refill would get "trusted.link" from mdd_xattr_list() but
4255 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4258 wait $pid1 || error "multiop 1"
4260 run_test 82 "fsetxattr and fgetxattr on orphan files"
4263 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4270 $LFS mkdir -i1 -c2 $tdir
4275 echo "start pid $pid1 to create/unlink striped directory"
4277 # Access the directory at the same time
4281 stat $tdir > /dev/null 2>&1
4285 echo "start pid $pid2 to stat striped directory"
4293 run_test 83 "access striped directory while it is being created/unlinked"
4296 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4297 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4301 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4302 error "create $tfile failed"
4303 mtime=$(stat -c%Y $DIR/$tfile)
4304 mtime=$((mtime + 200))
4306 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4307 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4309 touch -c -m $mtime $DIR/$tfile &
4311 # sleep a while to let 'touch' run first
4313 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4316 wait $setattr_pid || true
4318 run_test 84 "0-nlink race in lu_object_find()"
4321 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4326 [ "$SLOW" = "yes" ] && duration=600
4327 # Open/Create under striped directory
4331 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4332 touch $tdir/f{0..3} > /dev/null 2>&1
4336 echo "start pid $pid1 to open/create under striped directory"
4338 # unlink the striped directory at the same time
4342 rm -rf $tdir > /dev/null 2>&1
4346 echo "start pid $pid2 to unlink striped directory"
4355 run_test 90 "open/create and unlink striped directory"
4358 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4363 [ "$SLOW" = "yes" ] && duration=600
4364 # chmod striped directory
4368 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4369 chmod go+w $tdir > /dev/null 2>&1
4373 echo "start pid $pid1 to chmod striped directory"
4375 # unlink the striped directory at the same time
4379 rm -rf $tdir > /dev/null 2>&1
4383 echo "start pid $pid2 to unlink striped directory"
4392 run_test 91 "chmod and unlink striped directory"
4395 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4398 local cmd="exec $fd<$DIR1/$tdir"
4399 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4402 trap "eval $cmd" EXIT
4403 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4404 rmdir ../$tdir || error "rmdir ../$tdir fails"
4406 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4407 $LCTL set_param fail_loc=0x1408
4408 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4409 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4410 error "create remote dir succeeds"
4411 $LCTL set_param fail_loc=0
4415 run_test 92 "create remote directory under orphan directory"
4422 mkdir -p $DIR1/$tfile-1/
4423 mkdir -p $DIR2/$tfile-2/
4424 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4425 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4426 do_facet $SINGLEMDS lctl set_param -n \
4427 'lod.lustre-MDT*/qos_threshold_rr' 100
4428 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4429 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4431 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4434 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4438 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4439 do_facet $SINGLEMDS "lctl set_param -n \
4440 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4442 $GETSTRIPE $DIR1/$tfile-1/file1
4443 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4444 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4445 $GETSTRIPE $DIR2/$tfile-2/file2
4446 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4447 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4448 echo "rc1=$rc1 and rc2=$rc2 "
4449 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4450 error "object allocate on same ost detected"
4452 run_test 93 "alloc_rr should not allocate on same ost"
4456 skip "Reserved for glimpse-ahead" && return
4457 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4458 skip "Need MDS version at least 2.10.55"
4462 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4464 lctl set_param -n mdc.*.stats=clear
4465 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4467 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4468 # first stat from server should return size data and save glimpse
4469 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4470 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4471 # second stat to check size is NOT cached on client without IO lock
4472 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4474 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4475 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4478 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4481 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4482 skip "Need MDS version at least 2.10.55"
4486 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4488 lctl set_param -n mdc.*.stats=clear
4489 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4490 cancel_lru_locks mdc
4491 # first stat data from server should have size
4492 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4493 # second stat to check size is cached on client
4494 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4496 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4497 # both stats should cause no glimpse requests
4498 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4501 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4504 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4505 skip "Need MDS version at least 2.10.55"
4509 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4511 lctl set_param -n mdc.*.stats=clear
4512 lctl set_param -n osc.*.stats=clear
4513 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4515 # check that size is merged from MDT and OST correctly
4516 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4517 error "Wrong size from stat #1"
4519 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4520 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4524 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4527 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4528 skip "Need MDS version at least 2.10.55"
4532 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4535 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4536 lctl set_param -n mdc.*.stats=clear
4537 $TRUNCATE $DIR2/$tdir/dom 4096
4539 # check that reported size is valid after file grows to OST and
4540 # is truncated back to MDT stripe size
4541 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4542 error "Wrong size from stat #1"
4544 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4545 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4549 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4552 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
4553 skip "Need MDS version at least 2.11.50"
4555 local dom=$DIR/$tdir/dom
4556 local dom2=$DIR2/$tdir/dom
4559 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4561 cancel_lru_locks mdc
4562 dd if=/dev/urandom of=$dom bs=12000 count=1
4563 $TRUNCATE $dom2 6000
4564 cancel_lru_locks mdc
4565 lctl set_param -n mdc.*.stats=clear
4566 # expect read-on-open to return all data before write
4567 cat /etc/hosts >> $dom
4568 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4569 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4571 run_test 100e "DoM: read on open and file size"
4574 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4575 skip "Need MDS version at least 2.10.55" && return
4577 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4579 $CHECKSTAT -t file $DIR1/$tfile
4581 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4582 sysctl -wq vm.dirty_writeback_centisecs=0
4584 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4587 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4588 error_noexit "Write fails"
4589 # must discard pages
4590 lctl set_param -n mdc.*.stats=clear
4591 rm $DIR2/$tfile || error "Unlink fails"
4593 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4594 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4596 run_test 101a "Discard DoM data on unlink"
4599 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4600 skip "Need MDS version at least 2.10.55" && return
4602 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4603 touch $DIR1/${tfile}_2
4605 $CHECKSTAT -t file $DIR1/$tfile
4607 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4608 sysctl -wq vm.dirty_writeback_centisecs=0
4610 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4613 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4614 # must discard pages
4615 lctl set_param -n mdc.*.stats=clear
4616 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4618 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4619 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4621 run_test 101b "Discard DoM data on rename"
4624 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4625 skip "Need MDS version at least 2.10.55" && return
4627 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4629 $CHECKSTAT -t file $DIR1/$tfile
4631 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4632 sysctl -wq vm.dirty_writeback_centisecs=0
4634 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4637 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4638 $MULTIOP $DIR1/$tfile O_c &
4641 lctl set_param -n mdc.*.stats=clear
4642 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4643 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4645 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4646 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4648 run_test 101c "Discard DoM data on close-unlink"
4650 # test to verify file handle related system calls
4651 # (name_to_handle_at/open_by_handle_at)
4652 # The new system calls are supported in glibc >= 2.14.
4654 # test to verify we can open by handle an unlinked file from > 1 client
4655 # This test opens the file normally on $DIR1, which is on one mount, and then
4656 # opens it by handle on $DIR2, which is on a different mount.
4658 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
4659 skip "Needs MDS version 2.11.57 or later"
4661 echo "Test file_handle syscalls" > $DIR/$tfile ||
4662 error "write failed"
4663 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4664 error "check_fhandle_syscalls failed"
4667 run_test 102 "Test open by handle of unlinked file"
4669 # Compare file size between first & second mount, ensuring the client correctly
4670 # glimpses even with unused speculative locks - LU-11670
4672 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
4673 skip "Lockahead needs OST version at least 2.10.50"
4677 test_mkdir -p $DIR/$tdir
4679 # Force file on to OST0
4680 $LFS setstripe -i 0 $DIR/$tdir
4682 # Do not check multiple locks on glimpse
4683 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
4684 $LCTL set_param fail_loc=0x415
4686 # Delay write commit by 2 seconds to guarantee glimpse wins race
4687 # The same fail_loc is used on client & server so it can work in the
4688 # single node sanity setup
4689 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
4691 echo "Incorrect size expected (no glimpse fix):"
4692 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4694 if [ $rc -eq 0 ]; then
4695 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
4698 # guarantee write commit timeout has expired
4701 # Clear fail_loc on client
4702 $LCTL set_param fail_loc=0
4704 # Delay write commit by 2 seconds to guarantee glimpse wins race
4705 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4706 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
4708 # Write commit is still delayed by 2 seconds
4709 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4711 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
4713 # guarantee write commit timeout has expired
4716 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
4718 run_test 103 "Test size correctness with lockahead"
4724 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
4735 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
4736 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
4737 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
4738 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
4746 local xtimes=($(get_stat_xtimes))
4747 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4749 echo "STAT a|m|ctime ${xtimes[*]}"
4750 echo "MDT a|m|ctime ${xtimes[*]}"
4751 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
4752 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
4753 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4754 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4755 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4756 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4760 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
4761 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
4762 skip "Need MDS version at least 2.12.4"
4765 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
4766 local atime_diff=$(do_facet $SINGLEMDS \
4767 lctl get_param -n mdd.*MDT0000*.atime_diff)
4769 do_facet $SINGLEMDS \
4770 lctl set_param -n mdd.*MDT0000*.atime_diff=0
4772 stack_trap "do_facet $SINGLEMDS \
4773 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
4775 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4776 check_mdt_xtimes $mdtdev
4779 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4780 check_mdt_xtimes $mdtdev
4782 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
4785 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4787 kill -USR1 $pid && wait $pid || error "multiop failure"
4788 check_mdt_xtimes $mdtdev
4793 # Verify mtime/ctime is NOT upated on MDS when there is no modification
4794 # on the client side
4795 xtimes=($(get_stat_xtimes))
4796 $MULTIOP $DIR/$tfile O_c &
4799 kill -USR1 $pid && wait $pid || error "multiop failure"
4800 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4801 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4802 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4803 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4804 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4805 check_mdt_xtimes $mdtdev
4808 # Change ctime via chmod
4809 $MULTIOP $DIR/$tfile o_tc &
4812 kill -USR1 $pid && wait $pid || error "multiop failure"
4813 check_mdt_xtimes $mdtdev
4815 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
4817 log "cleanup: ======================================================"
4819 # kill and wait in each test only guarentee script finish, but command in script
4820 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4821 # otherwise umount below will fail
4822 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4827 check_and_cleanup_lustre