8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 # skip tests for PPC until they are fixed
26 if [[ $(uname -m) = ppc64 ]]; then
27 # bug number: LU-11597 LU-11787
28 ALWAYS_EXCEPT+=" 16a 71a"
31 if [ $mds1_FSTYPE = "zfs" ]; then
32 # LU-2829 / LU-2887 - make allowances for ZFS slowness
33 TEST33_NFILES=${TEST33_NFILES:-1000}
37 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
46 check_and_setup_lustre
51 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
53 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
54 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
56 # $RUNAS_ID may get set incorrectly somewhere else
57 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
59 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
63 [ -f $DIR2/$tfile ] || error "Check create"
64 chmod 777 $DIR2/$tfile
65 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
66 error "Check attribute update for 0777"
68 chmod a-x $DIR2/$tfile
69 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
70 error "Check attribute update for 0666"
73 $CHECKSTAT -a $DIR1/$tfile ||
74 error "Check unlink - removes file on other mountpoint"
76 run_test 1 "Check attribute updates on 2 mount points"
82 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
83 error "Either not file type or perms not 0777"
85 run_test 2a "check cached attribute updates on 2 mtpt's ========"
91 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
92 error "Either not file type or perms not 0777"
94 run_test 2b "check cached attribute updates on 2 mtpt's ========"
96 # NEED TO SAVE ROOT DIR MODE
99 $CHECKSTAT -t dir -p 0777 $DIR2 ||
100 error "Either not dir type or perms not 0777"
102 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
106 $CHECKSTAT -t dir -p 0755 $DIR2 ||
107 error "Either not file type or perms not 0775"
109 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
116 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
119 run_test 2e "check chmod on root is propagated to others"
122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
124 local remote_dir=$tdir/remote_dir
127 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
128 error "Create remote directory failed"
130 touch $DIR1/$remote_dir/$tfile ||
131 error "Create file under remote directory failed"
132 chmod 777 $DIR1/$remote_dir/$tfile ||
133 error "Chmod file under remote directory failed"
135 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
136 error "Check attr of file under remote directory failed"
138 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
139 error "Chown file under remote directory failed"
141 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
142 error "Check owner of file under remote directory failed"
144 cd $DIR2/$remote_dir || error "enter remote dir"
145 rm -rf $DIR1/$remote_dir/$tfile ||
146 error "Unlink remote directory failed"
148 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
149 error "unlink file still exists!"
151 cd $DIR2/$tdir || error "exit remote dir"
152 rm -rf $DIR1/$tdir || error "unlink directory failed"
154 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
157 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
159 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
161 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
162 echo "$DIR1/$tfile has $block1 blocks"
163 echo "$DIR2/$tfile has $block2 blocks"
164 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
166 run_test 2g "check blocks update on sync write"
169 local target="this/is/good"
170 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
171 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
172 error "link $DIR2/$tfile not as expected"
174 run_test 3 "symlink on one mtpt, readlink on another ==========="
177 multifstat $DIR1/f4 $DIR2/f4
179 run_test 4 "fstat validation on multiple mount points =========="
183 $TRUNCATE $DIR2/f5 100
184 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
185 error "Either not file type or size not equal to 100 bytes"
188 run_test 5 "create a file on one mount, truncate it on the other"
191 openunlink $DIR1/$tfile $DIR2/$tfile || \
192 error "openunlink $DIR1/$tfile $DIR2/$tfile"
194 run_test 6 "remove of open file on other node =================="
198 opendirunlink $DIR1/$dir $DIR2/$dir || \
199 error "opendirunlink $DIR1/$dir $DIR2/$dir"
201 run_test 7 "remove of open directory on other node ============="
204 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
205 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
207 run_test 8 "remove of open special file on other node =========="
213 for C in a b c d e f g h i j k l; do
214 dir=`eval echo \\$DIR$MTPT`
215 echo -n $C >> $dir/f9
216 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
218 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
219 error "`od -a $DIR1/f9` != abcdefghijkl"
221 run_test 9a "append of file with sub-page size on multiple mounts"
223 #LU-10681 - tiny writes & appending to sparse striped file
225 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
227 $LFS setstripe -c 2 -S 1M $DIR/$tfile
228 echo "foo" >> $DIR/$tfile
229 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
230 error "sparse dd $DIR2/$tfile failed"
231 echo "foo" >> $DIR/$tfile
233 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
234 echo "Data read (expecting 'foo')": $data
235 [ "$data" = "foo" ] || error "append to sparse striped file failed"
237 run_test 9b "append to striped sparse file"
244 for C in a b c d e f g h i j k l; do
245 dir=`eval echo \\$DIR$MTPT`
246 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
247 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
248 OFFSET=`expr $OFFSET + 1`
250 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
251 error "`od -a $DIR1/f10` != abcdefghijkl"
253 run_test 10a "write of file with sub-page size on multiple mounts "
257 yes "R" | head -c 4000 >$TMP/f10b-seed
258 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
260 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
262 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
264 # create a test file locally to compare
265 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
266 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
267 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
268 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
270 run_test 10b "write of file with sub-page size on multiple mounts "
274 multiop_bg_pause $DIR1/d11/f O_c || return 1
276 cp -p /bin/ls $DIR1/d11/f
280 wait $MULTIPID || error "wait for PID $MULTIPID failed"
281 [ $RC -eq 0 ] && error || true
283 run_test 11 "execution of file opened for write should return error ===="
286 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
288 run_test 12 "test lock ordering (link, stat, unlink)"
290 test_13() { # bug 2451 - directory coherency
292 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
294 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
296 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
297 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
298 # need to run it twice
299 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
301 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
302 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
304 run_test 13 "test directory page revocation"
307 test_mkdir $DIR1/$tdir
308 cp -p /bin/ls $DIR1/$tdir/$tfile
309 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
312 $DIR2/$tdir/$tfile && error || true
315 run_test 14aa "execution of file open for write returns -ETXTBSY"
318 test_mkdir $DIR1/$tdir
319 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
320 $DIR1/$tdir/sleep 60 &
322 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
325 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
327 test_14b() { # bug 3192, 7040
328 test_mkdir $DIR1/$tdir
329 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
330 $DIR1/$tdir/sleep 60 &
332 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
333 error "expected truncate error, got success"
335 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
337 run_test 14b "truncate of executing file returns -ETXTBSY ======"
339 test_14c() { # bug 3430, 7040
340 test_mkdir $DIR1/$tdir
341 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
342 $DIR1/$tdir/sleep 60 &
344 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
346 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
348 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
350 test_14d() { # bug 10921
351 test_mkdir $DIR1/$tdir
352 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
353 $DIR1/$tdir/sleep 60 &
356 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
358 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
360 run_test 14d "chmod of executing file is still possible ========"
362 test_15() { # bug 974 - ENOSPC
364 sh oos2.sh $MOUNT1 $MOUNT2
365 wait_delete_completed
366 grant_error=$(dmesg | grep "< tot_grant")
367 [ -z "$grant_error" ] || error "$grant_error"
369 run_test 15 "test out-of-space with multiple writers ==========="
372 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
373 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
374 # pass a 2500 operation dual-mount run within the time limit.
375 if [ "$ost1_FSTYPE" = "zfs" ]; then
376 FSXNUM=$((COUNT / 5))
378 elif [ "$SLOW" = "yes" ]; then
379 FSXNUM=$((COUNT * 5))
387 local file1=$DIR1/$tfile
388 local file2=$DIR2/$tfile
389 local stripe_size=$(do_facet $SINGLEMDS \
390 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
394 # to allocate grant because it may run out due to test_15.
395 $LFS setstripe -c -1 $file1
396 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
397 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
400 $LFS setstripe -c -1 $file1 # b=10919
401 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
405 # O_DIRECT reads and writes must be aligned to the device block size.
406 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
407 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
409 run_test 16a "$FSXNUM iterations of dual-mount fsx"
411 # Consistency check for tiny writes, LU-9409
413 local file1=$DIR1/$tfile
414 local file2=$DIR2/$tfile
415 local stripe_size=($($LFS getstripe -S $DIR))
419 # to allocate grant because it may run out due to test_15.
420 lfs setstripe -c -1 $file1
421 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
422 error "dd failed writing to file=$file1"
423 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
424 error "dd failed writing to file=$file2"
427 lfs setstripe -c -1 $file1 # b=10919
428 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
429 # create a mix of tiny writes & normal writes
430 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
431 $file1 $file2 || error "fsx with tiny write failed."
433 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
436 local file1=$DIR1/$tfile
437 local file2=$DIR2/$tfile
438 local stripe_size=$(do_facet $SINGLEMDS \
439 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
441 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
445 # to allocate grant because it may run out due to test_15.
446 $LFS setstripe -c -1 $file1
447 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
448 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
450 wait_delete_completed
452 local list=$(comma_list $(osts_nodes))
453 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
454 skip "not cache-capable obdfilter"
457 set_osd_param $list '' read_cache_enable 0
458 set_osd_param $list '' writethrough_cache_enable 0
460 $LFS setstripe -c -1 $file1 # b=10919
461 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
465 set_osd_param $list '' read_cache_enable 1
466 set_osd_param $list '' writethrough_cache_enable 1
470 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
473 local file1=$DIR1/$tfile
474 local file2=$DIR2/$tfile
475 local file3=$DIR1/file
476 local tmpfile=$(mktemp)
477 local stripe_size=$(do_facet $SINGLEMDS \
478 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
480 # to allocate grant because it may run out due to test_15.
481 $LFS setstripe -c -1 $file1
482 stack_trap "rm -f $file1 $file2 $file3 $tmpfile"
483 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
484 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
487 $LFS setstripe -c -1 $file1 # b=10919
488 $LCTL set_param ldlm.namespaces.*.lru_size=clear
490 # direct write on one client and direct read from another
491 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
492 dd if=$file2 of=$tmpfile iflag=direct bs=1M
493 diff $file1 $tmpfile || error "file different(1)"
496 # buffer write on one client, but direct read from another
497 dd if=$tmpfile of=$file1 bs=1M count=100
498 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
499 diff $file3 $tmpfile || error "file different(2)"
501 rm -f $file3 $file2 $file1
502 # direct write on one client
503 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
504 # buffer read from another client
505 dd if=$file2 of=$file3 bs=1M count=100
506 diff $file3 $tmpfile || error "file different(3)"
508 run_test 16d "Verify DIO and buffer IO with two clients"
510 test_16e() { # LU-13227
513 (( "$MDS1_VERSION" >= $(version_code 2.13.53) )) ||
514 skip "Need MDS version at least 2.13.53"
516 local file1=$DIR1/$tfile
517 local file2=$DIR2/$tfile
519 # client1 write 10M data
520 dd if=/dev/zero of=$file1 bs=1M count=10
522 cancel_lru_locks osc > /dev/null
523 # use lockahead to generate one PW lock to keep LVB loaded.
524 $LFS ladvise -a lockahead --start 0 --length 1M \
526 # direct write to extend file size on client2
527 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
528 oflag=direct conv=notrunc
529 local filesize=$(stat -c %s $file2)
530 [ "$filesize" -eq 22020096 ] ||
531 error "expected filesize 22020096 got $filesize"
534 run_test 16e "Verify size consistency for O_DIRECT write"
536 test_17() { # bug 3513, 3667
537 remote_ost_nodsh && skip "remote OST with nodsh" && return
539 lfs setstripe $DIR1/$tfile -i 0 -c 1
540 cp $SAMPLE_FILE $DIR1/$tfile
541 cancel_lru_locks osc > /dev/null
542 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
543 do_facet ost1 lctl set_param fail_loc=0x8000030a
544 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
545 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
547 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
549 run_test 17 "resource creation/LVB creation race ==============="
552 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
555 for idx in {a..z}; do
556 local ptr=EXCEPT_ALWAYS_18$idx
557 [ x${!ptr} = xtrue ] || continue
559 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
562 excepts="$excepts -e 7 -e 8 -e 9"
563 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
564 error "mmap_sanity test failed"
567 run_test 18 "mmap sanity check ================================="
569 test_19() { # bug3811
570 local node=$(facet_active_host ost1)
571 local device="$FSNAME-OST*"
573 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
574 device="$FSNAME-MDT*"
576 # check whether obdfilter is cache capable at all
577 get_osd_param $node $device read_cache_enable >/dev/null ||
578 skip "not cache-capable obdfilter"
580 local max=$(get_osd_param $node $device readcache_max_filesize |\
582 set_osd_param $node $device readcache_max_filesize 4096
583 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
584 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
585 cp $TMP/$tfile $DIR1/$tfile
586 for i in `seq 1 20`; do
587 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
588 cancel_lru_locks $OSC > /dev/null
589 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
590 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
592 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
593 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
594 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
595 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
597 set_osd_param $node $device readcache_max_filesize $max
600 run_test 19 "test concurrent uncached read races ==============="
603 test_mkdir $DIR1/$tdir
605 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
606 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
607 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
608 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
610 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
611 [[ $CNT2 == $CNT ]] ||
612 error $((CNT2 - CNT))" page left in cache after lock cancel"
614 run_test 20 "test extra readahead page left in cache ===="
621 test_21() { # Bug 5907
622 test_mkdir $DIR1/$tdir
623 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
625 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
626 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
627 test -d $DIR1/$tdir || error "Mounted directory disappeared"
629 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
632 run_test 21 " Try to remove mountpoint on another dir ===="
634 test_23() { # Bug 5972
635 local at_diff=$(do_facet $SINGLEMDS \
636 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
637 echo "atime should be updated while another read" > $DIR1/$tfile
639 # clear the lock(mode: LCK_PW) gotten from creating operation
640 cancel_lru_locks $OSC
643 sleep $((at_diff + 1))
645 echo "starting reads"
646 multiop_bg_pause $DIR1/$tfile or20_c || return 1
647 # with SOM and opencache enabled, we need to close a file and cancel
648 # open lock to get atime propogated to MDS
649 kill -USR1 $! || return 2
652 time2=$(stat -c "%X" $DIR/$tfile)
653 echo "new atime is $time2"
655 [ $time2 -gt $time1 ] || error "atime was not updated"
656 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
659 run_test 23 " others should see updated atime while another read===="
663 lfs df || error "lfs df failed"
664 lfs df -ih || error "lfs df -ih failed"
665 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
666 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
667 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
668 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
670 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
671 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
672 lctl --device %osc deactivate
673 lfs df -i || error "lfs df -i with deactivated OSC failed"
674 lctl --device %osc activate
675 lfs df || error "lfs df with reactivated OSC failed"
677 run_test 24a "lfs df [-ih] [path] test ========================="
681 fsnum=$(lfs_df | grep -c "summary")
682 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
684 run_test 24b "lfs df should show both filesystems ==============="
687 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
689 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
692 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
693 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
695 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
696 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
697 error "setfacl $DIR2/$tdir #1"
698 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
699 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
700 error "setfacl $DIR2/$tdir #2"
701 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
702 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
703 error "setfacl $DIR2/$tdir #3"
704 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
705 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
706 error "setfacl $DIR2/$tdir #4"
707 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
711 run_test 25a "change ACL on one mountpoint be seen on another ==="
714 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
716 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
718 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
721 $LFS mkdir -i 1 $DIR1/$tdir
722 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
723 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
725 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
726 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
727 error "setfacl $DIR2/$tdir #1"
728 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
729 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
730 error "setfacl $DIR2/$tdir #2"
731 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
732 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
733 error "setfacl $DIR2/$tdir #3"
734 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
735 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
736 error "setfacl $DIR2/$tdir #4"
737 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
741 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
744 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
746 run_test 26a "allow mtime to get older"
751 echo "aaa" >> $DIR1/$tfile
753 chmod a+x $DIR2/$tfile
754 mt1=`stat -c %Y $DIR1/$tfile`
755 mt2=`stat -c %Y $DIR2/$tfile`
757 if [ x"$mt1" != x"$mt2" ]; then
758 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
761 run_test 26b "sync mtime between ost and mds"
764 cancel_lru_locks $OSC
766 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
771 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
776 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
778 lctl set_param -n ldlm.dump_namespaces ""
779 wait $DD1_PID $DD2_PID
780 [ $? -ne 0 ] && lctl dk $TMP/debug || true
782 run_test 27 "align non-overlapping extent locks from request ==="
784 test_28() { # bug 9977
785 ECHO_UUID="ECHO_osc1_UUID"
786 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
788 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
789 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
790 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
794 attach echo_client ECHO_osc1 $ECHO_UUID
798 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
799 $LCTL --device $tECHOID destroy "${tOBJID}:0"
807 # reading of 1st stripe should pass
808 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
809 # reading of 2nd stripe should fail (this stripe was destroyed)
810 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
812 # now, recreating test file
813 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
814 # reading of 1st stripe should pass
815 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
816 # reading of 2nd stripe should pass
817 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
820 run_test 28 "read/write/truncate file with lost stripes"
822 test_30() { #b=11110, LU-2523
823 test_mkdir $DIR1/$tdir
824 cp -f /bin/bash $DIR1/$tdir/bash
825 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
826 $DIR1/$tdir/bash -c 'sleep 2;
827 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
831 run_test 30 "recreate file race"
834 test_mkdir $DIR1/$tdir
835 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
836 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
837 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
838 lctl set_param fail_loc=0x314
839 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
840 awk 'BEGIN { FS="+" } /in/ {print $1}')
841 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
843 run_test 31a "voluntary cancel / blocking ast race=============="
846 remote_ost || { skip "local OST" && return 0; }
847 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
849 # make sure there is no local locks due to destroy
850 wait_mds_ost_sync || error "wait_mds_ost_sync()"
851 wait_delete_completed || error "wait_delete_completed()"
853 test_mkdir $DIR1/$tdir
854 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
855 cp /etc/hosts $DIR/$tdir/$tfile
856 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
857 lctl set_param fail_loc=0x314
858 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
859 do_facet ost1 lctl set_param fail_loc=0x316
861 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
862 lctl set_param fail_loc=0
863 do_facet ost1 lctl set_param fail_loc=0
864 # cleanup: reconnect the client back
867 run_test 31b "voluntary OST cancel / blocking ast race=============="
869 test_32b() { # bug 11270
870 remote_ost_nodsh && skip "remote OST with nodsh" && return
873 local facets=$(get_facets OST)
874 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
876 save_lustre_params client "osc.*.contention_seconds" > $p
877 save_lustre_params $facets \
878 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
879 save_lustre_params $facets \
880 "ldlm.namespaces.filter-*.contended_locks" >> $p
881 save_lustre_params $facets \
882 "ldlm.namespaces.filter-*.contention_seconds" >> $p
883 clear_stats $OSC.*.${OSC}_stats
885 # agressive lockless i/o settings
886 do_nodes $(comma_list $(osts_nodes)) \
887 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
888 ldlm.namespaces.filter-*.contended_locks=0 \
889 ldlm.namespaces.filter-*.contention_seconds=60"
890 lctl set_param -n $OSC.*.contention_seconds=60
892 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
894 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
897 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
898 error "lockless i/o was not triggered"
899 # disable lockless i/o (it is disabled by default)
900 do_nodes $(comma_list $(osts_nodes)) \
901 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
902 ldlm.namespaces.filter-*.contended_locks=32 \
903 ldlm.namespaces.filter-*.contention_seconds=0"
904 # set contention_seconds to 0 at client too, otherwise Lustre still
905 # remembers lock contention
906 lctl set_param -n $OSC.*.contention_seconds=0
907 clear_stats $OSC.*.${OSC}_stats
909 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
911 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
914 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
915 error "lockless i/o works when disabled"
917 restore_lustre_params <$p
920 # Disable test 32b prior to full removal
921 #run_test 32b "lockless i/o"
925 local mdts=$(get_facets MDS)
930 for mds in ${mdts//,/ }; do
932 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
933 xargs readlink -f" ))
934 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
937 stat=$(( stat + val))
942 # commit on sharing tests
944 remote_mds_nodsh && skip "remote MDS with nodsh" && return
946 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
947 [ $CLIENTCOUNT -lt 2 ] &&
948 skip "Need two or more clients, have $CLIENTCOUNT"
950 local nfiles=${TEST33_NFILES:-10000}
951 local param_file=$TMP/$tfile-params
957 save_lustre_params $(get_facets MDS) \
958 "mdt.*.commit_on_sharing" > $param_file
961 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
965 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
967 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
968 echo "=== START createmany old: $jbdold transaction"
969 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")
970 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
971 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
972 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
973 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
974 avgtime=$(( avgtime + elapsed ))
976 eval cos${COS}_jbd=$((avgjbd / 3))
977 eval cos${COS}_time=$((avgtime / 3))
980 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
981 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
982 [ "$cos0_jbd" != 0 ] &&
983 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
984 [ "$cos0_time" != 0 ] &&
985 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
987 restore_lustre_params < $param_file
991 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
993 # commit on sharing tests
995 remote_mds_nodsh && skip "remote MDS with nodsh" && return
997 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
998 [ $CLIENTCOUNT -ge 2 ] ||
999 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1001 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1003 local nfiles=${TEST33_NFILES:-10000}
1004 local param_file=$TMP/$tfile-params
1006 save_lustre_params $(get_facets MDS) \
1007 "mdt.*.commit_on_sharing" > $param_file
1016 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1020 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1021 $DIR1/$tdir-\\\$(hostname)-$i"
1023 jbdold=$(print_jbd_stat)
1024 echo "=== START createmany old: $jbdold transaction"
1025 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1026 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1027 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1029 jbdnew=$(print_jbd_stat)
1030 jbd=$(( jbdnew - jbdold ))
1031 echo "=== END createmany new: $jbdnew transaction : \
1032 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1033 avgjbd=$(( avgjbd + jbd ))
1034 avgtime=$(( avgtime + elapsed ))
1036 eval cos${COS}_jbd=$((avgjbd / 3))
1037 eval cos${COS}_time=$((avgtime / 3))
1040 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1041 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1042 [ "$cos0_jbd" != 0 ] &&
1043 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1044 [ "$cos0_time" != 0 ] &&
1045 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1047 restore_lustre_params < $param_file
1051 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1054 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1055 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1056 skip "DNE CoS not supported"
1060 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1064 mkdir_on_mdt0 $DIR/$tdir
1066 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1067 # do twice in case transaction is committed before unlock, see LU-8200
1069 # remote dir is created on MDT1, which enqueued lock of $tdir on
1071 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1072 mkdir $DIR/$tdir/local.$i
1074 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1075 echo "sync_count $sync_count"
1076 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1079 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1080 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1081 # during sleep remote mkdir should have been committed and canceled
1082 # remote lock spontaneously, which shouldn't trigger sync
1084 mkdir $DIR/$tdir/local.3
1085 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1086 echo "sync_count $sync_count"
1087 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1089 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1091 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1095 local nodes=$(comma_list $(mdts_nodes))
1099 # trigger CoS twice in case transaction commit before unlock
1102 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1104 commit_nr=$(do_nodes $nodes \
1105 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1106 total=$((total + commit_nr));
1111 echo "CoS count $total"
1112 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1117 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1118 skip "DNE CoS not supported"
1120 # remote directory create
1121 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1122 # remote directory unlink
1123 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1124 # striped directory create
1125 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1126 # striped directory setattr
1127 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1128 "chmod 713 $DIR/$tdir"
1129 # striped directory unlink
1130 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1133 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1134 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1135 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1136 touch $DIR/$tdir/d1/tgt" \
1137 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1139 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1140 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1141 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1142 touch $DIR/$tdir/d1/src" \
1143 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1145 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1146 "$LFS migrate -m 1 $DIR/$tdir"
1150 run_test 33d "DNE distributed operation should trigger COS"
1153 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1154 [ $CLIENTCOUNT -ge 2 ] ||
1155 skip "Need two or more clients, have $CLIENTCOUNT"
1156 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1157 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1158 skip "DNE CoS not supported"
1160 local client2=${CLIENT2:-$(hostname)}
1164 local nodes=$(comma_list $(mdts_nodes))
1165 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1167 $LFS mkdir -c 2 $DIR/$tdir
1168 mkdir $DIR/$tdir/subdir
1169 echo abc > $DIR/$tdir/$tfile
1170 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1171 do_node $client2 touch $DIR/$tdir/subdir
1173 local async_commit_count=$(do_nodes $nodes \
1174 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1175 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1179 run_test 33e "DNE local operation shouldn't trigger COS"
1181 # End commit on sharing tests
1183 get_ost_lock_timeouts() {
1184 local nodes=${1:-$(comma_list $(osts_nodes))}
1186 local locks=$(do_nodes $nodes \
1187 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1195 do_nodes $(comma_list $(osts_nodes)) \
1196 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1197 for i in $(seq $OSTCOUNT); do
1198 wait_osc_import_ready client ost$i
1203 remote_ost_nodsh && skip "remote OST with nodsh" && return
1207 trap cleanup_34 EXIT RETURN
1208 for OPER in notimeout timeout ; do
1209 rm $DIR1/$tfile 2>/dev/null
1210 lock_in=$(get_ost_lock_timeouts)
1211 if [ $OPER == "timeout" ] ; then
1212 for j in `seq $OSTCOUNT`; do
1213 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1214 do_facet ost$j lctl set_param fail_loc=0x511
1216 echo lock should expire
1218 for j in `seq $OSTCOUNT`; do
1219 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1220 do_facet ost$j lctl set_param fail_loc=0x512
1222 echo lock should not expire
1224 echo writing on client1
1225 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1227 echo reading on client2
1228 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1229 # wait for a lock timeout
1231 lock_out=$(get_ost_lock_timeouts)
1232 if [ $OPER == "timeout" ] ; then
1233 if [ $lock_in == $lock_out ]; then
1234 error "no lock timeout happened"
1239 if [ $lock_in != $lock_out ]; then
1240 error "lock timeout happened"
1248 run_test 34 "no lock timeout under IO"
1250 test_35() { # bug 17645
1253 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1254 awk '/generation/{print $2}')
1256 generation[count]=$g
1260 test_mkdir $MOUNT1/$tdir
1261 cancel_lru_locks mdc
1263 # Let's initiate -EINTR situation by setting fail_loc and take
1264 # write lock on same file from same client. This will not cause
1265 # bl_ast yet as lock is already in local cache.
1266 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1267 do_facet client "lctl set_param fail_loc=0x80000317"
1268 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1269 let timeout=timeout*3
1271 while test $nr -lt 10; do
1272 log "Race attempt $nr"
1273 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1274 awk '/ldlm_bl_callback/ { print $2 }')
1275 test "x$blk1" = "x" && blk1=0
1276 createmany -o $MOUNT2/$tdir/a 4000 &
1280 # Let's make conflict and bl_ast
1281 ls -la $MOUNT1/$tdir > /dev/null &
1284 log "Wait for $pid1 $pid2 for $timeout sec..."
1286 kill -9 $pid1 $pid2 > /dev/null 2>&1
1288 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1289 awk '/ldlm_bl_callback/ { print $2 }')
1290 test "x$blk2" = "x" && blk2=0
1291 test $blk2 -gt $blk1 && break
1292 rm -fr $MOUNT1/$tdir
1293 cancel_lru_locks mdc
1296 do_facet client "lctl set_param fail_loc=0x0"
1297 df -h $MOUNT1 $MOUNT2
1299 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1300 awk '/generation/{print $2}')
1302 if ! test "$g" -eq "${generation[count]}"; then
1303 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1305 for imp in $list; do
1306 if [ $c = $count ]; then
1311 imp=$(echo "$imp" | awk -F"." '{print $2}')
1312 error "Eviction happened on import $imp"
1317 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1319 test_36() { #bug 16417
1324 test_mkdir $DIR1/$tdir
1325 $LFS setstripe -c -1 $DIR1/$tdir
1328 let SIZE_B=SIZE*1024*1024
1329 sync; sleep 2; sync # wait for delete thread
1330 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1331 wait_destroy_complete || error "wait_destroy_complete failed"
1333 while [ $i -le 10 ]; do
1334 lctl mark "start test - cycle ($i)"
1335 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1336 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1337 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1338 sync # sync data from client cache
1339 sync_all_data # sync data from server cache (delayed allocation)
1341 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1342 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1344 rm -f $DIR1/$tdir/$tfile
1345 kill -USR1 $read_pid
1347 sync; sleep 2; sync # Ensure new statfs
1348 wait_delete_completed
1349 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1350 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1352 # this free space! not used
1353 (( $after_dd <= $after)) ||
1354 error "space leaked after_dd:$after_dd > after:$after"
1358 run_test 36 "handle ESTALE/open-unlink correctly"
1360 test_37() { # bug 18695
1361 test_mkdir $DIR1/$tdir
1362 multiop_bg_pause $DIR1/$tdir D_c || return 1
1364 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1365 createmany -m $DIR2/$tdir/f 10000
1366 # set mtime/atime backward
1367 touch -t 198001010000 $DIR2/$tdir
1368 kill -USR1 $MULTIPID
1369 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1370 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1373 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1375 # this should be set to past
1376 TEST_39_MTIME=`date -d "1 year ago" +%s`
1380 local client1=${CLIENT1:-`hostname`}
1381 local client2=${CLIENT2:-`hostname`}
1383 do_node $client1 "touch $DIR1/$tfile"
1385 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1386 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1387 [ "$mtime1" = $TEST_39_MTIME ] || \
1388 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1390 local d1=`do_node $client1 date +%s`
1391 do_node $client1 'echo hello >> '$DIR1/$tfile
1392 local d2=`do_node $client1 date +%s`
1394 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1395 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1396 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1398 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1400 for (( i=0; i < 2; i++ )) ; do
1401 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1402 [ "$mtime2" = "$mtime3" ] || \
1403 error "mtime ($mtime2) changed (to $mtime3) on rename"
1405 cancel_lru_locks osc
1406 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1409 run_test 39a "test from 11063 =================================="
1412 local client1=${CLIENT1:-`hostname`}
1413 local client2=${CLIENT2:-`hostname`}
1417 local mtime1=`stat -c %Y $DIR1/$tfile`
1418 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1421 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1423 for (( i=0; i < 2; i++ )) ; do
1424 local mtime3=`stat -c %Y $DIR1/$tfile`
1425 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1427 [ "$mtime3" = "$mtime4" ] || \
1428 error "different mtime on clients: $mtime3, $mtime4"
1429 [ "$mtime3" = $TEST_39_MTIME ] || \
1430 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1432 cancel_lru_locks osc
1433 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1436 run_test 39b "11063 problem 1 =================================="
1439 local client1=${CLIENT1:-`hostname`}
1440 local client2=${CLIENT2:-`hostname`}
1442 echo hello > $DIR1/$tfile
1444 local mtime1=`stat -c %Y $DIR1/$tfile`
1445 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1446 [ "$mtime1" = "$mtime2" ] || \
1447 error "create: different mtime on clients: $mtime1, $mtime2"
1450 $TRUNCATE $DIR1/$tfile 1
1452 for (( i=0; i < 2; i++ )) ; do
1453 local mtime3=`stat -c %Y $DIR1/$tfile`
1454 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1456 [ "$mtime3" = "$mtime4" ] || \
1457 error "different mtime on clients: $mtime3, $mtime4"
1458 [ "$mtime3" -gt $mtime2 ] || \
1459 error "truncate did not update mtime: $mtime2, $mtime3"
1461 cancel_lru_locks osc
1462 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1465 run_test 39c "check truncate mtime update ======================"
1467 test_39d() { # LU-7310
1469 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1471 local mtime1=$(stat -c %Y $DIR2/$tfile)
1472 [ "$mtime1" = $TEST_39_MTIME ] ||
1473 error "mtime: $mtime1, should be $TEST_39_MTIME"
1476 # define OBD_FAIL_OSC_NO_GRANT 0x411
1477 $LCTL set_param fail_loc=0x411
1479 local d1=$(date +%s)
1480 echo hello >> $DIR1/$tfile
1481 local d2=$(date +%s)
1483 $LCTL set_param fail_loc=0
1485 cancel_lru_locks $OSC
1487 local mtime2=$(stat -c %Y $DIR2/$tfile)
1488 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1489 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1491 run_test 39d "sync write should update mtime"
1494 # how long 40-47 take with specific delay
1501 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1502 # avoid unexpected delays due to previous tests
1504 cancel_lru_locks mdc
1505 do_nodes $(comma_list $(mdts_nodes)) \
1506 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1507 do_nodes $(comma_list $(mdts_nodes)) \
1508 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1509 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1512 # check that pid exists hence second operation wasn't blocked by first one
1513 # if it is so then there is no conflict, return 0
1514 # else second operation is conflicting with first one, return 1
1515 check_pdo_conflict() {
1518 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1519 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1529 # test 40: check non-blocking operations
1531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 mkdir_on_mdt0 $DIR2/$tdir
1535 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1536 do_nodes $(comma_list $(mdts_nodes)) \
1537 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1538 mkdir $DIR1/$tdir/$tfile &
1540 touch $DIR2/$tdir/$tfile-2
1541 check_pdo_conflict $PID1 || error "create is blocked"
1542 mkdir $DIR2/$tdir/$tfile-3
1543 check_pdo_conflict $PID1 || error "mkdir is blocked"
1544 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1545 check_pdo_conflict $PID1 || error "link is blocked"
1546 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1547 check_pdo_conflict $PID1 || error "rename is blocked"
1548 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1549 check_pdo_conflict $PID1 || error "getattr is blocked"
1550 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1551 rmdir $DIR2/$tdir/$tfile-3
1552 check_pdo_conflict $PID1 || error "unlink is blocked"
1554 # all operations above shouldn't wait the first one
1555 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1556 do_nodes $(comma_list $(mdts_nodes)) \
1557 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1562 run_test 40a "pdirops: create vs others =============="
1565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1567 mkdir_on_mdt0 $DIR2/$tdir
1569 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1570 do_nodes $(comma_list $(mdts_nodes)) \
1571 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1572 touch $DIR1/$tdir/$tfile &
1575 touch $DIR2/$tdir/$tfile-2
1576 check_pdo_conflict $PID1 || error "create is blocked"
1577 mkdir $DIR2/$tdir/$tfile-3
1578 check_pdo_conflict $PID1 || error "mkdir is blocked"
1579 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1580 check_pdo_conflict $PID1 || error "link is blocked"
1581 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1582 check_pdo_conflict $PID1 || error "rename is blocked"
1583 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1584 check_pdo_conflict $PID1 || error "getattr is blocked"
1585 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1586 rmdir $DIR2/$tdir/$tfile-3
1587 check_pdo_conflict $PID1 || error "unlink is blocked"
1588 # all operations above shouldn't wait the first one
1590 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1591 do_nodes $(comma_list $(mdts_nodes)) \
1592 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1597 run_test 40b "pdirops: open|create and others =============="
1600 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1602 mkdir_on_mdt0 $DIR2/$tdir
1604 touch $DIR1/$tdir/$tfile
1605 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1606 do_nodes $(comma_list $(mdts_nodes)) \
1607 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1608 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1611 touch $DIR2/$tdir/$tfile-2
1612 check_pdo_conflict $PID1 || error "create is blocked"
1613 mkdir $DIR2/$tdir/$tfile-3
1614 check_pdo_conflict $PID1 || error "mkdir is blocked"
1615 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1616 check_pdo_conflict $PID1 || error "link is blocked"
1617 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1618 check_pdo_conflict $PID1 || error "rename is blocked"
1619 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1620 check_pdo_conflict $PID1 || error "getattr is blocked"
1621 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1622 rmdir $DIR2/$tdir/$tfile-3
1623 check_pdo_conflict $PID1 || error "unlink is blocked"
1625 # all operations above shouldn't wait the first one
1626 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1627 do_nodes $(comma_list $(mdts_nodes)) \
1628 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1633 run_test 40c "pdirops: link and others =============="
1636 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1638 mkdir_on_mdt0 $DIR2/$tdir
1640 touch $DIR1/$tdir/$tfile
1641 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1642 do_nodes $(comma_list $(mdts_nodes)) \
1643 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1644 rm $DIR1/$tdir/$tfile &
1647 touch $DIR2/$tdir/$tfile-2
1648 check_pdo_conflict $PID1 || error "create is blocked"
1649 mkdir $DIR2/$tdir/$tfile-3
1650 check_pdo_conflict $PID1 || error "mkdir is blocked"
1651 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1652 check_pdo_conflict $PID1 || error "link is blocked"
1653 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1654 check_pdo_conflict $PID1 || error "rename is blocked"
1655 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1656 check_pdo_conflict $PID1 || error "getattr is blocked"
1657 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1658 rmdir $DIR2/$tdir/$tfile-3
1659 check_pdo_conflict $PID1 || error "unlink is blocked"
1661 # all operations above shouldn't wait the first one
1662 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1663 do_nodes $(comma_list $(mdts_nodes)) \
1664 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1668 run_test 40d "pdirops: unlink and others =============="
1671 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1673 mkdir_on_mdt0 $DIR2/$tdir
1675 touch $DIR1/$tdir/$tfile
1676 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1677 do_nodes $(comma_list $(mdts_nodes)) \
1678 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1679 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1682 touch $DIR2/$tdir/$tfile-2
1683 check_pdo_conflict $PID1 || error "create is blocked"
1684 mkdir $DIR2/$tdir/$tfile-3
1685 check_pdo_conflict $PID1 || error "mkdir is blocked"
1686 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1687 check_pdo_conflict $PID1 || error "link is blocked"
1688 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1689 check_pdo_conflict $PID1 || error "getattr is blocked"
1690 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1691 rmdir $DIR2/$tdir/$tfile-3
1692 check_pdo_conflict $PID1 || error "unlink is blocked"
1694 # all operations above shouldn't wait the first one
1695 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1696 do_nodes $(comma_list $(mdts_nodes)) \
1697 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1702 run_test 40e "pdirops: rename and others =============="
1704 # test 41: create blocking operations
1707 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1708 do_nodes $(comma_list $(mdts_nodes)) \
1709 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1710 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1712 mkdir $DIR2/$tfile &
1714 do_nodes $(comma_list $(mdts_nodes)) \
1715 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1716 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1717 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1721 run_test 41a "pdirops: create vs mkdir =============="
1725 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1726 do_nodes $(comma_list $(mdts_nodes)) \
1727 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1728 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1730 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1732 do_nodes $(comma_list $(mdts_nodes)) \
1733 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1734 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1735 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1739 run_test 41b "pdirops: create vs create =============="
1743 touch $DIR1/$tfile-2
1744 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1745 do_nodes $(comma_list $(mdts_nodes)) \
1746 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1747 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1749 link $DIR2/$tfile-2 $DIR2/$tfile &
1751 do_nodes $(comma_list $(mdts_nodes)) \
1752 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1753 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1754 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1758 run_test 41c "pdirops: create vs link =============="
1762 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1763 do_nodes $(comma_list $(mdts_nodes)) \
1764 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1765 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1769 do_nodes $(comma_list $(mdts_nodes)) \
1770 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1771 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1772 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1776 run_test 41d "pdirops: create vs unlink =============="
1780 touch $DIR1/$tfile-2
1781 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1782 do_nodes $(comma_list $(mdts_nodes)) \
1783 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1784 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1786 mv $DIR2/$tfile-2 $DIR2/$tfile &
1788 do_nodes $(comma_list $(mdts_nodes)) \
1789 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1790 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1791 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1795 run_test 41e "pdirops: create and rename (tgt) =============="
1799 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1800 do_nodes $(comma_list $(mdts_nodes)) \
1801 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1802 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1804 mv $DIR2/$tfile $DIR2/$tfile-2 &
1806 do_nodes $(comma_list $(mdts_nodes)) \
1807 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1808 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1809 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1813 run_test 41f "pdirops: create and rename (src) =============="
1817 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1818 do_nodes $(comma_list $(mdts_nodes)) \
1819 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1820 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1822 stat $DIR2/$tfile > /dev/null &
1824 do_nodes $(comma_list $(mdts_nodes)) \
1825 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1826 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1827 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1831 run_test 41g "pdirops: create vs getattr =============="
1835 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1836 do_nodes $(comma_list $(mdts_nodes)) \
1837 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1838 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1840 ls -lia $DIR2/ > /dev/null &
1842 do_nodes $(comma_list $(mdts_nodes)) \
1843 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1844 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1849 run_test 41h "pdirops: create vs readdir =============="
1856 do_nodes $(comma_list $(mdts_nodes)) \
1857 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1859 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1862 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1865 if ! wait $PID1 && ! wait $PID2; then
1866 echo "Both creates failed (1 should fail, 1 should succeed)"
1868 elif wait $PID1 && wait $PID2; then
1869 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1874 do_nodes $(comma_list $(mdts_nodes)) \
1875 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1882 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1883 skip "Need MDS version newer than 2.13.56"
1886 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1887 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1888 for fail_loc in "0x80000169" "0x8000016a"; do
1889 echo "Begin 100 tests with fail_loc=$fail_loc"
1891 for i in {1..100}; do
1893 msg=$(sub_test_41i "$fail_loc") ||
1894 { echo; error "iter=$i : $msg"; }
1899 run_test 41i "reint_open: create vs create"
1902 # test 42: unlink and blocking operations
1905 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1906 do_nodes $(comma_list $(mdts_nodes)) \
1907 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1908 mkdir $DIR1/$tfile &
1910 mkdir $DIR2/$tfile &
1912 do_nodes $(comma_list $(mdts_nodes)) \
1913 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1914 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1915 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1919 run_test 42a "pdirops: mkdir vs mkdir =============="
1923 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1924 do_nodes $(comma_list $(mdts_nodes)) \
1925 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1926 mkdir $DIR1/$tfile &
1928 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1930 do_nodes $(comma_list $(mdts_nodes)) \
1931 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1932 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1933 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1937 run_test 42b "pdirops: mkdir vs create =============="
1941 touch $DIR1/$tfile-2
1942 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1943 do_nodes $(comma_list $(mdts_nodes)) \
1944 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1945 mkdir $DIR1/$tfile &
1947 link $DIR2/$tfile-2 $DIR2/$tfile &
1949 do_nodes $(comma_list $(mdts_nodes)) \
1950 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1951 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1952 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1956 run_test 42c "pdirops: mkdir vs link =============="
1960 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1961 do_nodes $(comma_list $(mdts_nodes)) \
1962 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1963 mkdir $DIR1/$tfile &
1965 rmdir $DIR2/$tfile &
1967 do_nodes $(comma_list $(mdts_nodes)) \
1968 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1969 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1970 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1974 run_test 42d "pdirops: mkdir vs unlink =============="
1978 touch $DIR1/$tfile-2
1979 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1980 do_nodes $(comma_list $(mdts_nodes)) \
1981 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1982 mkdir $DIR1/$tfile &
1984 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1986 do_nodes $(comma_list $(mdts_nodes)) \
1987 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1988 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1989 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1993 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1997 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1998 do_nodes $(comma_list $(mdts_nodes)) \
1999 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2000 mkdir $DIR1/$tfile &
2002 mv $DIR2/$tfile $DIR2/$tfile-2 &
2004 do_nodes $(comma_list $(mdts_nodes)) \
2005 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2006 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2007 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2011 run_test 42f "pdirops: mkdir and rename (src) =============="
2014 mkdir_on_mdt0 $DIR1/$tdir
2016 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2017 do_nodes $(comma_list $(mdts_nodes)) \
2018 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2019 mkdir $DIR1/$tdir/$tfile &
2021 stat $DIR2/$tdir/$tfile > /dev/null &
2023 do_nodes $(comma_list $(mdts_nodes)) \
2024 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2025 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2026 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2029 run_test 42g "pdirops: mkdir vs getattr =============="
2033 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2034 do_nodes $(comma_list $(mdts_nodes)) \
2035 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2036 mkdir $DIR1/$tfile &
2038 ls -lia $DIR2/ > /dev/null &
2040 do_nodes $(comma_list $(mdts_nodes)) \
2041 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2042 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2047 run_test 42h "pdirops: mkdir vs readdir =============="
2049 # test 43: rmdir,mkdir won't return -EEXIST
2051 for i in {1..1000}; do
2052 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2053 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2057 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2062 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2063 do_nodes $(comma_list $(mdts_nodes)) \
2064 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2067 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2069 do_nodes $(comma_list $(mdts_nodes)) \
2070 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2071 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2072 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2076 run_test 43b "pdirops: unlink vs create =============="
2081 touch $DIR1/$tfile-2
2082 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2083 do_nodes $(comma_list $(mdts_nodes)) \
2084 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2087 link $DIR2/$tfile-2 $DIR2/$tfile &
2089 do_nodes $(comma_list $(mdts_nodes)) \
2090 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2091 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2092 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2096 run_test 43c "pdirops: unlink vs link =============="
2101 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2102 do_nodes $(comma_list $(mdts_nodes)) \
2103 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2108 do_nodes $(comma_list $(mdts_nodes)) \
2109 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2110 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2111 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2115 run_test 43d "pdirops: unlink vs unlink =============="
2120 touch $DIR1/$tfile-2
2121 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2122 do_nodes $(comma_list $(mdts_nodes)) \
2123 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2126 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2128 do_nodes $(comma_list $(mdts_nodes)) \
2129 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2130 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2131 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2135 run_test 43e "pdirops: unlink and rename (tgt) =============="
2140 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2141 do_nodes $(comma_list $(mdts_nodes)) \
2142 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2145 mv $DIR2/$tfile $DIR2/$tfile-2 &
2147 do_nodes $(comma_list $(mdts_nodes)) \
2148 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2149 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2150 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2154 run_test 43f "pdirops: unlink and rename (src) =============="
2159 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2160 do_nodes $(comma_list $(mdts_nodes)) \
2161 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2164 stat $DIR2/$tfile > /dev/null &
2166 do_nodes $(comma_list $(mdts_nodes)) \
2167 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2168 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2169 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2173 run_test 43g "pdirops: unlink vs getattr =============="
2178 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2179 do_nodes $(comma_list $(mdts_nodes)) \
2180 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2183 ls -lia $DIR2/ > /dev/null &
2185 do_nodes $(comma_list $(mdts_nodes)) \
2186 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2187 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2192 run_test 43h "pdirops: unlink vs readdir =============="
2195 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2198 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2199 do_nodes $(comma_list $(mdts_nodes)) \
2200 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2203 $LFS mkdir -i 1 $DIR2/$tfile &
2205 do_nodes $(comma_list $(mdts_nodes)) \
2206 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2207 check_pdo_conflict $PID1 &&
2208 { wait $PID1; error "remote mkdir isn't blocked"; }
2209 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2213 run_test 43i "pdirops: unlink vs remote mkdir"
2216 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2217 skip "Need MDS version newer than 2.13.52"
2219 mkdir_on_mdt0 $DIR1/$tdir
2220 for i in {1..100}; do
2221 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2222 do_nodes $(comma_list $(mdts_nodes)) \
2223 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2226 mkdir $DIR1/$tdir/sub &
2228 mkdir $DIR2/$tdir/sub && ((OK++))
2229 wait $PID1 && ((OK++))
2230 (( OK == 1 )) || error "exactly one mkdir should succeed"
2232 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2236 run_test 43j "racy mkdir return EEXIST =============="
2243 # We test in a separate directory to be able to unblock server thread in
2244 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2245 test_mkdir $DIR2/$tdir
2246 touch $DIR2/$tdir/$tfile
2248 do_nodes $(comma_list $(mdts_nodes)) \
2249 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2250 echo content > $DIR1/$tdir/$tfile & PID1=$!
2252 multiop $DIR2/$tdir/$tfile u & PID2=$!
2256 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2259 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2262 do_nodes $(comma_list $(mdts_nodes)) \
2263 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2270 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2271 skip "Need MDS version newer than 2.13.56"
2274 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2275 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2276 for fail_loc in "0x80000169" "0x8000016a"; do
2277 echo "Begin 100 tests with fail_loc=$fail_loc"
2279 for i in {1..100}; do
2281 msg=$(sub_test_43k "$fail_loc") ||
2282 { echo; error "iter=$i : $msg"; }
2292 run_test 43k "unlink vs create"
2294 # test 44: rename tgt and blocking operations
2297 touch $DIR1/$tfile-2
2298 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2299 do_nodes $(comma_list $(mdts_nodes)) \
2300 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2301 mv $DIR1/$tfile-2 $DIR1/$tfile &
2303 mkdir $DIR2/$tfile &
2305 do_nodes $(comma_list $(mdts_nodes)) \
2306 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2307 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2308 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2313 run_test 44a "pdirops: rename tgt vs mkdir =============="
2317 touch $DIR1/$tfile-2
2318 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2319 do_nodes $(comma_list $(mdts_nodes)) \
2320 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2321 mv $DIR1/$tfile-2 $DIR1/$tfile &
2323 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2325 do_nodes $(comma_list $(mdts_nodes)) \
2326 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2327 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2328 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2332 run_test 44b "pdirops: rename tgt vs create =============="
2336 touch $DIR1/$tfile-2
2337 touch $DIR1/$tfile-3
2338 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2339 do_nodes $(comma_list $(mdts_nodes)) \
2340 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2341 mv $DIR1/$tfile-2 $DIR1/$tfile &
2343 link $DIR2/$tfile-3 $DIR2/$tfile &
2345 do_nodes $(comma_list $(mdts_nodes)) \
2346 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2347 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2348 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2352 run_test 44c "pdirops: rename tgt vs link =============="
2356 touch $DIR1/$tfile-2
2357 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2358 do_nodes $(comma_list $(mdts_nodes)) \
2359 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2360 mv $DIR1/$tfile-2 $DIR1/$tfile &
2364 do_nodes $(comma_list $(mdts_nodes)) \
2365 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2366 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2367 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2371 run_test 44d "pdirops: rename tgt vs unlink =============="
2376 touch $DIR1/$tfile-2
2377 touch $DIR1/$tfile-3
2378 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2379 do_nodes $(comma_list $(mdts_nodes)) \
2380 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2381 mv $DIR1/$tfile-2 $DIR1/$tfile &
2383 mv $DIR2/$tfile-3 $DIR2/$tfile &
2385 do_nodes $(comma_list $(mdts_nodes)) \
2386 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2387 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2388 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2392 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2396 touch $DIR1/$tfile-2
2397 touch $DIR1/$tfile-3
2398 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2399 do_nodes $(comma_list $(mdts_nodes)) \
2400 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2401 mv $DIR1/$tfile-2 $DIR1/$tfile &
2403 mv $DIR2/$tfile $DIR2/$tfile-3 &
2405 do_nodes $(comma_list $(mdts_nodes)) \
2406 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2407 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2408 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2412 run_test 44f "pdirops: rename tgt and rename (src) =============="
2416 touch $DIR1/$tfile-2
2417 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2418 do_nodes $(comma_list $(mdts_nodes)) \
2419 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2420 mv $DIR1/$tfile-2 $DIR1/$tfile &
2422 stat $DIR2/$tfile > /dev/null &
2424 do_nodes $(comma_list $(mdts_nodes)) \
2425 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2426 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2427 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2431 run_test 44g "pdirops: rename tgt vs getattr =============="
2435 touch $DIR1/$tfile-2
2436 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2437 do_nodes $(comma_list $(mdts_nodes)) \
2438 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2439 mv $DIR1/$tfile-2 $DIR1/$tfile &
2441 ls -lia $DIR2/ > /dev/null &
2443 do_nodes $(comma_list $(mdts_nodes)) \
2444 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2445 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2450 run_test 44h "pdirops: rename tgt vs readdir =============="
2452 # test 44: rename tgt and blocking operations
2454 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2456 touch $DIR1/$tfile-2
2457 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2458 do_nodes $(comma_list $(mdts_nodes)) \
2459 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2460 mv $DIR1/$tfile-2 $DIR1/$tfile &
2462 $LFS mkdir -i 1 $DIR2/$tfile &
2464 do_nodes $(comma_list $(mdts_nodes)) \
2465 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2466 check_pdo_conflict $PID1 && { wait $PID1;
2467 error "remote mkdir isn't blocked"; }
2468 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2472 run_test 44i "pdirops: rename tgt vs remote mkdir"
2474 # test 45: rename,mkdir doesn't fail with -EEXIST
2476 for i in {1..1000}; do
2477 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2478 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2479 error "mrename to $tdir.$i failed"
2484 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2489 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2490 do_nodes $(comma_list $(mdts_nodes)) \
2491 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2492 mv $DIR1/$tfile $DIR1/$tfile-2 &
2494 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2496 do_nodes $(comma_list $(mdts_nodes)) \
2497 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2498 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2499 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2503 run_test 45b "pdirops: rename src vs create =============="
2508 touch $DIR1/$tfile-3
2509 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2510 do_nodes $(comma_list $(mdts_nodes)) \
2511 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2512 mv $DIR1/$tfile $DIR1/$tfile-2 &
2514 link $DIR2/$tfile-3 $DIR2/$tfile &
2516 do_nodes $(comma_list $(mdts_nodes)) \
2517 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2518 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2519 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2523 run_test 45c "pdirops: rename src vs link =============="
2528 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2529 do_nodes $(comma_list $(mdts_nodes)) \
2530 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2531 mv $DIR1/$tfile $DIR1/$tfile-2 &
2535 do_nodes $(comma_list $(mdts_nodes)) \
2536 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2537 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2538 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2542 run_test 45d "pdirops: rename src vs unlink =============="
2547 touch $DIR1/$tfile-3
2548 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2549 do_nodes $(comma_list $(mdts_nodes)) \
2550 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2551 mv $DIR1/$tfile $DIR1/$tfile-2 &
2553 mv $DIR2/$tfile-3 $DIR2/$tfile &
2555 do_nodes $(comma_list $(mdts_nodes)) \
2556 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2557 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2558 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2562 run_test 45e "pdirops: rename src and rename (tgt) =============="
2567 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2568 do_nodes $(comma_list $(mdts_nodes)) \
2569 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2570 mv $DIR1/$tfile $DIR1/$tfile-2 &
2572 mv $DIR2/$tfile $DIR2/$tfile-3 &
2574 do_nodes $(comma_list $(mdts_nodes)) \
2575 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2576 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2577 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2581 run_test 45f "pdirops: rename src and rename (src) =============="
2586 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2587 do_nodes $(comma_list $(mdts_nodes)) \
2588 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2589 mv $DIR1/$tfile $DIR1/$tfile-2 &
2591 stat $DIR2/$tfile > /dev/null &
2593 do_nodes $(comma_list $(mdts_nodes)) \
2594 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2595 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2596 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2600 run_test 45g "pdirops: rename src vs getattr =============="
2605 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2606 do_nodes $(comma_list $(mdts_nodes)) \
2607 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2608 mv $DIR1/$tfile $DIR1/$tfile-2 &
2610 ls -lia $DIR2/ > /dev/null &
2611 do_nodes $(comma_list $(mdts_nodes)) \
2612 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2613 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2618 run_test 45h "pdirops: unlink vs readdir =============="
2621 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2624 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2625 do_nodes $(comma_list $(mdts_nodes)) \
2626 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2627 mv $DIR1/$tfile $DIR1/$tfile-2 &
2629 $LFS mkdir -i 1 $DIR2/$tfile &
2631 do_nodes $(comma_list $(mdts_nodes)) \
2632 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2633 check_pdo_conflict $PID1 && { wait $PID1;
2634 error "create remote dir isn't blocked"; }
2635 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2639 run_test 45i "pdirops: rename src vs remote mkdir"
2646 # We test in a sparate directory to be able to unblock server thread in
2647 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2648 test_mkdir $DIR2/$tdir
2649 echo file1 > $DIR2/$tdir/$tfile
2650 echo file2 > $DIR2/$tdir/$tfile-2
2652 do_nodes $(comma_list $(mdts_nodes)) \
2653 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2655 cat $DIR1/$tdir/$tfile >/dev/null &
2658 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2662 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2665 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2668 do_nodes $(comma_list $(mdts_nodes)) \
2669 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2676 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2677 skip "Need MDS version newer than 2.13.56"
2680 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2681 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2682 for fail_loc in "0x80000169" "0x8000016a"; do
2683 echo "Begin 100 tests with fail_loc=$fail_loc"
2685 for i in {1..100}; do
2687 msg=$(sub_test_45j "$fail_loc") ||
2688 { echo; error "iter=$i : $msg"; }
2693 run_test 45j "read vs rename =============="
2695 # test 46: link and blocking operations
2698 touch $DIR1/$tfile-2
2699 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2700 do_nodes $(comma_list $(mdts_nodes)) \
2701 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2702 link $DIR1/$tfile-2 $DIR1/$tfile &
2704 mkdir $DIR2/$tfile &
2706 do_nodes $(comma_list $(mdts_nodes)) \
2707 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2708 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2709 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2713 run_test 46a "pdirops: link vs mkdir =============="
2717 touch $DIR1/$tfile-2
2718 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2719 do_nodes $(comma_list $(mdts_nodes)) \
2720 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2721 link $DIR1/$tfile-2 $DIR1/$tfile &
2723 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2725 do_nodes $(comma_list $(mdts_nodes)) \
2726 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2727 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2728 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2732 run_test 46b "pdirops: link vs create =============="
2736 touch $DIR1/$tfile-2
2737 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2738 do_nodes $(comma_list $(mdts_nodes)) \
2739 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2740 link $DIR1/$tfile-2 $DIR1/$tfile &
2742 link $DIR2/$tfile $DIR2/$tfile &
2744 do_nodes $(comma_list $(mdts_nodes)) \
2745 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2746 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2747 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2751 run_test 46c "pdirops: link vs link =============="
2755 touch $DIR1/$tfile-2
2756 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2757 do_nodes $(comma_list $(mdts_nodes)) \
2758 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2759 link $DIR1/$tfile-2 $DIR1/$tfile &
2763 do_nodes $(comma_list $(mdts_nodes)) \
2764 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2765 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2766 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2770 run_test 46d "pdirops: link vs unlink =============="
2774 touch $DIR1/$tfile-2
2775 touch $DIR1/$tfile-3
2776 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2777 do_nodes $(comma_list $(mdts_nodes)) \
2778 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2779 link $DIR1/$tfile-2 $DIR1/$tfile &
2781 mv $DIR2/$tfile-3 $DIR2/$tfile &
2783 do_nodes $(comma_list $(mdts_nodes)) \
2784 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2785 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2786 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2790 run_test 46e "pdirops: link and rename (tgt) =============="
2794 touch $DIR1/$tfile-2
2795 touch $DIR1/$tfile-3
2796 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2797 do_nodes $(comma_list $(mdts_nodes)) \
2798 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2799 link $DIR1/$tfile-2 $DIR1/$tfile &
2801 mv $DIR2/$tfile $DIR2/$tfile-3 &
2803 do_nodes $(comma_list $(mdts_nodes)) \
2804 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2805 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2806 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2810 run_test 46f "pdirops: link and rename (src) =============="
2814 touch $DIR1/$tfile-2
2815 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2816 do_nodes $(comma_list $(mdts_nodes)) \
2817 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2818 link $DIR1/$tfile-2 $DIR1/$tfile &
2820 stat $DIR2/$tfile > /dev/null &
2822 do_nodes $(comma_list $(mdts_nodes)) \
2823 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2824 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2825 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2829 run_test 46g "pdirops: link vs getattr =============="
2833 touch $DIR1/$tfile-2
2834 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2835 do_nodes $(comma_list $(mdts_nodes)) \
2836 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2837 link $DIR1/$tfile-2 $DIR1/$tfile &
2839 ls -lia $DIR2/ > /dev/null &
2841 do_nodes $(comma_list $(mdts_nodes)) \
2842 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2843 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2848 run_test 46h "pdirops: link vs readdir =============="
2851 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2853 touch $DIR1/$tfile-2
2854 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2855 do_nodes $(comma_list $(mdts_nodes)) \
2856 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2857 link $DIR1/$tfile-2 $DIR1/$tfile &
2859 $LFS mkdir -i 1 $DIR2/$tfile &
2861 do_nodes $(comma_list $(mdts_nodes)) \
2862 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2863 check_pdo_conflict $PID1 && { wait $PID1;
2864 error "remote mkdir isn't blocked"; }
2865 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2869 run_test 46i "pdirops: link vs remote mkdir"
2871 # test 47: remote mkdir and blocking operations
2873 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2874 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2876 do_nodes $(comma_list $(mdts_nodes)) \
2877 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2878 $LFS mkdir -i 1 $DIR1/$tfile &
2880 mkdir $DIR2/$tfile &
2882 do_nodes $(comma_list $(mdts_nodes)) \
2883 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2884 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2885 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2889 run_test 47a "pdirops: remote mkdir vs mkdir"
2892 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2893 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2895 do_nodes $(comma_list $(mdts_nodes)) \
2896 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2897 $LFS mkdir -i 1 $DIR1/$tfile &
2899 sleep 1 # please do not remove this sleep, see LU-10754
2900 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2902 do_nodes $(comma_list $(mdts_nodes)) \
2903 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2904 check_pdo_conflict $PID1 && { wait $PID1;
2905 error "create isn't blocked"; }
2906 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2910 run_test 47b "pdirops: remote mkdir vs create"
2913 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2915 touch $DIR1/$tfile-2
2916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2917 do_nodes $(comma_list $(mdts_nodes)) \
2918 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2919 $LFS mkdir -i 1 $DIR1/$tfile &
2921 link $DIR2/$tfile-2 $DIR2/$tfile &
2923 do_nodes $(comma_list $(mdts_nodes)) \
2924 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2925 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2926 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2930 run_test 47c "pdirops: remote mkdir vs link"
2933 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2935 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2936 do_nodes $(comma_list $(mdts_nodes)) \
2937 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2938 $LFS mkdir -i 1 $DIR1/$tfile &
2940 rmdir $DIR2/$tfile &
2942 do_nodes $(comma_list $(mdts_nodes)) \
2943 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2944 check_pdo_conflict $PID1 && { wait $PID1;
2945 error "unlink isn't blocked"; }
2946 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2950 run_test 47d "pdirops: remote mkdir vs unlink"
2953 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2955 touch $DIR1/$tfile-2
2956 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2957 do_nodes $(comma_list $(mdts_nodes)) \
2958 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2959 $LFS mkdir -i 1 $DIR1/$tfile &
2961 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2963 do_nodes $(comma_list $(mdts_nodes)) \
2964 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2965 check_pdo_conflict $PID1 && { wait $PID1;
2966 error "rename isn't blocked"; }
2967 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2971 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2974 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2976 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2977 do_nodes $(comma_list $(mdts_nodes)) \
2978 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2979 $LFS mkdir -i 1 $DIR1/$tfile &
2981 mv $DIR2/$tfile $DIR2/$tfile-2 &
2983 do_nodes $(comma_list $(mdts_nodes)) \
2984 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2985 check_pdo_conflict $PID1 && { wait $PID1;
2986 error "rename isn't blocked"; }
2987 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2991 run_test 47f "pdirops: remote mkdir and rename (src)"
2994 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2998 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2999 do_nodes $(comma_list $(mdts_nodes)) \
3000 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3001 $LFS mkdir -i 1 $DIR1/$tfile &
3003 stat $DIR2/$tfile > /dev/null &
3005 do_nodes $(comma_list $(mdts_nodes)) \
3006 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3007 check_pdo_conflict $PID1 && { wait $PID1;
3008 error "getattr isn't blocked"; }
3009 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3013 run_test 47g "pdirops: remote mkdir vs getattr"
3017 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3018 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3019 do_facet client "lctl set_param fail_loc=0x410"
3020 $TRUNCATE $DIR2/$tfile $trunc_size
3021 do_facet client "lctl set_param fail_loc=0x0"
3023 size=`stat -c %s $DIR2/$tfile`
3024 [ $size -eq $trunc_size ] || error "wrong size"
3026 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3030 local origfile=/etc/hosts
3032 filesize=$(stat -c %s $origfile)
3034 # create an empty file
3035 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3036 # cache layout lock on both mount point
3037 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3038 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3040 # open and sleep 2 seconds then read
3041 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3045 # create the layout of testing file
3046 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3047 error "dd $DIR1/$tfile failed"
3049 # MULTIOP proc should be able to read enough bytes and exit
3050 for ((i = 0; i < 6; i++)); do
3052 kill -0 $pid || break
3054 kill -0 $pid 2> /dev/null && error "multiop is still there"
3055 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3059 run_test 51a "layout lock: refresh layout should work"
3062 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
3063 skip "Need MDS version at least 2.3.59"
3065 local tmpfile=`mktemp`
3067 $LFS setstripe -E 1M -c 1 -E -1 --extension-size 64M $DIR1/$tfile ||
3068 error "Create $DIR1/$tfile failed"
3070 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3071 error "dd $DIR1/$tfile failed"
3073 # delay glimpse so that layout has changed when glimpse finish
3074 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3075 $LCTL set_param fail_loc=0x1404 fail_val=4
3076 stat -c %s $DIR2/$tfile |tee $tmpfile &
3080 # extend layout of testing file
3081 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3082 error "dd $DIR1/$tfile failed"
3085 local fsize=$(cat $tmpfile)
3087 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3089 rm -f $DIR1/$tfile $tmpfile
3091 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3094 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3096 # set default layout to have 1 stripe
3098 $LFS setstripe -c 1 $DIR1/$tdir
3100 # create a file with empty layout
3101 $MCREATE $DIR1/$tdir/$tfile ||
3102 error "$MCREATE $DIR1/$tdir/$tfile failed"
3104 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3105 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3107 # change the layout of testing file
3108 echo "Setting layout to have $OSTCOUNT stripes ..."
3109 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3113 # write something to the file, it should be blocked on fetching layout
3114 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3115 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3118 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3119 # count to succeed with only 3/4 of the number of stripes (rounded up),
3120 # so creating striped files does not fail if an OST is offline or full
3121 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3122 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3126 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3129 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3130 cancel_lru_locks mdc
3132 # open should grant LAYOUT lock, mmap and read will install pages
3133 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3137 # rss before revoking
3138 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3139 echo "Before revoking layout lock: $br KB mapped"
3141 # cancel layout lock manually
3142 cancel_lru_locks mdc
3144 # rss after revoking
3145 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3148 wait $PID || error "wait PID $PID failed"
3150 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3152 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3155 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3156 skip "MDS version must be at least 2.13.54.148"
3160 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3164 $LFS getstripe $DIR2/$tfile
3166 wait $pid || error "multiop failed"
3168 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3172 $LFS getstripe $DIR2/$tfile
3174 wait $pid || error "multiop failed"
3176 run_test 51e "lfs getstripe does not break leases, part 2"
3180 echo "==> rename vs getattr vs setxattr should not deadlock"
3181 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3183 do_facet mds1 $LCTL set_param fail_loc=$1
3185 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3193 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3194 wait $PID1 || error "(3) mv failed"
3195 wait $PID2 || error "(4) stat failed"
3202 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3203 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3205 do_facet mds1 $LCTL set_param fail_loc=$1
3207 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3215 $MULTIOP $DIR2/d1/d2 Oc &
3219 stat $DIR/d1 || error "(2) stat failed"
3221 wait $PID1 || error "(3) mv failed"
3222 wait $PID2 || error "(4) stat failed"
3223 wait $PID3 && error "(5) multiop failed"
3229 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3230 save_lustre_params client "llite.*.xattr_cache" > $p
3231 lctl set_param llite.*.xattr_cache 1 ||
3232 { skip "xattr cache is not supported"; return 0; }
3234 #define OBD_FAIL_MDS_RENAME 0x153
3235 #define OBD_FAIL_MDS_RENAME2 0x154
3236 test_54_part1 0x80000153 || error 10
3237 test_54_part1 0x80000154 || error 11
3238 test_54_part2 0x80000153 || error 12
3239 test_54_part2 0x80000154 || error 13
3241 restore_lustre_params < $p
3244 run_test 54 "rename locking"
3247 mkdir_on_mdt0 $DIR/$tdir
3248 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3250 #define OBD_FAIL_MDS_RENAME4 0x156
3251 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3253 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3257 rm -r $DIR2/$tdir/d3
3258 wait $PID1 && error "(2) mv succeeded"
3262 run_test 55a "rename vs unlink target dir"
3266 mkdir_on_mdt0 $DIR/$tdir
3267 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3269 #define OBD_FAIL_MDS_RENAME4 0x156
3270 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3272 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3276 rm -r $DIR2/$tdir/d1
3277 wait $PID1 && error "(2) mv succeeded"
3281 run_test 55b "rename vs unlink source dir"
3285 mkdir_on_mdt0 $DIR/$tdir
3286 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3288 #define OBD_FAIL_MDS_RENAME4 0x156
3289 do_facet mds1 $LCTL set_param fail_loc=0x156
3291 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3295 # while rename is sleeping, open and remove d3
3296 $MULTIOP $DIR2/$tdir/d3 D_c &
3299 rm -rf $DIR2/$tdir/d3
3302 # while rename is sleeping 2nd time, close d3
3304 wait $PID2 || error "(3) multiop failed"
3306 wait $PID1 && error "(2) mv succeeded"
3310 run_test 55c "rename vs unlink orphan target dir"
3314 mkdir_on_mdt0 $DIR/$tdir
3318 #define OBD_FAIL_MDS_RENAME3 0x155
3319 do_facet mds1 $LCTL set_param fail_loc=0x155
3320 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3324 # while rename is sleeping, create $tdir, but as a directory
3325 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3327 # link in reverse locking order
3328 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3330 wait $PID1 && error "(2) mv succeeded"
3333 run_test 55d "rename file vs link"
3336 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3337 skip "MDS version must be >= 2.3.0"
3340 test_mkdir $DIR1/$tdir
3341 file1=$DIR1/$tdir/file
3342 file2=$DIR2/$tdir/file
3344 echo orig > $file2 || error "Could not create $file2"
3345 version=$($LFS data_version $file1)
3348 echo append >> $file2 || error "Could not append to $file2"
3349 version2=$($LFS data_version $file1)
3350 [ "$version" != "$version2" ] ||
3351 error "append did not change data version: $version"
3354 echo overwrite > $file2 || error "Could not overwrite $file2"
3355 version3=$($LFS data_version $file1)
3356 [ "$version2" != "$version3" ] ||
3357 error "overwrite did not change data version: $version2"
3359 # Truncate before EOF
3360 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3361 version4=$($LFS data_version $file1)
3362 [ "$version3" != "$version4" ] ||
3363 error "truncate did not change data version: $version3"
3365 # Truncate after EOF
3366 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3367 version5=$($LFS data_version $file1)
3368 [ "$version4" != "$version5" ] ||
3369 error "truncate did not change data version: $version4"
3371 # Chmod do not change version
3372 chmod 400 $file2 || error "Could not chmod 400 $file2"
3373 version6=$($LFS data_version $file1)
3374 [ "$version5" == "$version6" ] ||
3375 error "chmod should not change data version: $version5 != $version6"
3377 # Chown do not change version
3378 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3379 version7=$($LFS data_version $file1)
3380 [ "$version5" == "$version7" ] ||
3381 error "chown should not change data version: $version5 != $version7"
3383 run_test 60 "Verify data_version behaviour"
3386 local test_dir=$tdir/test_dir
3388 mkdir -p $DIR1/$tdir
3389 if [ $MDSCOUNT -ge 2 ]; then
3391 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3392 error "Create remote directory failed"
3394 mkdir -p $DIR1/$test_dir
3396 cd $DIR2/$test_dir || error "cd directory failed"
3397 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3399 cd $DIR2/$tdir || error "exit directory"
3401 run_test 70a "cd directory && rm directory"
3403 test_70b() { # LU-2781
3405 mkdir -p $DIR1/$tdir
3407 touch $DIR1/$tdir/file
3408 for ((i = 0; i < 32; i++)); do
3409 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3411 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3413 touch $DIR1/$tdir/file
3414 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3415 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3416 rm -rf $DIR1/$tdir/test_dir ||
3417 error "cannot remove directory after rm_entry"
3418 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3420 run_test 70b "remove files after calling rm_entry"
3423 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3424 skip "Need MDS version at least 2.1.6"
3426 # Patch not applied to 2.2 and 2.3 branches
3427 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3428 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3429 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3431 checkfiemap --test ||
3432 skip "checkfiemap not runnable: $?"
3433 # write data this way: hole - data - hole - data
3434 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3435 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3437 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3438 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3439 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3441 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3443 checkfiemap $DIR2/$tfile 81920 ||
3444 error "data is not flushed from client"
3445 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3448 # common case of "create file, copy file" on a single node
3449 # should not flush data from ost
3450 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3451 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3453 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3455 checkfiemap $DIR1/$tfile 81920 ||
3457 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3459 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3461 run_test 71a "correct file map just after write operation is finished"
3464 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3465 skip "Need MDS version at least 2.1.6"
3467 # Patch not applied to 2.2 and 2.3 branches
3468 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3469 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3470 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3471 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3473 checkfiemap --test ||
3474 skip "error $?: checkfiemap failed"
3476 mkdir -p $DIR1/$tdir
3478 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3479 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3480 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3482 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3483 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3485 run_test 71b "check fiemap support for stripecount > 1"
3488 local p="$TMP/sanityN-$TESTNAME.parameters"
3491 save_lustre_params client "llite.*.xattr_cache" > $p
3492 lctl set_param llite.*.xattr_cache 1 ||
3493 { skip "xattr cache is not supported"; return 0; }
3496 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3497 error "setfattr1 failed"
3498 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3499 error "getfattr1 failed"
3500 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3501 error "setfattr2 failed"
3502 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3503 error "getfattr2 failed"
3505 # check that trusted.link is consistent
3506 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3507 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3508 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3509 echo "$tlink1 $tlink2"
3510 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3514 restore_lustre_params < $p
3517 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3520 local p="$TMP/sanityN-$TESTNAME.parameters"
3521 save_lustre_params client "llite.*.xattr_cache" > $p
3522 lctl set_param llite.*.xattr_cache 1 ||
3523 { skip "xattr cache is not supported"; return 0; }
3526 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3527 error "setfattr1 failed"
3528 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3529 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3530 clear_stats llite.*.stats
3531 # PR lock should be cached by now on both clients
3532 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3533 # 2 hits for getfattr(0)+getfattr(size)
3534 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3535 error "not cached in $DIR1"
3536 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3537 # 4 hits for more getfattr(0)+getfattr(size)
3538 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3539 error "not cached in $DIR2"
3542 restore_lustre_params < $p
3545 run_test 73 "getxattr should not cause xattr lock cancellation"
3548 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3549 skip "Need MDS version at least 2.4.93"
3551 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3552 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3553 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3555 run_test 74 "flock deadlock: different mounts =============="
3559 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3560 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3561 cancel_lru_locks osc
3563 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3566 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3567 $LCTL set_param fail_loc=0x31d
3568 stat -c %s $DIR1/$tfile &
3573 # For bad lock error handler we should ASSERT and got kernel panic here
3575 $LCTL set_param fail_loc=0
3577 run_test 75 "osc: upcall after unuse lock==================="
3580 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3581 skip "Need MDS version at least 2.5.53"
3583 remote_mds_nodsh && skip "remote MDS with nodsh"
3584 local fcount=$((MDSCOUNT * 256))
3589 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3595 test_mkdir $DIR/$tdir
3597 # drop all open locks and close any cached "open" files on the client
3598 cancel_lru_locks mdc
3600 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3601 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3602 local already=${#fid_list[@]}
3603 for (( i = 0; i < $already; i++ )) ; do
3604 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3607 echo -n "opening files: "
3608 ulimit -n $((fcount + 50))
3609 for ((i = 0; i < $fcount; i++)); do
3610 touch $DIR/$tdir/f_$i
3611 local fd=$(free_fd ${fd_list[i]})
3612 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3617 (( $i % 32 == 0 )) && echo -n "."
3621 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3623 # Possible errors in openfiles FID list.
3624 # 1. Missing FIDs. Check 1
3625 # 2. Extra FIDs. Check 1
3626 # 3. Duplicated FID. Check 2
3627 # 4. Invalid FIDs. Check 2
3628 # 5. Valid FID, points to some other file. Check 3
3631 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3632 error "${#fid_list[@]} != $fcount (+$already old) open files"
3634 echo -n "closing files: "
3635 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3636 local close_cmd="exec ${fd_list[fd]}<&-"
3638 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3640 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3641 echo "skip old open file $filename"
3643 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3647 rm --interactive=no $filename
3649 error "Nonexisting fid ${fid_list[fid]} listed."
3650 (( $fd % 32 == 0 )) && echo -n "."
3655 ls_op=$(ls $DIR2/$tdir | wc -l)
3657 error "Some openfiles are missing in lproc output"
3661 run_test 76 "Verify MDT open_files listing"
3665 local dir=$DIR/$tdir
3668 mkdir $dir || error "mkdir $dir failed"
3669 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3672 do_nodes $CLIENTS $myRUNAS \
3673 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3674 error "dd at 0 on client failed (1)"
3676 do_nodes $CLIENTS $myRUNAS \
3678 for ((i = 0; i < $n; i++)); do
3679 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3680 seek=\\\$i count=1 conv=notrunc &
3681 pids_w[\\\$i]=\\\$!;
3684 for ((i = 0; i < $n; i++)); do
3685 wait \\\${pids_w[\\\$i]};
3687 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3691 do_nodes $CLIENTS sync;
3692 cancel_lru_locks osc
3694 do_nodes $CLIENTS $myRUNAS \
3696 for ((i = 0; i < $n; i++)); do
3697 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3698 seek=\\\$i count=1 &
3699 pids_r[\\\$i]=\\\$!;
3702 for ((i = 0; i < $n; i++)); do
3703 wait \\\${pids_r[\\\$i]};
3705 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3709 cancel_lru_locks osc
3711 wait $pid_w || error "dd (write) failed (2)"
3712 wait $pid_r || error "dd (read) failed (3)"
3713 rm -rvf $dir || error "rm -rf $dir failed"
3716 test_77a() { #LU-3266
3719 oss=$(comma_list $(osts_nodes))
3720 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3722 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3723 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3728 run_test 77a "check FIFO NRS policy"
3730 test_77b() { #LU-3266
3733 oss=$(comma_list $(osts_nodes))
3735 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3736 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3737 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3738 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3740 echo "policy: crr-n, crrn_quantum 1"
3743 do_nodes $oss lctl set_param \
3744 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3745 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3747 echo "policy: crr-n, crrn_quantum 64"
3751 do_nodes $oss lctl set_param \
3752 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3753 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3756 run_test 77b "check CRR-N NRS policy"
3761 oss=$(comma_list $(osts_nodes))
3763 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3764 ost.OSS.*.nrs_"$policy"_quantum=1 \
3765 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3766 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3768 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3769 "physical, ${policy}_supported reads"
3772 do_nodes $oss lctl set_param \
3773 ost.OSS.*.nrs_${policy}_supported="writes" \
3774 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3776 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3777 "physical, ${policy}_supported writes"
3780 do_nodes $oss lctl set_param \
3781 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3782 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3783 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3784 "logical, ${policy}_supported reads_and_writes"
3788 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3793 test_77c() { #LU-3266
3795 orr_trr "orr" || rc=$?
3796 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3797 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3800 run_test 77c "check ORR NRS policy"
3802 test_77d() { #LU-3266
3804 orr_trr "trr" || rc=$?
3805 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3806 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3809 run_test 77d "check TRR nrs policy"
3816 do_facet $facet lctl set_param \
3817 ost.OSS.ost_io.nrs_tbf_rule="$*"
3819 error "failed to run operate '$*' on TBF rules"
3822 cleanup_tbf_verify()
3826 echo "cleanup_tbf $DIR/$tdir"
3829 wait_delete_completed
3834 local dir=$DIR/$tdir
3835 local client1=${CLIENT1:-$(hostname)}
3838 local np=$(check_cpt_number ost1)
3839 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3840 echo "cpu_npartitions on ost1 is $np"
3842 mkdir $dir || error "mkdir $dir failed"
3843 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3846 trap cleanup_tbf_verify EXIT
3847 echo "Limited write rate: $1, read rate: $2"
3848 echo "Verify the write rate is under TBF control"
3849 local start=$SECONDS
3850 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3851 bs=1M count=100 oflag=direct 2>&1
3852 local runtime=$((SECONDS - start + 1))
3853 local rate=$(bc <<< "scale=6; 100 / $runtime")
3854 echo "Write runtime is $runtime s, speed is $rate IOPS"
3856 # verify the write rate does not exceed TBF rate limit
3857 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3858 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3860 cancel_lru_locks osc
3862 echo "Verify the read rate is under TBF control"
3864 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3865 bs=1M count=100 iflag=direct 2>&1
3866 runtime=$((SECONDS - start + 1))
3867 rate=$(bc <<< "scale=6; 100 / $runtime")
3868 echo "Read runtime is $runtime s, speed is $rate IOPS"
3870 # verify the read rate does not exceed TBF rate limit
3871 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3872 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3874 cancel_lru_locks osc
3875 cleanup_tbf_verify || error "rm -rf $dir failed"
3881 oss=$(comma_list $(osts_nodes))
3883 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3885 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3886 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3890 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3895 # Only operate rules on ost1 since OSTs might run on the same OSS
3897 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3898 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3899 local client_nids=$(nids_list $address "\\")
3900 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3901 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3905 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3906 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3907 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3911 tbf_rule_operate ost1 "stop\ localhost"
3912 tbf_rule_operate ost1 "stop\ clients"
3913 tbf_rule_operate ost1 "stop\ others"
3916 # Cleanup the TBF policy
3917 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3918 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3922 run_test 77e "check TBF NID nrs policy"
3927 oss=$(comma_list $(osts_nodes))
3929 do_nodes $oss $LCTL set_param \
3930 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3931 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3932 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3934 # Configure jobid_var
3935 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3937 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3938 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3939 if [ $saved_jobid_var != procname_uid ]; then
3940 set_persistent_param_and_check client \
3941 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3946 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3951 # Only operate rules on ost1 since OSTs might run on the same OSS
3953 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3954 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3955 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3956 nrs_write_read "$RUNAS"
3959 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3960 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3961 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3962 nrs_write_read "$RUNAS"
3965 tbf_rule_operate ost1 "stop\ runas"
3966 tbf_rule_operate ost1 "stop\ iozone_runas"
3967 tbf_rule_operate ost1 "stop\ dd_runas"
3968 nrs_write_read "$RUNAS"
3970 # Cleanup the TBF policy
3971 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3972 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3973 nrs_write_read "$RUNAS"
3975 local current_jobid_var=$($LCTL get_param -n jobid_var)
3976 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3977 if [ $saved_jobid_var != $current_jobid_var ]; then
3978 set_persistent_param_and_check client \
3979 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3983 run_test 77f "check TBF JobID nrs policy"
3988 oss=$(comma_list $(osts_nodes))
3990 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3992 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3993 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3995 do_nodes $oss lctl set_param \
3996 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3997 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4001 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4006 # Add a rule that only valid for Jobid TBF. If direct change between
4007 # TBF types is not supported, this operation will fail.
4008 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4010 # Cleanup the TBF policy
4011 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4012 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4015 run_test 77g "Change TBF type directly"
4018 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4019 skip "Need OST version at least 2.8.55"
4021 local old_policy=$(do_facet ost1 \
4022 lctl get_param ost.OSS.ost_io.nrs_policies)
4025 do_facet ost1 lctl set_param \
4026 ost.OSS.ost_io.nrs_policies="abc"
4027 [ $? -eq 0 ] && error "should return error"
4029 do_facet ost1 lctl set_param \
4030 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4031 [ $? -eq 0 ] && error "should return error"
4033 do_facet ost1 lctl set_param \
4034 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4035 [ $? -eq 0 ] && error "should return error"
4037 do_facet ost1 lctl set_param \
4038 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4039 [ $? -eq 0 ] && error "should return error"
4041 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4042 [ $? -eq 0 ] || error "shouldn't LBUG"
4044 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4048 run_test 77h "Wrong policy name should report error, not LBUG"
4054 local error_message=$3
4056 for rule in $expected; do
4057 rule_number=$((rule_number + 1))
4059 local stop_line=$(($rule_number + 3))
4060 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4062 local output=$(do_facet $facet lctl get_param \
4063 ost.OSS.ost_io.nrs_tbf_rule |
4067 if [ "$output" != "$expected" ]; then
4068 error "$error_message, expected '$expected', got '$output'"
4073 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4074 skip "Need OST version at least 2.8.55"
4076 for i in $(seq 1 $OSTCOUNT)
4078 do_facet ost"$i" lctl set_param \
4079 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4081 error "failed to set TBF policy"
4084 tbf_rule_check ost1 "default" "error before inserting any rule"
4086 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4087 tbf_rule_check ost1 "before default" \
4088 "error when inserting rule 'before'"
4090 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4091 tbf_rule_check ost1 "before after default" \
4092 "error when inserting rule 'after'"
4094 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4095 tbf_rule_check ost1 "before target after default" \
4096 "error when inserting rule 'target'"
4098 echo "Move before itself"
4099 tbf_rule_operate ost1 "change\ target\ rank=target"
4100 tbf_rule_check ost1 "before target after default" \
4101 "error when moving before itself"
4103 echo "Move to higher rank"
4104 tbf_rule_operate ost1 "change\ target\ rank=before"
4105 tbf_rule_check ost1 "target before after default" \
4106 "error when moving to higher rank"
4108 echo "Move to lower rank"
4109 tbf_rule_operate ost1 "change\ target\ rank=after"
4110 tbf_rule_check ost1 "before target after default" \
4111 "error when moving to lower rank"
4113 echo "Move before default"
4114 tbf_rule_operate ost1 "change\ target\ rank=default"
4115 tbf_rule_check ost1 "before after target default" \
4116 error "error when moving before default"
4118 # Cleanup the TBF policy
4119 do_nodes $(comma_list $(osts_nodes)) \
4120 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4123 run_test 77i "Change rank of TBF rule"
4129 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4130 skip "Need OST version at least 2.9.53"
4131 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4136 do_nodes $(comma_list $(osts_nodes)) \
4137 lctl set_param jobid_var=procname_uid \
4138 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4139 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4140 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4141 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4146 do_nodes $(comma_list $(osts_nodes)) \
4147 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4148 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4149 ost.OSS.ost_io.nrs_policies="fifo"
4151 # sleep 3 seconds to wait the tbf policy stop completely,
4152 # or the next test case is possible get -EAGAIN when
4153 # setting the tbf policy
4156 run_test 77j "check TBF-OPCode NRS policy"
4159 local idstr="${1}id"
4160 local policy="${idstr}={$2}"
4161 local rate="rate=$3"
4163 do_nodes $(comma_list $(osts_nodes)) \
4164 lctl set_param jobid_var=procname_uid \
4165 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4166 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4167 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4169 nrs_write_read "runas $4"
4170 tbf_verify $3 $3 "runas $4"
4172 do_nodes $(comma_list $(osts_nodes)) \
4173 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4174 ost.OSS.ost_io.nrs_policies="fifo"
4176 # sleep 3 seconds to wait the tbf policy stop completely,
4177 # or the next test case is possible get -eagain when
4178 # setting the tbf policy
4183 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4184 skip "Need OST version at least 2.11.50"
4187 test_id "u" "500" "5" "-u 500"
4188 test_id "g" "500" "5" "-u 500 -g 500"
4190 run_test 77ja "check TBF-UID/GID NRS policy"
4198 for rule in $rule_lists; do
4199 do_nodes $(comma_list $(osts_nodes)) \
4200 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4203 do_nodes $(comma_list $(osts_nodes)) \
4204 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4210 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4211 skip "Need OST version at least 2.9.53"
4213 do_nodes $(comma_list $(osts_nodes)) \
4214 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4215 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4216 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4218 nrs_write_read "$RUNAS"
4219 tbf_verify 20 10 "$RUNAS"
4221 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4222 local client_nids=$(nids_list $address "\\")
4223 do_nodes $(comma_list $(osts_nodes)) \
4224 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4225 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4226 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4227 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4232 do_nodes $(comma_list $(osts_nodes)) \
4233 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4234 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4235 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4237 nrs_write_read "$RUNAS"
4238 tbf_verify 20 20 "$RUNAS"
4240 do_nodes $(comma_list $(osts_nodes)) \
4241 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4242 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4243 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4245 nrs_write_read "$RUNAS"
4246 # with parameter "RUNAS", it will match the latest rule
4247 # "ext_b" first, so the limited write rate is 10.
4248 tbf_verify 10 10 "$RUNAS"
4251 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4253 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4254 skip "Need OST version at least 2.10.58"
4256 do_nodes $(comma_list $(osts_nodes)) \
4257 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4258 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4259 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4260 nrs_write_read "runas -u 500 -g 1000"
4261 tbf_verify 5 5 "runas -u 500 -g 1000"
4263 do_nodes $(comma_list $(osts_nodes)) \
4264 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4265 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4266 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4268 nrs_write_read "runas -u 500"
4269 tbf_verify 20 10 "runas -u 500"
4271 do_nodes $(comma_list $(osts_nodes)) \
4272 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4273 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4274 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4275 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4276 nrs_write_read "runas -u 500"
4277 tbf_verify 10 10 "runas -u 500"
4278 tbf_verify 20 10 "runas -u 500"
4279 cleanup_77k "ext_a ext_b" "fifo"
4281 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4284 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4285 skip "Need OST version at least 2.10.56"
4287 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4288 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4290 local output=$(do_facet ost1 lctl get_param \
4291 ost.OSS.ost_io.nrs_policies | \
4292 awk '/name: tbf/ {print;exit}' | \
4293 awk -F ': ' '{print $2}')
4295 if [ "$output" != "tbf" ]; then
4296 error "The generic TBF output is '$output', not 'tbf'"
4299 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4301 run_test 77l "check the output of NRS policies for generic TBF"
4304 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4305 skip "Need OST version at least 2.9.54"
4308 local dir=$DIR/$tdir
4310 mkdir $dir || error "mkdir $dir failed"
4311 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4314 local nodes=$(comma_list $(osts_nodes))
4315 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4316 ost.OSS.ost_io.nrs_delay_min=4 \
4317 ost.OSS.ost_io.nrs_delay_max=4 \
4318 ost.OSS.ost_io.nrs_delay_pct=100
4319 [ $? -ne 0 ] && error "Failed to set delay policy"
4321 local start=$SECONDS
4322 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4323 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4324 oflag=direct conv=fdatasync ||
4325 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4326 error "dd on client failed (1)"; }
4327 local elapsed=$((SECONDS - start))
4329 # NRS delay doesn't do sub-second timing, so a request enqueued at
4330 # 0.9 seconds can be dequeued at 4.0
4331 [ $elapsed -lt 3 ] &&
4332 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4333 error "Single 1M write should take at least 3 seconds"; }
4336 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4337 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4338 oflag=direct conv=fdatasync ||
4339 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4340 error "dd on client failed (2)"; }
4341 elapsed=$((SECONDS - start))
4343 [ $elapsed -lt 30 ] &&
4344 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4345 error "Ten 1M writes should take at least 30 seconds"; }
4347 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4348 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4352 run_test 77m "check NRS Delay slows write RPC processing"
4354 test_77n() { #LU-10802
4355 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4356 skip "Need OST version at least 2.10.58"
4359 # Configure jobid_var
4360 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4361 if [ $saved_jobid_var != procname_uid ]; then
4362 set_persistent_param_and_check client \
4363 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4366 do_nodes $(comma_list $(osts_nodes)) \
4367 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4368 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4369 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4372 tbf_verify 20 20 "$RUNAS"
4374 do_nodes $(comma_list $(osts_nodes)) \
4375 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4376 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4381 do_nodes $(comma_list $(osts_nodes)) \
4382 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4383 ost.OSS.ost_io.nrs_policies="fifo"
4387 local current_jobid_var=$($LCTL get_param -n jobid_var)
4388 if [ $saved_jobid_var != $current_jobid_var ]; then
4389 set_persistent_param_and_check client \
4390 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4393 run_test 77n "check wildcard support for TBF JobID NRS policy"
4395 test_78() { #LU-6673
4398 oss=$(comma_list $(osts_nodes))
4399 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4400 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4402 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4403 # Valid return codes are:
4404 # 0: Tuning succeeded
4405 # ENODEV: Policy is still stopped
4406 # EAGAIN: Policy is being initialized
4407 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4408 error "Expected set_param to return 0|ENODEV|EAGAIN"
4410 # Cleanup the ORR policy
4411 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4412 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4415 run_test 78 "Enable policy and specify tunings right away"
4418 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4419 test_mkdir $DIR/$tdir
4421 # Prevent interference from layout intent RPCs due to
4422 # asynchronous writeback. These will be tested in 130c below.
4423 do_nodes ${CLIENTS:-$HOSTNAME} sync
4425 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4426 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4428 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4429 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4430 local facet=mds$((mdtidx + 1))
4432 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4433 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4437 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4438 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4443 run_test 79 "xattr: intent error"
4446 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4453 mkdir -p $DIR1/$tdir/dir
4454 createmany -o $DIR1/$tdir/dir/f 10 ||
4455 error "create files under remote dir failed $i"
4457 cp /etc/passwd $DIR1/$tdir/$tfile
4459 #migrate open file should fails
4460 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4462 # give multiop a chance to open
4465 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4466 error "migrate open files should failed with open files"
4470 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4471 error "migrate remote dir error"
4473 echo "Finish migration, then checking.."
4474 for file in $(find $DIR1/$tdir); do
4475 mdt_index=$($LFS getstripe -m $file)
4476 [ $mdt_index == $MDTIDX ] ||
4477 error "$file is not on MDT${MDTIDX}"
4480 diff /etc/passwd $DIR1/$tdir/$tfile ||
4481 error "file different after migration"
4483 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4485 run_test 80a "migrate directory when some children is being opened"
4489 kill -9 $migrate_pid
4493 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4494 local migrate_dir1=$DIR1/$tdir/migrate_dir
4495 local migrate_dir2=$DIR2/$tdir/migrate_dir
4496 local migrate_run=$LUSTRE/tests/migrate.sh
4504 trap cleanup_80b EXIT
4505 #prepare migrate directory
4506 mkdir -p $migrate_dir1
4507 for F in {1,2,3,4,5}; do
4508 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4509 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4512 #migrate the directories among MDTs
4515 mdt_idx=$((RANDOM % MDSCOUNT))
4516 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4518 [ $rc -ne 0 -o $rc -ne 16 ] || break
4523 echo "start migration thread $migrate_pid"
4524 #Access the files at the same time
4525 start_time=$(date +%s)
4526 echo "accessing the migrating directory for 5 minutes..."
4528 ls $migrate_dir2 > /dev/null || {
4529 echo "read dir fails"
4532 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4533 echo "access file1 fails"
4537 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4538 echo "access file2/3 fails"
4542 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4543 echo "access file4 fails"
4547 stat $migrate_dir2/file5 > /dev/null || {
4548 echo "stat file5 fails"
4552 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4553 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4554 echo "touch file failed with $rc1"
4558 if [ -e $migrate_dir2/source_file ]; then
4559 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4560 &>/dev/null || rc1=$?
4561 if [ -e $migrate_dir2/link_file ]; then
4562 rm -rf $migrate_dir2/link_file
4565 mrename $migrate_dir2/source_file \
4566 $migrate_dir2/target_file &>/dev/null || rc1=$?
4567 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4568 echo "rename failed with $rc1"
4572 if [ -e $migrate_dir2/target_file ]; then
4573 rm -rf $migrate_dir2/target_file &>/dev/null ||
4576 rm -rf $migrate_dir2/source_file &>/dev/null ||
4579 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4580 echo "unlink failed with $rc1"
4585 end_time=$(date +%s)
4586 duration=$((end_time - start_time))
4587 if [ $((duration % 10)) -eq 0 ]; then
4588 if [ $show_time -eq 1 ]; then
4589 echo "...$duration seconds"
4596 kill -0 $migrate_pid || {
4597 echo "migration stopped 1"
4601 [ $duration -ge 300 ] && break
4604 #check migration are still there
4605 kill -0 $migrate_pid || error "migration stopped 2"
4608 run_test 80b "Accessing directory during migration"
4611 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4615 mkdir -p $DIR1/$tdir
4617 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4618 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4621 touch d0/0 || error "create 0 failed"
4622 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4623 stat d0/0 && error "stat mv filed succeed"
4624 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4625 stat d0/0 || error "stat failed"
4627 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4629 if [ $t -ne 3 ]; then
4630 ls -ai $DIR1/$tdir/d0
4631 error "expect 3 get $t"
4636 run_test 81a "rename and stat under striped directory"
4639 [ $MDSCOUNT -lt 2 ] &&
4640 skip "We need at least 2 MDTs for this test"
4647 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4648 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4657 for i in $(seq $total); do
4658 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4662 kill -9 $setattr_pid
4664 run_test 81b "rename under striped directory doesn't deadlock"
4667 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4668 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4669 skip "Need MDS version at least 2.13.52"
4671 # source is local, source parent is remote
4672 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4673 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4674 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4675 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4676 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4677 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4678 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4679 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4681 # source is remote, source parent is local
4682 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4683 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4684 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4685 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4686 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4687 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4688 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4689 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4691 # source and source parent are remote
4692 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4693 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4694 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4695 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4696 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4697 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4698 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4699 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4701 # source and source parent are remote, and source is remote object
4702 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4703 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4704 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4705 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4706 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4707 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4708 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4710 run_test 81c "rename revoke LOOKUP lock for remote object"
4713 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4714 skip "Need MDS version at least 2.6.92"
4716 # Client 1 creates a file.
4717 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4719 # Client 2 opens the file.
4720 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4722 # Client 1 makes the file an orphan.
4723 rm $DIR1/$tfile || error "rm"
4724 # Client 2 sets EA "user.multiop".
4726 wait $pid2 || error "multiop 2"
4727 # Client 1 gets EA "user.multiop". This used to fail because the EA
4728 # cache refill would get "trusted.link" from mdd_xattr_list() but
4729 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4732 wait $pid1 || error "multiop 1"
4734 run_test 82 "fsetxattr and fgetxattr on orphan files"
4737 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4744 $LFS mkdir -i1 -c2 $tdir
4749 echo "start pid $pid1 to create/unlink striped directory"
4751 # Access the directory at the same time
4755 stat $tdir > /dev/null 2>&1
4759 echo "start pid $pid2 to stat striped directory"
4767 run_test 83 "access striped directory while it is being created/unlinked"
4770 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4771 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4775 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4776 error "create $tfile failed"
4777 mtime=$(stat -c%Y $DIR/$tfile)
4778 mtime=$((mtime + 200))
4780 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4781 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4783 touch -c -m $mtime $DIR/$tfile &
4785 # sleep a while to let 'touch' run first
4787 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4790 wait $setattr_pid || true
4792 run_test 84 "0-nlink race in lu_object_find()"
4795 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4800 [ "$SLOW" = "yes" ] && duration=600
4801 # Open/Create under striped directory
4805 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4806 touch $tdir/f{0..3} > /dev/null 2>&1
4810 echo "start pid $pid1 to open/create under striped directory"
4812 # unlink the striped directory at the same time
4816 rm -rf $tdir > /dev/null 2>&1
4820 echo "start pid $pid2 to unlink striped directory"
4829 run_test 90 "open/create and unlink striped directory"
4832 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4837 [ "$SLOW" = "yes" ] && duration=600
4838 # chmod striped directory
4842 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4843 chmod go+w $tdir > /dev/null 2>&1
4847 echo "start pid $pid1 to chmod striped directory"
4849 # unlink the striped directory at the same time
4853 rm -rf $tdir > /dev/null 2>&1
4857 echo "start pid $pid2 to unlink striped directory"
4866 run_test 91 "chmod and unlink striped directory"
4869 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4872 local cmd="exec $fd<$DIR1/$tdir"
4873 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4876 trap "eval $cmd" EXIT
4877 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4878 rmdir ../$tdir || error "rmdir ../$tdir fails"
4880 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4881 $LCTL set_param fail_loc=0x1408
4882 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4883 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4884 error "create remote dir succeeds"
4885 $LCTL set_param fail_loc=0
4889 run_test 92 "create remote directory under orphan directory"
4896 mkdir -p $DIR1/$tfile-1/
4897 mkdir -p $DIR2/$tfile-2/
4898 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4899 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4900 do_facet $SINGLEMDS "$LCTL set_param -n \
4901 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4902 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4903 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4905 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4908 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4912 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4913 do_facet $SINGLEMDS "$LCTL set_param -n \
4914 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4916 $LFS getstripe $DIR1/$tfile-1/file1
4917 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4918 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4919 $LFS getstripe $DIR2/$tfile-2/file2
4920 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4921 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4922 echo "rc1=$rc1 and rc2=$rc2 "
4923 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4924 error "object allocate on same ost detected"
4926 run_test 93 "alloc_rr should not allocate on same ost"
4929 $LCTL set_param osc.*.idle_timeout=0
4930 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4932 local before=$(date +%s)
4936 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4937 $LCTL set_param fail_val=5 fail_loc=0x80000312
4938 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4942 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4943 $LCTL set_param fail_val=6 fail_loc=0x80000329
4944 $LCTL mark kill $pid
4947 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4950 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4952 evict=$(do_facet client $LCTL get_param \
4953 osc.$FSNAME-OST*-osc-*/state |
4954 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4956 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4957 (do_facet client $LCTL get_param \
4958 osc.$FSNAME-OST*-osc-*/state;
4959 error "eviction happened: $evict before:$before")
4960 $LCTL set_param osc.*.idle_timeout=debug
4962 run_test 94 "signal vs CP callback race"
4966 skip "Reserved for glimpse-ahead" && return
4967 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4968 skip "Need MDS version at least 2.10.55"
4972 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4974 lctl set_param -n mdc.*.stats=clear
4975 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4977 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4978 # first stat from server should return size data and save glimpse
4979 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4980 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4981 # second stat to check size is NOT cached on client without IO lock
4982 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4984 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4985 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4988 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4991 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4992 skip "Need MDS version at least 2.10.55"
4996 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4998 lctl set_param -n mdc.*.stats=clear
4999 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5000 cancel_lru_locks mdc
5001 # first stat data from server should have size
5002 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5003 # second stat to check size is cached on client
5004 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5006 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5007 # both stats should cause no glimpse requests
5008 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5011 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5014 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5015 skip "Need MDS version at least 2.10.55"
5019 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5021 lctl set_param -n mdc.*.stats=clear
5022 lctl set_param -n osc.*.stats=clear
5023 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5025 # check that size is merged from MDT and OST correctly
5026 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5027 error "Wrong size from stat #1"
5029 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5030 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5034 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5037 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5038 skip "Need MDS version at least 2.10.55"
5042 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5045 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5046 lctl set_param -n mdc.*.stats=clear
5047 $TRUNCATE $DIR2/$tdir/dom 4096
5049 # check that reported size is valid after file grows to OST and
5050 # is truncated back to MDT stripe size
5051 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5052 error "Wrong size from stat #1"
5054 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5055 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5059 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5062 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5063 skip "Need MDS version at least 2.11.50"
5065 local dom=$DIR/$tdir/dom
5066 local dom2=$DIR2/$tdir/dom
5069 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5071 cancel_lru_locks mdc
5072 dd if=/dev/urandom of=$dom bs=12000 count=1
5073 $TRUNCATE $dom2 6000
5074 cancel_lru_locks mdc
5075 lctl set_param -n mdc.*.stats=clear
5076 # expect read-on-open to return all data before write
5077 cat /etc/hosts >> $dom
5078 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5079 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5081 run_test 100e "DoM: read on open and file size"
5084 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5085 skip "Need MDS version at least 2.10.55"
5087 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5089 $CHECKSTAT -t file $DIR1/$tfile
5091 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5092 sysctl -wq vm.dirty_writeback_centisecs=0
5094 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5097 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5098 error_noexit "Write fails"
5099 # must discard pages
5100 lctl set_param -n mdc.*.stats=clear
5101 rm $DIR2/$tfile || error "Unlink fails"
5103 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5104 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5106 run_test 101a "Discard DoM data on unlink"
5109 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5110 skip "Need MDS version at least 2.10.55"
5112 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5113 touch $DIR1/${tfile}_2
5115 $CHECKSTAT -t file $DIR1/$tfile
5117 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5118 sysctl -wq vm.dirty_writeback_centisecs=0
5120 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5123 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5124 # must discard pages
5125 lctl set_param -n mdc.*.stats=clear
5126 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5128 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5129 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5131 run_test 101b "Discard DoM data on rename"
5134 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5135 skip "Need MDS version at least 2.10.55"
5137 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5139 $CHECKSTAT -t file $DIR1/$tfile
5141 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5142 sysctl -wq vm.dirty_writeback_centisecs=0
5144 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5147 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5148 $MULTIOP $DIR1/$tfile O_c &
5151 lctl set_param -n mdc.*.stats=clear
5152 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5153 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5155 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5156 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5158 run_test 101c "Discard DoM data on close-unlink"
5160 # test to verify file handle related system calls
5161 # (name_to_handle_at/open_by_handle_at)
5162 # The new system calls are supported in glibc >= 2.14.
5164 # test to verify we can open by handle an unlinked file from > 1 client
5165 # This test opens the file normally on $DIR1, which is on one mount, and then
5166 # opens it by handle on $DIR2, which is on a different mount.
5168 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
5169 skip "Needs MDS version 2.11.57 or later"
5171 echo "Test file_handle syscalls" > $DIR/$tfile ||
5172 error "write failed"
5173 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5174 error "check_fhandle_syscalls $tfile failed"
5176 # test this is working on DNE directories also
5177 if (( MDSCOUNT > 1 MDS1_VERSION >= $(version_code 2.14.52) )); then
5178 $LFS mkdir -i 1 $DIR/$tdir.remote
5179 cancel_lru_locks mdc
5180 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5181 error "check_fhandle_syscalls $tdir.remote failed"
5182 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5183 cancel_lru_locks mdc
5184 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5185 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5187 $LFS mkdir -c -1 $DIR/$tdir.stripe
5188 cancel_lru_locks mdc
5189 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5190 error "check_fhandle_syscalls $tdir.stripe failed"
5191 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5192 cancel_lru_locks mdc
5193 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5194 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5197 run_test 102 "Test open by handle of unlinked file"
5199 # Compare file size between first & second mount, ensuring the client correctly
5200 # glimpses even with unused speculative locks - LU-11670
5202 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5203 skip "Lockahead needs OST version at least 2.10.50"
5207 test_mkdir -p $DIR/$tdir
5209 # Force file on to OST0
5210 $LFS setstripe -i 0 $DIR/$tdir
5212 # Do not check multiple locks on glimpse
5213 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5214 $LCTL set_param fail_loc=0x415
5216 # Delay write commit by 2 seconds to guarantee glimpse wins race
5217 # The same fail_loc is used on client & server so it can work in the
5218 # single node sanity setup
5219 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5221 echo "Incorrect size expected (no glimpse fix):"
5222 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5224 if [ $rc -eq 0 ]; then
5225 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5228 # guarantee write commit timeout has expired
5231 # Clear fail_loc on client
5232 $LCTL set_param fail_loc=0
5234 # Delay write commit by 2 seconds to guarantee glimpse wins race
5235 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5236 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5238 # Write commit is still delayed by 2 seconds
5239 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5241 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5243 # guarantee write commit timeout has expired
5246 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5248 run_test 103 "Test size correctness with lockahead"
5254 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5265 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5266 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5267 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5268 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5276 local xtimes=($(get_stat_xtimes))
5277 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5279 echo "STAT a|m|ctime ${xtimes[*]}"
5280 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5281 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5282 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5283 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5284 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5285 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5286 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5290 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5291 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5292 skip "Need MDS version at least 2.12.4"
5295 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5296 local atime_diff=$(do_facet $SINGLEMDS \
5297 lctl get_param -n mdd.*MDT0000*.atime_diff)
5299 do_facet $SINGLEMDS \
5300 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5302 stack_trap "do_facet $SINGLEMDS \
5303 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5305 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5306 check_mdt_xtimes $mdtdev
5309 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5310 check_mdt_xtimes $mdtdev
5312 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5315 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5317 kill -USR1 $pid && wait $pid || error "multiop failure"
5318 check_mdt_xtimes $mdtdev
5323 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5324 # on the client side
5325 xtimes=($(get_stat_xtimes))
5326 $MULTIOP $DIR/$tfile O_c &
5329 kill -USR1 $pid && wait $pid || error "multiop failure"
5330 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5331 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5332 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5333 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5334 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5335 check_mdt_xtimes $mdtdev
5338 # Change ctime via chmod
5339 $MULTIOP $DIR/$tfile o_tc &
5342 kill -USR1 $pid && wait $pid || error "multiop failure"
5343 check_mdt_xtimes $mdtdev
5345 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5348 test_mkdir -p $DIR/$tdir
5349 echo test > $DIR/$tdir/$tfile
5350 $LCTL set_param fail_loc=0x416
5351 cancel_lru_locks osc & sleep 1
5352 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5354 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5356 run_test 105 "Glimpse and lock cancel race"
5359 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5360 skip_env "Test only for ldiskfs and statx() supported"
5365 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5367 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5368 btime=$($STATX -c %W $DIR/$tfile)
5369 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5371 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5372 [[ $btime == $mdt_btime ]] ||
5373 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5376 run_test 106a "Verify the btime via statx()"
5379 statx_supported || skip_env "statx() only test"
5384 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5385 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5386 cancel_lru_locks $OSC
5387 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5389 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5390 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5391 error "$STATX should send 1 glimpse RPC to $OSC"
5393 cancel_lru_locks $OSC
5394 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5395 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5396 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5398 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5399 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5400 [ $rpcs_after -eq $rpcs_before ] ||
5401 error "$STATX should not send glimpse RPCs to $OSC"
5403 cancel_lru_locks $OSC
5404 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5405 $STATX --cached=always $DIR/$tfile
5406 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5407 [ $rpcs_after -eq $rpcs_before ] ||
5408 error "$STATX should not send glimpse RPCs to $OSC"
5410 cancel_lru_locks $OSC
5411 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5412 $STATX -c %Y $DIR/$tfile
5413 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5414 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5415 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5417 cancel_lru_locks $OSC
5418 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5419 $STATX -c %s $DIR/$tfile
5420 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5421 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5422 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5424 cancel_lru_locks $OSC
5425 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5426 $STATX -c %b $DIR/$tfile
5427 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5428 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5429 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5431 run_test 106b "Glimpse RPCs test for statx"
5434 statx_supported || skip_env "statx() only test"
5439 # Mask supported in stx_attributes by Lustre is
5440 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5441 mask=$($STATX -c %p $DIR/$tfile)
5442 [[ $mask == "30" ]] ||
5443 error "supported stx_attributes: got '$mask', expected '30'"
5444 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5445 mask=$($STATX -c %r $DIR/$tfile)
5446 [[ $mask == "10" ]] ||
5447 error "got immutable flags '$mask', expected '10'"
5448 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5449 mask=$($STATX -c %r $DIR/$tfile)
5450 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5451 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5452 mask=$($STATX -c %r $DIR/$tfile)
5453 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5454 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5455 mask=$($STATX -c %r $DIR/$tfile)
5456 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5457 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5458 mask=$($STATX -c %r $DIR/$tfile)
5459 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5460 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5461 mask=$($STATX -c %r $DIR/$tfile)
5462 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5464 run_test 106c "Verify statx attributes mask"
5466 test_107a() { # LU-1031
5467 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5471 $LFS getstripe $DIR1/$tfile
5473 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5475 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5477 kill -USR1 $MULTIPID2
5479 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5480 error "First grouplock does not block second one"
5482 echo "First grouplock blocks second one"
5484 kill -USR1 $MULTIPID1
5488 run_test 107a "Basic grouplock conflict"
5491 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5495 $LFS getstripe $DIR1/$tfile
5497 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5499 multiop $DIR2/$tfile Or10c &
5503 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5504 error "Grouplock does not block IO"
5506 echo "Grouplock blocks IO"
5509 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5512 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5513 error "First grouplock does not block second one"
5515 echo "First grouplock blocks second one"
5518 kill -USR1 $MULTIPID1
5521 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5522 error "Second grouplock thread disappeared"
5525 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5526 error "Second grouplock does not block IO"
5528 echo "Second grouplock blocks IO"
5531 kill -USR1 $MULTIPID3
5536 run_test 107b "Grouplock is added to the head of waiting list"
5541 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5542 error "Create $DIR1/$tfile failed"
5544 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5545 error "dd $DIR1/$tfile failed"
5546 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5547 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5549 $TRUNCATE $DIR1/$tfile 2000
5550 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5551 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5553 #define OBD_FAIL_OSC_DELAY_IO 0x414
5554 $LCTL set_param fail_val=4 fail_loc=0x80000414
5555 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5559 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5561 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5563 run_test 108a "lseek: parallel updates"
5571 skip "Clients need to be on different nodes than the servers"
5573 umount_client $MOUNT
5574 umount_client $MOUNT2
5576 echo "Starting race between client mount instances (50 iterations):"
5577 for i in {1..50}; do
5580 #define OBD_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
5581 $LCTL set_param -n fail_loc=0x80001417
5583 mount_client $MOUNT & pid1=$!
5584 mount_client $MOUNT2 & pid2=$!
5585 wait $pid1 || error "Mount $MOUNT fails with $?"
5586 wait $pid2 || error "Mount $MOUNT2 fails with $?"
5588 umount_client $MOUNT & pid1=$!
5589 umount_client $MOUNT2 & pid2=$!
5590 wait $pid1 || error "Umount $MOUNT fails with $?"
5591 wait $pid2 || error "Umount $MOUNT2 fails with $?"
5593 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
5599 mount_client $MOUNT2
5602 run_test 109 "Race with several mount instances on 1 node"
5605 local before=$(date +%s)
5612 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
5613 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
5615 # disable last_xid logic by dropping link reply
5616 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
5619 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
5620 do_facet mds1 lctl set_param fail_loc=0x534
5622 # RPC will race with its Resend and the Resend will sleep to let
5623 # the original lock to get granted & cancelled.
5625 # AST_SENT is set artificially, so an explicit conflict is not needed
5627 # The woken up Resend gets a new lock, but client does not wait for it
5630 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
5632 # Take a conflict to wait long enough to see the eviction
5635 # let the client reconnect
5637 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
5638 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
5640 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5641 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
5642 error "eviction happened: $evict before:$before")
5644 run_test 110 "do not grant another lock on resend"
5646 log "cleanup: ======================================================"
5648 # kill and wait in each test only guarentee script finish, but command in script
5649 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5650 # otherwise umount below will fail
5651 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5656 check_and_cleanup_lustre