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 =============="
1774 do_nodes $(comma_list $(mdts_nodes)) \
1775 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1777 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1780 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1783 if ! wait $PID1 && ! wait $PID2; then
1784 echo "Both creates failed (1 should fail, 1 should succeed)"
1786 elif wait $PID1 && wait $PID2; then
1787 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1792 do_nodes $(comma_list $(mdts_nodes)) \
1793 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1800 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1801 skip "Need MDS version newer than 2.13.56"
1804 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1805 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1806 for fail_loc in "0x80000169" "0x8000016a"; do
1807 echo "Begin 100 tests with fail_loc=$fail_loc"
1809 for i in {1..100}; do
1811 msg=$(sub_test_41i "$fail_loc") ||
1812 { echo; error "iter=$i : $msg"; }
1817 run_test 41i "reint_open: create vs create"
1820 # test 42: unlink and blocking operations
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1825 mkdir $DIR1/$tfile &
1828 mkdir $DIR2/$tfile && error "mkdir must fail"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1833 run_test 42a "pdirops: mkdir vs mkdir =============="
1837 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1838 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1839 mkdir $DIR1/$tfile &
1842 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1843 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1847 run_test 42b "pdirops: mkdir vs create =============="
1851 touch $DIR1/$tfile-2
1852 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1853 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1854 mkdir $DIR1/$tfile &
1857 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1858 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1862 run_test 42c "pdirops: mkdir vs link =============="
1866 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1867 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1868 mkdir $DIR1/$tfile &
1871 rmdir $DIR2/$tfile || error "unlink must succeed"
1872 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1876 run_test 42d "pdirops: mkdir vs unlink =============="
1880 touch $DIR1/$tfile-2
1881 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1882 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1883 mkdir $DIR1/$tfile &
1886 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1887 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1891 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1895 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1896 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1897 mkdir $DIR1/$tfile &
1900 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1901 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1905 run_test 42f "pdirops: mkdir and rename (src) =============="
1909 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1910 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1911 mkdir $DIR1/$tfile &
1914 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1915 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1919 run_test 42g "pdirops: mkdir vs getattr =============="
1923 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1924 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1925 mkdir $DIR1/$tfile &
1928 ls -lia $DIR2/ > /dev/null
1929 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1933 run_test 42h "pdirops: mkdir vs readdir =============="
1935 # test 43: unlink and blocking operations
1939 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1940 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1944 mkdir $DIR2/$tfile || error "mkdir must succeed"
1945 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1949 run_test 43a "pdirops: unlink vs mkdir =============="
1954 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1955 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1959 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1960 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1964 run_test 43b "pdirops: unlink vs create =============="
1969 touch $DIR1/$tfile-2
1970 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1971 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1975 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1976 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1980 run_test 43c "pdirops: unlink vs link =============="
1985 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1986 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1990 rm $DIR2/$tfile && error "unlink must fail"
1991 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1995 run_test 43d "pdirops: unlink vs unlink =============="
2000 touch $DIR1/$tfile-2
2001 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2002 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2006 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
2007 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2011 run_test 43e "pdirops: unlink and rename (tgt) =============="
2016 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2017 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2021 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
2022 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2026 run_test 43f "pdirops: unlink and rename (src) =============="
2031 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2032 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2036 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2037 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2041 run_test 43g "pdirops: unlink vs getattr =============="
2046 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2047 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2051 ls -lia $DIR2/ > /dev/null
2052 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2056 run_test 43h "pdirops: unlink vs readdir =============="
2059 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2062 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2063 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2067 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
2068 check_pdo_conflict $PID1 &&
2069 { wait $PID1; error "remote mkdir isn't blocked"; }
2073 run_test 43i "pdirops: unlink vs remote mkdir"
2080 # We test in a separate directory to be able to unblock server thread in
2081 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2082 test_mkdir $DIR2/$tdir
2083 touch $DIR2/$tdir/$tfile
2085 do_nodes $(comma_list $(mdts_nodes)) \
2086 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2087 echo content > $DIR1/$tdir/$tfile & PID1=$!
2089 multiop $DIR2/$tdir/$tfile u & PID2=$!
2093 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2096 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2099 do_nodes $(comma_list $(mdts_nodes)) \
2100 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2107 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2108 skip "Need MDS version newer than 2.13.56"
2111 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2112 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2113 for fail_loc in "0x80000169" "0x8000016a"; do
2114 echo "Begin 100 tests with fail_loc=$fail_loc"
2116 for i in {1..100}; do
2118 msg=$(sub_test_43k "$fail_loc") ||
2119 { echo; error "iter=$i : $msg"; }
2129 run_test 43k "unlink vs create"
2131 # test 44: rename tgt and blocking operations
2134 touch $DIR1/$tfile-2
2135 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2136 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2137 mv $DIR1/$tfile-2 $DIR1/$tfile &
2140 mkdir $DIR2/$tfile && error "mkdir must fail"
2141 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2145 run_test 44a "pdirops: rename tgt vs mkdir =============="
2149 touch $DIR1/$tfile-2
2150 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2151 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2152 mv $DIR1/$tfile-2 $DIR1/$tfile &
2155 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2156 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2160 run_test 44b "pdirops: rename tgt vs create =============="
2164 touch $DIR1/$tfile-2
2165 touch $DIR1/$tfile-3
2166 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2167 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2168 mv $DIR1/$tfile-2 $DIR1/$tfile &
2171 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
2172 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2176 run_test 44c "pdirops: rename tgt vs link =============="
2180 touch $DIR1/$tfile-2
2181 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2182 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2183 mv $DIR1/$tfile-2 $DIR1/$tfile &
2186 rm $DIR2/$tfile || error "unlink must succeed"
2187 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2191 run_test 44d "pdirops: rename tgt vs unlink =============="
2196 touch $DIR1/$tfile-2
2197 touch $DIR1/$tfile-3
2198 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2199 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2200 mv $DIR1/$tfile-2 $DIR1/$tfile &
2203 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2204 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2208 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2212 touch $DIR1/$tfile-2
2213 touch $DIR1/$tfile-3
2214 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2215 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2216 mv $DIR1/$tfile-2 $DIR1/$tfile &
2219 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2220 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2224 run_test 44f "pdirops: rename tgt and rename (src) =============="
2228 touch $DIR1/$tfile-2
2229 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2230 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2231 mv $DIR1/$tfile-2 $DIR1/$tfile &
2234 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2235 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2239 run_test 44g "pdirops: rename tgt vs getattr =============="
2243 touch $DIR1/$tfile-2
2244 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2245 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2246 mv $DIR1/$tfile-2 $DIR1/$tfile &
2249 ls -lia $DIR2/ > /dev/null
2250 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2254 run_test 44h "pdirops: rename tgt vs readdir =============="
2256 # test 44: rename tgt and blocking operations
2258 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2260 touch $DIR1/$tfile-2
2261 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2262 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2263 mv $DIR1/$tfile-2 $DIR1/$tfile &
2266 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2267 check_pdo_conflict $PID1 && { wait $PID1;
2268 error "remote mkdir isn't blocked"; }
2272 run_test 44i "pdirops: rename tgt vs remote mkdir"
2274 # test 45: rename src and blocking operations
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 mkdir $DIR2/$tfile || error "mkdir must succeed"
2284 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2288 run_test 45a "pdirops: rename src vs mkdir =============="
2293 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2294 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2295 mv $DIR1/$tfile $DIR1/$tfile-2 &
2298 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2299 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2303 run_test 45b "pdirops: rename src vs create =============="
2308 touch $DIR1/$tfile-3
2309 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2310 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2311 mv $DIR1/$tfile $DIR1/$tfile-2 &
2314 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2315 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2319 run_test 45c "pdirops: rename src vs link =============="
2324 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2325 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2326 mv $DIR1/$tfile $DIR1/$tfile-2 &
2329 rm $DIR2/$tfile && error "unlink must fail"
2330 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2334 run_test 45d "pdirops: rename src vs unlink =============="
2339 touch $DIR1/$tfile-3
2340 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2341 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2342 mv $DIR1/$tfile $DIR1/$tfile-2 &
2345 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2346 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2350 run_test 45e "pdirops: rename src and rename (tgt) =============="
2355 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2356 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2357 mv $DIR1/$tfile $DIR1/$tfile-2 &
2360 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2361 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2365 run_test 45f "pdirops: rename src and rename (src) =============="
2370 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2371 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2372 mv $DIR1/$tfile $DIR1/$tfile-2 &
2375 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2376 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2380 run_test 45g "pdirops: rename src vs getattr =============="
2385 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2386 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2387 mv $DIR1/$tfile $DIR1/$tfile-2 &
2390 ls -lia $DIR2/ > /dev/null
2391 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2395 run_test 45h "pdirops: unlink vs readdir =============="
2398 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2401 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2402 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2403 mv $DIR1/$tfile $DIR1/$tfile-2 &
2406 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2407 check_pdo_conflict $PID1 && { wait $PID1;
2408 error "create remote dir isn't blocked"; }
2412 run_test 45i "pdirops: rename src vs remote mkdir"
2419 # We test in a sparate directory to be able to unblock server thread in
2420 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2421 test_mkdir $DIR2/$tdir
2422 echo file1 > $DIR2/$tdir/$tfile
2423 echo file2 > $DIR2/$tdir/$tfile-2
2425 do_nodes $(comma_list $(mdts_nodes)) \
2426 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2428 cat $DIR1/$tdir/$tfile >/dev/null &
2431 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2435 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2438 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2441 do_nodes $(comma_list $(mdts_nodes)) \
2442 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2449 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2450 skip "Need MDS version newer than 2.13.56"
2453 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2454 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2455 for fail_loc in "0x80000169" "0x8000016a"; do
2456 echo "Begin 100 tests with fail_loc=$fail_loc"
2458 for i in {1..100}; do
2460 msg=$(sub_test_45j "$fail_loc") ||
2461 { echo; error "iter=$i : $msg"; }
2466 run_test 45j "read vs rename =============="
2468 # test 46: link and blocking operations
2471 touch $DIR1/$tfile-2
2472 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2473 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2474 link $DIR1/$tfile-2 $DIR1/$tfile &
2477 mkdir $DIR2/$tfile && error "mkdir must fail"
2478 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2482 run_test 46a "pdirops: link vs mkdir =============="
2486 touch $DIR1/$tfile-2
2487 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2488 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2489 link $DIR1/$tfile-2 $DIR1/$tfile &
2492 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2493 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2497 run_test 46b "pdirops: link vs create =============="
2501 touch $DIR1/$tfile-2
2502 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2503 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2504 link $DIR1/$tfile-2 $DIR1/$tfile &
2507 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2508 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2512 run_test 46c "pdirops: link vs link =============="
2516 touch $DIR1/$tfile-2
2517 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2518 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2519 link $DIR1/$tfile-2 $DIR1/$tfile &
2522 rm $DIR2/$tfile || error "unlink must succeed"
2523 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2527 run_test 46d "pdirops: link vs unlink =============="
2531 touch $DIR1/$tfile-2
2532 touch $DIR1/$tfile-3
2533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2534 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2535 link $DIR1/$tfile-2 $DIR1/$tfile &
2538 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2539 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2543 run_test 46e "pdirops: link and rename (tgt) =============="
2547 touch $DIR1/$tfile-2
2548 touch $DIR1/$tfile-3
2549 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2550 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2551 link $DIR1/$tfile-2 $DIR1/$tfile &
2554 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2555 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2559 run_test 46f "pdirops: link and rename (src) =============="
2563 touch $DIR1/$tfile-2
2564 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2565 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2566 link $DIR1/$tfile-2 $DIR1/$tfile &
2569 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2570 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2574 run_test 46g "pdirops: link vs getattr =============="
2578 touch $DIR1/$tfile-2
2579 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2580 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2581 link $DIR1/$tfile-2 $DIR1/$tfile &
2584 ls -lia $DIR2/ > /dev/null
2585 check_pdo_conflict $PID1 && { wait $PID1;
2586 error "readdir isn't blocked"; }
2590 run_test 46h "pdirops: link vs readdir =============="
2593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2595 touch $DIR1/$tfile-2
2596 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2597 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2598 link $DIR1/$tfile-2 $DIR1/$tfile &
2601 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2602 check_pdo_conflict $PID1 && { wait $PID1;
2603 error "remote mkdir isn't blocked"; }
2607 run_test 46i "pdirops: link vs remote mkdir"
2609 # test 47: remote mkdir and blocking operations
2611 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2612 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2614 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2615 $LFS mkdir -i 1 $DIR1/$tfile &
2618 mkdir $DIR2/$tfile && error "mkdir must fail"
2619 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2623 run_test 47a "pdirops: remote mkdir vs mkdir"
2626 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2629 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2630 $LFS mkdir -i 1 $DIR1/$tfile &
2633 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2634 check_pdo_conflict $PID1 && { wait $PID1;
2635 error "create isn't blocked"; }
2639 run_test 47b "pdirops: remote mkdir vs create"
2642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2644 touch $DIR1/$tfile-2
2645 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2646 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2647 $LFS mkdir -i 1 $DIR1/$tfile &
2650 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2651 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2655 run_test 47c "pdirops: remote mkdir vs link"
2658 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2660 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2661 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2662 $LFS mkdir -i 1 $DIR1/$tfile &
2665 rmdir $DIR2/$tfile || error "unlink must succeed"
2666 check_pdo_conflict $PID1 && { wait $PID1;
2667 error "unlink isn't blocked"; }
2671 run_test 47d "pdirops: remote mkdir vs unlink"
2674 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2676 touch $DIR1/$tfile-2
2677 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2678 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2679 $LFS mkdir -i 1 $DIR1/$tfile &
2682 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2683 check_pdo_conflict $PID1 && { wait $PID1;
2684 error "rename isn't blocked"; }
2688 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2691 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2693 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2694 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2695 $LFS mkdir -i 1 $DIR1/$tfile &
2698 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2699 check_pdo_conflict $PID1 && { wait $PID1;
2700 error "rename isn't blocked"; }
2704 run_test 47f "pdirops: remote mkdir and rename (src)"
2707 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2711 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2712 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2713 $LFS mkdir -i 1 $DIR1/$tfile &
2716 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2717 check_pdo_conflict $PID1 && { wait $PID1;
2718 error "getattr isn't blocked"; }
2722 run_test 47g "pdirops: remote mkdir vs getattr"
2726 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2727 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2728 do_facet client "lctl set_param fail_loc=0x410"
2729 $TRUNCATE $DIR2/$tfile $trunc_size
2730 do_facet client "lctl set_param fail_loc=0x0"
2732 size=`stat -c %s $DIR2/$tfile`
2733 [ $size -eq $trunc_size ] || error "wrong size"
2735 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2739 local origfile=/etc/hosts
2741 filesize=$(stat -c %s $origfile)
2743 # create an empty file
2744 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2745 # cache layout lock on both mount point
2746 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2747 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2749 # open and sleep 2 seconds then read
2750 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2754 # create the layout of testing file
2755 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2756 error "dd $DIR1/$tfile failed"
2758 # MULTIOP proc should be able to read enough bytes and exit
2759 for ((i = 0; i < 6; i++)); do
2761 kill -0 $pid || break
2763 kill -0 $pid 2> /dev/null && error "multiop is still there"
2764 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2768 run_test 51a "layout lock: refresh layout should work"
2771 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2772 { skip "Need MDS version at least 2.3.59"; return 0; }
2774 local tmpfile=`mktemp`
2776 # create an empty file
2777 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2779 # delay glimpse so that layout has changed when glimpse finish
2780 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2781 $LCTL set_param fail_loc=0x1404
2782 stat -c %s $DIR2/$tfile |tee $tmpfile &
2786 # create layout of testing file
2787 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2788 error "dd $DIR1/$tfile failed"
2791 local fsize=$(cat $tmpfile)
2793 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2795 rm -f $DIR1/$tfile $tmpfile
2797 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2800 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2802 # set default layout to have 1 stripe
2804 $LFS setstripe -c 1 $DIR1/$tdir
2806 # create a file with empty layout
2807 $MCREATE $DIR1/$tdir/$tfile ||
2808 error "$MCREATE $DIR1/$tdir/$tfile failed"
2810 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2811 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2813 # change the layout of testing file
2814 echo "Setting layout to have $OSTCOUNT stripes ..."
2815 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2819 # write something to the file, it should be blocked on fetching layout
2820 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2821 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2824 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2825 # count to succeed with only 3/4 of the number of stripes (rounded up),
2826 # so creating striped files does not fail if an OST is offline or full
2827 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2828 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2832 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2835 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2836 cancel_lru_locks mdc
2838 # open should grant LAYOUT lock, mmap and read will install pages
2839 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2843 # rss before revoking
2844 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2845 echo "Before revoking layout lock: $br KB mapped"
2847 # cancel layout lock manually
2848 cancel_lru_locks mdc
2850 # rss after revoking
2851 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2854 wait $PID || error "wait PID $PID failed"
2856 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2858 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2862 echo "==> rename vs getattr vs setxattr should not deadlock"
2863 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2865 do_facet mds1 $LCTL set_param fail_loc=$1
2867 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2875 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2876 wait $PID1 || error "(3) mv failed"
2877 wait $PID2 || error "(4) stat failed"
2884 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2885 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2887 do_facet mds1 $LCTL set_param fail_loc=$1
2889 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2897 $MULTIOP $DIR2/d1/d2 Oc &
2901 stat $DIR/d1 || error "(2) stat failed"
2903 wait $PID1 || error "(3) mv failed"
2904 wait $PID2 || error "(4) stat failed"
2905 wait $PID3 && error "(5) multiop failed"
2911 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2912 save_lustre_params client "llite.*.xattr_cache" > $p
2913 lctl set_param llite.*.xattr_cache 1 ||
2914 { skip "xattr cache is not supported"; return 0; }
2916 #define OBD_FAIL_MDS_RENAME 0x153
2917 #define OBD_FAIL_MDS_RENAME2 0x154
2918 test_54_part1 0x80000153 || error 10
2919 test_54_part1 0x80000154 || error 11
2920 test_54_part2 0x80000153 || error 12
2921 test_54_part2 0x80000154 || error 13
2923 restore_lustre_params < $p
2926 run_test 54 "rename locking"
2929 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2931 #define OBD_FAIL_MDS_RENAME4 0x156
2932 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2934 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2939 wait $PID1 && error "(2) mv succeeded"
2943 run_test 55a "rename vs unlink target dir"
2947 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2949 #define OBD_FAIL_MDS_RENAME4 0x156
2950 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2952 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2957 wait $PID1 && error "(2) mv succeeded"
2961 run_test 55b "rename vs unlink source dir"
2965 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2967 #define OBD_FAIL_MDS_RENAME4 0x156
2968 do_facet mds1 $LCTL set_param fail_loc=0x156
2970 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2974 # while rename is sleeping, open and remove d3
2975 $MULTIOP $DIR2/d3 D_c &
2981 # while rename is sleeping 2nd time, close d3
2983 wait $PID2 || error "(3) multiop failed"
2985 wait $PID1 && error "(2) mv succeeded"
2989 run_test 55c "rename vs unlink orphan target dir"
2995 #define OBD_FAIL_MDS_RENAME3 0x155
2996 do_facet mds1 $LCTL set_param fail_loc=0x155
2997 mv $DIR/f1 $DIR/$tdir &
3001 # while rename is sleeping, create $tdir, but as a directory
3002 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
3004 # link in reverse locking order
3005 ln $DIR2/f1 $DIR2/$tdir/
3007 wait $PID1 && error "(2) mv succeeded"
3010 run_test 55d "rename file vs link"
3013 local MDSVER=$(lustre_build_version $SINGLEMDS)
3014 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
3015 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
3018 test_mkdir $DIR1/$tdir
3019 file1=$DIR1/$tdir/file
3020 file2=$DIR2/$tdir/file
3022 echo orig > $file2 || error "Could not create $file2"
3023 version=$($LFS data_version $file1)
3026 echo append >> $file2 || error "Could not append to $file2"
3027 version2=$($LFS data_version $file1)
3028 [ "$version" != "$version2" ] ||
3029 error "append did not change data version: $version"
3032 echo overwrite > $file2 || error "Could not overwrite $file2"
3033 version3=$($LFS data_version $file1)
3034 [ "$version2" != "$version3" ] ||
3035 error "overwrite did not change data version: $version2"
3037 # Truncate before EOF
3038 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3039 version4=$($LFS data_version $file1)
3040 [ "$version3" != "$version4" ] ||
3041 error "truncate did not change data version: $version3"
3043 # Truncate after EOF
3044 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3045 version5=$($LFS data_version $file1)
3046 [ "$version4" != "$version5" ] ||
3047 error "truncate did not change data version: $version4"
3049 # Chmod do not change version
3050 chmod 400 $file2 || error "Could not chmod 400 $file2"
3051 version6=$($LFS data_version $file1)
3052 [ "$version5" == "$version6" ] ||
3053 error "chmod should not change data version: $version5 != $version6"
3055 # Chown do not change version
3056 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3057 version7=$($LFS data_version $file1)
3058 [ "$version5" == "$version7" ] ||
3059 error "chown should not change data version: $version5 != $version7"
3061 run_test 60 "Verify data_version behaviour"
3064 local test_dir=$tdir/test_dir
3066 mkdir -p $DIR1/$tdir
3067 if [ $MDSCOUNT -ge 2 ]; then
3069 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3070 error "Create remote directory failed"
3072 mkdir -p $DIR1/$test_dir
3074 cd $DIR2/$test_dir || error "cd directory failed"
3075 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3077 cd $DIR2/$tdir || error "exit directory"
3079 run_test 70a "cd directory && rm directory"
3081 test_70b() { # LU-2781
3083 mkdir -p $DIR1/$tdir
3085 touch $DIR1/$tdir/file
3086 for ((i = 0; i < 32; i++)); do
3087 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3089 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3091 touch $DIR1/$tdir/file
3092 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3093 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3094 rm -rf $DIR1/$tdir/test_dir ||
3095 error "cannot remove directory after rm_entry"
3096 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3098 run_test 70b "remove files after calling rm_entry"
3101 local server_version=$(lustre_version_code $SINGLEMDS)
3103 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3104 skip "Need MDS version at least 2.1.6" && return
3106 # Patch not applied to 2.2 and 2.3 branches
3107 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3108 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3109 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3112 checkfiemap --test ||
3113 { skip "checkfiemap not runnable: $?" && return; }
3114 # write data this way: hole - data - hole - data
3115 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3116 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
3118 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3119 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3120 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3122 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3124 checkfiemap $DIR2/$tfile 81920 ||
3125 error "data is not flushed from client"
3126 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3129 # common case of "create file, copy file" on a single node
3130 # should not flush data from ost
3131 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3132 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3134 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3136 checkfiemap $DIR1/$tfile 81920 ||
3138 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3140 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3142 run_test 71a "correct file map just after write operation is finished"
3145 local server_version=$(lustre_version_code $SINGLEMDS)
3147 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3148 skip "Need MDS version at least 2.1.6" && return
3150 # Patch not applied to 2.2 and 2.3 branches
3151 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3152 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3153 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3155 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
3157 checkfiemap --test ||
3158 { skip "error $?: checkfiemap failed" && return; }
3160 mkdir -p $DIR1/$tdir
3162 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3163 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3164 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
3166 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3167 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3169 run_test 71b "check fiemap support for stripecount > 1"
3172 local p="$TMP/sanityN-$TESTNAME.parameters"
3175 save_lustre_params client "llite.*.xattr_cache" > $p
3176 lctl set_param llite.*.xattr_cache 1 ||
3177 { skip "xattr cache is not supported"; return 0; }
3180 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3181 error "setfattr1 failed"
3182 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3183 error "getfattr1 failed"
3184 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3185 error "setfattr2 failed"
3186 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3187 error "getfattr2 failed"
3189 # check that trusted.link is consistent
3190 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3191 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3192 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3193 echo "$tlink1 $tlink2"
3194 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3198 restore_lustre_params < $p
3201 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3204 local p="$TMP/sanityN-$TESTNAME.parameters"
3205 save_lustre_params client "llite.*.xattr_cache" > $p
3206 lctl set_param llite.*.xattr_cache 1 ||
3207 { skip "xattr cache is not supported"; return 0; }
3210 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3211 error "setfattr1 failed"
3212 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3213 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3214 clear_stats llite.*.stats
3215 # PR lock should be cached by now on both clients
3216 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3217 # 2 hits for getfattr(0)+getfattr(size)
3218 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3219 error "not cached in $DIR1"
3220 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3221 # 4 hits for more getfattr(0)+getfattr(size)
3222 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3223 error "not cached in $DIR2"
3226 restore_lustre_params < $p
3229 run_test 73 "getxattr should not cause xattr lock cancellation"
3232 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3233 skip "Need MDS version at least 2.4.93" && return
3235 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3236 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3237 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3239 run_test 74 "flock deadlock: different mounts =============="
3243 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3244 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3245 cancel_lru_locks osc
3247 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3250 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3251 $LCTL set_param fail_loc=0x31d
3252 stat -c %s $DIR1/$tfile &
3257 # For bad lock error handler we should ASSERT and got kernel panic here
3259 $LCTL set_param fail_loc=0
3261 run_test 75 "osc: upcall after unuse lock==================="
3264 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3265 skip "Need MDS version at least 2.5.53" && return
3267 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3268 local fcount=$((MDSCOUNT * 256))
3273 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3279 test_mkdir $DIR/$tdir
3281 # drop all open locks and close any cached "open" files on the client
3282 cancel_lru_locks mdc
3284 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3285 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3286 local already=${#fid_list[@]}
3287 for (( i = 0; i < $already; i++ )) ; do
3288 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3291 echo -n "opening files: "
3292 ulimit -n $((fcount + 50))
3293 for ((i = 0; i < $fcount; i++)); do
3294 touch $DIR/$tdir/f_$i
3295 local fd=$(free_fd ${fd_list[i]})
3296 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3301 (( $i % 32 == 0 )) && echo -n "."
3305 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3307 # Possible errors in openfiles FID list.
3308 # 1. Missing FIDs. Check 1
3309 # 2. Extra FIDs. Check 1
3310 # 3. Duplicated FID. Check 2
3311 # 4. Invalid FIDs. Check 2
3312 # 5. Valid FID, points to some other file. Check 3
3315 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3316 error "${#fid_list[@]} != $fcount (+$already old) open files"
3318 echo -n "closing files: "
3319 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3320 local close_cmd="exec ${fd_list[fd]}<&-"
3322 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3324 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3325 echo "skip old open file $filename"
3327 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3331 rm --interactive=no $filename
3333 error "Nonexisting fid ${fid_list[fid]} listed."
3334 (( $fd % 32 == 0 )) && echo -n "."
3339 ls_op=$(ls $DIR2/$tdir | wc -l)
3341 error "Some openfiles are missing in lproc output"
3345 run_test 76 "Verify MDT open_files listing"
3349 local dir=$DIR/$tdir
3352 mkdir $dir || error "mkdir $dir failed"
3353 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3356 do_nodes $CLIENTS $myRUNAS \
3357 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3358 error "dd at 0 on client failed (1)"
3360 do_nodes $CLIENTS $myRUNAS \
3362 for ((i = 0; i < $n; i++)); do
3363 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3364 seek=\\\$i count=1 conv=notrunc &
3365 pids_w[\\\$i]=\\\$!;
3368 for ((i = 0; i < $n; i++)); do
3369 wait \\\${pids_w[\\\$i]};
3371 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3375 do_nodes $CLIENTS sync;
3376 cancel_lru_locks osc
3378 do_nodes $CLIENTS $myRUNAS \
3380 for ((i = 0; i < $n; i++)); do
3381 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3382 seek=\\\$i count=1 &
3383 pids_r[\\\$i]=\\\$!;
3386 for ((i = 0; i < $n; i++)); do
3387 wait \\\${pids_r[\\\$i]};
3389 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3393 cancel_lru_locks osc
3395 wait $pid_w || error "dd (write) failed (2)"
3396 wait $pid_r || error "dd (read) failed (3)"
3397 rm -rvf $dir || error "rm -rf $dir failed"
3400 test_77a() { #LU-3266
3403 oss=$(comma_list $(osts_nodes))
3404 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3406 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3407 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3412 run_test 77a "check FIFO NRS policy"
3414 test_77b() { #LU-3266
3417 oss=$(comma_list $(osts_nodes))
3419 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3420 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3421 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3422 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3424 echo "policy: crr-n, crrn_quantum 1"
3427 do_nodes $oss lctl set_param \
3428 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3429 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3431 echo "policy: crr-n, crrn_quantum 64"
3435 do_nodes $oss lctl set_param \
3436 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3437 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3440 run_test 77b "check CRR-N NRS policy"
3445 oss=$(comma_list $(osts_nodes))
3447 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3448 ost.OSS.*.nrs_"$policy"_quantum=1 \
3449 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3450 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3452 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3453 "physical, ${policy}_supported reads"
3456 do_nodes $oss lctl set_param \
3457 ost.OSS.*.nrs_${policy}_supported="writes" \
3458 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3460 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3461 "physical, ${policy}_supported writes"
3464 do_nodes $oss lctl set_param \
3465 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3466 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3467 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3468 "logical, ${policy}_supported reads_and_writes"
3472 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3477 test_77c() { #LU-3266
3479 orr_trr "orr" || rc=$?
3480 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3481 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3484 run_test 77c "check ORR NRS policy"
3486 test_77d() { #LU-3266
3488 orr_trr "trr" || rc=$?
3489 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3490 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3493 run_test 77d "check TRR nrs policy"
3500 do_facet $facet lctl set_param \
3501 ost.OSS.ost_io.nrs_tbf_rule="$*"
3503 error "failed to run operate '$*' on TBF rules"
3506 cleanup_tbf_verify()
3510 echo "cleanup_tbf $DIR/$tdir"
3513 wait_delete_completed
3518 local dir=$DIR/$tdir
3519 local client1=${CLIENT1:-$(hostname)}
3522 local np=$(check_cpt_number ost1)
3523 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3524 echo "cpu_npartitions on ost1 is $np"
3526 mkdir $dir || error "mkdir $dir failed"
3527 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3530 trap cleanup_tbf_verify EXIT
3531 echo "Limited write rate: $1, read rate: $2"
3532 echo "Verify the write rate is under TBF control"
3533 local start=$SECONDS
3534 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3535 bs=1M count=100 oflag=direct 2>&1
3536 local runtime=$((SECONDS - start + 1))
3537 local rate=$(bc <<< "scale=6; 100 / $runtime")
3538 echo "Write runtime is $runtime s, speed is $rate IOPS"
3540 # verify the write rate does not exceed TBF rate limit
3541 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3542 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3544 cancel_lru_locks osc
3546 echo "Verify the read rate is under TBF control"
3548 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3549 bs=1M count=100 iflag=direct 2>&1
3550 runtime=$((SECONDS - start + 1))
3551 rate=$(bc <<< "scale=6; 100 / $runtime")
3552 echo "Read runtime is $runtime s, speed is $rate IOPS"
3554 # verify the read rate does not exceed TBF rate limit
3555 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3556 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3558 cancel_lru_locks osc
3559 cleanup_tbf_verify || error "rm -rf $dir failed"
3565 oss=$(comma_list $(osts_nodes))
3567 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3569 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3570 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3574 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3579 # Only operate rules on ost1 since OSTs might run on the same OSS
3581 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3582 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3583 local client_nids=$(nids_list $address "\\")
3584 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3585 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3589 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3590 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3591 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3595 tbf_rule_operate ost1 "stop\ localhost"
3596 tbf_rule_operate ost1 "stop\ clients"
3597 tbf_rule_operate ost1 "stop\ others"
3600 # Cleanup the TBF policy
3601 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3602 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3606 run_test 77e "check TBF NID nrs policy"
3611 oss=$(comma_list $(osts_nodes))
3613 do_nodes $oss $LCTL set_param \
3614 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3615 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3616 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3618 # Configure jobid_var
3619 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3621 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3622 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3623 if [ $saved_jobid_var != procname_uid ]; then
3624 set_persistent_param_and_check client \
3625 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3630 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3635 # Only operate rules on ost1 since OSTs might run on the same OSS
3637 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3638 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3639 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3640 nrs_write_read "$RUNAS"
3643 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3644 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3645 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3646 nrs_write_read "$RUNAS"
3649 tbf_rule_operate ost1 "stop\ runas"
3650 tbf_rule_operate ost1 "stop\ iozone_runas"
3651 tbf_rule_operate ost1 "stop\ dd_runas"
3652 nrs_write_read "$RUNAS"
3654 # Cleanup the TBF policy
3655 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3656 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3657 nrs_write_read "$RUNAS"
3659 local current_jobid_var=$($LCTL get_param -n jobid_var)
3660 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3661 if [ $saved_jobid_var != $current_jobid_var ]; then
3662 set_persistent_param_and_check client \
3663 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3667 run_test 77f "check TBF JobID nrs policy"
3672 oss=$(comma_list $(osts_nodes))
3674 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3676 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3677 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3679 do_nodes $oss lctl set_param \
3680 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3681 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3685 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3690 # Add a rule that only valid for Jobid TBF. If direct change between
3691 # TBF types is not supported, this operation will fail.
3692 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3694 # Cleanup the TBF policy
3695 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3696 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3699 run_test 77g "Change TBF type directly"
3702 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3703 { skip "Need OST version at least 2.8.55"; return 0; }
3705 local old_policy=$(do_facet ost1 \
3706 lctl get_param ost.OSS.ost_io.nrs_policies)
3709 do_facet ost1 lctl set_param \
3710 ost.OSS.ost_io.nrs_policies="abc"
3711 [ $? -eq 0 ] && error "should return error"
3713 do_facet ost1 lctl set_param \
3714 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3715 [ $? -eq 0 ] && error "should return error"
3717 do_facet ost1 lctl set_param \
3718 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3719 [ $? -eq 0 ] && error "should return error"
3721 do_facet ost1 lctl set_param \
3722 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3723 [ $? -eq 0 ] && error "should return error"
3725 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3726 [ $? -eq 0 ] || error "shouldn't LBUG"
3728 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3732 run_test 77h "Wrong policy name should report error, not LBUG"
3738 local error_message=$3
3740 for rule in $expected; do
3741 rule_number=$((rule_number + 1))
3743 local stop_line=$(($rule_number + 3))
3744 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3746 local output=$(do_facet $facet lctl get_param \
3747 ost.OSS.ost_io.nrs_tbf_rule |
3751 if [ "$output" != "$expected" ]; then
3752 error "$error_message, expected '$expected', got '$output'"
3757 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3758 { skip "Need OST version at least 2.8.55"; return 0; }
3760 for i in $(seq 1 $OSTCOUNT)
3762 do_facet ost"$i" lctl set_param \
3763 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3765 error "failed to set TBF policy"
3768 tbf_rule_check ost1 "default" "error before inserting any rule"
3770 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3771 tbf_rule_check ost1 "before default" \
3772 "error when inserting rule 'before'"
3774 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3775 tbf_rule_check ost1 "before after default" \
3776 "error when inserting rule 'after'"
3778 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3779 tbf_rule_check ost1 "before target after default" \
3780 "error when inserting rule 'target'"
3782 echo "Move before itself"
3783 tbf_rule_operate ost1 "change\ target\ rank=target"
3784 tbf_rule_check ost1 "before target after default" \
3785 "error when moving before itself"
3787 echo "Move to higher rank"
3788 tbf_rule_operate ost1 "change\ target\ rank=before"
3789 tbf_rule_check ost1 "target before after default" \
3790 "error when moving to higher rank"
3792 echo "Move to lower rank"
3793 tbf_rule_operate ost1 "change\ target\ rank=after"
3794 tbf_rule_check ost1 "before target after default" \
3795 "error when moving to lower rank"
3797 echo "Move before default"
3798 tbf_rule_operate ost1 "change\ target\ rank=default"
3799 tbf_rule_check ost1 "before after target default" \
3800 error "error when moving before default"
3802 # Cleanup the TBF policy
3803 do_nodes $(comma_list $(osts_nodes)) \
3804 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3807 run_test 77i "Change rank of TBF rule"
3812 local ost_version=$(lustre_version_code ost1)
3814 [ $ost_version -ge $(version_code 2.9.53) ] ||
3815 { skip "Need OST version at least 2.9.53"; return 0; }
3816 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3821 do_nodes $(comma_list $(osts_nodes)) \
3822 lctl set_param jobid_var=procname_uid \
3823 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3824 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3825 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3826 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3831 do_nodes $(comma_list $(osts_nodes)) \
3832 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3833 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3834 ost.OSS.ost_io.nrs_policies="fifo"
3836 # sleep 3 seconds to wait the tbf policy stop completely,
3837 # or the next test case is possible get -EAGAIN when
3838 # setting the tbf policy
3841 run_test 77j "check TBF-OPCode NRS policy"
3844 local idstr="${1}id"
3845 local policy="${idstr}={$2}"
3846 local rate="rate=$3"
3848 do_nodes $(comma_list $(osts_nodes)) \
3849 lctl set_param jobid_var=procname_uid \
3850 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3851 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3852 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3854 nrs_write_read "runas $4"
3855 tbf_verify $3 $3 "runas $4"
3857 do_nodes $(comma_list $(osts_nodes)) \
3858 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3859 ost.OSS.ost_io.nrs_policies="fifo"
3861 # sleep 3 seconds to wait the tbf policy stop completely,
3862 # or the next test case is possible get -eagain when
3863 # setting the tbf policy
3868 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3869 skip "Need OST version at least 2.11.50"
3872 test_id "u" "500" "5" "-u 500"
3873 test_id "g" "500" "5" "-u 500 -g 500"
3875 run_test 77ja "check TBF-UID/GID NRS policy"
3883 for rule in $rule_lists; do
3884 do_nodes $(comma_list $(osts_nodes)) \
3885 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3888 do_nodes $(comma_list $(osts_nodes)) \
3889 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3895 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3896 { skip "Need OST version at least 2.9.53"; return 0; }
3898 do_nodes $(comma_list $(osts_nodes)) \
3899 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3900 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3901 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3903 nrs_write_read "$RUNAS"
3904 tbf_verify 20 10 "$RUNAS"
3906 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3907 local client_nids=$(nids_list $address "\\")
3908 do_nodes $(comma_list $(osts_nodes)) \
3909 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3910 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3911 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3912 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3917 do_nodes $(comma_list $(osts_nodes)) \
3918 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3919 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3920 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3922 nrs_write_read "$RUNAS"
3923 tbf_verify 20 20 "$RUNAS"
3925 do_nodes $(comma_list $(osts_nodes)) \
3926 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3927 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3928 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3930 nrs_write_read "$RUNAS"
3931 # with parameter "RUNAS", it will match the latest rule
3932 # "ext_b" first, so the limited write rate is 10.
3933 tbf_verify 10 10 "$RUNAS"
3936 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3938 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3939 { skip "Need OST version at least 2.10.58"; return 0; }
3941 do_nodes $(comma_list $(osts_nodes)) \
3942 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3943 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3944 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3945 nrs_write_read "runas -u 500 -g 1000"
3946 tbf_verify 5 5 "runas -u 500 -g 1000"
3948 do_nodes $(comma_list $(osts_nodes)) \
3949 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3950 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3951 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3953 nrs_write_read "runas -u 500"
3954 tbf_verify 20 10 "runas -u 500"
3956 do_nodes $(comma_list $(osts_nodes)) \
3957 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3958 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3959 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3960 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3961 nrs_write_read "runas -u 500"
3962 tbf_verify 10 10 "runas -u 500"
3963 tbf_verify 20 10 "runas -u 500"
3964 cleanup_77k "ext_a ext_b" "fifo"
3966 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3969 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3970 { skip "Need OST version at least 2.10.56"; return 0; }
3972 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3973 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3975 local output=$(do_facet ost1 lctl get_param \
3976 ost.OSS.ost_io.nrs_policies | \
3977 awk '/name: tbf/ {print;exit}' | \
3978 awk -F ': ' '{print $2}')
3980 if [ "$output" != "tbf" ]; then
3981 error "The generic TBF output is '$output', not 'tbf'"
3984 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3986 run_test 77l "check the output of NRS policies for generic TBF"
3989 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3990 skip "Need OST version at least 2.9.54"
3994 local dir=$DIR/$tdir
3996 mkdir $dir || error "mkdir $dir failed"
3997 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4000 local nodes=$(comma_list $(osts_nodes))
4001 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4002 ost.OSS.ost_io.nrs_delay_min=4 \
4003 ost.OSS.ost_io.nrs_delay_max=4 \
4004 ost.OSS.ost_io.nrs_delay_pct=100
4005 [ $? -ne 0 ] && error "Failed to set delay policy"
4007 local start=$SECONDS
4008 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4009 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4010 oflag=direct conv=fdatasync ||
4011 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4012 error "dd on client failed (1)"; }
4013 local elapsed=$((SECONDS - start))
4015 # NRS delay doesn't do sub-second timing, so a request enqueued at
4016 # 0.9 seconds can be dequeued at 4.0
4017 [ $elapsed -lt 3 ] &&
4018 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4019 error "Single 1M write should take at least 3 seconds"; }
4022 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4023 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4024 oflag=direct conv=fdatasync ||
4025 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4026 error "dd on client failed (2)"; }
4027 elapsed=$((SECONDS - start))
4029 [ $elapsed -lt 30 ] &&
4030 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4031 error "Ten 1M writes should take at least 30 seconds"; }
4033 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4034 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4038 run_test 77m "check NRS Delay slows write RPC processing"
4040 test_77n() { #LU-10802
4041 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
4042 skip "Need OST version at least 2.10.58"
4046 # Configure jobid_var
4047 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4048 if [ $saved_jobid_var != procname_uid ]; then
4049 set_persistent_param_and_check client \
4050 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4053 do_nodes $(comma_list $(osts_nodes)) \
4054 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4055 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4056 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4059 tbf_verify 20 20 "$RUNAS"
4061 do_nodes $(comma_list $(osts_nodes)) \
4062 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4063 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4068 do_nodes $(comma_list $(osts_nodes)) \
4069 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4070 ost.OSS.ost_io.nrs_policies="fifo"
4074 local current_jobid_var=$($LCTL get_param -n jobid_var)
4075 if [ $saved_jobid_var != $current_jobid_var ]; then
4076 set_persistent_param_and_check client \
4077 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4080 run_test 77n "check wildcard support for TBF JobID NRS policy"
4082 test_78() { #LU-6673
4085 oss=$(comma_list $(osts_nodes))
4086 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4087 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4089 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4090 # Valid return codes are:
4091 # 0: Tuning succeeded
4092 # ENODEV: Policy is still stopped
4093 # EAGAIN: Policy is being initialized
4094 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4095 error "Expected set_param to return 0|ENODEV|EAGAIN"
4097 # Cleanup the ORR policy
4098 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4099 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4102 run_test 78 "Enable policy and specify tunings right away"
4105 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4106 test_mkdir $DIR/$tdir
4108 # Prevent interference from layout intent RPCs due to
4109 # asynchronous writeback. These will be tested in 130c below.
4110 do_nodes ${CLIENTS:-$HOSTNAME} sync
4112 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4113 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4115 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4116 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4117 local facet=mds$((mdtidx + 1))
4119 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4120 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4124 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4125 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4130 run_test 79 "xattr: intent error"
4133 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4140 mkdir -p $DIR1/$tdir/dir
4141 createmany -o $DIR1/$tdir/dir/f 10 ||
4142 error "create files under remote dir failed $i"
4144 cp /etc/passwd $DIR1/$tdir/$tfile
4146 #migrate open file should fails
4147 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4149 # give multiop a chance to open
4152 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4153 error "migrate open files should failed with open files"
4157 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4158 error "migrate remote dir error"
4160 echo "Finish migration, then checking.."
4161 for file in $(find $DIR1/$tdir); do
4162 mdt_index=$($LFS getstripe -m $file)
4163 [ $mdt_index == $MDTIDX ] ||
4164 error "$file is not on MDT${MDTIDX}"
4167 diff /etc/passwd $DIR1/$tdir/$tfile ||
4168 error "file different after migration"
4170 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4172 run_test 80a "migrate directory when some children is being opened"
4176 kill -9 $migrate_pid
4180 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4181 local migrate_dir1=$DIR1/$tdir/migrate_dir
4182 local migrate_dir2=$DIR2/$tdir/migrate_dir
4183 local migrate_run=$LUSTRE/tests/migrate.sh
4191 trap cleanup_80b EXIT
4192 #prepare migrate directory
4193 mkdir -p $migrate_dir1
4194 for F in {1,2,3,4,5}; do
4195 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4196 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4199 #migrate the directories among MDTs
4202 mdt_idx=$((RANDOM % MDSCOUNT))
4203 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4205 [ $rc -ne 0 -o $rc -ne 16 ] || break
4210 echo "start migration thread $migrate_pid"
4211 #Access the files at the same time
4212 start_time=$(date +%s)
4213 echo "accessing the migrating directory for 5 minutes..."
4215 ls $migrate_dir2 > /dev/null || {
4216 echo "read dir fails"
4219 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4220 echo "access file1 fails"
4224 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4225 echo "access file2/3 fails"
4229 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4230 echo "access file4 fails"
4234 stat $migrate_dir2/file5 > /dev/null || {
4235 echo "stat file5 fails"
4239 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4240 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4241 echo "touch file failed with $rc1"
4245 if [ -e $migrate_dir2/source_file ]; then
4246 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4247 &>/dev/null || rc1=$?
4248 if [ -e $migrate_dir2/link_file ]; then
4249 rm -rf $migrate_dir2/link_file
4252 mrename $migrate_dir2/source_file \
4253 $migrate_dir2/target_file &>/dev/null || rc1=$?
4254 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4255 echo "rename failed with $rc1"
4259 if [ -e $migrate_dir2/target_file ]; then
4260 rm -rf $migrate_dir2/target_file &>/dev/null ||
4263 rm -rf $migrate_dir2/source_file &>/dev/null ||
4266 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4267 echo "unlink failed with $rc1"
4272 end_time=$(date +%s)
4273 duration=$((end_time - start_time))
4274 if [ $((duration % 10)) -eq 0 ]; then
4275 if [ $show_time -eq 1 ]; then
4276 echo "...$duration seconds"
4283 kill -0 $migrate_pid || {
4284 echo "migration stopped 1"
4288 [ $duration -ge 300 ] && break
4291 #check migration are still there
4292 kill -0 $migrate_pid || error "migration stopped 2"
4295 run_test 80b "Accessing directory during migration"
4298 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4302 mkdir -p $DIR1/$tdir
4304 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4305 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4308 touch d0/0 || error "create 0 failed"
4309 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4310 stat d0/0 && error "stat mv filed succeed"
4311 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4312 stat d0/0 || error "stat failed"
4314 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4316 if [ $t -ne 3 ]; then
4317 ls -ai $DIR1/$tdir/d0
4318 error "expect 3 get $t"
4323 run_test 81a "rename and stat under striped directory"
4326 [ $MDSCOUNT -lt 2 ] &&
4327 skip "We need at least 2 MDTs for this test"
4334 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4335 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4344 for i in $(seq $total); do
4345 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4349 kill -9 $setattr_pid
4351 run_test 81b "rename under striped directory doesn't deadlock"
4354 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4355 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4356 skip "Need MDS version at least 2.13.52"
4358 # source is local, source parent is remote
4359 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4360 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4361 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4362 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4363 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4364 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4365 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4366 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4368 # source is remote, source parent is local
4369 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4370 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4371 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4372 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4373 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4374 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4375 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4376 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4378 # source and source parent are remote
4379 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4380 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4381 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4382 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4383 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4384 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4385 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4386 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4388 # source and source parent are remote, and source is remote object
4389 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4390 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4391 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4392 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4393 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4394 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4395 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4397 run_test 81c "rename revoke LOOKUP lock for remote object"
4400 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4401 { skip "Need MDS version at least 2.6.92"; return 0; }
4403 # Client 1 creates a file.
4404 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4406 # Client 2 opens the file.
4407 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4409 # Client 1 makes the file an orphan.
4410 rm $DIR1/$tfile || error "rm"
4411 # Client 2 sets EA "user.multiop".
4413 wait $pid2 || error "multiop 2"
4414 # Client 1 gets EA "user.multiop". This used to fail because the EA
4415 # cache refill would get "trusted.link" from mdd_xattr_list() but
4416 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4419 wait $pid1 || error "multiop 1"
4421 run_test 82 "fsetxattr and fgetxattr on orphan files"
4424 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4431 $LFS mkdir -i1 -c2 $tdir
4436 echo "start pid $pid1 to create/unlink striped directory"
4438 # Access the directory at the same time
4442 stat $tdir > /dev/null 2>&1
4446 echo "start pid $pid2 to stat striped directory"
4454 run_test 83 "access striped directory while it is being created/unlinked"
4457 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4458 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4462 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4463 error "create $tfile failed"
4464 mtime=$(stat -c%Y $DIR/$tfile)
4465 mtime=$((mtime + 200))
4467 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4468 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4470 touch -c -m $mtime $DIR/$tfile &
4472 # sleep a while to let 'touch' run first
4474 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4477 wait $setattr_pid || true
4479 run_test 84 "0-nlink race in lu_object_find()"
4482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4487 [ "$SLOW" = "yes" ] && duration=600
4488 # Open/Create under striped directory
4492 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4493 touch $tdir/f{0..3} > /dev/null 2>&1
4497 echo "start pid $pid1 to open/create under striped directory"
4499 # unlink the striped directory at the same time
4503 rm -rf $tdir > /dev/null 2>&1
4507 echo "start pid $pid2 to unlink striped directory"
4516 run_test 90 "open/create and unlink striped directory"
4519 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4524 [ "$SLOW" = "yes" ] && duration=600
4525 # chmod striped directory
4529 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4530 chmod go+w $tdir > /dev/null 2>&1
4534 echo "start pid $pid1 to chmod striped directory"
4536 # unlink the striped directory at the same time
4540 rm -rf $tdir > /dev/null 2>&1
4544 echo "start pid $pid2 to unlink striped directory"
4553 run_test 91 "chmod and unlink striped directory"
4556 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4559 local cmd="exec $fd<$DIR1/$tdir"
4560 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4563 trap "eval $cmd" EXIT
4564 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4565 rmdir ../$tdir || error "rmdir ../$tdir fails"
4567 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4568 $LCTL set_param fail_loc=0x1408
4569 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4570 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4571 error "create remote dir succeeds"
4572 $LCTL set_param fail_loc=0
4576 run_test 92 "create remote directory under orphan directory"
4583 mkdir -p $DIR1/$tfile-1/
4584 mkdir -p $DIR2/$tfile-2/
4585 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4586 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4587 do_facet $SINGLEMDS lctl set_param -n \
4588 'lod.lustre-MDT*/qos_threshold_rr' 100
4589 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4590 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4592 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4595 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4599 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4600 do_facet $SINGLEMDS "lctl set_param -n \
4601 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4603 $GETSTRIPE $DIR1/$tfile-1/file1
4604 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4605 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4606 $GETSTRIPE $DIR2/$tfile-2/file2
4607 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4608 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4609 echo "rc1=$rc1 and rc2=$rc2 "
4610 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4611 error "object allocate on same ost detected"
4613 run_test 93 "alloc_rr should not allocate on same ost"
4617 skip "Reserved for glimpse-ahead" && return
4618 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4619 skip "Need MDS version at least 2.10.55"
4623 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4625 lctl set_param -n mdc.*.stats=clear
4626 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4628 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4629 # first stat from server should return size data and save glimpse
4630 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4631 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4632 # second stat to check size is NOT cached on client without IO lock
4633 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4635 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4636 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4639 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4642 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4643 skip "Need MDS version at least 2.10.55"
4647 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4649 lctl set_param -n mdc.*.stats=clear
4650 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4651 cancel_lru_locks mdc
4652 # first stat data from server should have size
4653 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4654 # second stat to check size is cached on client
4655 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4657 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4658 # both stats should cause no glimpse requests
4659 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4662 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4665 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4666 skip "Need MDS version at least 2.10.55"
4670 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4672 lctl set_param -n mdc.*.stats=clear
4673 lctl set_param -n osc.*.stats=clear
4674 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4676 # check that size is merged from MDT and OST correctly
4677 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4678 error "Wrong size from stat #1"
4680 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4681 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4685 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4688 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4689 skip "Need MDS version at least 2.10.55"
4693 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4696 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4697 lctl set_param -n mdc.*.stats=clear
4698 $TRUNCATE $DIR2/$tdir/dom 4096
4700 # check that reported size is valid after file grows to OST and
4701 # is truncated back to MDT stripe size
4702 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4703 error "Wrong size from stat #1"
4705 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4706 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4710 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4713 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
4714 skip "Need MDS version at least 2.11.50"
4716 local dom=$DIR/$tdir/dom
4717 local dom2=$DIR2/$tdir/dom
4720 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4722 cancel_lru_locks mdc
4723 dd if=/dev/urandom of=$dom bs=12000 count=1
4724 $TRUNCATE $dom2 6000
4725 cancel_lru_locks mdc
4726 lctl set_param -n mdc.*.stats=clear
4727 # expect read-on-open to return all data before write
4728 cat /etc/hosts >> $dom
4729 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4730 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4732 run_test 100e "DoM: read on open and file size"
4735 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4736 skip "Need MDS version at least 2.10.55" && return
4738 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4740 $CHECKSTAT -t file $DIR1/$tfile
4742 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4743 sysctl -wq vm.dirty_writeback_centisecs=0
4745 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4748 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4749 error_noexit "Write fails"
4750 # must discard pages
4751 lctl set_param -n mdc.*.stats=clear
4752 rm $DIR2/$tfile || error "Unlink fails"
4754 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4755 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4757 run_test 101a "Discard DoM data on unlink"
4760 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4761 skip "Need MDS version at least 2.10.55" && return
4763 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4764 touch $DIR1/${tfile}_2
4766 $CHECKSTAT -t file $DIR1/$tfile
4768 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4769 sysctl -wq vm.dirty_writeback_centisecs=0
4771 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4774 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4775 # must discard pages
4776 lctl set_param -n mdc.*.stats=clear
4777 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4779 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4780 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4782 run_test 101b "Discard DoM data on rename"
4785 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4786 skip "Need MDS version at least 2.10.55" && return
4788 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4790 $CHECKSTAT -t file $DIR1/$tfile
4792 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4793 sysctl -wq vm.dirty_writeback_centisecs=0
4795 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4798 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4799 $MULTIOP $DIR1/$tfile O_c &
4802 lctl set_param -n mdc.*.stats=clear
4803 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4804 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4806 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4807 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4809 run_test 101c "Discard DoM data on close-unlink"
4811 # test to verify file handle related system calls
4812 # (name_to_handle_at/open_by_handle_at)
4813 # The new system calls are supported in glibc >= 2.14.
4815 # test to verify we can open by handle an unlinked file from > 1 client
4816 # This test opens the file normally on $DIR1, which is on one mount, and then
4817 # opens it by handle on $DIR2, which is on a different mount.
4819 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
4820 skip "Needs MDS version 2.11.57 or later"
4822 echo "Test file_handle syscalls" > $DIR/$tfile ||
4823 error "write failed"
4824 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4825 error "check_fhandle_syscalls failed"
4828 run_test 102 "Test open by handle of unlinked file"
4830 # Compare file size between first & second mount, ensuring the client correctly
4831 # glimpses even with unused speculative locks - LU-11670
4833 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
4834 skip "Lockahead needs OST version at least 2.10.50"
4838 test_mkdir -p $DIR/$tdir
4840 # Force file on to OST0
4841 $LFS setstripe -i 0 $DIR/$tdir
4843 # Do not check multiple locks on glimpse
4844 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
4845 $LCTL set_param fail_loc=0x415
4847 # Delay write commit by 2 seconds to guarantee glimpse wins race
4848 # The same fail_loc is used on client & server so it can work in the
4849 # single node sanity setup
4850 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
4852 echo "Incorrect size expected (no glimpse fix):"
4853 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4855 if [ $rc -eq 0 ]; then
4856 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
4859 # guarantee write commit timeout has expired
4862 # Clear fail_loc on client
4863 $LCTL set_param fail_loc=0
4865 # Delay write commit by 2 seconds to guarantee glimpse wins race
4866 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4867 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
4869 # Write commit is still delayed by 2 seconds
4870 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4872 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
4874 # guarantee write commit timeout has expired
4877 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
4879 run_test 103 "Test size correctness with lockahead"
4885 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
4896 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
4897 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
4898 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
4899 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
4907 local xtimes=($(get_stat_xtimes))
4908 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4910 echo "STAT a|m|ctime ${xtimes[*]}"
4911 echo "MDT a|m|ctime ${xtimes[*]}"
4912 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
4913 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
4914 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4915 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4916 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4917 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4921 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
4922 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
4923 skip "Need MDS version at least 2.12.4"
4926 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
4927 local atime_diff=$(do_facet $SINGLEMDS \
4928 lctl get_param -n mdd.*MDT0000*.atime_diff)
4930 do_facet $SINGLEMDS \
4931 lctl set_param -n mdd.*MDT0000*.atime_diff=0
4933 stack_trap "do_facet $SINGLEMDS \
4934 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
4936 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4937 check_mdt_xtimes $mdtdev
4940 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4941 check_mdt_xtimes $mdtdev
4943 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
4946 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4948 kill -USR1 $pid && wait $pid || error "multiop failure"
4949 check_mdt_xtimes $mdtdev
4954 # Verify mtime/ctime is NOT upated on MDS when there is no modification
4955 # on the client side
4956 xtimes=($(get_stat_xtimes))
4957 $MULTIOP $DIR/$tfile O_c &
4960 kill -USR1 $pid && wait $pid || error "multiop failure"
4961 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4962 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4963 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4964 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4965 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4966 check_mdt_xtimes $mdtdev
4969 # Change ctime via chmod
4970 $MULTIOP $DIR/$tfile o_tc &
4973 kill -USR1 $pid && wait $pid || error "multiop failure"
4974 check_mdt_xtimes $mdtdev
4976 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
4978 log "cleanup: ======================================================"
4980 # kill and wait in each test only guarentee script finish, but command in script
4981 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4982 # otherwise umount below will fail
4983 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4988 check_and_cleanup_lustre