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"
1471 # how long 40-47 take with specific delay
1478 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1479 # avoid unexpected delays due to previous tests
1481 cancel_lru_locks mdc
1482 do_nodes $(comma_list $(mdts_nodes)) \
1483 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1484 do_nodes $(comma_list $(mdts_nodes)) \
1485 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1486 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1489 # check that pid exists hence second operation wasn't blocked by first one
1490 # if it is so then there is no conflict, return 0
1491 # else second operation is conflicting with first one, return 1
1492 check_pdo_conflict() {
1495 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1496 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1506 # test 40: check non-blocking operations
1508 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1510 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1511 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1513 mkdir $DIR1/$tfile &
1515 touch $DIR2/$tfile-2
1516 check_pdo_conflict $PID1 || error "create is blocked"
1517 mkdir $DIR2/$tfile-3
1518 check_pdo_conflict $PID1 || error "mkdir is blocked"
1519 link $DIR2/$tfile-2 $DIR2/$tfile-4
1520 check_pdo_conflict $PID1 || error "link is blocked"
1521 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1522 check_pdo_conflict $PID1 || error "rename is blocked"
1523 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1524 check_pdo_conflict $PID1 || error "getattr is blocked"
1525 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1526 rmdir $DIR2/$tfile-3
1527 check_pdo_conflict $PID1 || error "unlink is blocked"
1529 # all operations above shouldn't wait the first one
1530 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1531 do_facet $SINGLEMDS lctl set_param fail_loc=0
1536 run_test 40a "pdirops: create vs others =============="
1539 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1541 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1542 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1543 touch $DIR1/$tfile &
1546 touch $DIR2/$tfile-2
1547 check_pdo_conflict $PID1 || error "create is blocked"
1548 mkdir $DIR2/$tfile-3
1549 check_pdo_conflict $PID1 || error "mkdir is blocked"
1550 link $DIR2/$tfile-2 $DIR2/$tfile-4
1551 check_pdo_conflict $PID1 || error "link is blocked"
1552 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1553 check_pdo_conflict $PID1 || error "rename is blocked"
1554 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1555 check_pdo_conflict $PID1 || error "getattr is blocked"
1556 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1557 rmdir $DIR2/$tfile-3
1558 check_pdo_conflict $PID1 || error "unlink is blocked"
1559 # all operations above shouldn't wait the first one
1561 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1562 do_facet $SINGLEMDS lctl set_param fail_loc=0
1567 run_test 40b "pdirops: open|create and others =============="
1570 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1573 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1574 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1575 link $DIR1/$tfile $DIR1/$tfile-0 &
1578 touch $DIR2/$tfile-2
1579 check_pdo_conflict $PID1 || error "create is blocked"
1580 mkdir $DIR2/$tfile-3
1581 check_pdo_conflict $PID1 || error "mkdir is blocked"
1582 link $DIR2/$tfile-2 $DIR2/$tfile-4
1583 check_pdo_conflict $PID1 || error "link is blocked"
1584 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1585 check_pdo_conflict $PID1 || error "rename is blocked"
1586 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1587 check_pdo_conflict $PID1 || error "getattr is blocked"
1588 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1589 rmdir $DIR2/$tfile-3
1590 check_pdo_conflict $PID1 || error "unlink is blocked"
1592 # all operations above shouldn't wait the first one
1593 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1594 do_facet $SINGLEMDS lctl set_param fail_loc=0
1599 run_test 40c "pdirops: link and others =============="
1602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1605 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1606 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1610 touch $DIR2/$tfile-2
1611 check_pdo_conflict $PID1 || error "create is blocked"
1612 mkdir $DIR2/$tfile-3
1613 check_pdo_conflict $PID1 || error "mkdir is blocked"
1614 link $DIR2/$tfile-2 $DIR2/$tfile-4
1615 check_pdo_conflict $PID1 || error "link is blocked"
1616 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1617 check_pdo_conflict $PID1 || error "rename is blocked"
1618 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1619 check_pdo_conflict $PID1 || error "getattr is blocked"
1620 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1621 rmdir $DIR2/$tfile-3
1622 check_pdo_conflict $PID1 || error "unlink is blocked"
1624 # all operations above shouldn't wait the first one
1625 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1626 do_facet $SINGLEMDS lctl set_param fail_loc=0
1630 run_test 40d "pdirops: unlink and others =============="
1633 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1636 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1637 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1638 mv $DIR1/$tfile $DIR1/$tfile-0 &
1641 touch $DIR2/$tfile-2
1642 check_pdo_conflict $PID1 || error "create is blocked"
1643 mkdir $DIR2/$tfile-3
1644 check_pdo_conflict $PID1 || error "mkdir is blocked"
1645 link $DIR2/$tfile-2 $DIR2/$tfile-4
1646 check_pdo_conflict $PID1 || error "link is blocked"
1647 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1648 check_pdo_conflict $PID1 || error "getattr is blocked"
1649 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1650 rmdir $DIR2/$tfile-3
1651 check_pdo_conflict $PID1 || error "unlink is blocked"
1653 # all operations above shouldn't wait the first one
1654 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1655 do_facet $SINGLEMDS lctl set_param fail_loc=0
1660 run_test 40e "pdirops: rename and others =============="
1662 # test 41: create blocking operations
1665 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1666 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1667 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1669 mkdir $DIR2/$tfile &
1671 do_facet $SINGLEMDS lctl set_param fail_loc=0
1672 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1673 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1677 run_test 41a "pdirops: create vs mkdir =============="
1681 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1682 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1683 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1685 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1687 do_facet $SINGLEMDS lctl set_param fail_loc=0
1688 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1689 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1693 run_test 41b "pdirops: create vs create =============="
1697 touch $DIR1/$tfile-2
1698 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1699 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1700 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1702 link $DIR2/$tfile-2 $DIR2/$tfile &
1704 do_facet $SINGLEMDS lctl set_param fail_loc=0
1705 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1706 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1710 run_test 41c "pdirops: create vs link =============="
1714 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1715 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1716 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1720 do_facet $SINGLEMDS lctl set_param fail_loc=0
1721 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1722 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1726 run_test 41d "pdirops: create vs unlink =============="
1730 touch $DIR1/$tfile-2
1731 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1732 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1733 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1735 mv $DIR2/$tfile-2 $DIR2/$tfile &
1737 do_facet $SINGLEMDS lctl set_param fail_loc=0
1738 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1739 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1743 run_test 41e "pdirops: create and rename (tgt) =============="
1747 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1748 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1749 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1751 mv $DIR2/$tfile $DIR2/$tfile-2 &
1753 do_facet $SINGLEMDS lctl set_param fail_loc=0
1754 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1755 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1759 run_test 41f "pdirops: create and rename (src) =============="
1763 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1764 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1765 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1767 stat $DIR2/$tfile > /dev/null &
1769 do_facet $SINGLEMDS lctl set_param fail_loc=0
1770 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1771 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1775 run_test 41g "pdirops: create vs getattr =============="
1779 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1780 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1781 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1783 ls -lia $DIR2/ > /dev/null &
1785 do_facet $SINGLEMDS lctl set_param fail_loc=0
1786 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1791 run_test 41h "pdirops: create vs readdir =============="
1798 do_nodes $(comma_list $(mdts_nodes)) \
1799 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1801 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1804 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1807 if ! wait $PID1 && ! wait $PID2; then
1808 echo "Both creates failed (1 should fail, 1 should succeed)"
1810 elif wait $PID1 && wait $PID2; then
1811 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1816 do_nodes $(comma_list $(mdts_nodes)) \
1817 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1824 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1825 skip "Need MDS version newer than 2.13.56"
1828 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1829 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1830 for fail_loc in "0x80000169" "0x8000016a"; do
1831 echo "Begin 100 tests with fail_loc=$fail_loc"
1833 for i in {1..100}; do
1835 msg=$(sub_test_41i "$fail_loc") ||
1836 { echo; error "iter=$i : $msg"; }
1841 run_test 41i "reint_open: create vs create"
1844 # test 42: unlink and blocking operations
1847 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1848 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1849 mkdir $DIR1/$tfile &
1851 mkdir $DIR2/$tfile &
1853 do_facet $SINGLEMDS lctl set_param fail_loc=0
1854 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1855 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1859 run_test 42a "pdirops: mkdir vs mkdir =============="
1863 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1864 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1865 mkdir $DIR1/$tfile &
1867 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1869 do_facet $SINGLEMDS lctl set_param fail_loc=0
1870 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1871 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1875 run_test 42b "pdirops: mkdir vs create =============="
1879 touch $DIR1/$tfile-2
1880 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1881 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1882 mkdir $DIR1/$tfile &
1884 link $DIR2/$tfile-2 $DIR2/$tfile &
1886 do_facet $SINGLEMDS lctl set_param fail_loc=0
1887 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1888 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1892 run_test 42c "pdirops: mkdir vs link =============="
1896 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1897 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1898 mkdir $DIR1/$tfile &
1900 rmdir $DIR2/$tfile &
1902 do_facet $SINGLEMDS lctl set_param fail_loc=0
1903 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1904 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1908 run_test 42d "pdirops: mkdir vs unlink =============="
1912 touch $DIR1/$tfile-2
1913 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1914 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1915 mkdir $DIR1/$tfile &
1917 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1919 do_facet $SINGLEMDS lctl set_param fail_loc=0
1920 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1921 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1925 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1929 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1930 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1931 mkdir $DIR1/$tfile &
1933 mv $DIR2/$tfile $DIR2/$tfile-2 &
1935 do_facet $SINGLEMDS lctl set_param fail_loc=0
1936 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1937 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1941 run_test 42f "pdirops: mkdir and rename (src) =============="
1945 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1946 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1947 mkdir $DIR1/$tfile &
1949 stat $DIR2/$tfile > /dev/null &
1951 do_facet $SINGLEMDS lctl set_param fail_loc=0
1952 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1953 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1957 run_test 42g "pdirops: mkdir vs getattr =============="
1961 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1962 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1963 mkdir $DIR1/$tfile &
1965 ls -lia $DIR2/ > /dev/null &
1967 do_facet $SINGLEMDS lctl set_param fail_loc=0
1968 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1973 run_test 42h "pdirops: mkdir vs readdir =============="
1975 # test 43: rmdir,mkdir won't return -EEXIST
1977 for i in {1..1000}; do
1978 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
1979 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
1983 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
1988 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1992 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1994 do_facet $SINGLEMDS lctl set_param fail_loc=0
1995 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1996 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2000 run_test 43b "pdirops: unlink vs create =============="
2005 touch $DIR1/$tfile-2
2006 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2007 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2010 link $DIR2/$tfile-2 $DIR2/$tfile &
2012 do_facet $SINGLEMDS lctl set_param fail_loc=0
2013 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2014 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2018 run_test 43c "pdirops: unlink vs link =============="
2023 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2024 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2029 do_facet $SINGLEMDS lctl set_param fail_loc=0
2030 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2031 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2035 run_test 43d "pdirops: unlink vs unlink =============="
2040 touch $DIR1/$tfile-2
2041 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2042 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2045 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2047 do_facet $SINGLEMDS lctl set_param fail_loc=0
2048 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2049 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2053 run_test 43e "pdirops: unlink and rename (tgt) =============="
2058 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2059 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2062 mv $DIR2/$tfile $DIR2/$tfile-2 &
2064 do_facet $SINGLEMDS lctl set_param fail_loc=0
2065 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2066 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2070 run_test 43f "pdirops: unlink and rename (src) =============="
2075 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2076 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2079 stat $DIR2/$tfile > /dev/null &
2081 do_facet $SINGLEMDS lctl set_param fail_loc=0
2082 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2083 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2087 run_test 43g "pdirops: unlink vs getattr =============="
2092 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2093 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2096 ls -lia $DIR2/ > /dev/null &
2098 do_facet $SINGLEMDS lctl set_param fail_loc=0
2099 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2104 run_test 43h "pdirops: unlink vs readdir =============="
2107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2110 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2111 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2114 $LFS mkdir -i 1 $DIR2/$tfile &
2116 do_facet $SINGLEMDS lctl set_param fail_loc=0
2117 check_pdo_conflict $PID1 &&
2118 { wait $PID1; error "remote mkdir isn't blocked"; }
2119 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2123 run_test 43i "pdirops: unlink vs remote mkdir"
2126 [[ $MDS1_VERSION -lt $(version_code 2.12.7) ]] &&
2127 skip "Need MDS version newer than 2.12.7"
2129 for i in {1..100}; do
2130 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2131 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000167
2135 mkdir $DIR2/$tdir && ((OK++))
2136 wait $PID1 && ((OK++))
2137 (( OK == 1 )) || error "exactly one mkdir should succeed"
2139 rmdir $DIR1/$tdir || error "rmdir failed"
2143 run_test 43j "racy mkdir return EEXIST =============="
2150 # We test in a separate directory to be able to unblock server thread in
2151 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2152 test_mkdir $DIR2/$tdir
2153 touch $DIR2/$tdir/$tfile
2155 do_nodes $(comma_list $(mdts_nodes)) \
2156 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2157 echo content > $DIR1/$tdir/$tfile & PID1=$!
2159 multiop $DIR2/$tdir/$tfile u & PID2=$!
2163 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2166 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2169 do_nodes $(comma_list $(mdts_nodes)) \
2170 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2177 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2178 skip "Need MDS version newer than 2.13.56"
2181 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2182 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2183 for fail_loc in "0x80000169" "0x8000016a"; do
2184 echo "Begin 100 tests with fail_loc=$fail_loc"
2186 for i in {1..100}; do
2188 msg=$(sub_test_43k "$fail_loc") ||
2189 { echo; error "iter=$i : $msg"; }
2199 run_test 43k "unlink vs create"
2201 # test 44: rename tgt and blocking operations
2204 touch $DIR1/$tfile-2
2205 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2206 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2207 mv $DIR1/$tfile-2 $DIR1/$tfile &
2209 mkdir $DIR2/$tfile &
2211 do_facet $SINGLEMDS lctl set_param fail_loc=0
2212 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2213 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2218 run_test 44a "pdirops: rename tgt vs mkdir =============="
2222 touch $DIR1/$tfile-2
2223 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2224 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2225 mv $DIR1/$tfile-2 $DIR1/$tfile &
2227 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2229 do_facet $SINGLEMDS lctl set_param fail_loc=0
2230 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2231 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2235 run_test 44b "pdirops: rename tgt vs create =============="
2239 touch $DIR1/$tfile-2
2240 touch $DIR1/$tfile-3
2241 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2242 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2243 mv $DIR1/$tfile-2 $DIR1/$tfile &
2245 link $DIR2/$tfile-3 $DIR2/$tfile &
2247 do_facet $SINGLEMDS lctl set_param fail_loc=0
2248 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2249 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2253 run_test 44c "pdirops: rename tgt vs link =============="
2257 touch $DIR1/$tfile-2
2258 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2259 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2260 mv $DIR1/$tfile-2 $DIR1/$tfile &
2264 do_facet $SINGLEMDS lctl set_param fail_loc=0
2265 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2266 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2270 run_test 44d "pdirops: rename tgt vs unlink =============="
2275 touch $DIR1/$tfile-2
2276 touch $DIR1/$tfile-3
2277 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2278 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2279 mv $DIR1/$tfile-2 $DIR1/$tfile &
2281 mv $DIR2/$tfile-3 $DIR2/$tfile &
2283 do_facet $SINGLEMDS lctl set_param fail_loc=0
2284 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2285 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2289 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2293 touch $DIR1/$tfile-2
2294 touch $DIR1/$tfile-3
2295 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2296 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2297 mv $DIR1/$tfile-2 $DIR1/$tfile &
2299 mv $DIR2/$tfile $DIR2/$tfile-3 &
2301 do_facet $SINGLEMDS lctl set_param fail_loc=0
2302 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2303 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2307 run_test 44f "pdirops: rename tgt and rename (src) =============="
2311 touch $DIR1/$tfile-2
2312 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2313 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2314 mv $DIR1/$tfile-2 $DIR1/$tfile &
2316 stat $DIR2/$tfile > /dev/null &
2318 do_facet $SINGLEMDS lctl set_param fail_loc=0
2319 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2320 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2324 run_test 44g "pdirops: rename tgt vs getattr =============="
2328 touch $DIR1/$tfile-2
2329 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2330 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2331 mv $DIR1/$tfile-2 $DIR1/$tfile &
2333 ls -lia $DIR2/ > /dev/null &
2335 do_facet $SINGLEMDS lctl set_param fail_loc=0
2336 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2341 run_test 44h "pdirops: rename tgt vs readdir =============="
2343 # test 44: rename tgt and blocking operations
2345 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2347 touch $DIR1/$tfile-2
2348 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2349 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2350 mv $DIR1/$tfile-2 $DIR1/$tfile &
2352 $LFS mkdir -i 1 $DIR2/$tfile &
2354 do_facet $SINGLEMDS lctl set_param fail_loc=0
2355 check_pdo_conflict $PID1 && { wait $PID1;
2356 error "remote mkdir isn't blocked"; }
2357 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2361 run_test 44i "pdirops: rename tgt vs remote mkdir"
2363 # test 45: rename,mkdir doesn't fail with -EEXIST
2365 for i in {1..1000}; do
2366 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2367 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2368 error "mrename to $tdir.$i failed"
2373 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2378 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2379 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2380 mv $DIR1/$tfile $DIR1/$tfile-2 &
2382 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2384 do_facet $SINGLEMDS lctl set_param fail_loc=0
2385 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2386 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2390 run_test 45b "pdirops: rename src vs create =============="
2395 touch $DIR1/$tfile-3
2396 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2397 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2398 mv $DIR1/$tfile $DIR1/$tfile-2 &
2400 link $DIR2/$tfile-3 $DIR2/$tfile &
2402 do_facet $SINGLEMDS lctl set_param fail_loc=0
2403 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2404 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2408 run_test 45c "pdirops: rename src vs link =============="
2413 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2414 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2415 mv $DIR1/$tfile $DIR1/$tfile-2 &
2419 do_facet $SINGLEMDS lctl set_param fail_loc=0
2420 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2421 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2425 run_test 45d "pdirops: rename src vs unlink =============="
2430 touch $DIR1/$tfile-3
2431 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2432 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2433 mv $DIR1/$tfile $DIR1/$tfile-2 &
2435 mv $DIR2/$tfile-3 $DIR2/$tfile &
2437 do_facet $SINGLEMDS lctl set_param fail_loc=0
2438 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2439 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2443 run_test 45e "pdirops: rename src and rename (tgt) =============="
2448 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2449 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2450 mv $DIR1/$tfile $DIR1/$tfile-2 &
2452 mv $DIR2/$tfile $DIR2/$tfile-3 &
2454 do_facet $SINGLEMDS lctl set_param fail_loc=0
2455 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2456 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2460 run_test 45f "pdirops: rename src and rename (src) =============="
2465 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2466 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2467 mv $DIR1/$tfile $DIR1/$tfile-2 &
2469 stat $DIR2/$tfile > /dev/null &
2471 do_facet $SINGLEMDS lctl set_param fail_loc=0
2472 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2473 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2477 run_test 45g "pdirops: rename src vs getattr =============="
2482 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2483 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2484 mv $DIR1/$tfile $DIR1/$tfile-2 &
2486 ls -lia $DIR2/ > /dev/null &
2487 do_facet $SINGLEMDS lctl set_param fail_loc=0
2488 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2493 run_test 45h "pdirops: unlink vs readdir =============="
2496 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2499 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2500 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2501 mv $DIR1/$tfile $DIR1/$tfile-2 &
2503 $LFS mkdir -i 1 $DIR2/$tfile &
2505 do_facet $SINGLEMDS lctl set_param fail_loc=0
2506 check_pdo_conflict $PID1 && { wait $PID1;
2507 error "create remote dir isn't blocked"; }
2508 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2512 run_test 45i "pdirops: rename src vs remote mkdir"
2519 # We test in a sparate directory to be able to unblock server thread in
2520 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2521 test_mkdir $DIR2/$tdir
2522 echo file1 > $DIR2/$tdir/$tfile
2523 echo file2 > $DIR2/$tdir/$tfile-2
2525 do_nodes $(comma_list $(mdts_nodes)) \
2526 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2528 cat $DIR1/$tdir/$tfile >/dev/null &
2531 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2535 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2538 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2541 do_nodes $(comma_list $(mdts_nodes)) \
2542 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2549 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2550 skip "Need MDS version newer than 2.13.56"
2553 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2554 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2555 for fail_loc in "0x80000169" "0x8000016a"; do
2556 echo "Begin 100 tests with fail_loc=$fail_loc"
2558 for i in {1..100}; do
2560 msg=$(sub_test_45j "$fail_loc") ||
2561 { echo; error "iter=$i : $msg"; }
2566 run_test 45j "read vs rename =============="
2568 # test 46: link and blocking operations
2571 touch $DIR1/$tfile-2
2572 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2573 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2574 link $DIR1/$tfile-2 $DIR1/$tfile &
2576 mkdir $DIR2/$tfile &
2578 do_facet $SINGLEMDS lctl set_param fail_loc=0
2579 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2580 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2584 run_test 46a "pdirops: link vs mkdir =============="
2588 touch $DIR1/$tfile-2
2589 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2590 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2591 link $DIR1/$tfile-2 $DIR1/$tfile &
2593 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2595 do_facet $SINGLEMDS lctl set_param fail_loc=0
2596 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2597 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2601 run_test 46b "pdirops: link vs create =============="
2605 touch $DIR1/$tfile-2
2606 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2607 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2608 link $DIR1/$tfile-2 $DIR1/$tfile &
2610 link $DIR2/$tfile $DIR2/$tfile &
2612 do_facet $SINGLEMDS lctl set_param fail_loc=0
2613 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2614 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2618 run_test 46c "pdirops: link vs link =============="
2622 touch $DIR1/$tfile-2
2623 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2624 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2625 link $DIR1/$tfile-2 $DIR1/$tfile &
2629 do_facet $SINGLEMDS lctl set_param fail_loc=0
2630 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2631 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2635 run_test 46d "pdirops: link vs unlink =============="
2639 touch $DIR1/$tfile-2
2640 touch $DIR1/$tfile-3
2641 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2642 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2643 link $DIR1/$tfile-2 $DIR1/$tfile &
2645 mv $DIR2/$tfile-3 $DIR2/$tfile &
2647 do_facet $SINGLEMDS lctl set_param fail_loc=0
2648 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2649 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2653 run_test 46e "pdirops: link and rename (tgt) =============="
2657 touch $DIR1/$tfile-2
2658 touch $DIR1/$tfile-3
2659 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2660 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2661 link $DIR1/$tfile-2 $DIR1/$tfile &
2663 mv $DIR2/$tfile $DIR2/$tfile-3 &
2665 do_facet $SINGLEMDS lctl set_param fail_loc=0
2666 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2667 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2671 run_test 46f "pdirops: link and rename (src) =============="
2675 touch $DIR1/$tfile-2
2676 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2677 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2678 link $DIR1/$tfile-2 $DIR1/$tfile &
2680 stat $DIR2/$tfile > /dev/null &
2682 do_facet $SINGLEMDS lctl set_param fail_loc=0
2683 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2684 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2688 run_test 46g "pdirops: link vs getattr =============="
2692 touch $DIR1/$tfile-2
2693 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2694 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2695 link $DIR1/$tfile-2 $DIR1/$tfile &
2697 ls -lia $DIR2/ > /dev/null &
2699 do_facet $SINGLEMDS lctl set_param fail_loc=0
2700 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2705 run_test 46h "pdirops: link vs readdir =============="
2708 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2710 touch $DIR1/$tfile-2
2711 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2712 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2713 link $DIR1/$tfile-2 $DIR1/$tfile &
2715 $LFS mkdir -i 1 $DIR2/$tfile &
2717 do_facet $SINGLEMDS lctl set_param fail_loc=0
2718 check_pdo_conflict $PID1 && { wait $PID1;
2719 error "remote mkdir isn't blocked"; }
2720 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2724 run_test 46i "pdirops: link vs remote mkdir"
2726 # test 47: remote mkdir and blocking operations
2728 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2729 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2731 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2732 $LFS mkdir -i 1 $DIR1/$tfile &
2734 mkdir $DIR2/$tfile &
2736 do_facet $SINGLEMDS lctl set_param fail_loc=0
2737 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2738 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2742 run_test 47a "pdirops: remote mkdir vs mkdir"
2745 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2746 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2748 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2749 $LFS mkdir -i 1 $DIR1/$tfile &
2751 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2753 do_facet $SINGLEMDS lctl set_param fail_loc=0
2754 check_pdo_conflict $PID1 && { wait $PID1;
2755 error "create isn't blocked"; }
2756 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2760 run_test 47b "pdirops: remote mkdir vs create"
2763 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2765 touch $DIR1/$tfile-2
2766 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2767 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2768 $LFS mkdir -i 1 $DIR1/$tfile &
2770 link $DIR2/$tfile-2 $DIR2/$tfile &
2772 do_facet $SINGLEMDS lctl set_param fail_loc=0
2773 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2774 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2778 run_test 47c "pdirops: remote mkdir vs link"
2781 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2783 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2784 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2785 $LFS mkdir -i 1 $DIR1/$tfile &
2787 rmdir $DIR2/$tfile &
2789 do_facet $SINGLEMDS lctl set_param fail_loc=0
2790 check_pdo_conflict $PID1 && { wait $PID1;
2791 error "unlink isn't blocked"; }
2792 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2796 run_test 47d "pdirops: remote mkdir vs unlink"
2799 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2801 touch $DIR1/$tfile-2
2802 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2803 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2804 $LFS mkdir -i 1 $DIR1/$tfile &
2806 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2808 do_facet $SINGLEMDS lctl set_param fail_loc=0
2809 check_pdo_conflict $PID1 && { wait $PID1;
2810 error "rename isn't blocked"; }
2811 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2815 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2818 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2820 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2821 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2822 $LFS mkdir -i 1 $DIR1/$tfile &
2824 mv $DIR2/$tfile $DIR2/$tfile-2 &
2826 do_facet $SINGLEMDS lctl set_param fail_loc=0
2827 check_pdo_conflict $PID1 && { wait $PID1;
2828 error "rename isn't blocked"; }
2829 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2833 run_test 47f "pdirops: remote mkdir and rename (src)"
2836 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2840 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2841 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2842 $LFS mkdir -i 1 $DIR1/$tfile &
2844 stat $DIR2/$tfile > /dev/null &
2846 do_facet $SINGLEMDS lctl set_param fail_loc=0
2847 check_pdo_conflict $PID1 && { wait $PID1;
2848 error "getattr isn't blocked"; }
2849 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2853 run_test 47g "pdirops: remote mkdir vs getattr"
2857 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2858 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2859 do_facet client "lctl set_param fail_loc=0x410"
2860 $TRUNCATE $DIR2/$tfile $trunc_size
2861 do_facet client "lctl set_param fail_loc=0x0"
2863 size=`stat -c %s $DIR2/$tfile`
2864 [ $size -eq $trunc_size ] || error "wrong size"
2866 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2870 local origfile=/etc/hosts
2872 filesize=$(stat -c %s $origfile)
2874 # create an empty file
2875 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2876 # cache layout lock on both mount point
2877 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2878 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2880 # open and sleep 2 seconds then read
2881 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2885 # create the layout of testing file
2886 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2887 error "dd $DIR1/$tfile failed"
2889 # MULTIOP proc should be able to read enough bytes and exit
2890 for ((i = 0; i < 6; i++)); do
2892 kill -0 $pid || break
2894 kill -0 $pid 2> /dev/null && error "multiop is still there"
2895 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2899 run_test 51a "layout lock: refresh layout should work"
2902 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2903 { skip "Need MDS version at least 2.3.59"; return 0; }
2905 local tmpfile=`mktemp`
2907 # create an empty file
2908 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2910 # delay glimpse so that layout has changed when glimpse finish
2911 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2912 $LCTL set_param fail_loc=0x1404
2913 stat -c %s $DIR2/$tfile |tee $tmpfile &
2917 # create layout of testing file
2918 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2919 error "dd $DIR1/$tfile failed"
2922 local fsize=$(cat $tmpfile)
2924 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2926 rm -f $DIR1/$tfile $tmpfile
2928 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2931 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2933 # set default layout to have 1 stripe
2935 $LFS setstripe -c 1 $DIR1/$tdir
2937 # create a file with empty layout
2938 $MCREATE $DIR1/$tdir/$tfile ||
2939 error "$MCREATE $DIR1/$tdir/$tfile failed"
2941 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2942 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2944 # change the layout of testing file
2945 echo "Setting layout to have $OSTCOUNT stripes ..."
2946 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2950 # write something to the file, it should be blocked on fetching layout
2951 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2952 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2955 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2956 # count to succeed with only 3/4 of the number of stripes (rounded up),
2957 # so creating striped files does not fail if an OST is offline or full
2958 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2959 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2963 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2966 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2967 cancel_lru_locks mdc
2969 # open should grant LAYOUT lock, mmap and read will install pages
2970 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2974 # rss before revoking
2975 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2976 echo "Before revoking layout lock: $br KB mapped"
2978 # cancel layout lock manually
2979 cancel_lru_locks mdc
2981 # rss after revoking
2982 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2985 wait $PID || error "wait PID $PID failed"
2987 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2989 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2993 echo "==> rename vs getattr vs setxattr should not deadlock"
2994 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2996 do_facet mds1 $LCTL set_param fail_loc=$1
2998 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3006 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3007 wait $PID1 || error "(3) mv failed"
3008 wait $PID2 || error "(4) stat failed"
3015 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3016 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3018 do_facet mds1 $LCTL set_param fail_loc=$1
3020 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3028 $MULTIOP $DIR2/d1/d2 Oc &
3032 stat $DIR/d1 || error "(2) stat failed"
3034 wait $PID1 || error "(3) mv failed"
3035 wait $PID2 || error "(4) stat failed"
3036 wait $PID3 && error "(5) multiop failed"
3042 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3043 save_lustre_params client "llite.*.xattr_cache" > $p
3044 lctl set_param llite.*.xattr_cache 1 ||
3045 { skip "xattr cache is not supported"; return 0; }
3047 #define OBD_FAIL_MDS_RENAME 0x153
3048 #define OBD_FAIL_MDS_RENAME2 0x154
3049 test_54_part1 0x80000153 || error 10
3050 test_54_part1 0x80000154 || error 11
3051 test_54_part2 0x80000153 || error 12
3052 test_54_part2 0x80000154 || error 13
3054 restore_lustre_params < $p
3057 run_test 54 "rename locking"
3060 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3062 #define OBD_FAIL_MDS_RENAME4 0x156
3063 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3065 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3070 wait $PID1 && error "(2) mv succeeded"
3074 run_test 55a "rename vs unlink target dir"
3078 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3080 #define OBD_FAIL_MDS_RENAME4 0x156
3081 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3083 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3088 wait $PID1 && error "(2) mv succeeded"
3092 run_test 55b "rename vs unlink source dir"
3096 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3098 #define OBD_FAIL_MDS_RENAME4 0x156
3099 do_facet mds1 $LCTL set_param fail_loc=0x156
3101 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3105 # while rename is sleeping, open and remove d3
3106 $MULTIOP $DIR2/d3 D_c &
3112 # while rename is sleeping 2nd time, close d3
3114 wait $PID2 || error "(3) multiop failed"
3116 wait $PID1 && error "(2) mv succeeded"
3120 run_test 55c "rename vs unlink orphan target dir"
3126 #define OBD_FAIL_MDS_RENAME3 0x155
3127 do_facet mds1 $LCTL set_param fail_loc=0x155
3128 mv $DIR/f1 $DIR/$tdir &
3132 # while rename is sleeping, create $tdir, but as a directory
3133 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
3135 # link in reverse locking order
3136 ln $DIR2/f1 $DIR2/$tdir/
3138 wait $PID1 && error "(2) mv succeeded"
3141 run_test 55d "rename file vs link"
3144 local MDSVER=$(lustre_build_version $SINGLEMDS)
3145 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
3146 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
3149 test_mkdir $DIR1/$tdir
3150 file1=$DIR1/$tdir/file
3151 file2=$DIR2/$tdir/file
3153 echo orig > $file2 || error "Could not create $file2"
3154 version=$($LFS data_version $file1)
3157 echo append >> $file2 || error "Could not append to $file2"
3158 version2=$($LFS data_version $file1)
3159 [ "$version" != "$version2" ] ||
3160 error "append did not change data version: $version"
3163 echo overwrite > $file2 || error "Could not overwrite $file2"
3164 version3=$($LFS data_version $file1)
3165 [ "$version2" != "$version3" ] ||
3166 error "overwrite did not change data version: $version2"
3168 # Truncate before EOF
3169 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3170 version4=$($LFS data_version $file1)
3171 [ "$version3" != "$version4" ] ||
3172 error "truncate did not change data version: $version3"
3174 # Truncate after EOF
3175 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3176 version5=$($LFS data_version $file1)
3177 [ "$version4" != "$version5" ] ||
3178 error "truncate did not change data version: $version4"
3180 # Chmod do not change version
3181 chmod 400 $file2 || error "Could not chmod 400 $file2"
3182 version6=$($LFS data_version $file1)
3183 [ "$version5" == "$version6" ] ||
3184 error "chmod should not change data version: $version5 != $version6"
3186 # Chown do not change version
3187 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3188 version7=$($LFS data_version $file1)
3189 [ "$version5" == "$version7" ] ||
3190 error "chown should not change data version: $version5 != $version7"
3192 run_test 60 "Verify data_version behaviour"
3195 local test_dir=$tdir/test_dir
3197 mkdir -p $DIR1/$tdir
3198 if [ $MDSCOUNT -ge 2 ]; then
3200 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3201 error "Create remote directory failed"
3203 mkdir -p $DIR1/$test_dir
3205 cd $DIR2/$test_dir || error "cd directory failed"
3206 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3208 cd $DIR2/$tdir || error "exit directory"
3210 run_test 70a "cd directory && rm directory"
3212 test_70b() { # LU-2781
3214 mkdir -p $DIR1/$tdir
3216 touch $DIR1/$tdir/file
3217 for ((i = 0; i < 32; i++)); do
3218 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3220 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3222 touch $DIR1/$tdir/file
3223 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3224 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3225 rm -rf $DIR1/$tdir/test_dir ||
3226 error "cannot remove directory after rm_entry"
3227 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3229 run_test 70b "remove files after calling rm_entry"
3232 local server_version=$(lustre_version_code $SINGLEMDS)
3234 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3235 skip "Need MDS version at least 2.1.6" && return
3237 # Patch not applied to 2.2 and 2.3 branches
3238 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3239 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3240 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3243 checkfiemap --test ||
3244 { skip "checkfiemap not runnable: $?" && return; }
3245 # write data this way: hole - data - hole - data
3246 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3247 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
3249 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3250 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3251 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3253 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3255 checkfiemap $DIR2/$tfile 81920 ||
3256 error "data is not flushed from client"
3257 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3260 # common case of "create file, copy file" on a single node
3261 # should not flush data from ost
3262 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3263 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3265 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3267 checkfiemap $DIR1/$tfile 81920 ||
3269 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3271 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3273 run_test 71a "correct file map just after write operation is finished"
3276 local server_version=$(lustre_version_code $SINGLEMDS)
3278 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3279 skip "Need MDS version at least 2.1.6" && return
3281 # Patch not applied to 2.2 and 2.3 branches
3282 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3283 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3284 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3286 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
3288 checkfiemap --test ||
3289 { skip "error $?: checkfiemap failed" && return; }
3291 mkdir -p $DIR1/$tdir
3293 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3294 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3295 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
3297 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3298 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3300 run_test 71b "check fiemap support for stripecount > 1"
3303 local p="$TMP/sanityN-$TESTNAME.parameters"
3306 save_lustre_params client "llite.*.xattr_cache" > $p
3307 lctl set_param llite.*.xattr_cache 1 ||
3308 { skip "xattr cache is not supported"; return 0; }
3311 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3312 error "setfattr1 failed"
3313 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3314 error "getfattr1 failed"
3315 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3316 error "setfattr2 failed"
3317 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3318 error "getfattr2 failed"
3320 # check that trusted.link is consistent
3321 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3322 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3323 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3324 echo "$tlink1 $tlink2"
3325 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3329 restore_lustre_params < $p
3332 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3335 local p="$TMP/sanityN-$TESTNAME.parameters"
3336 save_lustre_params client "llite.*.xattr_cache" > $p
3337 lctl set_param llite.*.xattr_cache 1 ||
3338 { skip "xattr cache is not supported"; return 0; }
3341 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3342 error "setfattr1 failed"
3343 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3344 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3345 clear_stats llite.*.stats
3346 # PR lock should be cached by now on both clients
3347 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3348 # 2 hits for getfattr(0)+getfattr(size)
3349 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3350 error "not cached in $DIR1"
3351 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3352 # 4 hits for more getfattr(0)+getfattr(size)
3353 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3354 error "not cached in $DIR2"
3357 restore_lustre_params < $p
3360 run_test 73 "getxattr should not cause xattr lock cancellation"
3363 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3364 skip "Need MDS version at least 2.4.93" && return
3366 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3367 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3368 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3370 run_test 74 "flock deadlock: different mounts =============="
3374 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3375 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3376 cancel_lru_locks osc
3378 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3381 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3382 $LCTL set_param fail_loc=0x31d
3383 stat -c %s $DIR1/$tfile &
3388 # For bad lock error handler we should ASSERT and got kernel panic here
3390 $LCTL set_param fail_loc=0
3392 run_test 75 "osc: upcall after unuse lock==================="
3395 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3396 skip "Need MDS version at least 2.5.53" && return
3398 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3399 local fcount=$((MDSCOUNT * 256))
3404 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3410 test_mkdir $DIR/$tdir
3412 # drop all open locks and close any cached "open" files on the client
3413 cancel_lru_locks mdc
3415 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3416 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3417 local already=${#fid_list[@]}
3418 for (( i = 0; i < $already; i++ )) ; do
3419 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3422 echo -n "opening files: "
3423 ulimit -n $((fcount + 50))
3424 for ((i = 0; i < $fcount; i++)); do
3425 touch $DIR/$tdir/f_$i
3426 local fd=$(free_fd ${fd_list[i]})
3427 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3432 (( $i % 32 == 0 )) && echo -n "."
3436 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3438 # Possible errors in openfiles FID list.
3439 # 1. Missing FIDs. Check 1
3440 # 2. Extra FIDs. Check 1
3441 # 3. Duplicated FID. Check 2
3442 # 4. Invalid FIDs. Check 2
3443 # 5. Valid FID, points to some other file. Check 3
3446 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3447 error "${#fid_list[@]} != $fcount (+$already old) open files"
3449 echo -n "closing files: "
3450 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3451 local close_cmd="exec ${fd_list[fd]}<&-"
3453 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3455 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3456 echo "skip old open file $filename"
3458 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3462 rm --interactive=no $filename
3464 error "Nonexisting fid ${fid_list[fid]} listed."
3465 (( $fd % 32 == 0 )) && echo -n "."
3470 ls_op=$(ls $DIR2/$tdir | wc -l)
3472 error "Some openfiles are missing in lproc output"
3476 run_test 76 "Verify MDT open_files listing"
3480 local dir=$DIR/$tdir
3483 mkdir $dir || error "mkdir $dir failed"
3484 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3487 do_nodes $CLIENTS $myRUNAS \
3488 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3489 error "dd at 0 on client failed (1)"
3491 do_nodes $CLIENTS $myRUNAS \
3493 for ((i = 0; i < $n; i++)); do
3494 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3495 seek=\\\$i count=1 conv=notrunc &
3496 pids_w[\\\$i]=\\\$!;
3499 for ((i = 0; i < $n; i++)); do
3500 wait \\\${pids_w[\\\$i]};
3502 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3506 do_nodes $CLIENTS sync;
3507 cancel_lru_locks osc
3509 do_nodes $CLIENTS $myRUNAS \
3511 for ((i = 0; i < $n; i++)); do
3512 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3513 seek=\\\$i count=1 &
3514 pids_r[\\\$i]=\\\$!;
3517 for ((i = 0; i < $n; i++)); do
3518 wait \\\${pids_r[\\\$i]};
3520 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3524 cancel_lru_locks osc
3526 wait $pid_w || error "dd (write) failed (2)"
3527 wait $pid_r || error "dd (read) failed (3)"
3528 rm -rvf $dir || error "rm -rf $dir failed"
3531 test_77a() { #LU-3266
3534 oss=$(comma_list $(osts_nodes))
3535 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3537 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3538 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3543 run_test 77a "check FIFO NRS policy"
3545 test_77b() { #LU-3266
3548 oss=$(comma_list $(osts_nodes))
3550 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3551 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3552 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3553 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3555 echo "policy: crr-n, crrn_quantum 1"
3558 do_nodes $oss lctl set_param \
3559 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3560 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3562 echo "policy: crr-n, crrn_quantum 64"
3566 do_nodes $oss lctl set_param \
3567 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3568 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3571 run_test 77b "check CRR-N NRS policy"
3576 oss=$(comma_list $(osts_nodes))
3578 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3579 ost.OSS.*.nrs_"$policy"_quantum=1 \
3580 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3581 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3583 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3584 "physical, ${policy}_supported reads"
3587 do_nodes $oss lctl set_param \
3588 ost.OSS.*.nrs_${policy}_supported="writes" \
3589 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3591 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3592 "physical, ${policy}_supported writes"
3595 do_nodes $oss lctl set_param \
3596 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3597 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3598 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3599 "logical, ${policy}_supported reads_and_writes"
3603 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3608 test_77c() { #LU-3266
3610 orr_trr "orr" || rc=$?
3611 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3612 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3615 run_test 77c "check ORR NRS policy"
3617 test_77d() { #LU-3266
3619 orr_trr "trr" || rc=$?
3620 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3621 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3624 run_test 77d "check TRR nrs policy"
3631 do_facet $facet lctl set_param \
3632 ost.OSS.ost_io.nrs_tbf_rule="$*"
3634 error "failed to run operate '$*' on TBF rules"
3637 cleanup_tbf_verify()
3641 echo "cleanup_tbf $DIR/$tdir"
3644 wait_delete_completed
3649 local dir=$DIR/$tdir
3650 local client1=${CLIENT1:-$(hostname)}
3653 local np=$(check_cpt_number ost1)
3654 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3655 echo "cpu_npartitions on ost1 is $np"
3657 mkdir $dir || error "mkdir $dir failed"
3658 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3661 trap cleanup_tbf_verify EXIT
3662 echo "Limited write rate: $1, read rate: $2"
3663 echo "Verify the write rate is under TBF control"
3664 local start=$SECONDS
3665 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3666 bs=1M count=100 oflag=direct 2>&1
3667 local runtime=$((SECONDS - start + 1))
3668 local rate=$(bc <<< "scale=6; 100 / $runtime")
3669 echo "Write runtime is $runtime s, speed is $rate IOPS"
3671 # verify the write rate does not exceed TBF rate limit
3672 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3673 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3675 cancel_lru_locks osc
3677 echo "Verify the read rate is under TBF control"
3679 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3680 bs=1M count=100 iflag=direct 2>&1
3681 runtime=$((SECONDS - start + 1))
3682 rate=$(bc <<< "scale=6; 100 / $runtime")
3683 echo "Read runtime is $runtime s, speed is $rate IOPS"
3685 # verify the read rate does not exceed TBF rate limit
3686 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3687 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3689 cancel_lru_locks osc
3690 cleanup_tbf_verify || error "rm -rf $dir failed"
3696 oss=$(comma_list $(osts_nodes))
3698 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3700 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3701 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3705 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3710 # Only operate rules on ost1 since OSTs might run on the same OSS
3712 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3713 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3714 local client_nids=$(nids_list $address "\\")
3715 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3716 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3720 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3721 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3722 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3726 tbf_rule_operate ost1 "stop\ localhost"
3727 tbf_rule_operate ost1 "stop\ clients"
3728 tbf_rule_operate ost1 "stop\ others"
3731 # Cleanup the TBF policy
3732 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3733 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3737 run_test 77e "check TBF NID nrs policy"
3742 oss=$(comma_list $(osts_nodes))
3744 do_nodes $oss $LCTL set_param \
3745 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3746 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3747 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3749 # Configure jobid_var
3750 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3752 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3753 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3754 if [ $saved_jobid_var != procname_uid ]; then
3755 set_persistent_param_and_check client \
3756 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3761 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3766 # Only operate rules on ost1 since OSTs might run on the same OSS
3768 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3769 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3770 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3771 nrs_write_read "$RUNAS"
3774 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3775 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3776 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3777 nrs_write_read "$RUNAS"
3780 tbf_rule_operate ost1 "stop\ runas"
3781 tbf_rule_operate ost1 "stop\ iozone_runas"
3782 tbf_rule_operate ost1 "stop\ dd_runas"
3783 nrs_write_read "$RUNAS"
3785 # Cleanup the TBF policy
3786 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3787 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3788 nrs_write_read "$RUNAS"
3790 local current_jobid_var=$($LCTL get_param -n jobid_var)
3791 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3792 if [ $saved_jobid_var != $current_jobid_var ]; then
3793 set_persistent_param_and_check client \
3794 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3798 run_test 77f "check TBF JobID nrs policy"
3803 oss=$(comma_list $(osts_nodes))
3805 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3807 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3808 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3810 do_nodes $oss lctl set_param \
3811 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3812 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3816 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3821 # Add a rule that only valid for Jobid TBF. If direct change between
3822 # TBF types is not supported, this operation will fail.
3823 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3825 # Cleanup the TBF policy
3826 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3827 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3830 run_test 77g "Change TBF type directly"
3833 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3834 { skip "Need OST version at least 2.8.55"; return 0; }
3836 local old_policy=$(do_facet ost1 \
3837 lctl get_param ost.OSS.ost_io.nrs_policies)
3840 do_facet ost1 lctl set_param \
3841 ost.OSS.ost_io.nrs_policies="abc"
3842 [ $? -eq 0 ] && error "should return error"
3844 do_facet ost1 lctl set_param \
3845 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3846 [ $? -eq 0 ] && error "should return error"
3848 do_facet ost1 lctl set_param \
3849 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3850 [ $? -eq 0 ] && error "should return error"
3852 do_facet ost1 lctl set_param \
3853 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3854 [ $? -eq 0 ] && error "should return error"
3856 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3857 [ $? -eq 0 ] || error "shouldn't LBUG"
3859 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3863 run_test 77h "Wrong policy name should report error, not LBUG"
3869 local error_message=$3
3871 for rule in $expected; do
3872 rule_number=$((rule_number + 1))
3874 local stop_line=$(($rule_number + 3))
3875 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3877 local output=$(do_facet $facet lctl get_param \
3878 ost.OSS.ost_io.nrs_tbf_rule |
3882 if [ "$output" != "$expected" ]; then
3883 error "$error_message, expected '$expected', got '$output'"
3888 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3889 { skip "Need OST version at least 2.8.55"; return 0; }
3891 for i in $(seq 1 $OSTCOUNT)
3893 do_facet ost"$i" lctl set_param \
3894 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3896 error "failed to set TBF policy"
3899 tbf_rule_check ost1 "default" "error before inserting any rule"
3901 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3902 tbf_rule_check ost1 "before default" \
3903 "error when inserting rule 'before'"
3905 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3906 tbf_rule_check ost1 "before after default" \
3907 "error when inserting rule 'after'"
3909 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3910 tbf_rule_check ost1 "before target after default" \
3911 "error when inserting rule 'target'"
3913 echo "Move before itself"
3914 tbf_rule_operate ost1 "change\ target\ rank=target"
3915 tbf_rule_check ost1 "before target after default" \
3916 "error when moving before itself"
3918 echo "Move to higher rank"
3919 tbf_rule_operate ost1 "change\ target\ rank=before"
3920 tbf_rule_check ost1 "target before after default" \
3921 "error when moving to higher rank"
3923 echo "Move to lower rank"
3924 tbf_rule_operate ost1 "change\ target\ rank=after"
3925 tbf_rule_check ost1 "before target after default" \
3926 "error when moving to lower rank"
3928 echo "Move before default"
3929 tbf_rule_operate ost1 "change\ target\ rank=default"
3930 tbf_rule_check ost1 "before after target default" \
3931 error "error when moving before default"
3933 # Cleanup the TBF policy
3934 do_nodes $(comma_list $(osts_nodes)) \
3935 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3938 run_test 77i "Change rank of TBF rule"
3943 local ost_version=$(lustre_version_code ost1)
3945 [ $ost_version -ge $(version_code 2.9.53) ] ||
3946 { skip "Need OST version at least 2.9.53"; return 0; }
3947 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3952 do_nodes $(comma_list $(osts_nodes)) \
3953 lctl set_param jobid_var=procname_uid \
3954 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3955 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3956 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3957 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3962 do_nodes $(comma_list $(osts_nodes)) \
3963 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3964 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3965 ost.OSS.ost_io.nrs_policies="fifo"
3967 # sleep 3 seconds to wait the tbf policy stop completely,
3968 # or the next test case is possible get -EAGAIN when
3969 # setting the tbf policy
3972 run_test 77j "check TBF-OPCode NRS policy"
3975 local idstr="${1}id"
3976 local policy="${idstr}={$2}"
3977 local rate="rate=$3"
3979 do_nodes $(comma_list $(osts_nodes)) \
3980 lctl set_param jobid_var=procname_uid \
3981 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3982 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3983 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3985 nrs_write_read "runas $4"
3986 tbf_verify $3 $3 "runas $4"
3988 do_nodes $(comma_list $(osts_nodes)) \
3989 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3990 ost.OSS.ost_io.nrs_policies="fifo"
3992 # sleep 3 seconds to wait the tbf policy stop completely,
3993 # or the next test case is possible get -eagain when
3994 # setting the tbf policy
3999 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
4000 skip "Need OST version at least 2.11.50"
4003 test_id "u" "500" "5" "-u 500"
4004 test_id "g" "500" "5" "-u 500 -g 500"
4006 run_test 77ja "check TBF-UID/GID NRS policy"
4014 for rule in $rule_lists; do
4015 do_nodes $(comma_list $(osts_nodes)) \
4016 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4019 do_nodes $(comma_list $(osts_nodes)) \
4020 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4026 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
4027 { skip "Need OST version at least 2.9.53"; return 0; }
4029 do_nodes $(comma_list $(osts_nodes)) \
4030 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4031 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4032 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4034 nrs_write_read "$RUNAS"
4035 tbf_verify 20 10 "$RUNAS"
4037 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4038 local client_nids=$(nids_list $address "\\")
4039 do_nodes $(comma_list $(osts_nodes)) \
4040 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4041 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4042 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4043 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4048 do_nodes $(comma_list $(osts_nodes)) \
4049 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4050 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4051 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4053 nrs_write_read "$RUNAS"
4054 tbf_verify 20 20 "$RUNAS"
4056 do_nodes $(comma_list $(osts_nodes)) \
4057 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4058 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4059 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4061 nrs_write_read "$RUNAS"
4062 # with parameter "RUNAS", it will match the latest rule
4063 # "ext_b" first, so the limited write rate is 10.
4064 tbf_verify 10 10 "$RUNAS"
4067 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4069 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
4070 { skip "Need OST version at least 2.10.58"; return 0; }
4072 do_nodes $(comma_list $(osts_nodes)) \
4073 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4074 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4075 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4076 nrs_write_read "runas -u 500 -g 1000"
4077 tbf_verify 5 5 "runas -u 500 -g 1000"
4079 do_nodes $(comma_list $(osts_nodes)) \
4080 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4081 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4082 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4084 nrs_write_read "runas -u 500"
4085 tbf_verify 20 10 "runas -u 500"
4087 do_nodes $(comma_list $(osts_nodes)) \
4088 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4089 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4090 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4091 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4092 nrs_write_read "runas -u 500"
4093 tbf_verify 10 10 "runas -u 500"
4094 tbf_verify 20 10 "runas -u 500"
4095 cleanup_77k "ext_a ext_b" "fifo"
4097 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4100 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
4101 { skip "Need OST version at least 2.10.56"; return 0; }
4103 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4104 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4106 local output=$(do_facet ost1 lctl get_param \
4107 ost.OSS.ost_io.nrs_policies | \
4108 awk '/name: tbf/ {print;exit}' | \
4109 awk -F ': ' '{print $2}')
4111 if [ "$output" != "tbf" ]; then
4112 error "The generic TBF output is '$output', not 'tbf'"
4115 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4117 run_test 77l "check the output of NRS policies for generic TBF"
4120 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
4121 skip "Need OST version at least 2.9.54"
4125 local dir=$DIR/$tdir
4127 mkdir $dir || error "mkdir $dir failed"
4128 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4131 local nodes=$(comma_list $(osts_nodes))
4132 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4133 ost.OSS.ost_io.nrs_delay_min=4 \
4134 ost.OSS.ost_io.nrs_delay_max=4 \
4135 ost.OSS.ost_io.nrs_delay_pct=100
4136 [ $? -ne 0 ] && error "Failed to set delay policy"
4138 local start=$SECONDS
4139 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4140 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4141 oflag=direct conv=fdatasync ||
4142 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4143 error "dd on client failed (1)"; }
4144 local elapsed=$((SECONDS - start))
4146 # NRS delay doesn't do sub-second timing, so a request enqueued at
4147 # 0.9 seconds can be dequeued at 4.0
4148 [ $elapsed -lt 3 ] &&
4149 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4150 error "Single 1M write should take at least 3 seconds"; }
4153 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4154 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4155 oflag=direct conv=fdatasync ||
4156 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4157 error "dd on client failed (2)"; }
4158 elapsed=$((SECONDS - start))
4160 [ $elapsed -lt 30 ] &&
4161 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4162 error "Ten 1M writes should take at least 30 seconds"; }
4164 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4165 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4169 run_test 77m "check NRS Delay slows write RPC processing"
4171 test_77n() { #LU-10802
4172 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
4173 skip "Need OST version at least 2.10.58"
4177 # Configure jobid_var
4178 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4179 if [ $saved_jobid_var != procname_uid ]; then
4180 set_persistent_param_and_check client \
4181 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4184 do_nodes $(comma_list $(osts_nodes)) \
4185 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4186 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4187 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4190 tbf_verify 20 20 "$RUNAS"
4192 do_nodes $(comma_list $(osts_nodes)) \
4193 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4194 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4199 do_nodes $(comma_list $(osts_nodes)) \
4200 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4201 ost.OSS.ost_io.nrs_policies="fifo"
4205 local current_jobid_var=$($LCTL get_param -n jobid_var)
4206 if [ $saved_jobid_var != $current_jobid_var ]; then
4207 set_persistent_param_and_check client \
4208 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4211 run_test 77n "check wildcard support for TBF JobID NRS policy"
4213 test_78() { #LU-6673
4216 oss=$(comma_list $(osts_nodes))
4217 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4218 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4220 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4221 # Valid return codes are:
4222 # 0: Tuning succeeded
4223 # ENODEV: Policy is still stopped
4224 # EAGAIN: Policy is being initialized
4225 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4226 error "Expected set_param to return 0|ENODEV|EAGAIN"
4228 # Cleanup the ORR policy
4229 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4230 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4233 run_test 78 "Enable policy and specify tunings right away"
4236 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4237 test_mkdir $DIR/$tdir
4239 # Prevent interference from layout intent RPCs due to
4240 # asynchronous writeback. These will be tested in 130c below.
4241 do_nodes ${CLIENTS:-$HOSTNAME} sync
4243 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4244 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4246 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4247 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4248 local facet=mds$((mdtidx + 1))
4250 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4251 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4255 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4256 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4261 run_test 79 "xattr: intent error"
4264 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4271 mkdir -p $DIR1/$tdir/dir
4272 createmany -o $DIR1/$tdir/dir/f 10 ||
4273 error "create files under remote dir failed $i"
4275 cp /etc/passwd $DIR1/$tdir/$tfile
4277 #migrate open file should fails
4278 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4280 # give multiop a chance to open
4283 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4284 error "migrate open files should failed with open files"
4288 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4289 error "migrate remote dir error"
4291 echo "Finish migration, then checking.."
4292 for file in $(find $DIR1/$tdir); do
4293 mdt_index=$($LFS getstripe -m $file)
4294 [ $mdt_index == $MDTIDX ] ||
4295 error "$file is not on MDT${MDTIDX}"
4298 diff /etc/passwd $DIR1/$tdir/$tfile ||
4299 error "file different after migration"
4301 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4303 run_test 80a "migrate directory when some children is being opened"
4307 kill -9 $migrate_pid
4311 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4312 local migrate_dir1=$DIR1/$tdir/migrate_dir
4313 local migrate_dir2=$DIR2/$tdir/migrate_dir
4314 local migrate_run=$LUSTRE/tests/migrate.sh
4322 trap cleanup_80b EXIT
4323 #prepare migrate directory
4324 mkdir -p $migrate_dir1
4325 for F in {1,2,3,4,5}; do
4326 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4327 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4330 #migrate the directories among MDTs
4333 mdt_idx=$((RANDOM % MDSCOUNT))
4334 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4336 [ $rc -ne 0 -o $rc -ne 16 ] || break
4341 echo "start migration thread $migrate_pid"
4342 #Access the files at the same time
4343 start_time=$(date +%s)
4344 echo "accessing the migrating directory for 5 minutes..."
4346 ls $migrate_dir2 > /dev/null || {
4347 echo "read dir fails"
4350 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4351 echo "access file1 fails"
4355 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4356 echo "access file2/3 fails"
4360 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4361 echo "access file4 fails"
4365 stat $migrate_dir2/file5 > /dev/null || {
4366 echo "stat file5 fails"
4370 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4371 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4372 echo "touch file failed with $rc1"
4376 if [ -e $migrate_dir2/source_file ]; then
4377 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4378 &>/dev/null || rc1=$?
4379 if [ -e $migrate_dir2/link_file ]; then
4380 rm -rf $migrate_dir2/link_file
4383 mrename $migrate_dir2/source_file \
4384 $migrate_dir2/target_file &>/dev/null || rc1=$?
4385 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4386 echo "rename failed with $rc1"
4390 if [ -e $migrate_dir2/target_file ]; then
4391 rm -rf $migrate_dir2/target_file &>/dev/null ||
4394 rm -rf $migrate_dir2/source_file &>/dev/null ||
4397 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4398 echo "unlink failed with $rc1"
4403 end_time=$(date +%s)
4404 duration=$((end_time - start_time))
4405 if [ $((duration % 10)) -eq 0 ]; then
4406 if [ $show_time -eq 1 ]; then
4407 echo "...$duration seconds"
4414 kill -0 $migrate_pid || {
4415 echo "migration stopped 1"
4419 [ $duration -ge 300 ] && break
4422 #check migration are still there
4423 kill -0 $migrate_pid || error "migration stopped 2"
4426 run_test 80b "Accessing directory during migration"
4429 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4433 mkdir -p $DIR1/$tdir
4435 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4436 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4439 touch d0/0 || error "create 0 failed"
4440 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4441 stat d0/0 && error "stat mv filed succeed"
4442 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4443 stat d0/0 || error "stat failed"
4445 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4447 if [ $t -ne 3 ]; then
4448 ls -ai $DIR1/$tdir/d0
4449 error "expect 3 get $t"
4454 run_test 81a "rename and stat under striped directory"
4457 [ $MDSCOUNT -lt 2 ] &&
4458 skip "We need at least 2 MDTs for this test"
4465 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4466 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4475 for i in $(seq $total); do
4476 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4480 kill -9 $setattr_pid
4482 run_test 81b "rename under striped directory doesn't deadlock"
4485 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4486 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4487 skip "Need MDS version at least 2.13.52"
4489 # source is local, source parent is remote
4490 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4491 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4492 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4493 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4494 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4495 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4496 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4497 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4499 # source is remote, source parent is local
4500 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4501 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4502 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4503 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4504 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4505 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4506 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4507 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4509 # source and source parent are remote
4510 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4511 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4512 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4513 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4514 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4515 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4516 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4517 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4519 # source and source parent are remote, and source is remote object
4520 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4521 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4522 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4523 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4524 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4525 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4526 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4528 run_test 81c "rename revoke LOOKUP lock for remote object"
4531 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4532 { skip "Need MDS version at least 2.6.92"; return 0; }
4534 # Client 1 creates a file.
4535 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4537 # Client 2 opens the file.
4538 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4540 # Client 1 makes the file an orphan.
4541 rm $DIR1/$tfile || error "rm"
4542 # Client 2 sets EA "user.multiop".
4544 wait $pid2 || error "multiop 2"
4545 # Client 1 gets EA "user.multiop". This used to fail because the EA
4546 # cache refill would get "trusted.link" from mdd_xattr_list() but
4547 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4550 wait $pid1 || error "multiop 1"
4552 run_test 82 "fsetxattr and fgetxattr on orphan files"
4555 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4562 $LFS mkdir -i1 -c2 $tdir
4567 echo "start pid $pid1 to create/unlink striped directory"
4569 # Access the directory at the same time
4573 stat $tdir > /dev/null 2>&1
4577 echo "start pid $pid2 to stat striped directory"
4585 run_test 83 "access striped directory while it is being created/unlinked"
4588 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4589 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4593 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4594 error "create $tfile failed"
4595 mtime=$(stat -c%Y $DIR/$tfile)
4596 mtime=$((mtime + 200))
4598 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4599 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4601 touch -c -m $mtime $DIR/$tfile &
4603 # sleep a while to let 'touch' run first
4605 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4608 wait $setattr_pid || true
4610 run_test 84 "0-nlink race in lu_object_find()"
4613 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4618 [ "$SLOW" = "yes" ] && duration=600
4619 # Open/Create under striped directory
4623 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4624 touch $tdir/f{0..3} > /dev/null 2>&1
4628 echo "start pid $pid1 to open/create under striped directory"
4630 # unlink the striped directory at the same time
4634 rm -rf $tdir > /dev/null 2>&1
4638 echo "start pid $pid2 to unlink striped directory"
4647 run_test 90 "open/create and unlink striped directory"
4650 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4655 [ "$SLOW" = "yes" ] && duration=600
4656 # chmod striped directory
4660 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4661 chmod go+w $tdir > /dev/null 2>&1
4665 echo "start pid $pid1 to chmod striped directory"
4667 # unlink the striped directory at the same time
4671 rm -rf $tdir > /dev/null 2>&1
4675 echo "start pid $pid2 to unlink striped directory"
4684 run_test 91 "chmod and unlink striped directory"
4687 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4690 local cmd="exec $fd<$DIR1/$tdir"
4691 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4694 trap "eval $cmd" EXIT
4695 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4696 rmdir ../$tdir || error "rmdir ../$tdir fails"
4698 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4699 $LCTL set_param fail_loc=0x1408
4700 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4701 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4702 error "create remote dir succeeds"
4703 $LCTL set_param fail_loc=0
4707 run_test 92 "create remote directory under orphan directory"
4714 mkdir -p $DIR1/$tfile-1/
4715 mkdir -p $DIR2/$tfile-2/
4716 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4717 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4718 do_facet $SINGLEMDS lctl set_param -n \
4719 'lod.lustre-MDT*/qos_threshold_rr' 100
4720 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4721 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4723 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4726 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4730 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4731 do_facet $SINGLEMDS "lctl set_param -n \
4732 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4734 $GETSTRIPE $DIR1/$tfile-1/file1
4735 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4736 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4737 $GETSTRIPE $DIR2/$tfile-2/file2
4738 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4739 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4740 echo "rc1=$rc1 and rc2=$rc2 "
4741 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4742 error "object allocate on same ost detected"
4744 run_test 93 "alloc_rr should not allocate on same ost"
4747 $LCTL set_param osc.*.idle_timeout=0
4748 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4750 local before=$(date +%s)
4754 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4755 $LCTL set_param fail_val=5 fail_loc=0x80000312
4756 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4760 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4761 $LCTL set_param fail_val=6 fail_loc=0x80000329
4762 $LCTL mark kill $pid
4765 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4768 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4770 evict=$(do_facet client $LCTL get_param \
4771 osc.$FSNAME-OST*-osc-*/state |
4772 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4774 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4775 (do_facet client $LCTL get_param \
4776 osc.$FSNAME-OST*-osc-*/state;
4777 error "eviction happened: $evict before:$before")
4778 $LCTL set_param osc.*.idle_timeout=debug
4780 run_test 94 "signal vs CP callback race"
4784 skip "Reserved for glimpse-ahead" && return
4785 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4786 skip "Need MDS version at least 2.10.55"
4790 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4792 lctl set_param -n mdc.*.stats=clear
4793 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4795 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4796 # first stat from server should return size data and save glimpse
4797 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4798 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4799 # second stat to check size is NOT cached on client without IO lock
4800 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4802 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4803 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4806 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4809 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4810 skip "Need MDS version at least 2.10.55"
4814 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4816 lctl set_param -n mdc.*.stats=clear
4817 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4818 cancel_lru_locks mdc
4819 # first stat data from server should have size
4820 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4821 # second stat to check size is cached on client
4822 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4824 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4825 # both stats should cause no glimpse requests
4826 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4829 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4832 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4833 skip "Need MDS version at least 2.10.55"
4837 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4839 lctl set_param -n mdc.*.stats=clear
4840 lctl set_param -n osc.*.stats=clear
4841 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4843 # check that size is merged from MDT and OST correctly
4844 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4845 error "Wrong size from stat #1"
4847 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4848 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4852 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4855 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4856 skip "Need MDS version at least 2.10.55"
4860 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4863 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4864 lctl set_param -n mdc.*.stats=clear
4865 $TRUNCATE $DIR2/$tdir/dom 4096
4867 # check that reported size is valid after file grows to OST and
4868 # is truncated back to MDT stripe size
4869 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4870 error "Wrong size from stat #1"
4872 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4873 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4877 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4880 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
4881 skip "Need MDS version at least 2.11.50"
4883 local dom=$DIR/$tdir/dom
4884 local dom2=$DIR2/$tdir/dom
4887 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4889 cancel_lru_locks mdc
4890 dd if=/dev/urandom of=$dom bs=12000 count=1
4891 $TRUNCATE $dom2 6000
4892 cancel_lru_locks mdc
4893 lctl set_param -n mdc.*.stats=clear
4894 # expect read-on-open to return all data before write
4895 cat /etc/hosts >> $dom
4896 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4897 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4899 run_test 100e "DoM: read on open and file size"
4902 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4903 skip "Need MDS version at least 2.10.55" && return
4905 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4907 $CHECKSTAT -t file $DIR1/$tfile
4909 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4910 sysctl -wq vm.dirty_writeback_centisecs=0
4912 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4915 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4916 error_noexit "Write fails"
4917 # must discard pages
4918 lctl set_param -n mdc.*.stats=clear
4919 rm $DIR2/$tfile || error "Unlink fails"
4921 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4922 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4924 run_test 101a "Discard DoM data on unlink"
4927 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4928 skip "Need MDS version at least 2.10.55" && return
4930 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4931 touch $DIR1/${tfile}_2
4933 $CHECKSTAT -t file $DIR1/$tfile
4935 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4936 sysctl -wq vm.dirty_writeback_centisecs=0
4938 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4941 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4942 # must discard pages
4943 lctl set_param -n mdc.*.stats=clear
4944 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4946 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4947 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4949 run_test 101b "Discard DoM data on rename"
4952 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4953 skip "Need MDS version at least 2.10.55" && return
4955 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4957 $CHECKSTAT -t file $DIR1/$tfile
4959 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4960 sysctl -wq vm.dirty_writeback_centisecs=0
4962 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4965 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4966 $MULTIOP $DIR1/$tfile O_c &
4969 lctl set_param -n mdc.*.stats=clear
4970 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4971 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4973 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4974 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4976 run_test 101c "Discard DoM data on close-unlink"
4978 # test to verify file handle related system calls
4979 # (name_to_handle_at/open_by_handle_at)
4980 # The new system calls are supported in glibc >= 2.14.
4982 # test to verify we can open by handle an unlinked file from > 1 client
4983 # This test opens the file normally on $DIR1, which is on one mount, and then
4984 # opens it by handle on $DIR2, which is on a different mount.
4986 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
4987 skip "Needs MDS version 2.11.57 or later"
4989 echo "Test file_handle syscalls" > $DIR/$tfile ||
4990 error "write failed"
4991 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4992 error "check_fhandle_syscalls failed"
4995 run_test 102 "Test open by handle of unlinked file"
4997 # Compare file size between first & second mount, ensuring the client correctly
4998 # glimpses even with unused speculative locks - LU-11670
5000 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5001 skip "Lockahead needs OST version at least 2.10.50"
5005 test_mkdir -p $DIR/$tdir
5007 # Force file on to OST0
5008 $LFS setstripe -i 0 $DIR/$tdir
5010 # Do not check multiple locks on glimpse
5011 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5012 $LCTL set_param fail_loc=0x415
5014 # Delay write commit by 2 seconds to guarantee glimpse wins race
5015 # The same fail_loc is used on client & server so it can work in the
5016 # single node sanity setup
5017 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5019 echo "Incorrect size expected (no glimpse fix):"
5020 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5022 if [ $rc -eq 0 ]; then
5023 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5026 # guarantee write commit timeout has expired
5029 # Clear fail_loc on client
5030 $LCTL set_param fail_loc=0
5032 # Delay write commit by 2 seconds to guarantee glimpse wins race
5033 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5034 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5036 # Write commit is still delayed by 2 seconds
5037 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5039 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5041 # guarantee write commit timeout has expired
5044 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5046 run_test 103 "Test size correctness with lockahead"
5052 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5063 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5064 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5065 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5066 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5074 local xtimes=($(get_stat_xtimes))
5075 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5077 echo "STAT a|m|ctime ${xtimes[*]}"
5078 echo "MDT a|m|ctime ${xtimes[*]}"
5079 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5080 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5081 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5082 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5083 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5084 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5088 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5089 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5090 skip "Need MDS version at least 2.12.4"
5093 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5094 local atime_diff=$(do_facet $SINGLEMDS \
5095 lctl get_param -n mdd.*MDT0000*.atime_diff)
5097 do_facet $SINGLEMDS \
5098 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5100 stack_trap "do_facet $SINGLEMDS \
5101 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5103 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5104 check_mdt_xtimes $mdtdev
5107 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5108 check_mdt_xtimes $mdtdev
5110 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5113 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5115 kill -USR1 $pid && wait $pid || error "multiop failure"
5116 check_mdt_xtimes $mdtdev
5121 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5122 # on the client side
5123 xtimes=($(get_stat_xtimes))
5124 $MULTIOP $DIR/$tfile O_c &
5127 kill -USR1 $pid && wait $pid || error "multiop failure"
5128 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5129 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5130 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5131 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5132 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5133 check_mdt_xtimes $mdtdev
5136 # Change ctime via chmod
5137 $MULTIOP $DIR/$tfile o_tc &
5140 kill -USR1 $pid && wait $pid || error "multiop failure"
5141 check_mdt_xtimes $mdtdev
5143 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5145 log "cleanup: ======================================================"
5147 # kill and wait in each test only guarentee script finish, but command in script
5148 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5149 # otherwise umount below will fail
5150 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5155 check_and_cleanup_lustre