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 run_test 32b "lockless i/o"
924 local mdts=$(get_facets MDS)
929 for mds in ${mdts//,/ }; do
931 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
932 xargs readlink -f" ))
933 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
936 stat=$(( stat + val))
941 # commit on sharing tests
943 remote_mds_nodsh && skip "remote MDS with nodsh" && return
945 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
946 [ $CLIENTCOUNT -lt 2 ] &&
947 skip "Need two or more clients, have $CLIENTCOUNT"
949 local nfiles=${TEST33_NFILES:-10000}
950 local param_file=$TMP/$tfile-params
956 save_lustre_params $(get_facets MDS) \
957 "mdt.*.commit_on_sharing" > $param_file
960 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
964 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
966 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
967 echo "=== START createmany old: $jbdold transaction"
968 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")
969 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
970 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
971 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
972 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
973 avgtime=$(( avgtime + elapsed ))
975 eval cos${COS}_jbd=$((avgjbd / 3))
976 eval cos${COS}_time=$((avgtime / 3))
979 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
980 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
981 [ "$cos0_jbd" != 0 ] &&
982 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
983 [ "$cos0_time" != 0 ] &&
984 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
986 restore_lustre_params < $param_file
990 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
992 # commit on sharing tests
994 remote_mds_nodsh && skip "remote MDS with nodsh" && return
996 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
997 [ $CLIENTCOUNT -ge 2 ] ||
998 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1000 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1002 local nfiles=${TEST33_NFILES:-10000}
1003 local param_file=$TMP/$tfile-params
1005 save_lustre_params $(get_facets MDS) \
1006 "mdt.*.commit_on_sharing" > $param_file
1015 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1019 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1020 $DIR1/$tdir-\\\$(hostname)-$i"
1022 jbdold=$(print_jbd_stat)
1023 echo "=== START createmany old: $jbdold transaction"
1024 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1025 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1026 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1028 jbdnew=$(print_jbd_stat)
1029 jbd=$(( jbdnew - jbdold ))
1030 echo "=== END createmany new: $jbdnew transaction : \
1031 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1032 avgjbd=$(( avgjbd + jbd ))
1033 avgtime=$(( avgtime + elapsed ))
1035 eval cos${COS}_jbd=$((avgjbd / 3))
1036 eval cos${COS}_time=$((avgtime / 3))
1039 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1040 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1041 [ "$cos0_jbd" != 0 ] &&
1042 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1043 [ "$cos0_time" != 0 ] &&
1044 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1046 restore_lustre_params < $param_file
1050 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1053 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1054 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1055 skip "DNE CoS not supported"
1059 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1063 mkdir_on_mdt0 $DIR/$tdir
1065 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1066 # do twice in case transaction is committed before unlock, see LU-8200
1068 # remote dir is created on MDT1, which enqueued lock of $tdir on
1070 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1071 mkdir $DIR/$tdir/local.$i
1073 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1074 echo "sync_count $sync_count"
1075 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1078 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1079 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1080 # during sleep remote mkdir should have been committed and canceled
1081 # remote lock spontaneously, which shouldn't trigger sync
1083 mkdir $DIR/$tdir/local.3
1084 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1085 echo "sync_count $sync_count"
1086 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1088 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1090 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1094 local nodes=$(comma_list $(mdts_nodes))
1098 # trigger CoS twice in case transaction commit before unlock
1101 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1103 commit_nr=$(do_nodes $nodes \
1104 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1105 total=$((total + commit_nr));
1110 echo "CoS count $total"
1111 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1115 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1116 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1117 skip "DNE CoS not supported"
1119 # remote directory create
1120 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1121 # remote directory unlink
1122 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1123 # striped directory create
1124 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1125 # striped directory setattr
1126 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1127 "chmod 713 $DIR/$tdir"
1128 # striped directory unlink
1129 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1132 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1133 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1134 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1135 touch $DIR/$tdir/d1/tgt" \
1136 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1138 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1139 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1140 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1141 touch $DIR/$tdir/d1/src" \
1142 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1144 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1145 "$LFS migrate -m 1 $DIR/$tdir"
1149 run_test 33d "DNE distributed operation should trigger COS"
1152 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1153 [ $CLIENTCOUNT -ge 2 ] ||
1154 skip "Need two or more clients, have $CLIENTCOUNT"
1155 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1156 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1157 skip "DNE CoS not supported"
1159 local client2=${CLIENT2:-$(hostname)}
1163 local nodes=$(comma_list $(mdts_nodes))
1164 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1166 $LFS mkdir -c 2 $DIR/$tdir
1167 mkdir $DIR/$tdir/subdir
1168 echo abc > $DIR/$tdir/$tfile
1169 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1170 do_node $client2 touch $DIR/$tdir/subdir
1172 local async_commit_count=$(do_nodes $nodes \
1173 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1174 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1178 run_test 33e "DNE local operation shouldn't trigger COS"
1180 # End commit on sharing tests
1182 get_ost_lock_timeouts() {
1183 local nodes=${1:-$(comma_list $(osts_nodes))}
1185 local locks=$(do_nodes $nodes \
1186 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1194 do_nodes $(comma_list $(osts_nodes)) \
1195 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1196 for i in $(seq $OSTCOUNT); do
1197 wait_osc_import_ready client ost$i
1202 remote_ost_nodsh && skip "remote OST with nodsh" && return
1206 trap cleanup_34 EXIT RETURN
1207 for OPER in notimeout timeout ; do
1208 rm $DIR1/$tfile 2>/dev/null
1209 lock_in=$(get_ost_lock_timeouts)
1210 if [ $OPER == "timeout" ] ; then
1211 for j in `seq $OSTCOUNT`; do
1212 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1213 do_facet ost$j lctl set_param fail_loc=0x511
1215 echo lock should expire
1217 for j in `seq $OSTCOUNT`; do
1218 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1219 do_facet ost$j lctl set_param fail_loc=0x512
1221 echo lock should not expire
1223 echo writing on client1
1224 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1226 echo reading on client2
1227 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1228 # wait for a lock timeout
1230 lock_out=$(get_ost_lock_timeouts)
1231 if [ $OPER == "timeout" ] ; then
1232 if [ $lock_in == $lock_out ]; then
1233 error "no lock timeout happened"
1238 if [ $lock_in != $lock_out ]; then
1239 error "lock timeout happened"
1247 run_test 34 "no lock timeout under IO"
1249 test_35() { # bug 17645
1252 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1253 awk '/generation/{print $2}')
1255 generation[count]=$g
1259 test_mkdir $MOUNT1/$tdir
1260 cancel_lru_locks mdc
1262 # Let's initiate -EINTR situation by setting fail_loc and take
1263 # write lock on same file from same client. This will not cause
1264 # bl_ast yet as lock is already in local cache.
1265 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1266 do_facet client "lctl set_param fail_loc=0x80000317"
1267 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1268 let timeout=timeout*3
1270 while test $nr -lt 10; do
1271 log "Race attempt $nr"
1272 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1273 awk '/ldlm_bl_callback/ { print $2 }')
1274 test "x$blk1" = "x" && blk1=0
1275 createmany -o $MOUNT2/$tdir/a 4000 &
1279 # Let's make conflict and bl_ast
1280 ls -la $MOUNT1/$tdir > /dev/null &
1283 log "Wait for $pid1 $pid2 for $timeout sec..."
1285 kill -9 $pid1 $pid2 > /dev/null 2>&1
1287 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1288 awk '/ldlm_bl_callback/ { print $2 }')
1289 test "x$blk2" = "x" && blk2=0
1290 test $blk2 -gt $blk1 && break
1291 rm -fr $MOUNT1/$tdir
1292 cancel_lru_locks mdc
1295 do_facet client "lctl set_param fail_loc=0x0"
1296 df -h $MOUNT1 $MOUNT2
1298 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1299 awk '/generation/{print $2}')
1301 if ! test "$g" -eq "${generation[count]}"; then
1302 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1304 for imp in $list; do
1305 if [ $c = $count ]; then
1310 imp=$(echo "$imp" | awk -F"." '{print $2}')
1311 error "Eviction happened on import $imp"
1316 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1318 test_36() { #bug 16417
1323 test_mkdir $DIR1/$tdir
1324 $LFS setstripe -c -1 $DIR1/$tdir
1327 let SIZE_B=SIZE*1024*1024
1328 sync; sleep 2; sync # wait for delete thread
1329 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1330 wait_destroy_complete || error "wait_destroy_complete failed"
1332 while [ $i -le 10 ]; do
1333 lctl mark "start test - cycle ($i)"
1334 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1335 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1336 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1337 sync # sync data from client cache
1338 sync_all_data # sync data from server cache (delayed allocation)
1340 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1341 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1343 rm -f $DIR1/$tdir/$tfile
1344 kill -USR1 $read_pid
1346 sync; sleep 2; sync # Ensure new statfs
1347 wait_delete_completed
1348 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1349 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1351 # this free space! not used
1352 (( $after_dd <= $after)) ||
1353 error "space leaked after_dd:$after_dd > after:$after"
1357 run_test 36 "handle ESTALE/open-unlink correctly"
1359 test_37() { # bug 18695
1360 test_mkdir $DIR1/$tdir
1361 multiop_bg_pause $DIR1/$tdir D_c || return 1
1363 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1364 createmany -m $DIR2/$tdir/f 10000
1365 # set mtime/atime backward
1366 touch -t 198001010000 $DIR2/$tdir
1367 kill -USR1 $MULTIPID
1368 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1369 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1372 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1374 # this should be set to past
1375 TEST_39_MTIME=`date -d "1 year ago" +%s`
1379 local client1=${CLIENT1:-`hostname`}
1380 local client2=${CLIENT2:-`hostname`}
1382 do_node $client1 "touch $DIR1/$tfile"
1384 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1385 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1386 [ "$mtime1" = $TEST_39_MTIME ] || \
1387 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1389 local d1=`do_node $client1 date +%s`
1390 do_node $client1 'echo hello >> '$DIR1/$tfile
1391 local d2=`do_node $client1 date +%s`
1393 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1394 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1395 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1397 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1399 for (( i=0; i < 2; i++ )) ; do
1400 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1401 [ "$mtime2" = "$mtime3" ] || \
1402 error "mtime ($mtime2) changed (to $mtime3) on rename"
1404 cancel_lru_locks osc
1405 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1408 run_test 39a "test from 11063 =================================="
1411 local client1=${CLIENT1:-`hostname`}
1412 local client2=${CLIENT2:-`hostname`}
1416 local mtime1=`stat -c %Y $DIR1/$tfile`
1417 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1420 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1422 for (( i=0; i < 2; i++ )) ; do
1423 local mtime3=`stat -c %Y $DIR1/$tfile`
1424 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1426 [ "$mtime3" = "$mtime4" ] || \
1427 error "different mtime on clients: $mtime3, $mtime4"
1428 [ "$mtime3" = $TEST_39_MTIME ] || \
1429 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1431 cancel_lru_locks osc
1432 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1435 run_test 39b "11063 problem 1 =================================="
1438 local client1=${CLIENT1:-`hostname`}
1439 local client2=${CLIENT2:-`hostname`}
1441 echo hello > $DIR1/$tfile
1443 local mtime1=`stat -c %Y $DIR1/$tfile`
1444 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1445 [ "$mtime1" = "$mtime2" ] || \
1446 error "create: different mtime on clients: $mtime1, $mtime2"
1449 $TRUNCATE $DIR1/$tfile 1
1451 for (( i=0; i < 2; i++ )) ; do
1452 local mtime3=`stat -c %Y $DIR1/$tfile`
1453 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1455 [ "$mtime3" = "$mtime4" ] || \
1456 error "different mtime on clients: $mtime3, $mtime4"
1457 [ "$mtime3" -gt $mtime2 ] || \
1458 error "truncate did not update mtime: $mtime2, $mtime3"
1460 cancel_lru_locks osc
1461 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1464 run_test 39c "check truncate mtime update ======================"
1466 test_39d() { # LU-7310
1468 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1470 local mtime1=$(stat -c %Y $DIR2/$tfile)
1471 [ "$mtime1" = $TEST_39_MTIME ] ||
1472 error "mtime: $mtime1, should be $TEST_39_MTIME"
1475 # define OBD_FAIL_OSC_NO_GRANT 0x411
1476 $LCTL set_param fail_loc=0x411
1478 local d1=$(date +%s)
1479 echo hello >> $DIR1/$tfile
1480 local d2=$(date +%s)
1482 $LCTL set_param fail_loc=0
1484 cancel_lru_locks $OSC
1486 local mtime2=$(stat -c %Y $DIR2/$tfile)
1487 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1488 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1490 run_test 39d "sync write should update mtime"
1493 # how long 40-47 take with specific delay
1500 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1501 # avoid unexpected delays due to previous tests
1503 cancel_lru_locks mdc
1504 do_nodes $(comma_list $(mdts_nodes)) \
1505 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1506 do_nodes $(comma_list $(mdts_nodes)) \
1507 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1508 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1511 # check that pid exists hence second operation wasn't blocked by first one
1512 # if it is so then there is no conflict, return 0
1513 # else second operation is conflicting with first one, return 1
1514 check_pdo_conflict() {
1517 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1518 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1528 # test 40: check non-blocking operations
1530 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1532 mkdir_on_mdt0 $DIR2/$tdir
1534 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1535 do_nodes $(comma_list $(mdts_nodes)) \
1536 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1537 mkdir $DIR1/$tdir/$tfile &
1539 touch $DIR2/$tdir/$tfile-2
1540 check_pdo_conflict $PID1 || error "create is blocked"
1541 mkdir $DIR2/$tdir/$tfile-3
1542 check_pdo_conflict $PID1 || error "mkdir is blocked"
1543 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1544 check_pdo_conflict $PID1 || error "link is blocked"
1545 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1546 check_pdo_conflict $PID1 || error "rename is blocked"
1547 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1548 check_pdo_conflict $PID1 || error "getattr is blocked"
1549 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1550 rmdir $DIR2/$tdir/$tfile-3
1551 check_pdo_conflict $PID1 || error "unlink is blocked"
1553 # all operations above shouldn't wait the first one
1554 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1555 do_nodes $(comma_list $(mdts_nodes)) \
1556 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1561 run_test 40a "pdirops: create vs others =============="
1564 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1566 mkdir_on_mdt0 $DIR2/$tdir
1568 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1569 do_nodes $(comma_list $(mdts_nodes)) \
1570 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1571 touch $DIR1/$tdir/$tfile &
1574 touch $DIR2/$tdir/$tfile-2
1575 check_pdo_conflict $PID1 || error "create is blocked"
1576 mkdir $DIR2/$tdir/$tfile-3
1577 check_pdo_conflict $PID1 || error "mkdir is blocked"
1578 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1579 check_pdo_conflict $PID1 || error "link is blocked"
1580 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1581 check_pdo_conflict $PID1 || error "rename is blocked"
1582 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1583 check_pdo_conflict $PID1 || error "getattr is blocked"
1584 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1585 rmdir $DIR2/$tdir/$tfile-3
1586 check_pdo_conflict $PID1 || error "unlink is blocked"
1587 # all operations above shouldn't wait the first one
1589 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1590 do_nodes $(comma_list $(mdts_nodes)) \
1591 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1596 run_test 40b "pdirops: open|create and others =============="
1599 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1601 mkdir_on_mdt0 $DIR2/$tdir
1603 touch $DIR1/$tdir/$tfile
1604 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1605 do_nodes $(comma_list $(mdts_nodes)) \
1606 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1607 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1610 touch $DIR2/$tdir/$tfile-2
1611 check_pdo_conflict $PID1 || error "create is blocked"
1612 mkdir $DIR2/$tdir/$tfile-3
1613 check_pdo_conflict $PID1 || error "mkdir is blocked"
1614 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1615 check_pdo_conflict $PID1 || error "link is blocked"
1616 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1617 check_pdo_conflict $PID1 || error "rename is blocked"
1618 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1619 check_pdo_conflict $PID1 || error "getattr is blocked"
1620 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1621 rmdir $DIR2/$tdir/$tfile-3
1622 check_pdo_conflict $PID1 || error "unlink is blocked"
1624 # all operations above shouldn't wait the first one
1625 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1626 do_nodes $(comma_list $(mdts_nodes)) \
1627 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1632 run_test 40c "pdirops: link and others =============="
1635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1637 mkdir_on_mdt0 $DIR2/$tdir
1639 touch $DIR1/$tdir/$tfile
1640 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1641 do_nodes $(comma_list $(mdts_nodes)) \
1642 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1643 rm $DIR1/$tdir/$tfile &
1646 touch $DIR2/$tdir/$tfile-2
1647 check_pdo_conflict $PID1 || error "create is blocked"
1648 mkdir $DIR2/$tdir/$tfile-3
1649 check_pdo_conflict $PID1 || error "mkdir is blocked"
1650 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1651 check_pdo_conflict $PID1 || error "link is blocked"
1652 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1653 check_pdo_conflict $PID1 || error "rename is blocked"
1654 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1655 check_pdo_conflict $PID1 || error "getattr is blocked"
1656 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1657 rmdir $DIR2/$tdir/$tfile-3
1658 check_pdo_conflict $PID1 || error "unlink is blocked"
1660 # all operations above shouldn't wait the first one
1661 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1662 do_nodes $(comma_list $(mdts_nodes)) \
1663 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1667 run_test 40d "pdirops: unlink and others =============="
1670 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1672 mkdir_on_mdt0 $DIR2/$tdir
1674 touch $DIR1/$tdir/$tfile
1675 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1676 do_nodes $(comma_list $(mdts_nodes)) \
1677 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1678 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1681 touch $DIR2/$tdir/$tfile-2
1682 check_pdo_conflict $PID1 || error "create is blocked"
1683 mkdir $DIR2/$tdir/$tfile-3
1684 check_pdo_conflict $PID1 || error "mkdir is blocked"
1685 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1686 check_pdo_conflict $PID1 || error "link is blocked"
1687 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1688 check_pdo_conflict $PID1 || error "getattr is blocked"
1689 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1690 rmdir $DIR2/$tdir/$tfile-3
1691 check_pdo_conflict $PID1 || error "unlink is blocked"
1693 # all operations above shouldn't wait the first one
1694 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1695 do_nodes $(comma_list $(mdts_nodes)) \
1696 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1701 run_test 40e "pdirops: rename and others =============="
1703 # test 41: create blocking operations
1706 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1707 do_nodes $(comma_list $(mdts_nodes)) \
1708 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1709 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1711 mkdir $DIR2/$tfile &
1713 do_nodes $(comma_list $(mdts_nodes)) \
1714 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1715 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1716 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1720 run_test 41a "pdirops: create vs mkdir =============="
1724 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1725 do_nodes $(comma_list $(mdts_nodes)) \
1726 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1727 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1729 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1731 do_nodes $(comma_list $(mdts_nodes)) \
1732 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1733 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1734 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1738 run_test 41b "pdirops: create vs create =============="
1742 touch $DIR1/$tfile-2
1743 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1744 do_nodes $(comma_list $(mdts_nodes)) \
1745 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1746 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1748 link $DIR2/$tfile-2 $DIR2/$tfile &
1750 do_nodes $(comma_list $(mdts_nodes)) \
1751 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1752 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1753 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1757 run_test 41c "pdirops: create vs link =============="
1761 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1762 do_nodes $(comma_list $(mdts_nodes)) \
1763 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1764 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1768 do_nodes $(comma_list $(mdts_nodes)) \
1769 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1770 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1771 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1775 run_test 41d "pdirops: create vs unlink =============="
1779 touch $DIR1/$tfile-2
1780 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1781 do_nodes $(comma_list $(mdts_nodes)) \
1782 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1783 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1785 mv $DIR2/$tfile-2 $DIR2/$tfile &
1787 do_nodes $(comma_list $(mdts_nodes)) \
1788 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1789 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1790 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1794 run_test 41e "pdirops: create and rename (tgt) =============="
1798 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1799 do_nodes $(comma_list $(mdts_nodes)) \
1800 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1801 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1803 mv $DIR2/$tfile $DIR2/$tfile-2 &
1805 do_nodes $(comma_list $(mdts_nodes)) \
1806 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1807 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1808 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1812 run_test 41f "pdirops: create and rename (src) =============="
1816 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1817 do_nodes $(comma_list $(mdts_nodes)) \
1818 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1819 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1821 stat $DIR2/$tfile > /dev/null &
1823 do_nodes $(comma_list $(mdts_nodes)) \
1824 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1825 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1826 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1830 run_test 41g "pdirops: create vs getattr =============="
1834 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1835 do_nodes $(comma_list $(mdts_nodes)) \
1836 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1837 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1839 ls -lia $DIR2/ > /dev/null &
1841 do_nodes $(comma_list $(mdts_nodes)) \
1842 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1843 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1848 run_test 41h "pdirops: create vs readdir =============="
1855 do_nodes $(comma_list $(mdts_nodes)) \
1856 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1858 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1861 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1864 if ! wait $PID1 && ! wait $PID2; then
1865 echo "Both creates failed (1 should fail, 1 should succeed)"
1867 elif wait $PID1 && wait $PID2; then
1868 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1873 do_nodes $(comma_list $(mdts_nodes)) \
1874 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1881 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1882 skip "Need MDS version newer than 2.13.56"
1885 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1886 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1887 for fail_loc in "0x80000169" "0x8000016a"; do
1888 echo "Begin 100 tests with fail_loc=$fail_loc"
1890 for i in {1..100}; do
1892 msg=$(sub_test_41i "$fail_loc") ||
1893 { echo; error "iter=$i : $msg"; }
1898 run_test 41i "reint_open: create vs create"
1901 # test 42: unlink and blocking operations
1904 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1905 do_nodes $(comma_list $(mdts_nodes)) \
1906 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1907 mkdir $DIR1/$tfile &
1909 mkdir $DIR2/$tfile &
1911 do_nodes $(comma_list $(mdts_nodes)) \
1912 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1913 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1914 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1918 run_test 42a "pdirops: mkdir vs mkdir =============="
1922 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1923 do_nodes $(comma_list $(mdts_nodes)) \
1924 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1925 mkdir $DIR1/$tfile &
1927 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1929 do_nodes $(comma_list $(mdts_nodes)) \
1930 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1931 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1932 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1936 run_test 42b "pdirops: mkdir vs create =============="
1940 touch $DIR1/$tfile-2
1941 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1942 do_nodes $(comma_list $(mdts_nodes)) \
1943 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1944 mkdir $DIR1/$tfile &
1946 link $DIR2/$tfile-2 $DIR2/$tfile &
1948 do_nodes $(comma_list $(mdts_nodes)) \
1949 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1950 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1951 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1955 run_test 42c "pdirops: mkdir vs link =============="
1959 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1960 do_nodes $(comma_list $(mdts_nodes)) \
1961 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1962 mkdir $DIR1/$tfile &
1964 rmdir $DIR2/$tfile &
1966 do_nodes $(comma_list $(mdts_nodes)) \
1967 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1968 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1969 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1973 run_test 42d "pdirops: mkdir vs unlink =============="
1977 touch $DIR1/$tfile-2
1978 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1979 do_nodes $(comma_list $(mdts_nodes)) \
1980 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1981 mkdir $DIR1/$tfile &
1983 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1985 do_nodes $(comma_list $(mdts_nodes)) \
1986 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1987 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1988 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1992 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1996 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1997 do_nodes $(comma_list $(mdts_nodes)) \
1998 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1999 mkdir $DIR1/$tfile &
2001 mv $DIR2/$tfile $DIR2/$tfile-2 &
2003 do_nodes $(comma_list $(mdts_nodes)) \
2004 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2005 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2006 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2010 run_test 42f "pdirops: mkdir and rename (src) =============="
2013 mkdir_on_mdt0 $DIR1/$tdir
2015 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2016 do_nodes $(comma_list $(mdts_nodes)) \
2017 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2018 mkdir $DIR1/$tdir/$tfile &
2020 stat $DIR2/$tdir/$tfile > /dev/null &
2022 do_nodes $(comma_list $(mdts_nodes)) \
2023 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2024 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2025 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2028 run_test 42g "pdirops: mkdir vs getattr =============="
2032 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2033 do_nodes $(comma_list $(mdts_nodes)) \
2034 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2035 mkdir $DIR1/$tfile &
2037 ls -lia $DIR2/ > /dev/null &
2039 do_nodes $(comma_list $(mdts_nodes)) \
2040 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2041 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2046 run_test 42h "pdirops: mkdir vs readdir =============="
2048 # test 43: rmdir,mkdir won't return -EEXIST
2050 for i in {1..1000}; do
2051 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2052 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2056 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2061 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2062 do_nodes $(comma_list $(mdts_nodes)) \
2063 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2066 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2068 do_nodes $(comma_list $(mdts_nodes)) \
2069 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2070 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2071 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2075 run_test 43b "pdirops: unlink vs create =============="
2080 touch $DIR1/$tfile-2
2081 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2082 do_nodes $(comma_list $(mdts_nodes)) \
2083 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2086 link $DIR2/$tfile-2 $DIR2/$tfile &
2088 do_nodes $(comma_list $(mdts_nodes)) \
2089 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2090 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2091 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2095 run_test 43c "pdirops: unlink vs link =============="
2100 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2101 do_nodes $(comma_list $(mdts_nodes)) \
2102 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2107 do_nodes $(comma_list $(mdts_nodes)) \
2108 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2109 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2110 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2114 run_test 43d "pdirops: unlink vs unlink =============="
2119 touch $DIR1/$tfile-2
2120 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2121 do_nodes $(comma_list $(mdts_nodes)) \
2122 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2125 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2127 do_nodes $(comma_list $(mdts_nodes)) \
2128 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2129 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2130 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2134 run_test 43e "pdirops: unlink and rename (tgt) =============="
2139 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2140 do_nodes $(comma_list $(mdts_nodes)) \
2141 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2144 mv $DIR2/$tfile $DIR2/$tfile-2 &
2146 do_nodes $(comma_list $(mdts_nodes)) \
2147 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2148 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2149 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2153 run_test 43f "pdirops: unlink and rename (src) =============="
2158 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2159 do_nodes $(comma_list $(mdts_nodes)) \
2160 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2163 stat $DIR2/$tfile > /dev/null &
2165 do_nodes $(comma_list $(mdts_nodes)) \
2166 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2167 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2168 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2172 run_test 43g "pdirops: unlink vs getattr =============="
2177 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2178 do_nodes $(comma_list $(mdts_nodes)) \
2179 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2182 ls -lia $DIR2/ > /dev/null &
2184 do_nodes $(comma_list $(mdts_nodes)) \
2185 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2186 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2191 run_test 43h "pdirops: unlink vs readdir =============="
2194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2197 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2198 do_nodes $(comma_list $(mdts_nodes)) \
2199 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2202 $LFS mkdir -i 1 $DIR2/$tfile &
2204 do_nodes $(comma_list $(mdts_nodes)) \
2205 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2206 check_pdo_conflict $PID1 &&
2207 { wait $PID1; error "remote mkdir isn't blocked"; }
2208 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2212 run_test 43i "pdirops: unlink vs remote mkdir"
2215 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2216 skip "Need MDS version newer than 2.13.52"
2218 mkdir_on_mdt0 $DIR1/$tdir
2219 for i in {1..100}; do
2220 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2221 do_nodes $(comma_list $(mdts_nodes)) \
2222 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2225 mkdir $DIR1/$tdir/sub &
2227 mkdir $DIR2/$tdir/sub && ((OK++))
2228 wait $PID1 && ((OK++))
2229 (( OK == 1 )) || error "exactly one mkdir should succeed"
2231 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2235 run_test 43j "racy mkdir return EEXIST =============="
2242 # We test in a separate directory to be able to unblock server thread in
2243 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2244 test_mkdir $DIR2/$tdir
2245 touch $DIR2/$tdir/$tfile
2247 do_nodes $(comma_list $(mdts_nodes)) \
2248 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2249 echo content > $DIR1/$tdir/$tfile & PID1=$!
2251 multiop $DIR2/$tdir/$tfile u & PID2=$!
2255 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2258 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2261 do_nodes $(comma_list $(mdts_nodes)) \
2262 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2269 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2270 skip "Need MDS version newer than 2.13.56"
2273 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2274 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2275 for fail_loc in "0x80000169" "0x8000016a"; do
2276 echo "Begin 100 tests with fail_loc=$fail_loc"
2278 for i in {1..100}; do
2280 msg=$(sub_test_43k "$fail_loc") ||
2281 { echo; error "iter=$i : $msg"; }
2291 run_test 43k "unlink vs create"
2293 # test 44: rename tgt and blocking operations
2296 touch $DIR1/$tfile-2
2297 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2298 do_nodes $(comma_list $(mdts_nodes)) \
2299 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2300 mv $DIR1/$tfile-2 $DIR1/$tfile &
2302 mkdir $DIR2/$tfile &
2304 do_nodes $(comma_list $(mdts_nodes)) \
2305 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2306 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2307 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2312 run_test 44a "pdirops: rename tgt vs mkdir =============="
2316 touch $DIR1/$tfile-2
2317 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2318 do_nodes $(comma_list $(mdts_nodes)) \
2319 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2320 mv $DIR1/$tfile-2 $DIR1/$tfile &
2322 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2324 do_nodes $(comma_list $(mdts_nodes)) \
2325 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2326 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2327 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2331 run_test 44b "pdirops: rename tgt vs create =============="
2335 touch $DIR1/$tfile-2
2336 touch $DIR1/$tfile-3
2337 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2338 do_nodes $(comma_list $(mdts_nodes)) \
2339 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2340 mv $DIR1/$tfile-2 $DIR1/$tfile &
2342 link $DIR2/$tfile-3 $DIR2/$tfile &
2344 do_nodes $(comma_list $(mdts_nodes)) \
2345 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2346 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2347 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2351 run_test 44c "pdirops: rename tgt vs link =============="
2355 touch $DIR1/$tfile-2
2356 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2357 do_nodes $(comma_list $(mdts_nodes)) \
2358 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2359 mv $DIR1/$tfile-2 $DIR1/$tfile &
2363 do_nodes $(comma_list $(mdts_nodes)) \
2364 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2365 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2366 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2370 run_test 44d "pdirops: rename tgt vs unlink =============="
2375 touch $DIR1/$tfile-2
2376 touch $DIR1/$tfile-3
2377 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2378 do_nodes $(comma_list $(mdts_nodes)) \
2379 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2380 mv $DIR1/$tfile-2 $DIR1/$tfile &
2382 mv $DIR2/$tfile-3 $DIR2/$tfile &
2384 do_nodes $(comma_list $(mdts_nodes)) \
2385 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2386 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2387 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2391 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2395 touch $DIR1/$tfile-2
2396 touch $DIR1/$tfile-3
2397 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2398 do_nodes $(comma_list $(mdts_nodes)) \
2399 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2400 mv $DIR1/$tfile-2 $DIR1/$tfile &
2402 mv $DIR2/$tfile $DIR2/$tfile-3 &
2404 do_nodes $(comma_list $(mdts_nodes)) \
2405 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2406 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2407 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2411 run_test 44f "pdirops: rename tgt and rename (src) =============="
2415 touch $DIR1/$tfile-2
2416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2417 do_nodes $(comma_list $(mdts_nodes)) \
2418 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2419 mv $DIR1/$tfile-2 $DIR1/$tfile &
2421 stat $DIR2/$tfile > /dev/null &
2423 do_nodes $(comma_list $(mdts_nodes)) \
2424 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2425 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2426 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2430 run_test 44g "pdirops: rename tgt vs getattr =============="
2434 touch $DIR1/$tfile-2
2435 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2436 do_nodes $(comma_list $(mdts_nodes)) \
2437 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2438 mv $DIR1/$tfile-2 $DIR1/$tfile &
2440 ls -lia $DIR2/ > /dev/null &
2442 do_nodes $(comma_list $(mdts_nodes)) \
2443 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2444 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2449 run_test 44h "pdirops: rename tgt vs readdir =============="
2451 # test 44: rename tgt and blocking operations
2453 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2455 touch $DIR1/$tfile-2
2456 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2457 do_nodes $(comma_list $(mdts_nodes)) \
2458 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2459 mv $DIR1/$tfile-2 $DIR1/$tfile &
2461 $LFS mkdir -i 1 $DIR2/$tfile &
2463 do_nodes $(comma_list $(mdts_nodes)) \
2464 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2465 check_pdo_conflict $PID1 && { wait $PID1;
2466 error "remote mkdir isn't blocked"; }
2467 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2471 run_test 44i "pdirops: rename tgt vs remote mkdir"
2473 # test 45: rename,mkdir doesn't fail with -EEXIST
2475 for i in {1..1000}; do
2476 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2477 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2478 error "mrename to $tdir.$i failed"
2483 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2488 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2489 do_nodes $(comma_list $(mdts_nodes)) \
2490 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2491 mv $DIR1/$tfile $DIR1/$tfile-2 &
2493 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2495 do_nodes $(comma_list $(mdts_nodes)) \
2496 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2497 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2498 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2502 run_test 45b "pdirops: rename src vs create =============="
2507 touch $DIR1/$tfile-3
2508 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2509 do_nodes $(comma_list $(mdts_nodes)) \
2510 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2511 mv $DIR1/$tfile $DIR1/$tfile-2 &
2513 link $DIR2/$tfile-3 $DIR2/$tfile &
2515 do_nodes $(comma_list $(mdts_nodes)) \
2516 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2517 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2518 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2522 run_test 45c "pdirops: rename src vs link =============="
2527 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2528 do_nodes $(comma_list $(mdts_nodes)) \
2529 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2530 mv $DIR1/$tfile $DIR1/$tfile-2 &
2534 do_nodes $(comma_list $(mdts_nodes)) \
2535 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2536 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2537 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2541 run_test 45d "pdirops: rename src vs unlink =============="
2546 touch $DIR1/$tfile-3
2547 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2548 do_nodes $(comma_list $(mdts_nodes)) \
2549 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2550 mv $DIR1/$tfile $DIR1/$tfile-2 &
2552 mv $DIR2/$tfile-3 $DIR2/$tfile &
2554 do_nodes $(comma_list $(mdts_nodes)) \
2555 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2556 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2557 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2561 run_test 45e "pdirops: rename src and rename (tgt) =============="
2566 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2567 do_nodes $(comma_list $(mdts_nodes)) \
2568 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2569 mv $DIR1/$tfile $DIR1/$tfile-2 &
2571 mv $DIR2/$tfile $DIR2/$tfile-3 &
2573 do_nodes $(comma_list $(mdts_nodes)) \
2574 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2575 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2576 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2580 run_test 45f "pdirops: rename src and rename (src) =============="
2585 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2586 do_nodes $(comma_list $(mdts_nodes)) \
2587 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2588 mv $DIR1/$tfile $DIR1/$tfile-2 &
2590 stat $DIR2/$tfile > /dev/null &
2592 do_nodes $(comma_list $(mdts_nodes)) \
2593 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2594 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2595 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2599 run_test 45g "pdirops: rename src vs getattr =============="
2604 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2605 do_nodes $(comma_list $(mdts_nodes)) \
2606 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2607 mv $DIR1/$tfile $DIR1/$tfile-2 &
2609 ls -lia $DIR2/ > /dev/null &
2610 do_nodes $(comma_list $(mdts_nodes)) \
2611 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2612 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2617 run_test 45h "pdirops: unlink vs readdir =============="
2620 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2623 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2624 do_nodes $(comma_list $(mdts_nodes)) \
2625 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2626 mv $DIR1/$tfile $DIR1/$tfile-2 &
2628 $LFS mkdir -i 1 $DIR2/$tfile &
2630 do_nodes $(comma_list $(mdts_nodes)) \
2631 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2632 check_pdo_conflict $PID1 && { wait $PID1;
2633 error "create remote dir isn't blocked"; }
2634 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2638 run_test 45i "pdirops: rename src vs remote mkdir"
2645 # We test in a sparate directory to be able to unblock server thread in
2646 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2647 test_mkdir $DIR2/$tdir
2648 echo file1 > $DIR2/$tdir/$tfile
2649 echo file2 > $DIR2/$tdir/$tfile-2
2651 do_nodes $(comma_list $(mdts_nodes)) \
2652 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2654 cat $DIR1/$tdir/$tfile >/dev/null &
2657 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2661 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2664 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2667 do_nodes $(comma_list $(mdts_nodes)) \
2668 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2675 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2676 skip "Need MDS version newer than 2.13.56"
2679 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2680 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2681 for fail_loc in "0x80000169" "0x8000016a"; do
2682 echo "Begin 100 tests with fail_loc=$fail_loc"
2684 for i in {1..100}; do
2686 msg=$(sub_test_45j "$fail_loc") ||
2687 { echo; error "iter=$i : $msg"; }
2692 run_test 45j "read vs rename =============="
2694 # test 46: link and blocking operations
2697 touch $DIR1/$tfile-2
2698 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2699 do_nodes $(comma_list $(mdts_nodes)) \
2700 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2701 link $DIR1/$tfile-2 $DIR1/$tfile &
2703 mkdir $DIR2/$tfile &
2705 do_nodes $(comma_list $(mdts_nodes)) \
2706 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2707 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2708 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2712 run_test 46a "pdirops: link vs mkdir =============="
2716 touch $DIR1/$tfile-2
2717 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2718 do_nodes $(comma_list $(mdts_nodes)) \
2719 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2720 link $DIR1/$tfile-2 $DIR1/$tfile &
2722 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2724 do_nodes $(comma_list $(mdts_nodes)) \
2725 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2726 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2727 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2731 run_test 46b "pdirops: link vs create =============="
2735 touch $DIR1/$tfile-2
2736 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2737 do_nodes $(comma_list $(mdts_nodes)) \
2738 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2739 link $DIR1/$tfile-2 $DIR1/$tfile &
2741 link $DIR2/$tfile $DIR2/$tfile &
2743 do_nodes $(comma_list $(mdts_nodes)) \
2744 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2745 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2746 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2750 run_test 46c "pdirops: link vs link =============="
2754 touch $DIR1/$tfile-2
2755 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2756 do_nodes $(comma_list $(mdts_nodes)) \
2757 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2758 link $DIR1/$tfile-2 $DIR1/$tfile &
2762 do_nodes $(comma_list $(mdts_nodes)) \
2763 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2764 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2765 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2769 run_test 46d "pdirops: link vs unlink =============="
2773 touch $DIR1/$tfile-2
2774 touch $DIR1/$tfile-3
2775 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2776 do_nodes $(comma_list $(mdts_nodes)) \
2777 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2778 link $DIR1/$tfile-2 $DIR1/$tfile &
2780 mv $DIR2/$tfile-3 $DIR2/$tfile &
2782 do_nodes $(comma_list $(mdts_nodes)) \
2783 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2784 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2785 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2789 run_test 46e "pdirops: link and rename (tgt) =============="
2793 touch $DIR1/$tfile-2
2794 touch $DIR1/$tfile-3
2795 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2796 do_nodes $(comma_list $(mdts_nodes)) \
2797 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2798 link $DIR1/$tfile-2 $DIR1/$tfile &
2800 mv $DIR2/$tfile $DIR2/$tfile-3 &
2802 do_nodes $(comma_list $(mdts_nodes)) \
2803 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2804 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2805 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2809 run_test 46f "pdirops: link and rename (src) =============="
2813 touch $DIR1/$tfile-2
2814 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2815 do_nodes $(comma_list $(mdts_nodes)) \
2816 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2817 link $DIR1/$tfile-2 $DIR1/$tfile &
2819 stat $DIR2/$tfile > /dev/null &
2821 do_nodes $(comma_list $(mdts_nodes)) \
2822 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2823 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2824 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2828 run_test 46g "pdirops: link vs getattr =============="
2832 touch $DIR1/$tfile-2
2833 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2834 do_nodes $(comma_list $(mdts_nodes)) \
2835 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2836 link $DIR1/$tfile-2 $DIR1/$tfile &
2838 ls -lia $DIR2/ > /dev/null &
2840 do_nodes $(comma_list $(mdts_nodes)) \
2841 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2842 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2847 run_test 46h "pdirops: link vs readdir =============="
2850 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2852 touch $DIR1/$tfile-2
2853 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2854 do_nodes $(comma_list $(mdts_nodes)) \
2855 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2856 link $DIR1/$tfile-2 $DIR1/$tfile &
2858 $LFS mkdir -i 1 $DIR2/$tfile &
2860 do_nodes $(comma_list $(mdts_nodes)) \
2861 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2862 check_pdo_conflict $PID1 && { wait $PID1;
2863 error "remote mkdir isn't blocked"; }
2864 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2868 run_test 46i "pdirops: link vs remote mkdir"
2870 # test 47: remote mkdir and blocking operations
2872 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2873 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2875 do_nodes $(comma_list $(mdts_nodes)) \
2876 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2877 $LFS mkdir -i 1 $DIR1/$tfile &
2879 mkdir $DIR2/$tfile &
2881 do_nodes $(comma_list $(mdts_nodes)) \
2882 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2883 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2884 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2888 run_test 47a "pdirops: remote mkdir vs mkdir"
2891 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2892 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2894 do_nodes $(comma_list $(mdts_nodes)) \
2895 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2896 $LFS mkdir -i 1 $DIR1/$tfile &
2898 sleep 1 # please do not remove this sleep, see LU-10754
2899 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2901 do_nodes $(comma_list $(mdts_nodes)) \
2902 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2903 check_pdo_conflict $PID1 && { wait $PID1;
2904 error "create isn't blocked"; }
2905 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2909 run_test 47b "pdirops: remote mkdir vs create"
2912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2914 touch $DIR1/$tfile-2
2915 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2916 do_nodes $(comma_list $(mdts_nodes)) \
2917 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2918 $LFS mkdir -i 1 $DIR1/$tfile &
2920 link $DIR2/$tfile-2 $DIR2/$tfile &
2922 do_nodes $(comma_list $(mdts_nodes)) \
2923 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2924 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2925 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2929 run_test 47c "pdirops: remote mkdir vs link"
2932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2934 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2935 do_nodes $(comma_list $(mdts_nodes)) \
2936 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2937 $LFS mkdir -i 1 $DIR1/$tfile &
2939 rmdir $DIR2/$tfile &
2941 do_nodes $(comma_list $(mdts_nodes)) \
2942 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2943 check_pdo_conflict $PID1 && { wait $PID1;
2944 error "unlink isn't blocked"; }
2945 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2949 run_test 47d "pdirops: remote mkdir vs unlink"
2952 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2954 touch $DIR1/$tfile-2
2955 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2956 do_nodes $(comma_list $(mdts_nodes)) \
2957 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2958 $LFS mkdir -i 1 $DIR1/$tfile &
2960 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2962 do_nodes $(comma_list $(mdts_nodes)) \
2963 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2964 check_pdo_conflict $PID1 && { wait $PID1;
2965 error "rename isn't blocked"; }
2966 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2970 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2973 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2975 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2976 do_nodes $(comma_list $(mdts_nodes)) \
2977 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2978 $LFS mkdir -i 1 $DIR1/$tfile &
2980 mv $DIR2/$tfile $DIR2/$tfile-2 &
2982 do_nodes $(comma_list $(mdts_nodes)) \
2983 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2984 check_pdo_conflict $PID1 && { wait $PID1;
2985 error "rename isn't blocked"; }
2986 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2990 run_test 47f "pdirops: remote mkdir and rename (src)"
2993 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2997 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2998 do_nodes $(comma_list $(mdts_nodes)) \
2999 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3000 $LFS mkdir -i 1 $DIR1/$tfile &
3002 stat $DIR2/$tfile > /dev/null &
3004 do_nodes $(comma_list $(mdts_nodes)) \
3005 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3006 check_pdo_conflict $PID1 && { wait $PID1;
3007 error "getattr isn't blocked"; }
3008 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3012 run_test 47g "pdirops: remote mkdir vs getattr"
3016 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3017 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3018 do_facet client "lctl set_param fail_loc=0x410"
3019 $TRUNCATE $DIR2/$tfile $trunc_size
3020 do_facet client "lctl set_param fail_loc=0x0"
3022 size=`stat -c %s $DIR2/$tfile`
3023 [ $size -eq $trunc_size ] || error "wrong size"
3025 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3029 local origfile=/etc/hosts
3031 filesize=$(stat -c %s $origfile)
3033 # create an empty file
3034 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3035 # cache layout lock on both mount point
3036 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3037 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3039 # open and sleep 2 seconds then read
3040 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3044 # create the layout of testing file
3045 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3046 error "dd $DIR1/$tfile failed"
3048 # MULTIOP proc should be able to read enough bytes and exit
3049 for ((i = 0; i < 6; i++)); do
3051 kill -0 $pid || break
3053 kill -0 $pid 2> /dev/null && error "multiop is still there"
3054 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3058 run_test 51a "layout lock: refresh layout should work"
3061 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
3062 skip "Need MDS version at least 2.3.59"
3064 local tmpfile=`mktemp`
3066 $LFS setstripe -E 1M -c 1 -E -1 --extension-size 64M $DIR1/$tfile ||
3067 error "Create $DIR1/$tfile failed"
3069 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3070 error "dd $DIR1/$tfile failed"
3072 # delay glimpse so that layout has changed when glimpse finish
3073 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3074 $LCTL set_param fail_loc=0x1404 fail_val=4
3075 stat -c %s $DIR2/$tfile |tee $tmpfile &
3079 # extend layout of testing file
3080 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3081 error "dd $DIR1/$tfile failed"
3084 local fsize=$(cat $tmpfile)
3086 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3088 rm -f $DIR1/$tfile $tmpfile
3090 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3093 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3095 # set default layout to have 1 stripe
3097 $LFS setstripe -c 1 $DIR1/$tdir
3099 # create a file with empty layout
3100 $MCREATE $DIR1/$tdir/$tfile ||
3101 error "$MCREATE $DIR1/$tdir/$tfile failed"
3103 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3104 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3106 # change the layout of testing file
3107 echo "Setting layout to have $OSTCOUNT stripes ..."
3108 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3112 # write something to the file, it should be blocked on fetching layout
3113 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3114 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3117 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3118 # count to succeed with only 3/4 of the number of stripes (rounded up),
3119 # so creating striped files does not fail if an OST is offline or full
3120 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3121 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3125 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3128 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3129 cancel_lru_locks mdc
3131 # open should grant LAYOUT lock, mmap and read will install pages
3132 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3136 # rss before revoking
3137 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3138 echo "Before revoking layout lock: $br KB mapped"
3140 # cancel layout lock manually
3141 cancel_lru_locks mdc
3143 # rss after revoking
3144 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3147 wait $PID || error "wait PID $PID failed"
3149 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3151 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3154 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3155 skip "MDS version must be at least 2.13.54.148"
3159 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3163 $LFS getstripe $DIR2/$tfile
3165 wait $pid || error "multiop failed"
3167 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3171 $LFS getstripe $DIR2/$tfile
3173 wait $pid || error "multiop failed"
3175 run_test 51e "lfs getstripe does not break leases, part 2"
3179 echo "==> rename vs getattr vs setxattr should not deadlock"
3180 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3182 do_facet mds1 $LCTL set_param fail_loc=$1
3184 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3192 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3193 wait $PID1 || error "(3) mv failed"
3194 wait $PID2 || error "(4) stat failed"
3201 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3202 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3204 do_facet mds1 $LCTL set_param fail_loc=$1
3206 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3214 $MULTIOP $DIR2/d1/d2 Oc &
3218 stat $DIR/d1 || error "(2) stat failed"
3220 wait $PID1 || error "(3) mv failed"
3221 wait $PID2 || error "(4) stat failed"
3222 wait $PID3 && error "(5) multiop failed"
3228 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3229 save_lustre_params client "llite.*.xattr_cache" > $p
3230 lctl set_param llite.*.xattr_cache 1 ||
3231 { skip "xattr cache is not supported"; return 0; }
3233 #define OBD_FAIL_MDS_RENAME 0x153
3234 #define OBD_FAIL_MDS_RENAME2 0x154
3235 test_54_part1 0x80000153 || error 10
3236 test_54_part1 0x80000154 || error 11
3237 test_54_part2 0x80000153 || error 12
3238 test_54_part2 0x80000154 || error 13
3240 restore_lustre_params < $p
3243 run_test 54 "rename locking"
3246 mkdir_on_mdt0 $DIR/$tdir
3247 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3249 #define OBD_FAIL_MDS_RENAME4 0x156
3250 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3252 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3256 rm -r $DIR2/$tdir/d3
3257 wait $PID1 && error "(2) mv succeeded"
3261 run_test 55a "rename vs unlink target dir"
3265 mkdir_on_mdt0 $DIR/$tdir
3266 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3268 #define OBD_FAIL_MDS_RENAME4 0x156
3269 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3271 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3275 rm -r $DIR2/$tdir/d1
3276 wait $PID1 && error "(2) mv succeeded"
3280 run_test 55b "rename vs unlink source dir"
3284 mkdir_on_mdt0 $DIR/$tdir
3285 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3287 #define OBD_FAIL_MDS_RENAME4 0x156
3288 do_facet mds1 $LCTL set_param fail_loc=0x156
3290 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3294 # while rename is sleeping, open and remove d3
3295 $MULTIOP $DIR2/$tdir/d3 D_c &
3298 rm -rf $DIR2/$tdir/d3
3301 # while rename is sleeping 2nd time, close d3
3303 wait $PID2 || error "(3) multiop failed"
3305 wait $PID1 && error "(2) mv succeeded"
3309 run_test 55c "rename vs unlink orphan target dir"
3313 mkdir_on_mdt0 $DIR/$tdir
3317 #define OBD_FAIL_MDS_RENAME3 0x155
3318 do_facet mds1 $LCTL set_param fail_loc=0x155
3319 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3323 # while rename is sleeping, create $tdir, but as a directory
3324 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3326 # link in reverse locking order
3327 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3329 wait $PID1 && error "(2) mv succeeded"
3332 run_test 55d "rename file vs link"
3335 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3336 skip "MDS version must be >= 2.3.0"
3339 test_mkdir $DIR1/$tdir
3340 file1=$DIR1/$tdir/file
3341 file2=$DIR2/$tdir/file
3343 echo orig > $file2 || error "Could not create $file2"
3344 version=$($LFS data_version $file1)
3347 echo append >> $file2 || error "Could not append to $file2"
3348 version2=$($LFS data_version $file1)
3349 [ "$version" != "$version2" ] ||
3350 error "append did not change data version: $version"
3353 echo overwrite > $file2 || error "Could not overwrite $file2"
3354 version3=$($LFS data_version $file1)
3355 [ "$version2" != "$version3" ] ||
3356 error "overwrite did not change data version: $version2"
3358 # Truncate before EOF
3359 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3360 version4=$($LFS data_version $file1)
3361 [ "$version3" != "$version4" ] ||
3362 error "truncate did not change data version: $version3"
3364 # Truncate after EOF
3365 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3366 version5=$($LFS data_version $file1)
3367 [ "$version4" != "$version5" ] ||
3368 error "truncate did not change data version: $version4"
3370 # Chmod do not change version
3371 chmod 400 $file2 || error "Could not chmod 400 $file2"
3372 version6=$($LFS data_version $file1)
3373 [ "$version5" == "$version6" ] ||
3374 error "chmod should not change data version: $version5 != $version6"
3376 # Chown do not change version
3377 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3378 version7=$($LFS data_version $file1)
3379 [ "$version5" == "$version7" ] ||
3380 error "chown should not change data version: $version5 != $version7"
3382 run_test 60 "Verify data_version behaviour"
3385 local test_dir=$tdir/test_dir
3387 mkdir -p $DIR1/$tdir
3388 if [ $MDSCOUNT -ge 2 ]; then
3390 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3391 error "Create remote directory failed"
3393 mkdir -p $DIR1/$test_dir
3395 cd $DIR2/$test_dir || error "cd directory failed"
3396 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3398 cd $DIR2/$tdir || error "exit directory"
3400 run_test 70a "cd directory && rm directory"
3402 test_70b() { # LU-2781
3404 mkdir -p $DIR1/$tdir
3406 touch $DIR1/$tdir/file
3407 for ((i = 0; i < 32; i++)); do
3408 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3410 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3412 touch $DIR1/$tdir/file
3413 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3414 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3415 rm -rf $DIR1/$tdir/test_dir ||
3416 error "cannot remove directory after rm_entry"
3417 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3419 run_test 70b "remove files after calling rm_entry"
3422 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3423 skip "Need MDS version at least 2.1.6"
3425 # Patch not applied to 2.2 and 2.3 branches
3426 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3427 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3428 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3430 checkfiemap --test ||
3431 skip "checkfiemap not runnable: $?"
3432 # write data this way: hole - data - hole - data
3433 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3434 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3436 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3437 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3438 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3440 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3442 checkfiemap $DIR2/$tfile 81920 ||
3443 error "data is not flushed from client"
3444 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3447 # common case of "create file, copy file" on a single node
3448 # should not flush data from ost
3449 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3450 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3452 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3454 checkfiemap $DIR1/$tfile 81920 ||
3456 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3458 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3460 run_test 71a "correct file map just after write operation is finished"
3463 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3464 skip "Need MDS version at least 2.1.6"
3466 # Patch not applied to 2.2 and 2.3 branches
3467 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3468 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3469 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3470 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3472 checkfiemap --test ||
3473 skip "error $?: checkfiemap failed"
3475 mkdir -p $DIR1/$tdir
3477 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3478 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3479 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3481 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3482 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3484 run_test 71b "check fiemap support for stripecount > 1"
3487 local p="$TMP/sanityN-$TESTNAME.parameters"
3490 save_lustre_params client "llite.*.xattr_cache" > $p
3491 lctl set_param llite.*.xattr_cache 1 ||
3492 { skip "xattr cache is not supported"; return 0; }
3495 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3496 error "setfattr1 failed"
3497 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3498 error "getfattr1 failed"
3499 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3500 error "setfattr2 failed"
3501 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3502 error "getfattr2 failed"
3504 # check that trusted.link is consistent
3505 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3506 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3507 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3508 echo "$tlink1 $tlink2"
3509 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3513 restore_lustre_params < $p
3516 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3519 local p="$TMP/sanityN-$TESTNAME.parameters"
3520 save_lustre_params client "llite.*.xattr_cache" > $p
3521 lctl set_param llite.*.xattr_cache 1 ||
3522 { skip "xattr cache is not supported"; return 0; }
3525 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3526 error "setfattr1 failed"
3527 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3528 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3529 clear_stats llite.*.stats
3530 # PR lock should be cached by now on both clients
3531 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3532 # 2 hits for getfattr(0)+getfattr(size)
3533 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3534 error "not cached in $DIR1"
3535 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3536 # 4 hits for more getfattr(0)+getfattr(size)
3537 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3538 error "not cached in $DIR2"
3541 restore_lustre_params < $p
3544 run_test 73 "getxattr should not cause xattr lock cancellation"
3547 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3548 skip "Need MDS version at least 2.4.93"
3550 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3551 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3552 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3554 run_test 74 "flock deadlock: different mounts =============="
3558 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3559 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3560 cancel_lru_locks osc
3562 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3565 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3566 $LCTL set_param fail_loc=0x31d
3567 stat -c %s $DIR1/$tfile &
3572 # For bad lock error handler we should ASSERT and got kernel panic here
3574 $LCTL set_param fail_loc=0
3576 run_test 75 "osc: upcall after unuse lock==================="
3579 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3580 skip "Need MDS version at least 2.5.53"
3582 remote_mds_nodsh && skip "remote MDS with nodsh"
3583 local fcount=$((MDSCOUNT * 256))
3588 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3594 test_mkdir $DIR/$tdir
3596 # drop all open locks and close any cached "open" files on the client
3597 cancel_lru_locks mdc
3599 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3600 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3601 local already=${#fid_list[@]}
3602 for (( i = 0; i < $already; i++ )) ; do
3603 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3606 echo -n "opening files: "
3607 ulimit -n $((fcount + 50))
3608 for ((i = 0; i < $fcount; i++)); do
3609 touch $DIR/$tdir/f_$i
3610 local fd=$(free_fd ${fd_list[i]})
3611 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3616 (( $i % 32 == 0 )) && echo -n "."
3620 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3622 # Possible errors in openfiles FID list.
3623 # 1. Missing FIDs. Check 1
3624 # 2. Extra FIDs. Check 1
3625 # 3. Duplicated FID. Check 2
3626 # 4. Invalid FIDs. Check 2
3627 # 5. Valid FID, points to some other file. Check 3
3630 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3631 error "${#fid_list[@]} != $fcount (+$already old) open files"
3633 echo -n "closing files: "
3634 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3635 local close_cmd="exec ${fd_list[fd]}<&-"
3637 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3639 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3640 echo "skip old open file $filename"
3642 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3646 rm --interactive=no $filename
3648 error "Nonexisting fid ${fid_list[fid]} listed."
3649 (( $fd % 32 == 0 )) && echo -n "."
3654 ls_op=$(ls $DIR2/$tdir | wc -l)
3656 error "Some openfiles are missing in lproc output"
3660 run_test 76 "Verify MDT open_files listing"
3664 local dir=$DIR/$tdir
3667 mkdir $dir || error "mkdir $dir failed"
3668 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3671 do_nodes $CLIENTS $myRUNAS \
3672 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3673 error "dd at 0 on client failed (1)"
3675 do_nodes $CLIENTS $myRUNAS \
3677 for ((i = 0; i < $n; i++)); do
3678 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3679 seek=\\\$i count=1 conv=notrunc &
3680 pids_w[\\\$i]=\\\$!;
3683 for ((i = 0; i < $n; i++)); do
3684 wait \\\${pids_w[\\\$i]};
3686 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3690 do_nodes $CLIENTS sync;
3691 cancel_lru_locks osc
3693 do_nodes $CLIENTS $myRUNAS \
3695 for ((i = 0; i < $n; i++)); do
3696 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3697 seek=\\\$i count=1 &
3698 pids_r[\\\$i]=\\\$!;
3701 for ((i = 0; i < $n; i++)); do
3702 wait \\\${pids_r[\\\$i]};
3704 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3708 cancel_lru_locks osc
3710 wait $pid_w || error "dd (write) failed (2)"
3711 wait $pid_r || error "dd (read) failed (3)"
3712 rm -rvf $dir || error "rm -rf $dir failed"
3715 test_77a() { #LU-3266
3718 oss=$(comma_list $(osts_nodes))
3719 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3721 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3722 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3727 run_test 77a "check FIFO NRS policy"
3729 test_77b() { #LU-3266
3732 oss=$(comma_list $(osts_nodes))
3734 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3735 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3736 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3737 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3739 echo "policy: crr-n, crrn_quantum 1"
3742 do_nodes $oss lctl set_param \
3743 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3744 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3746 echo "policy: crr-n, crrn_quantum 64"
3750 do_nodes $oss lctl set_param \
3751 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3752 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3755 run_test 77b "check CRR-N NRS policy"
3760 oss=$(comma_list $(osts_nodes))
3762 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3763 ost.OSS.*.nrs_"$policy"_quantum=1 \
3764 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3765 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3767 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3768 "physical, ${policy}_supported reads"
3771 do_nodes $oss lctl set_param \
3772 ost.OSS.*.nrs_${policy}_supported="writes" \
3773 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3775 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3776 "physical, ${policy}_supported writes"
3779 do_nodes $oss lctl set_param \
3780 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3781 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3782 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3783 "logical, ${policy}_supported reads_and_writes"
3787 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3792 test_77c() { #LU-3266
3794 orr_trr "orr" || rc=$?
3795 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3796 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3799 run_test 77c "check ORR NRS policy"
3801 test_77d() { #LU-3266
3803 orr_trr "trr" || rc=$?
3804 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3805 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3808 run_test 77d "check TRR nrs policy"
3815 do_facet $facet lctl set_param \
3816 ost.OSS.ost_io.nrs_tbf_rule="$*"
3818 error "failed to run operate '$*' on TBF rules"
3821 cleanup_tbf_verify()
3825 echo "cleanup_tbf $DIR/$tdir"
3828 wait_delete_completed
3833 local dir=$DIR/$tdir
3834 local client1=${CLIENT1:-$(hostname)}
3837 local np=$(check_cpt_number ost1)
3838 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3839 echo "cpu_npartitions on ost1 is $np"
3841 mkdir $dir || error "mkdir $dir failed"
3842 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3845 trap cleanup_tbf_verify EXIT
3846 echo "Limited write rate: $1, read rate: $2"
3847 echo "Verify the write rate is under TBF control"
3848 local start=$SECONDS
3849 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3850 bs=1M count=100 oflag=direct 2>&1
3851 local runtime=$((SECONDS - start + 1))
3852 local rate=$(bc <<< "scale=6; 100 / $runtime")
3853 echo "Write runtime is $runtime s, speed is $rate IOPS"
3855 # verify the write rate does not exceed TBF rate limit
3856 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3857 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3859 cancel_lru_locks osc
3861 echo "Verify the read rate is under TBF control"
3863 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3864 bs=1M count=100 iflag=direct 2>&1
3865 runtime=$((SECONDS - start + 1))
3866 rate=$(bc <<< "scale=6; 100 / $runtime")
3867 echo "Read runtime is $runtime s, speed is $rate IOPS"
3869 # verify the read rate does not exceed TBF rate limit
3870 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3871 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3873 cancel_lru_locks osc
3874 cleanup_tbf_verify || error "rm -rf $dir failed"
3880 oss=$(comma_list $(osts_nodes))
3882 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3884 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3885 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3889 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3894 # Only operate rules on ost1 since OSTs might run on the same OSS
3896 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3897 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3898 local client_nids=$(nids_list $address "\\")
3899 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3900 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3904 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3905 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3906 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3910 tbf_rule_operate ost1 "stop\ localhost"
3911 tbf_rule_operate ost1 "stop\ clients"
3912 tbf_rule_operate ost1 "stop\ others"
3915 # Cleanup the TBF policy
3916 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3917 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3921 run_test 77e "check TBF NID nrs policy"
3926 oss=$(comma_list $(osts_nodes))
3928 do_nodes $oss $LCTL set_param \
3929 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3930 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3931 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3933 # Configure jobid_var
3934 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3936 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3937 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3938 if [ $saved_jobid_var != procname_uid ]; then
3939 set_persistent_param_and_check client \
3940 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3945 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3950 # Only operate rules on ost1 since OSTs might run on the same OSS
3952 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3953 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3954 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3955 nrs_write_read "$RUNAS"
3958 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3959 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3960 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3961 nrs_write_read "$RUNAS"
3964 tbf_rule_operate ost1 "stop\ runas"
3965 tbf_rule_operate ost1 "stop\ iozone_runas"
3966 tbf_rule_operate ost1 "stop\ dd_runas"
3967 nrs_write_read "$RUNAS"
3969 # Cleanup the TBF policy
3970 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3971 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3972 nrs_write_read "$RUNAS"
3974 local current_jobid_var=$($LCTL get_param -n jobid_var)
3975 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3976 if [ $saved_jobid_var != $current_jobid_var ]; then
3977 set_persistent_param_and_check client \
3978 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3982 run_test 77f "check TBF JobID nrs policy"
3987 oss=$(comma_list $(osts_nodes))
3989 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3991 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3992 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3994 do_nodes $oss lctl set_param \
3995 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3996 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4000 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4005 # Add a rule that only valid for Jobid TBF. If direct change between
4006 # TBF types is not supported, this operation will fail.
4007 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4009 # Cleanup the TBF policy
4010 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4011 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4014 run_test 77g "Change TBF type directly"
4017 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4018 skip "Need OST version at least 2.8.55"
4020 local old_policy=$(do_facet ost1 \
4021 lctl get_param ost.OSS.ost_io.nrs_policies)
4024 do_facet ost1 lctl set_param \
4025 ost.OSS.ost_io.nrs_policies="abc"
4026 [ $? -eq 0 ] && error "should return error"
4028 do_facet ost1 lctl set_param \
4029 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4030 [ $? -eq 0 ] && error "should return error"
4032 do_facet ost1 lctl set_param \
4033 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4034 [ $? -eq 0 ] && error "should return error"
4036 do_facet ost1 lctl set_param \
4037 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4038 [ $? -eq 0 ] && error "should return error"
4040 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4041 [ $? -eq 0 ] || error "shouldn't LBUG"
4043 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4047 run_test 77h "Wrong policy name should report error, not LBUG"
4053 local error_message=$3
4055 for rule in $expected; do
4056 rule_number=$((rule_number + 1))
4058 local stop_line=$(($rule_number + 3))
4059 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4061 local output=$(do_facet $facet lctl get_param \
4062 ost.OSS.ost_io.nrs_tbf_rule |
4066 if [ "$output" != "$expected" ]; then
4067 error "$error_message, expected '$expected', got '$output'"
4072 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4073 skip "Need OST version at least 2.8.55"
4075 for i in $(seq 1 $OSTCOUNT)
4077 do_facet ost"$i" lctl set_param \
4078 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4080 error "failed to set TBF policy"
4083 tbf_rule_check ost1 "default" "error before inserting any rule"
4085 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4086 tbf_rule_check ost1 "before default" \
4087 "error when inserting rule 'before'"
4089 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4090 tbf_rule_check ost1 "before after default" \
4091 "error when inserting rule 'after'"
4093 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4094 tbf_rule_check ost1 "before target after default" \
4095 "error when inserting rule 'target'"
4097 echo "Move before itself"
4098 tbf_rule_operate ost1 "change\ target\ rank=target"
4099 tbf_rule_check ost1 "before target after default" \
4100 "error when moving before itself"
4102 echo "Move to higher rank"
4103 tbf_rule_operate ost1 "change\ target\ rank=before"
4104 tbf_rule_check ost1 "target before after default" \
4105 "error when moving to higher rank"
4107 echo "Move to lower rank"
4108 tbf_rule_operate ost1 "change\ target\ rank=after"
4109 tbf_rule_check ost1 "before target after default" \
4110 "error when moving to lower rank"
4112 echo "Move before default"
4113 tbf_rule_operate ost1 "change\ target\ rank=default"
4114 tbf_rule_check ost1 "before after target default" \
4115 error "error when moving before default"
4117 # Cleanup the TBF policy
4118 do_nodes $(comma_list $(osts_nodes)) \
4119 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4122 run_test 77i "Change rank of TBF rule"
4128 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4129 skip "Need OST version at least 2.9.53"
4130 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4135 do_nodes $(comma_list $(osts_nodes)) \
4136 lctl set_param jobid_var=procname_uid \
4137 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4138 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4139 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4140 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4145 do_nodes $(comma_list $(osts_nodes)) \
4146 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4147 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4148 ost.OSS.ost_io.nrs_policies="fifo"
4150 # sleep 3 seconds to wait the tbf policy stop completely,
4151 # or the next test case is possible get -EAGAIN when
4152 # setting the tbf policy
4155 run_test 77j "check TBF-OPCode NRS policy"
4158 local idstr="${1}id"
4159 local policy="${idstr}={$2}"
4160 local rate="rate=$3"
4162 do_nodes $(comma_list $(osts_nodes)) \
4163 lctl set_param jobid_var=procname_uid \
4164 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4165 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4166 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4168 nrs_write_read "runas $4"
4169 tbf_verify $3 $3 "runas $4"
4171 do_nodes $(comma_list $(osts_nodes)) \
4172 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4173 ost.OSS.ost_io.nrs_policies="fifo"
4175 # sleep 3 seconds to wait the tbf policy stop completely,
4176 # or the next test case is possible get -eagain when
4177 # setting the tbf policy
4182 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4183 skip "Need OST version at least 2.11.50"
4186 test_id "u" "500" "5" "-u 500"
4187 test_id "g" "500" "5" "-u 500 -g 500"
4189 run_test 77ja "check TBF-UID/GID NRS policy"
4197 for rule in $rule_lists; do
4198 do_nodes $(comma_list $(osts_nodes)) \
4199 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4202 do_nodes $(comma_list $(osts_nodes)) \
4203 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4209 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4210 skip "Need OST version at least 2.9.53"
4212 do_nodes $(comma_list $(osts_nodes)) \
4213 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4214 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4215 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4217 nrs_write_read "$RUNAS"
4218 tbf_verify 20 10 "$RUNAS"
4220 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4221 local client_nids=$(nids_list $address "\\")
4222 do_nodes $(comma_list $(osts_nodes)) \
4223 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4224 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4225 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4226 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4231 do_nodes $(comma_list $(osts_nodes)) \
4232 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4233 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4234 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4236 nrs_write_read "$RUNAS"
4237 tbf_verify 20 20 "$RUNAS"
4239 do_nodes $(comma_list $(osts_nodes)) \
4240 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4241 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4242 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4244 nrs_write_read "$RUNAS"
4245 # with parameter "RUNAS", it will match the latest rule
4246 # "ext_b" first, so the limited write rate is 10.
4247 tbf_verify 10 10 "$RUNAS"
4250 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4252 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4253 skip "Need OST version at least 2.10.58"
4255 do_nodes $(comma_list $(osts_nodes)) \
4256 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4257 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4258 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4259 nrs_write_read "runas -u 500 -g 1000"
4260 tbf_verify 5 5 "runas -u 500 -g 1000"
4262 do_nodes $(comma_list $(osts_nodes)) \
4263 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4264 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4265 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4267 nrs_write_read "runas -u 500"
4268 tbf_verify 20 10 "runas -u 500"
4270 do_nodes $(comma_list $(osts_nodes)) \
4271 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4272 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4273 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4274 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4275 nrs_write_read "runas -u 500"
4276 tbf_verify 10 10 "runas -u 500"
4277 tbf_verify 20 10 "runas -u 500"
4278 cleanup_77k "ext_a ext_b" "fifo"
4280 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4283 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4284 skip "Need OST version at least 2.10.56"
4286 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4287 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4289 local output=$(do_facet ost1 lctl get_param \
4290 ost.OSS.ost_io.nrs_policies | \
4291 awk '/name: tbf/ {print;exit}' | \
4292 awk -F ': ' '{print $2}')
4294 if [ "$output" != "tbf" ]; then
4295 error "The generic TBF output is '$output', not 'tbf'"
4298 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4300 run_test 77l "check the output of NRS policies for generic TBF"
4303 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4304 skip "Need OST version at least 2.9.54"
4307 local dir=$DIR/$tdir
4309 mkdir $dir || error "mkdir $dir failed"
4310 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4313 local nodes=$(comma_list $(osts_nodes))
4314 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4315 ost.OSS.ost_io.nrs_delay_min=4 \
4316 ost.OSS.ost_io.nrs_delay_max=4 \
4317 ost.OSS.ost_io.nrs_delay_pct=100
4318 [ $? -ne 0 ] && error "Failed to set delay policy"
4320 local start=$SECONDS
4321 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4322 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4323 oflag=direct conv=fdatasync ||
4324 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4325 error "dd on client failed (1)"; }
4326 local elapsed=$((SECONDS - start))
4328 # NRS delay doesn't do sub-second timing, so a request enqueued at
4329 # 0.9 seconds can be dequeued at 4.0
4330 [ $elapsed -lt 3 ] &&
4331 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4332 error "Single 1M write should take at least 3 seconds"; }
4335 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4336 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4337 oflag=direct conv=fdatasync ||
4338 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4339 error "dd on client failed (2)"; }
4340 elapsed=$((SECONDS - start))
4342 [ $elapsed -lt 30 ] &&
4343 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4344 error "Ten 1M writes should take at least 30 seconds"; }
4346 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4347 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4351 run_test 77m "check NRS Delay slows write RPC processing"
4353 test_77n() { #LU-10802
4354 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4355 skip "Need OST version at least 2.10.58"
4358 # Configure jobid_var
4359 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4360 if [ $saved_jobid_var != procname_uid ]; then
4361 set_persistent_param_and_check client \
4362 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4365 do_nodes $(comma_list $(osts_nodes)) \
4366 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4367 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4368 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4371 tbf_verify 20 20 "$RUNAS"
4373 do_nodes $(comma_list $(osts_nodes)) \
4374 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4375 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4380 do_nodes $(comma_list $(osts_nodes)) \
4381 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4382 ost.OSS.ost_io.nrs_policies="fifo"
4386 local current_jobid_var=$($LCTL get_param -n jobid_var)
4387 if [ $saved_jobid_var != $current_jobid_var ]; then
4388 set_persistent_param_and_check client \
4389 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4392 run_test 77n "check wildcard support for TBF JobID NRS policy"
4394 test_78() { #LU-6673
4397 oss=$(comma_list $(osts_nodes))
4398 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4399 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4401 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4402 # Valid return codes are:
4403 # 0: Tuning succeeded
4404 # ENODEV: Policy is still stopped
4405 # EAGAIN: Policy is being initialized
4406 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4407 error "Expected set_param to return 0|ENODEV|EAGAIN"
4409 # Cleanup the ORR policy
4410 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4411 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4414 run_test 78 "Enable policy and specify tunings right away"
4417 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4418 test_mkdir $DIR/$tdir
4420 # Prevent interference from layout intent RPCs due to
4421 # asynchronous writeback. These will be tested in 130c below.
4422 do_nodes ${CLIENTS:-$HOSTNAME} sync
4424 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4425 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4427 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4428 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4429 local facet=mds$((mdtidx + 1))
4431 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4432 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4436 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4437 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4442 run_test 79 "xattr: intent error"
4445 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4452 mkdir -p $DIR1/$tdir/dir
4453 createmany -o $DIR1/$tdir/dir/f 10 ||
4454 error "create files under remote dir failed $i"
4456 cp /etc/passwd $DIR1/$tdir/$tfile
4458 #migrate open file should fails
4459 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4461 # give multiop a chance to open
4464 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4465 error "migrate open files should failed with open files"
4469 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4470 error "migrate remote dir error"
4472 echo "Finish migration, then checking.."
4473 for file in $(find $DIR1/$tdir); do
4474 mdt_index=$($LFS getstripe -m $file)
4475 [ $mdt_index == $MDTIDX ] ||
4476 error "$file is not on MDT${MDTIDX}"
4479 diff /etc/passwd $DIR1/$tdir/$tfile ||
4480 error "file different after migration"
4482 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4484 run_test 80a "migrate directory when some children is being opened"
4488 kill -9 $migrate_pid
4492 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4493 local migrate_dir1=$DIR1/$tdir/migrate_dir
4494 local migrate_dir2=$DIR2/$tdir/migrate_dir
4495 local migrate_run=$LUSTRE/tests/migrate.sh
4503 trap cleanup_80b EXIT
4504 #prepare migrate directory
4505 mkdir -p $migrate_dir1
4506 for F in {1,2,3,4,5}; do
4507 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4508 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4511 #migrate the directories among MDTs
4514 mdt_idx=$((RANDOM % MDSCOUNT))
4515 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4517 [ $rc -ne 0 -o $rc -ne 16 ] || break
4522 echo "start migration thread $migrate_pid"
4523 #Access the files at the same time
4524 start_time=$(date +%s)
4525 echo "accessing the migrating directory for 5 minutes..."
4527 ls $migrate_dir2 > /dev/null || {
4528 echo "read dir fails"
4531 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4532 echo "access file1 fails"
4536 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4537 echo "access file2/3 fails"
4541 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4542 echo "access file4 fails"
4546 stat $migrate_dir2/file5 > /dev/null || {
4547 echo "stat file5 fails"
4551 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4552 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4553 echo "touch file failed with $rc1"
4557 if [ -e $migrate_dir2/source_file ]; then
4558 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4559 &>/dev/null || rc1=$?
4560 if [ -e $migrate_dir2/link_file ]; then
4561 rm -rf $migrate_dir2/link_file
4564 mrename $migrate_dir2/source_file \
4565 $migrate_dir2/target_file &>/dev/null || rc1=$?
4566 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4567 echo "rename failed with $rc1"
4571 if [ -e $migrate_dir2/target_file ]; then
4572 rm -rf $migrate_dir2/target_file &>/dev/null ||
4575 rm -rf $migrate_dir2/source_file &>/dev/null ||
4578 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4579 echo "unlink failed with $rc1"
4584 end_time=$(date +%s)
4585 duration=$((end_time - start_time))
4586 if [ $((duration % 10)) -eq 0 ]; then
4587 if [ $show_time -eq 1 ]; then
4588 echo "...$duration seconds"
4595 kill -0 $migrate_pid || {
4596 echo "migration stopped 1"
4600 [ $duration -ge 300 ] && break
4603 #check migration are still there
4604 kill -0 $migrate_pid || error "migration stopped 2"
4607 run_test 80b "Accessing directory during migration"
4610 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4614 mkdir -p $DIR1/$tdir
4616 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4617 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4620 touch d0/0 || error "create 0 failed"
4621 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4622 stat d0/0 && error "stat mv filed succeed"
4623 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4624 stat d0/0 || error "stat failed"
4626 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4628 if [ $t -ne 3 ]; then
4629 ls -ai $DIR1/$tdir/d0
4630 error "expect 3 get $t"
4635 run_test 81a "rename and stat under striped directory"
4638 [ $MDSCOUNT -lt 2 ] &&
4639 skip "We need at least 2 MDTs for this test"
4646 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4647 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4656 for i in $(seq $total); do
4657 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4661 kill -9 $setattr_pid
4663 run_test 81b "rename under striped directory doesn't deadlock"
4666 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4667 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4668 skip "Need MDS version at least 2.13.52"
4670 # source is local, source parent is remote
4671 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4672 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4673 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4674 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4675 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4676 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4677 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4678 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4680 # source is remote, source parent is local
4681 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4682 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4683 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4684 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4685 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4686 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4687 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4688 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4690 # source and source parent are remote
4691 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4692 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4693 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4694 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4695 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4696 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4697 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4698 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4700 # source and source parent are remote, and source is remote object
4701 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4702 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4703 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4704 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4705 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4706 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4707 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4709 run_test 81c "rename revoke LOOKUP lock for remote object"
4712 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4713 skip "Need MDS version at least 2.6.92"
4715 # Client 1 creates a file.
4716 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4718 # Client 2 opens the file.
4719 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4721 # Client 1 makes the file an orphan.
4722 rm $DIR1/$tfile || error "rm"
4723 # Client 2 sets EA "user.multiop".
4725 wait $pid2 || error "multiop 2"
4726 # Client 1 gets EA "user.multiop". This used to fail because the EA
4727 # cache refill would get "trusted.link" from mdd_xattr_list() but
4728 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4731 wait $pid1 || error "multiop 1"
4733 run_test 82 "fsetxattr and fgetxattr on orphan files"
4736 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4743 $LFS mkdir -i1 -c2 $tdir
4748 echo "start pid $pid1 to create/unlink striped directory"
4750 # Access the directory at the same time
4754 stat $tdir > /dev/null 2>&1
4758 echo "start pid $pid2 to stat striped directory"
4766 run_test 83 "access striped directory while it is being created/unlinked"
4769 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4770 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4774 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4775 error "create $tfile failed"
4776 mtime=$(stat -c%Y $DIR/$tfile)
4777 mtime=$((mtime + 200))
4779 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4780 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4782 touch -c -m $mtime $DIR/$tfile &
4784 # sleep a while to let 'touch' run first
4786 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4789 wait $setattr_pid || true
4791 run_test 84 "0-nlink race in lu_object_find()"
4794 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4799 [ "$SLOW" = "yes" ] && duration=600
4800 # Open/Create under striped directory
4804 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4805 touch $tdir/f{0..3} > /dev/null 2>&1
4809 echo "start pid $pid1 to open/create under striped directory"
4811 # unlink the striped directory at the same time
4815 rm -rf $tdir > /dev/null 2>&1
4819 echo "start pid $pid2 to unlink striped directory"
4828 run_test 90 "open/create and unlink striped directory"
4831 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4836 [ "$SLOW" = "yes" ] && duration=600
4837 # chmod striped directory
4841 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4842 chmod go+w $tdir > /dev/null 2>&1
4846 echo "start pid $pid1 to chmod striped directory"
4848 # unlink the striped directory at the same time
4852 rm -rf $tdir > /dev/null 2>&1
4856 echo "start pid $pid2 to unlink striped directory"
4865 run_test 91 "chmod and unlink striped directory"
4868 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4871 local cmd="exec $fd<$DIR1/$tdir"
4872 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4875 trap "eval $cmd" EXIT
4876 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4877 rmdir ../$tdir || error "rmdir ../$tdir fails"
4879 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4880 $LCTL set_param fail_loc=0x1408
4881 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4882 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4883 error "create remote dir succeeds"
4884 $LCTL set_param fail_loc=0
4888 run_test 92 "create remote directory under orphan directory"
4895 mkdir -p $DIR1/$tfile-1/
4896 mkdir -p $DIR2/$tfile-2/
4897 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4898 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4899 do_facet $SINGLEMDS "$LCTL set_param -n \
4900 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4901 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4902 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4904 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4907 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4911 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4912 do_facet $SINGLEMDS "$LCTL set_param -n \
4913 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4915 $LFS getstripe $DIR1/$tfile-1/file1
4916 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4917 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4918 $LFS getstripe $DIR2/$tfile-2/file2
4919 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4920 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4921 echo "rc1=$rc1 and rc2=$rc2 "
4922 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4923 error "object allocate on same ost detected"
4925 run_test 93 "alloc_rr should not allocate on same ost"
4928 $LCTL set_param osc.*.idle_timeout=0
4929 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4931 local before=$(date +%s)
4935 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4936 $LCTL set_param fail_val=5 fail_loc=0x80000312
4937 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4941 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4942 $LCTL set_param fail_val=6 fail_loc=0x80000329
4943 $LCTL mark kill $pid
4946 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4949 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4951 evict=$(do_facet client $LCTL get_param \
4952 osc.$FSNAME-OST*-osc-*/state |
4953 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4955 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4956 (do_facet client $LCTL get_param \
4957 osc.$FSNAME-OST*-osc-*/state;
4958 error "eviction happened: $evict before:$before")
4959 $LCTL set_param osc.*.idle_timeout=debug
4961 run_test 94 "signal vs CP callback race"
4965 skip "Reserved for glimpse-ahead" && return
4966 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4967 skip "Need MDS version at least 2.10.55"
4971 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4973 lctl set_param -n mdc.*.stats=clear
4974 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4976 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4977 # first stat from server should return size data and save glimpse
4978 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4979 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4980 # second stat to check size is NOT cached on client without IO lock
4981 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4983 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4984 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4987 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4990 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4991 skip "Need MDS version at least 2.10.55"
4995 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4997 lctl set_param -n mdc.*.stats=clear
4998 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4999 cancel_lru_locks mdc
5000 # first stat data from server should have size
5001 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5002 # second stat to check size is cached on client
5003 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5005 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5006 # both stats should cause no glimpse requests
5007 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5010 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5013 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5014 skip "Need MDS version at least 2.10.55"
5018 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5020 lctl set_param -n mdc.*.stats=clear
5021 lctl set_param -n osc.*.stats=clear
5022 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5024 # check that size is merged from MDT and OST correctly
5025 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5026 error "Wrong size from stat #1"
5028 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5029 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5033 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5036 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5037 skip "Need MDS version at least 2.10.55"
5041 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5044 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5045 lctl set_param -n mdc.*.stats=clear
5046 $TRUNCATE $DIR2/$tdir/dom 4096
5048 # check that reported size is valid after file grows to OST and
5049 # is truncated back to MDT stripe size
5050 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5051 error "Wrong size from stat #1"
5053 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5054 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5058 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5061 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5062 skip "Need MDS version at least 2.11.50"
5064 local dom=$DIR/$tdir/dom
5065 local dom2=$DIR2/$tdir/dom
5068 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5070 cancel_lru_locks mdc
5071 dd if=/dev/urandom of=$dom bs=12000 count=1
5072 $TRUNCATE $dom2 6000
5073 cancel_lru_locks mdc
5074 lctl set_param -n mdc.*.stats=clear
5075 # expect read-on-open to return all data before write
5076 cat /etc/hosts >> $dom
5077 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5078 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5080 run_test 100e "DoM: read on open and file size"
5083 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5084 skip "Need MDS version at least 2.10.55"
5086 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5088 $CHECKSTAT -t file $DIR1/$tfile
5090 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5091 sysctl -wq vm.dirty_writeback_centisecs=0
5093 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5096 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5097 error_noexit "Write fails"
5098 # must discard pages
5099 lctl set_param -n mdc.*.stats=clear
5100 rm $DIR2/$tfile || error "Unlink fails"
5102 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5103 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5105 run_test 101a "Discard DoM data on unlink"
5108 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5109 skip "Need MDS version at least 2.10.55"
5111 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5112 touch $DIR1/${tfile}_2
5114 $CHECKSTAT -t file $DIR1/$tfile
5116 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5117 sysctl -wq vm.dirty_writeback_centisecs=0
5119 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5122 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5123 # must discard pages
5124 lctl set_param -n mdc.*.stats=clear
5125 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5127 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5128 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5130 run_test 101b "Discard DoM data on rename"
5133 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5134 skip "Need MDS version at least 2.10.55"
5136 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5138 $CHECKSTAT -t file $DIR1/$tfile
5140 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5141 sysctl -wq vm.dirty_writeback_centisecs=0
5143 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5146 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5147 $MULTIOP $DIR1/$tfile O_c &
5150 lctl set_param -n mdc.*.stats=clear
5151 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5152 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5154 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5155 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5157 run_test 101c "Discard DoM data on close-unlink"
5159 # test to verify file handle related system calls
5160 # (name_to_handle_at/open_by_handle_at)
5161 # The new system calls are supported in glibc >= 2.14.
5163 # test to verify we can open by handle an unlinked file from > 1 client
5164 # This test opens the file normally on $DIR1, which is on one mount, and then
5165 # opens it by handle on $DIR2, which is on a different mount.
5167 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
5168 skip "Needs MDS version 2.11.57 or later"
5170 echo "Test file_handle syscalls" > $DIR/$tfile ||
5171 error "write failed"
5172 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5173 error "check_fhandle_syscalls $tfile failed"
5175 # test this is working on DNE directories also
5176 if (( MDSCOUNT > 1 MDS1_VERSION >= $(version_code 2.14.52) )); then
5177 $LFS mkdir -i 1 $DIR/$tdir.remote
5178 cancel_lru_locks mdc
5179 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5180 error "check_fhandle_syscalls $tdir.remote failed"
5181 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5182 cancel_lru_locks mdc
5183 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5184 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5186 $LFS mkdir -c -1 $DIR/$tdir.stripe
5187 cancel_lru_locks mdc
5188 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5189 error "check_fhandle_syscalls $tdir.stripe failed"
5190 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5191 cancel_lru_locks mdc
5192 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5193 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5196 run_test 102 "Test open by handle of unlinked file"
5198 # Compare file size between first & second mount, ensuring the client correctly
5199 # glimpses even with unused speculative locks - LU-11670
5201 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5202 skip "Lockahead needs OST version at least 2.10.50"
5206 test_mkdir -p $DIR/$tdir
5208 # Force file on to OST0
5209 $LFS setstripe -i 0 $DIR/$tdir
5211 # Do not check multiple locks on glimpse
5212 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5213 $LCTL set_param fail_loc=0x415
5215 # Delay write commit by 2 seconds to guarantee glimpse wins race
5216 # The same fail_loc is used on client & server so it can work in the
5217 # single node sanity setup
5218 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5220 echo "Incorrect size expected (no glimpse fix):"
5221 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5223 if [ $rc -eq 0 ]; then
5224 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5227 # guarantee write commit timeout has expired
5230 # Clear fail_loc on client
5231 $LCTL set_param fail_loc=0
5233 # Delay write commit by 2 seconds to guarantee glimpse wins race
5234 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5235 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5237 # Write commit is still delayed by 2 seconds
5238 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5240 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5242 # guarantee write commit timeout has expired
5245 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5247 run_test 103 "Test size correctness with lockahead"
5253 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5264 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5265 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5266 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5267 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5275 local xtimes=($(get_stat_xtimes))
5276 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5278 echo "STAT a|m|ctime ${xtimes[*]}"
5279 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5280 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5281 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5282 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5283 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5284 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5285 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5289 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5290 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5291 skip "Need MDS version at least 2.12.4"
5294 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5295 local atime_diff=$(do_facet $SINGLEMDS \
5296 lctl get_param -n mdd.*MDT0000*.atime_diff)
5298 do_facet $SINGLEMDS \
5299 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5301 stack_trap "do_facet $SINGLEMDS \
5302 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5304 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5305 check_mdt_xtimes $mdtdev
5308 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5309 check_mdt_xtimes $mdtdev
5311 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5314 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5316 kill -USR1 $pid && wait $pid || error "multiop failure"
5317 check_mdt_xtimes $mdtdev
5322 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5323 # on the client side
5324 xtimes=($(get_stat_xtimes))
5325 $MULTIOP $DIR/$tfile O_c &
5328 kill -USR1 $pid && wait $pid || error "multiop failure"
5329 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5330 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5331 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5332 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5333 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5334 check_mdt_xtimes $mdtdev
5337 # Change ctime via chmod
5338 $MULTIOP $DIR/$tfile o_tc &
5341 kill -USR1 $pid && wait $pid || error "multiop failure"
5342 check_mdt_xtimes $mdtdev
5344 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5347 test_mkdir -p $DIR/$tdir
5348 echo test > $DIR/$tdir/$tfile
5349 $LCTL set_param fail_loc=0x416
5350 cancel_lru_locks osc & sleep 1
5351 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5353 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5355 run_test 105 "Glimpse and lock cancel race"
5358 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5359 skip_env "Test only for ldiskfs and statx() supported"
5364 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5366 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5367 btime=$($STATX -c %W $DIR/$tfile)
5368 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5370 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5371 [[ $btime == $mdt_btime ]] ||
5372 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5375 run_test 106a "Verify the btime via statx()"
5378 statx_supported || skip_env "statx() only test"
5383 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5384 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5385 cancel_lru_locks $OSC
5386 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5388 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5389 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5390 error "$STATX should send 1 glimpse RPC to $OSC"
5392 cancel_lru_locks $OSC
5393 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5394 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5395 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5397 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5398 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5399 [ $rpcs_after -eq $rpcs_before ] ||
5400 error "$STATX should not send glimpse RPCs to $OSC"
5402 cancel_lru_locks $OSC
5403 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5404 $STATX --cached=always $DIR/$tfile
5405 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5406 [ $rpcs_after -eq $rpcs_before ] ||
5407 error "$STATX should not send glimpse RPCs to $OSC"
5409 cancel_lru_locks $OSC
5410 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5411 $STATX -c %Y $DIR/$tfile
5412 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5413 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5414 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5416 cancel_lru_locks $OSC
5417 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5418 $STATX -c %s $DIR/$tfile
5419 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5420 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5421 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5423 cancel_lru_locks $OSC
5424 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5425 $STATX -c %b $DIR/$tfile
5426 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5427 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5428 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5430 run_test 106b "Glimpse RPCs test for statx"
5433 statx_supported || skip_env "statx() only test"
5438 # Mask supported in stx_attributes by Lustre is
5439 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5440 mask=$($STATX -c %p $DIR/$tfile)
5441 [[ $mask == "30" ]] ||
5442 error "supported stx_attributes: got '$mask', expected '30'"
5443 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5444 mask=$($STATX -c %r $DIR/$tfile)
5445 [[ $mask == "10" ]] ||
5446 error "got immutable flags '$mask', expected '10'"
5447 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5448 mask=$($STATX -c %r $DIR/$tfile)
5449 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5450 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5451 mask=$($STATX -c %r $DIR/$tfile)
5452 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5453 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5454 mask=$($STATX -c %r $DIR/$tfile)
5455 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5456 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5457 mask=$($STATX -c %r $DIR/$tfile)
5458 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5459 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5460 mask=$($STATX -c %r $DIR/$tfile)
5461 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5463 run_test 106c "Verify statx attributes mask"
5465 test_107a() { # LU-1031
5466 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5470 $LFS getstripe $DIR1/$tfile
5472 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5474 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5476 kill -USR1 $MULTIPID2
5478 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5479 error "First grouplock does not block second one"
5481 echo "First grouplock blocks second one"
5483 kill -USR1 $MULTIPID1
5487 run_test 107a "Basic grouplock conflict"
5490 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5494 $LFS getstripe $DIR1/$tfile
5496 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5498 multiop $DIR2/$tfile Or10c &
5502 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5503 error "Grouplock does not block IO"
5505 echo "Grouplock blocks IO"
5508 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5511 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5512 error "First grouplock does not block second one"
5514 echo "First grouplock blocks second one"
5517 kill -USR1 $MULTIPID1
5520 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5521 error "Second grouplock thread disappeared"
5524 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5525 error "Second grouplock does not block IO"
5527 echo "Second grouplock blocks IO"
5530 kill -USR1 $MULTIPID3
5535 run_test 107b "Grouplock is added to the head of waiting list"
5540 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5541 error "Create $DIR1/$tfile failed"
5543 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5544 error "dd $DIR1/$tfile failed"
5545 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5546 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5548 $TRUNCATE $DIR1/$tfile 2000
5549 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5550 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5552 #define OBD_FAIL_OSC_DELAY_IO 0x414
5553 $LCTL set_param fail_val=4 fail_loc=0x80000414
5554 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5558 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5560 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5562 run_test 108a "lseek: parallel updates"
5570 skip "Clients need to be on different nodes than the servers"
5572 umount_client $MOUNT
5573 umount_client $MOUNT2
5575 echo "Starting race between client mount instances (50 iterations):"
5576 for i in {1..50}; do
5579 #define OBD_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
5580 $LCTL set_param -n fail_loc=0x80001417
5582 mount_client $MOUNT & pid1=$!
5583 mount_client $MOUNT2 & pid2=$!
5584 wait $pid1 || error "Mount $MOUNT fails with $?"
5585 wait $pid2 || error "Mount $MOUNT2 fails with $?"
5587 umount_client $MOUNT & pid1=$!
5588 umount_client $MOUNT2 & pid2=$!
5589 wait $pid1 || error "Umount $MOUNT fails with $?"
5590 wait $pid2 || error "Umount $MOUNT2 fails with $?"
5592 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
5598 mount_client $MOUNT2
5601 run_test 109 "Race with several mount instances on 1 node"
5604 local before=$(date +%s)
5611 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
5612 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
5614 # disable last_xid logic by dropping link reply
5615 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
5618 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
5619 do_facet mds1 lctl set_param fail_loc=0x534
5621 # RPC will race with its Resend and the Resend will sleep to let
5622 # the original lock to get granted & cancelled.
5624 # AST_SENT is set artificially, so an explicit conflict is not needed
5626 # The woken up Resend gets a new lock, but client does not wait for it
5629 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
5631 # Take a conflict to wait long enough to see the eviction
5634 # let the client reconnect
5636 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
5637 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
5639 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5640 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
5641 error "eviction happened: $evict before:$before")
5643 run_test 110 "do not grant another lock on resend"
5645 log "cleanup: ======================================================"
5647 # kill and wait in each test only guarentee script finish, but command in script
5648 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5649 # otherwise umount below will fail
5650 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5655 check_and_cleanup_lustre