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")
392 # to allocate grant because it may run out due to test_15.
393 $LFS setstripe -c -1 $file1
394 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
395 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
398 $LFS setstripe -c -1 $file1 # b=10919
399 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
403 # O_DIRECT reads and writes must be aligned to the device block size.
404 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
405 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
407 run_test 16a "$FSXNUM iterations of dual-mount fsx"
409 # Consistency check for tiny writes, LU-9409
411 local file1=$DIR1/$tfile
412 local file2=$DIR2/$tfile
413 local stripe_size=($($LFS getstripe -S $DIR))
415 # to allocate grant because it may run out due to test_15.
416 lfs setstripe -c -1 $file1
417 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
418 error "dd failed writing to file=$file1"
419 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
420 error "dd failed writing to file=$file2"
423 lfs setstripe -c -1 $file1 # b=10919
424 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
425 # create a mix of tiny writes & normal writes
426 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
427 $file1 $file2 || error "fsx with tiny write failed."
429 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
432 local file1=$DIR1/$tfile
433 local file2=$DIR2/$tfile
434 local stripe_size=$(do_facet $SINGLEMDS \
435 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
437 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
439 # to allocate grant because it may run out due to test_15.
440 $LFS setstripe -c -1 $file1
441 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
442 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
444 wait_delete_completed
446 local list=$(comma_list $(osts_nodes))
447 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
448 skip "not cache-capable obdfilter"
451 set_osd_param $list '' read_cache_enable 0
452 set_osd_param $list '' writethrough_cache_enable 0
454 $LFS setstripe -c -1 $file1 # b=10919
455 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
459 set_osd_param $list '' read_cache_enable 1
460 set_osd_param $list '' writethrough_cache_enable 1
464 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
467 local file1=$DIR1/$tfile
468 local file2=$DIR2/$tfile
469 local file3=$DIR1/file
470 local stripe_size=$(do_facet $SINGLEMDS \
471 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
473 # to allocate grant because it may run out due to test_15.
474 $LFS setstripe -c -1 $file1
475 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
476 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
479 local tmpfile=`mktemp`
480 $LFS setstripe -c -1 $file1 # b=10919
481 $LCTL set_param ldlm.namespaces.*.lru_size=clear
483 # direct write on one client and direct read from another
484 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
485 dd if=$file2 of=$tmpfile iflag=direct bs=1M
486 diff $file1 $tmpfile || error "file different(1)"
489 # buffer write on one client, but direct read from another
490 dd if=$tmpfile of=$file1 bs=1M count=100
491 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
492 diff $file3 $tmpfile || error "file different(2)"
494 rm -f $file3 $file2 $file1
495 # direct write on one client
496 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
497 # buffer read from another client
498 dd if=$file2 of=$file3 bs=1M count=100
499 diff $file3 $tmpfile || error "file different(3)"
501 rm -f $file1 $file2 $file3 $tmpfile
504 run_test 16d "Verify DIO and buffer IO with two clients"
506 test_16e() { # LU-13227
507 local file1=$DIR1/$tfile
508 local file2=$DIR2/$tfile
510 # client1 write 10M data
511 dd if=/dev/zero of=$file1 bs=1M count=10
513 cancel_lru_locks osc > /dev/null
514 # use lockahead to generate one PW lock to keep LVB loaded.
515 $LFS ladvise -a lockahead --start 0 --length 1M \
517 # direct write to extend file size on client2
518 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
519 oflag=direct conv=notrunc
520 local filesize=$(stat -c %s $file2)
521 [ "$filesize" -eq 22020096 ] ||
522 error "expected filesize 22020096 got $filesize"
525 run_test 16e "Verify size consistency for O_DIRECT write"
527 test_17() { # bug 3513, 3667
528 remote_ost_nodsh && skip "remote OST with nodsh" && return
530 lfs setstripe $DIR1/$tfile -i 0 -c 1
531 cp $SAMPLE_FILE $DIR1/$tfile
532 cancel_lru_locks osc > /dev/null
533 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
534 do_facet ost1 lctl set_param fail_loc=0x8000030a
535 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
536 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
538 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
540 run_test 17 "resource creation/LVB creation race ==============="
543 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
546 for idx in {a..z}; do
547 local ptr=EXCEPT_ALWAYS_18$idx
548 [ x${!ptr} = xtrue ] || continue
550 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
553 excepts="$excepts -e 7 -e 8 -e 9"
554 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
555 error "mmap_sanity test failed"
558 run_test 18 "mmap sanity check ================================="
560 test_19() { # bug3811
561 local node=$(facet_active_host ost1)
563 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
565 # check whether obdfilter is cache capable at all
566 get_osd_param $node '' read_cache_enable >/dev/null ||
567 skip "not cache-capable obdfilter"
569 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
570 set_osd_param $node '' readcache_max_filesize 4096
571 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
572 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
573 cp $TMP/$tfile $DIR1/$tfile
574 for i in `seq 1 20`; do
575 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
576 cancel_lru_locks $OSC > /dev/null
577 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
578 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
580 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
581 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
582 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
583 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
585 set_osd_param $node '' readcache_max_filesize $MAX
588 run_test 19 "test concurrent uncached read races ==============="
591 test_mkdir $DIR1/$tdir
593 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
594 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
595 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
596 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
598 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
599 [[ $CNT2 == $CNT ]] ||
600 error $((CNT2 - CNT))" page left in cache after lock cancel"
602 run_test 20 "test extra readahead page left in cache ===="
609 test_21() { # Bug 5907
610 test_mkdir $DIR1/$tdir
611 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
613 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
614 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
615 test -d $DIR1/$tdir || error "Mounted directory disappeared"
617 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
620 run_test 21 " Try to remove mountpoint on another dir ===="
622 test_23() { # Bug 5972
623 local at_diff=$(do_facet $SINGLEMDS \
624 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
625 echo "atime should be updated while another read" > $DIR1/$tfile
627 # clear the lock(mode: LCK_PW) gotten from creating operation
628 cancel_lru_locks $OSC
631 sleep $((at_diff + 1))
633 echo "starting reads"
634 multiop_bg_pause $DIR1/$tfile or20_c || return 1
635 # with SOM and opencache enabled, we need to close a file and cancel
636 # open lock to get atime propogated to MDS
637 kill -USR1 $! || return 2
640 time2=$(stat -c "%X" $DIR/$tfile)
641 echo "new atime is $time2"
643 [ $time2 -gt $time1 ] || error "atime was not updated"
644 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
647 run_test 23 " others should see updated atime while another read===="
651 lfs df || error "lfs df failed"
652 lfs df -ih || error "lfs df -ih failed"
653 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
654 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
655 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
656 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
658 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
659 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
660 lctl --device %osc deactivate
661 lfs df -i || error "lfs df -i with deactivated OSC failed"
662 lctl --device %osc activate
663 lfs df || error "lfs df with reactivated OSC failed"
665 run_test 24a "lfs df [-ih] [path] test ========================="
669 fsnum=$(lfs_df | grep -c "summary")
670 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
672 run_test 24b "lfs df should show both filesystems ==============="
675 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
677 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
680 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
681 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
683 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
684 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
685 error "setfacl $DIR2/$tdir #1"
686 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
687 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
688 error "setfacl $DIR2/$tdir #2"
689 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
690 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
691 error "setfacl $DIR2/$tdir #3"
692 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
693 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
694 error "setfacl $DIR2/$tdir #4"
695 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
699 run_test 25a "change ACL on one mountpoint be seen on another ==="
702 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
704 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
706 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
709 $LFS mkdir -i 1 $DIR1/$tdir
710 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
711 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
713 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
714 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
715 error "setfacl $DIR2/$tdir #1"
716 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
717 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
718 error "setfacl $DIR2/$tdir #2"
719 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
720 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
721 error "setfacl $DIR2/$tdir #3"
722 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
723 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
724 error "setfacl $DIR2/$tdir #4"
725 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
729 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
732 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
734 run_test 26a "allow mtime to get older"
739 echo "aaa" >> $DIR1/$tfile
741 chmod a+x $DIR2/$tfile
742 mt1=`stat -c %Y $DIR1/$tfile`
743 mt2=`stat -c %Y $DIR2/$tfile`
745 if [ x"$mt1" != x"$mt2" ]; then
746 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
749 run_test 26b "sync mtime between ost and mds"
752 cancel_lru_locks $OSC
754 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
759 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
764 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
766 lctl set_param -n ldlm.dump_namespaces ""
767 wait $DD1_PID $DD2_PID
768 [ $? -ne 0 ] && lctl dk $TMP/debug || true
770 run_test 27 "align non-overlapping extent locks from request ==="
772 test_28() { # bug 9977
773 ECHO_UUID="ECHO_osc1_UUID"
774 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
776 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
777 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
778 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
782 attach echo_client ECHO_osc1 $ECHO_UUID
786 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
787 $LCTL --device $tECHOID destroy "${tOBJID}:0"
795 # reading of 1st stripe should pass
796 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
797 # reading of 2nd stripe should fail (this stripe was destroyed)
798 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
800 # now, recreating test file
801 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
802 # reading of 1st stripe should pass
803 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
804 # reading of 2nd stripe should pass
805 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
808 run_test 28 "read/write/truncate file with lost stripes"
810 test_30() { #b=11110, LU-2523
811 test_mkdir $DIR1/$tdir
812 cp -f /bin/bash $DIR1/$tdir/bash
813 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
814 $DIR1/$tdir/bash -c 'sleep 2;
815 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
819 run_test 30 "recreate file race"
822 test_mkdir $DIR1/$tdir
823 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
824 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
825 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
826 lctl set_param fail_loc=0x314
827 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
828 awk 'BEGIN { FS="+" } /in/ {print $1}')
829 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
831 run_test 31a "voluntary cancel / blocking ast race=============="
834 remote_ost || { skip "local OST" && return 0; }
835 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
837 # make sure there is no local locks due to destroy
838 wait_mds_ost_sync || error "wait_mds_ost_sync()"
839 wait_delete_completed || error "wait_delete_completed()"
841 test_mkdir $DIR1/$tdir
842 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
843 cp /etc/hosts $DIR/$tdir/$tfile
844 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
845 lctl set_param fail_loc=0x314
846 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
847 do_facet ost1 lctl set_param fail_loc=0x316
849 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
850 lctl set_param fail_loc=0
851 do_facet ost1 lctl set_param fail_loc=0
852 # cleanup: reconnect the client back
855 run_test 31b "voluntary OST cancel / blocking ast race=============="
857 # enable/disable lockless truncate feature, depending on the arg 0/1
858 enable_lockless_truncate() {
859 lctl set_param -n $OSC.*.lockless_truncate $1
862 test_32a() { # bug 11270
863 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
864 local stripe_size=$(do_facet $SINGLEMDS \
865 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
867 save_lustre_params client "$OSC.*.lockless_truncate" > $save
868 # restore lockless_truncate default values on exit
869 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
870 cancel_lru_locks $OSC
871 enable_lockless_truncate 1
873 lfs setstripe -c -1 $DIR1/$tfile
874 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
876 clear_stats $OSC.*.${OSC}_stats
878 log "checking cached lockless truncate"
879 $TRUNCATE $DIR1/$tfile 8000000
880 $CHECKSTAT -s 8000000 $DIR2/$tfile ||
881 error "cached truncate - wrong file size"
882 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
883 error "cached truncate isn't lockless"
885 log "checking not cached lockless truncate"
886 $TRUNCATE $DIR2/$tfile 5000000
887 $CHECKSTAT -s 5000000 $DIR1/$tfile ||
888 error "not cached truncate - wrong file size"
889 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
890 error "not cached truncate isn't lockless"
892 log "disabled lockless truncate"
893 enable_lockless_truncate 0
894 clear_stats $OSC.*.${OSC}_stats
895 $TRUNCATE $DIR2/$tfile 3000000
896 $CHECKSTAT -s 3000000 $DIR1/$tfile ||
897 error "lockless truncate disabled - wrong file size"
898 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
899 error "lockless truncate disabling failed"
902 run_test 32a "lockless truncate"
904 test_32b() { # bug 11270
905 remote_ost_nodsh && skip "remote OST with nodsh" && return
908 local facets=$(get_facets OST)
909 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
911 save_lustre_params client "osc.*.contention_seconds" > $p
912 save_lustre_params $facets \
913 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
914 save_lustre_params $facets \
915 "ldlm.namespaces.filter-*.contended_locks" >> $p
916 save_lustre_params $facets \
917 "ldlm.namespaces.filter-*.contention_seconds" >> $p
918 clear_stats $OSC.*.${OSC}_stats
920 # agressive lockless i/o settings
921 do_nodes $(comma_list $(osts_nodes)) \
922 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
923 ldlm.namespaces.filter-*.contended_locks=0 \
924 ldlm.namespaces.filter-*.contention_seconds=60"
925 lctl set_param -n $OSC.*.contention_seconds=60
927 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
929 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
932 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
933 error "lockless i/o was not triggered"
934 # disable lockless i/o (it is disabled by default)
935 do_nodes $(comma_list $(osts_nodes)) \
936 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
937 ldlm.namespaces.filter-*.contended_locks=32 \
938 ldlm.namespaces.filter-*.contention_seconds=0"
939 # set contention_seconds to 0 at client too, otherwise Lustre still
940 # remembers lock contention
941 lctl set_param -n $OSC.*.contention_seconds=0
942 clear_stats $OSC.*.${OSC}_stats
944 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
946 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
949 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
950 error "lockless i/o works when disabled"
952 restore_lustre_params <$p
955 run_test 32b "lockless i/o"
959 local mdts=$(get_facets MDS)
964 for mds in ${mdts//,/ }; do
966 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
967 xargs readlink -f" ))
968 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
971 stat=$(( stat + val))
976 # commit on sharing tests
978 remote_mds_nodsh && skip "remote MDS with nodsh" && return
980 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
981 [ $CLIENTCOUNT -lt 2 ] &&
982 skip "Need two or more clients, have $CLIENTCOUNT"
984 local nfiles=${TEST33_NFILES:-10000}
985 local param_file=$TMP/$tfile-params
991 save_lustre_params $(get_facets MDS) \
992 "mdt.*.commit_on_sharing" > $param_file
995 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
999 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1001 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1002 echo "=== START createmany old: $jbdold transaction"
1003 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")
1004 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1005 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1006 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1007 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1008 avgtime=$(( avgtime + elapsed ))
1010 eval cos${COS}_jbd=$((avgjbd / 3))
1011 eval cos${COS}_time=$((avgtime / 3))
1014 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1015 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1016 [ "$cos0_jbd" != 0 ] &&
1017 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1018 [ "$cos0_time" != 0 ] &&
1019 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1021 restore_lustre_params < $param_file
1025 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1027 # commit on sharing tests
1029 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1031 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1032 [ $CLIENTCOUNT -ge 2 ] ||
1033 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1037 local nfiles=${TEST33_NFILES:-10000}
1038 local param_file=$TMP/$tfile-params
1040 save_lustre_params $(get_facets MDS) \
1041 "mdt.*.commit_on_sharing" > $param_file
1050 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1054 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1055 $DIR1/$tdir-\\\$(hostname)-$i"
1057 jbdold=$(print_jbd_stat)
1058 echo "=== START createmany old: $jbdold transaction"
1059 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1060 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1061 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1063 jbdnew=$(print_jbd_stat)
1064 jbd=$(( jbdnew - jbdold ))
1065 echo "=== END createmany new: $jbdnew transaction : \
1066 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1067 avgjbd=$(( avgjbd + jbd ))
1068 avgtime=$(( avgtime + elapsed ))
1070 eval cos${COS}_jbd=$((avgjbd / 3))
1071 eval cos${COS}_time=$((avgtime / 3))
1074 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1075 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1076 [ "$cos0_jbd" != 0 ] &&
1077 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1078 [ "$cos0_time" != 0 ] &&
1079 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1081 restore_lustre_params < $param_file
1085 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1088 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1089 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1090 skip "DNE CoS not supported"
1094 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1100 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1101 # do twice in case transaction is committed before unlock, see LU-8200
1103 # remote dir is created on MDT1, which enqueued lock of $tdir on
1105 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1106 mkdir $DIR/$tdir/local.$i
1108 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1109 echo "sync_count $sync_count"
1110 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1113 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1114 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1115 # during sleep remote mkdir should have been committed and canceled
1116 # remote lock spontaneously, which shouldn't trigger sync
1118 mkdir $DIR/$tdir/local.3
1119 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1120 echo "sync_count $sync_count"
1121 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1123 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1125 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1129 local nodes=$(comma_list $(mdts_nodes))
1133 # trigger CoS twice in case transaction commit before unlock
1136 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1138 commit_nr=$(do_nodes $nodes \
1139 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1140 total=$((total + commit_nr));
1145 echo "CoS count $total"
1146 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1150 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1151 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1152 skip "DNE CoS not supported"
1154 # remote directory create
1155 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1156 # remote directory unlink
1157 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1158 # striped directory create
1159 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1160 # striped directory setattr
1161 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1162 "chmod 713 $DIR/$tdir"
1163 # striped directory unlink
1164 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1167 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1168 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1169 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1170 touch $DIR/$tdir/d1/tgt" \
1171 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1173 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1174 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1175 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1176 touch $DIR/$tdir/d1/src" \
1177 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1179 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1180 "$LFS migrate -m 1 $DIR/$tdir"
1184 run_test 33d "DNE distributed operation should trigger COS"
1187 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1188 [ $CLIENTCOUNT -ge 2 ] ||
1189 skip "Need two or more clients, have $CLIENTCOUNT"
1190 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1191 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1192 skip "DNE CoS not supported"
1194 local client2=${CLIENT2:-$(hostname)}
1198 local nodes=$(comma_list $(mdts_nodes))
1199 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1201 $LFS mkdir -c 2 $DIR/$tdir
1202 mkdir $DIR/$tdir/subdir
1203 echo abc > $DIR/$tdir/$tfile
1204 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1205 do_node $client2 touch $DIR/$tdir/subdir
1207 local async_commit_count=$(do_nodes $nodes \
1208 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1209 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1213 run_test 33e "DNE local operation shouldn't trigger COS"
1215 # End commit on sharing tests
1217 get_ost_lock_timeouts() {
1218 local nodes=${1:-$(comma_list $(osts_nodes))}
1220 local locks=$(do_nodes $nodes \
1221 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1229 do_nodes $(comma_list $(osts_nodes)) \
1230 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1231 for i in $(seq $OSTCOUNT); do
1232 wait_osc_import_ready client ost$i
1237 remote_ost_nodsh && skip "remote OST with nodsh" && return
1241 trap cleanup_34 EXIT RETURN
1242 for OPER in notimeout timeout ; do
1243 rm $DIR1/$tfile 2>/dev/null
1244 lock_in=$(get_ost_lock_timeouts)
1245 if [ $OPER == "timeout" ] ; then
1246 for j in `seq $OSTCOUNT`; do
1247 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1248 do_facet ost$j lctl set_param fail_loc=0x511
1250 echo lock should expire
1252 for j in `seq $OSTCOUNT`; do
1253 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1254 do_facet ost$j lctl set_param fail_loc=0x512
1256 echo lock should not expire
1258 echo writing on client1
1259 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1261 echo reading on client2
1262 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1263 # wait for a lock timeout
1265 lock_out=$(get_ost_lock_timeouts)
1266 if [ $OPER == "timeout" ] ; then
1267 if [ $lock_in == $lock_out ]; then
1268 error "no lock timeout happened"
1273 if [ $lock_in != $lock_out ]; then
1274 error "lock timeout happened"
1282 run_test 34 "no lock timeout under IO"
1284 test_35() { # bug 17645
1287 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1288 awk '/generation/{print $2}')
1290 generation[count]=$g
1294 test_mkdir $MOUNT1/$tdir
1295 cancel_lru_locks mdc
1297 # Let's initiate -EINTR situation by setting fail_loc and take
1298 # write lock on same file from same client. This will not cause
1299 # bl_ast yet as lock is already in local cache.
1300 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1301 do_facet client "lctl set_param fail_loc=0x80000317"
1302 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1303 let timeout=timeout*3
1305 while test $nr -lt 10; do
1306 log "Race attempt $nr"
1307 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1308 awk '/ldlm_bl_callback/ { print $2 }')
1309 test "x$blk1" = "x" && blk1=0
1310 createmany -o $MOUNT2/$tdir/a 4000 &
1314 # Let's make conflict and bl_ast
1315 ls -la $MOUNT1/$tdir > /dev/null &
1318 log "Wait for $pid1 $pid2 for $timeout sec..."
1320 kill -9 $pid1 $pid2 > /dev/null 2>&1
1322 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1323 awk '/ldlm_bl_callback/ { print $2 }')
1324 test "x$blk2" = "x" && blk2=0
1325 test $blk2 -gt $blk1 && break
1326 rm -fr $MOUNT1/$tdir
1327 cancel_lru_locks mdc
1330 do_facet client "lctl set_param fail_loc=0x0"
1331 df -h $MOUNT1 $MOUNT2
1333 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1334 awk '/generation/{print $2}')
1336 if ! test "$g" -eq "${generation[count]}"; then
1337 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1339 for imp in $list; do
1340 if [ $c = $count ]; then
1345 imp=$(echo "$imp" | awk -F"." '{print $2}')
1346 error "Eviction happened on import $imp"
1351 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1353 test_36() { #bug 16417
1358 test_mkdir $DIR1/$tdir
1359 $LFS setstripe -c -1 $DIR1/$tdir
1362 let SIZE_B=SIZE*1024*1024
1363 sync; sleep 2; sync # wait for delete thread
1364 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1365 wait_destroy_complete || error "wait_destroy_complete failed"
1367 while [ $i -le 10 ]; do
1368 lctl mark "start test - cycle ($i)"
1369 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1370 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1371 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1372 sync # sync data from client cache
1373 sync_all_data # sync data from server cache (delayed allocation)
1375 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1376 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1378 rm -f $DIR1/$tdir/$tfile
1379 kill -USR1 $read_pid
1381 sync; sleep 2; sync # Ensure new statfs
1382 wait_delete_completed
1383 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1384 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1386 # this free space! not used
1387 (( $after_dd <= $after)) ||
1388 error "space leaked after_dd:$after_dd > after:$after"
1392 run_test 36 "handle ESTALE/open-unlink correctly"
1394 test_37() { # bug 18695
1395 test_mkdir $DIR1/$tdir
1396 multiop_bg_pause $DIR1/$tdir D_c || return 1
1398 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1399 createmany -m $DIR2/$tdir/f 10000
1400 # set mtime/atime backward
1401 touch -t 198001010000 $DIR2/$tdir
1402 kill -USR1 $MULTIPID
1403 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1404 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1407 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1409 # this should be set to past
1410 TEST_39_MTIME=`date -d "1 year ago" +%s`
1414 local client1=${CLIENT1:-`hostname`}
1415 local client2=${CLIENT2:-`hostname`}
1417 do_node $client1 "touch $DIR1/$tfile"
1419 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1420 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1421 [ "$mtime1" = $TEST_39_MTIME ] || \
1422 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1424 local d1=`do_node $client1 date +%s`
1425 do_node $client1 'echo hello >> '$DIR1/$tfile
1426 local d2=`do_node $client1 date +%s`
1428 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1429 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1430 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1432 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1434 for (( i=0; i < 2; i++ )) ; do
1435 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1436 [ "$mtime2" = "$mtime3" ] || \
1437 error "mtime ($mtime2) changed (to $mtime3) on rename"
1439 cancel_lru_locks osc
1440 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1443 run_test 39a "test from 11063 =================================="
1446 local client1=${CLIENT1:-`hostname`}
1447 local client2=${CLIENT2:-`hostname`}
1451 local mtime1=`stat -c %Y $DIR1/$tfile`
1452 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1455 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1457 for (( i=0; i < 2; i++ )) ; do
1458 local mtime3=`stat -c %Y $DIR1/$tfile`
1459 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1461 [ "$mtime3" = "$mtime4" ] || \
1462 error "different mtime on clients: $mtime3, $mtime4"
1463 [ "$mtime3" = $TEST_39_MTIME ] || \
1464 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1466 cancel_lru_locks osc
1467 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1470 run_test 39b "11063 problem 1 =================================="
1473 local client1=${CLIENT1:-`hostname`}
1474 local client2=${CLIENT2:-`hostname`}
1476 echo hello > $DIR1/$tfile
1478 local mtime1=`stat -c %Y $DIR1/$tfile`
1479 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1480 [ "$mtime1" = "$mtime2" ] || \
1481 error "create: different mtime on clients: $mtime1, $mtime2"
1484 $TRUNCATE $DIR1/$tfile 1
1486 for (( i=0; i < 2; i++ )) ; do
1487 local mtime3=`stat -c %Y $DIR1/$tfile`
1488 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1490 [ "$mtime3" = "$mtime4" ] || \
1491 error "different mtime on clients: $mtime3, $mtime4"
1492 [ "$mtime3" -gt $mtime2 ] || \
1493 error "truncate did not update mtime: $mtime2, $mtime3"
1495 cancel_lru_locks osc
1496 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1499 run_test 39c "check truncate mtime update ======================"
1501 test_39d() { # LU-7310
1503 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1505 local mtime1=$(stat -c %Y $DIR2/$tfile)
1506 [ "$mtime1" = $TEST_39_MTIME ] ||
1507 error "mtime: $mtime1, should be $TEST_39_MTIME"
1510 # define OBD_FAIL_OSC_NO_GRANT 0x411
1511 $LCTL set_param fail_loc=0x411
1513 local d1=$(date +%s)
1514 echo hello >> $DIR1/$tfile
1515 local d2=$(date +%s)
1517 $LCTL set_param fail_loc=0
1519 cancel_lru_locks $OSC
1521 local mtime2=$(stat -c %Y $DIR2/$tfile)
1522 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1523 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1525 run_test 39d "sync write should update mtime"
1528 # how long 40-47 take with specific delay
1535 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1536 # avoid unexpected delays due to previous tests
1538 cancel_lru_locks mdc
1539 do_nodes $(comma_list $(mdts_nodes)) \
1540 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1541 do_nodes $(comma_list $(mdts_nodes)) \
1542 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1543 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1546 # check that pid exists hence second operation wasn't blocked by first one
1547 # if it is so then there is no conflict, return 0
1548 # else second operation is conflicting with first one, return 1
1549 check_pdo_conflict() {
1552 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1553 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1563 # test 40: check non-blocking operations
1565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1567 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1568 do_nodes $(comma_list $(mdts_nodes)) \
1569 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1571 mkdir $DIR1/$tfile &
1573 touch $DIR2/$tfile-2
1574 check_pdo_conflict $PID1 || error "create is blocked"
1575 mkdir $DIR2/$tfile-3
1576 check_pdo_conflict $PID1 || error "mkdir is blocked"
1577 link $DIR2/$tfile-2 $DIR2/$tfile-4
1578 check_pdo_conflict $PID1 || error "link is blocked"
1579 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1580 check_pdo_conflict $PID1 || error "rename is blocked"
1581 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1582 check_pdo_conflict $PID1 || error "getattr is blocked"
1583 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1584 rmdir $DIR2/$tfile-3
1585 check_pdo_conflict $PID1 || error "unlink is blocked"
1587 # all operations above shouldn't wait the first one
1588 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1589 do_nodes $(comma_list $(mdts_nodes)) \
1590 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1595 run_test 40a "pdirops: create vs others =============="
1598 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1600 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1601 do_nodes $(comma_list $(mdts_nodes)) \
1602 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1603 touch $DIR1/$tfile &
1606 touch $DIR2/$tfile-2
1607 check_pdo_conflict $PID1 || error "create is blocked"
1608 mkdir $DIR2/$tfile-3
1609 check_pdo_conflict $PID1 || error "mkdir is blocked"
1610 link $DIR2/$tfile-2 $DIR2/$tfile-4
1611 check_pdo_conflict $PID1 || error "link is blocked"
1612 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1613 check_pdo_conflict $PID1 || error "rename is blocked"
1614 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1615 check_pdo_conflict $PID1 || error "getattr is blocked"
1616 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1617 rmdir $DIR2/$tfile-3
1618 check_pdo_conflict $PID1 || error "unlink is blocked"
1619 # all operations above shouldn't wait the first one
1621 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1622 do_nodes $(comma_list $(mdts_nodes)) \
1623 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1628 run_test 40b "pdirops: open|create and others =============="
1631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1634 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1635 do_nodes $(comma_list $(mdts_nodes)) \
1636 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1637 link $DIR1/$tfile $DIR1/$tfile-0 &
1640 touch $DIR2/$tfile-2
1641 check_pdo_conflict $PID1 || error "create is blocked"
1642 mkdir $DIR2/$tfile-3
1643 check_pdo_conflict $PID1 || error "mkdir is blocked"
1644 link $DIR2/$tfile-2 $DIR2/$tfile-4
1645 check_pdo_conflict $PID1 || error "link is blocked"
1646 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1647 check_pdo_conflict $PID1 || error "rename is blocked"
1648 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1649 check_pdo_conflict $PID1 || error "getattr is blocked"
1650 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1651 rmdir $DIR2/$tfile-3
1652 check_pdo_conflict $PID1 || error "unlink is blocked"
1654 # all operations above shouldn't wait the first one
1655 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1656 do_nodes $(comma_list $(mdts_nodes)) \
1657 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1662 run_test 40c "pdirops: link and others =============="
1665 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1668 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1669 do_nodes $(comma_list $(mdts_nodes)) \
1670 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1674 touch $DIR2/$tfile-2
1675 check_pdo_conflict $PID1 || error "create is blocked"
1676 mkdir $DIR2/$tfile-3
1677 check_pdo_conflict $PID1 || error "mkdir is blocked"
1678 link $DIR2/$tfile-2 $DIR2/$tfile-4
1679 check_pdo_conflict $PID1 || error "link is blocked"
1680 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1681 check_pdo_conflict $PID1 || error "rename is blocked"
1682 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1683 check_pdo_conflict $PID1 || error "getattr is blocked"
1684 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1685 rmdir $DIR2/$tfile-3
1686 check_pdo_conflict $PID1 || error "unlink is blocked"
1688 # all operations above shouldn't wait the first one
1689 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1690 do_nodes $(comma_list $(mdts_nodes)) \
1691 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1695 run_test 40d "pdirops: unlink and others =============="
1698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1701 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1702 do_nodes $(comma_list $(mdts_nodes)) \
1703 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1704 mv $DIR1/$tfile $DIR1/$tfile-0 &
1707 touch $DIR2/$tfile-2
1708 check_pdo_conflict $PID1 || error "create is blocked"
1709 mkdir $DIR2/$tfile-3
1710 check_pdo_conflict $PID1 || error "mkdir is blocked"
1711 link $DIR2/$tfile-2 $DIR2/$tfile-4
1712 check_pdo_conflict $PID1 || error "link is blocked"
1713 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1714 check_pdo_conflict $PID1 || error "getattr is blocked"
1715 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1716 rmdir $DIR2/$tfile-3
1717 check_pdo_conflict $PID1 || error "unlink is blocked"
1719 # all operations above shouldn't wait the first one
1720 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1721 do_nodes $(comma_list $(mdts_nodes)) \
1722 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1727 run_test 40e "pdirops: rename and others =============="
1729 # test 41: create blocking operations
1732 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1733 do_nodes $(comma_list $(mdts_nodes)) \
1734 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1735 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1737 mkdir $DIR2/$tfile &
1739 do_nodes $(comma_list $(mdts_nodes)) \
1740 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1741 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1742 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1746 run_test 41a "pdirops: create vs mkdir =============="
1750 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1751 do_nodes $(comma_list $(mdts_nodes)) \
1752 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1753 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1755 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1757 do_nodes $(comma_list $(mdts_nodes)) \
1758 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1760 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1764 run_test 41b "pdirops: create vs create =============="
1768 touch $DIR1/$tfile-2
1769 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1770 do_nodes $(comma_list $(mdts_nodes)) \
1771 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1772 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1774 link $DIR2/$tfile-2 $DIR2/$tfile &
1776 do_nodes $(comma_list $(mdts_nodes)) \
1777 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1778 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1779 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1783 run_test 41c "pdirops: create vs link =============="
1787 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1788 do_nodes $(comma_list $(mdts_nodes)) \
1789 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1790 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1794 do_nodes $(comma_list $(mdts_nodes)) \
1795 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1796 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1797 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1801 run_test 41d "pdirops: create vs unlink =============="
1805 touch $DIR1/$tfile-2
1806 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1807 do_nodes $(comma_list $(mdts_nodes)) \
1808 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1809 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1811 mv $DIR2/$tfile-2 $DIR2/$tfile &
1813 do_nodes $(comma_list $(mdts_nodes)) \
1814 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1815 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1816 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1820 run_test 41e "pdirops: create and rename (tgt) =============="
1824 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1825 do_nodes $(comma_list $(mdts_nodes)) \
1826 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1827 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1829 mv $DIR2/$tfile $DIR2/$tfile-2 &
1831 do_nodes $(comma_list $(mdts_nodes)) \
1832 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1833 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1834 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1838 run_test 41f "pdirops: create and rename (src) =============="
1842 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1843 do_nodes $(comma_list $(mdts_nodes)) \
1844 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1845 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1847 stat $DIR2/$tfile > /dev/null &
1849 do_nodes $(comma_list $(mdts_nodes)) \
1850 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1851 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1852 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1856 run_test 41g "pdirops: create vs getattr =============="
1860 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1861 do_nodes $(comma_list $(mdts_nodes)) \
1862 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1863 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1865 ls -lia $DIR2/ > /dev/null &
1867 do_nodes $(comma_list $(mdts_nodes)) \
1868 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1869 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1874 run_test 41h "pdirops: create vs readdir =============="
1881 do_nodes $(comma_list $(mdts_nodes)) \
1882 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1884 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1887 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1890 if ! wait $PID1 && ! wait $PID2; then
1891 echo "Both creates failed (1 should fail, 1 should succeed)"
1893 elif wait $PID1 && wait $PID2; then
1894 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1899 do_nodes $(comma_list $(mdts_nodes)) \
1900 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1907 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1908 skip "Need MDS version newer than 2.13.56"
1911 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1912 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1913 for fail_loc in "0x80000169" "0x8000016a"; do
1914 echo "Begin 100 tests with fail_loc=$fail_loc"
1916 for i in {1..100}; do
1918 msg=$(sub_test_41i "$fail_loc") ||
1919 { echo; error "iter=$i : $msg"; }
1924 run_test 41i "reint_open: create vs create"
1927 # test 42: unlink and blocking operations
1930 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1931 do_nodes $(comma_list $(mdts_nodes)) \
1932 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1933 mkdir $DIR1/$tfile &
1935 mkdir $DIR2/$tfile &
1937 do_nodes $(comma_list $(mdts_nodes)) \
1938 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1939 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1940 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1944 run_test 42a "pdirops: mkdir vs mkdir =============="
1948 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1949 do_nodes $(comma_list $(mdts_nodes)) \
1950 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1951 mkdir $DIR1/$tfile &
1953 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1955 do_nodes $(comma_list $(mdts_nodes)) \
1956 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1957 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1958 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1962 run_test 42b "pdirops: mkdir vs create =============="
1966 touch $DIR1/$tfile-2
1967 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1968 do_nodes $(comma_list $(mdts_nodes)) \
1969 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1970 mkdir $DIR1/$tfile &
1972 link $DIR2/$tfile-2 $DIR2/$tfile &
1974 do_nodes $(comma_list $(mdts_nodes)) \
1975 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1976 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1977 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1981 run_test 42c "pdirops: mkdir vs link =============="
1985 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1986 do_nodes $(comma_list $(mdts_nodes)) \
1987 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1988 mkdir $DIR1/$tfile &
1990 rmdir $DIR2/$tfile &
1992 do_nodes $(comma_list $(mdts_nodes)) \
1993 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1994 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1995 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1999 run_test 42d "pdirops: mkdir vs unlink =============="
2003 touch $DIR1/$tfile-2
2004 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2005 do_nodes $(comma_list $(mdts_nodes)) \
2006 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2007 mkdir $DIR1/$tfile &
2009 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2011 do_nodes $(comma_list $(mdts_nodes)) \
2012 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2013 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2014 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2018 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2022 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2023 do_nodes $(comma_list $(mdts_nodes)) \
2024 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2025 mkdir $DIR1/$tfile &
2027 mv $DIR2/$tfile $DIR2/$tfile-2 &
2029 do_nodes $(comma_list $(mdts_nodes)) \
2030 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2031 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2032 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2036 run_test 42f "pdirops: mkdir and rename (src) =============="
2040 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2041 do_nodes $(comma_list $(mdts_nodes)) \
2042 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2043 mkdir $DIR1/$tfile &
2045 stat $DIR2/$tfile > /dev/null &
2047 do_nodes $(comma_list $(mdts_nodes)) \
2048 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2049 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2050 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2054 run_test 42g "pdirops: mkdir vs getattr =============="
2058 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2059 do_nodes $(comma_list $(mdts_nodes)) \
2060 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2061 mkdir $DIR1/$tfile &
2063 ls -lia $DIR2/ > /dev/null &
2065 do_nodes $(comma_list $(mdts_nodes)) \
2066 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2067 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2072 run_test 42h "pdirops: mkdir vs readdir =============="
2074 # test 43: rmdir,mkdir won't return -EEXIST
2076 for i in {1..1000}; do
2077 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2078 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2082 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2087 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2088 do_nodes $(comma_list $(mdts_nodes)) \
2089 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2092 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2094 do_nodes $(comma_list $(mdts_nodes)) \
2095 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2096 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2097 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2101 run_test 43b "pdirops: unlink vs create =============="
2106 touch $DIR1/$tfile-2
2107 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2108 do_nodes $(comma_list $(mdts_nodes)) \
2109 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2112 link $DIR2/$tfile-2 $DIR2/$tfile &
2114 do_nodes $(comma_list $(mdts_nodes)) \
2115 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2116 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2117 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2121 run_test 43c "pdirops: unlink vs link =============="
2126 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2127 do_nodes $(comma_list $(mdts_nodes)) \
2128 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2133 do_nodes $(comma_list $(mdts_nodes)) \
2134 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2135 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2136 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2140 run_test 43d "pdirops: unlink vs unlink =============="
2145 touch $DIR1/$tfile-2
2146 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2147 do_nodes $(comma_list $(mdts_nodes)) \
2148 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2151 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2153 do_nodes $(comma_list $(mdts_nodes)) \
2154 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2155 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2156 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2160 run_test 43e "pdirops: unlink and rename (tgt) =============="
2165 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2166 do_nodes $(comma_list $(mdts_nodes)) \
2167 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2170 mv $DIR2/$tfile $DIR2/$tfile-2 &
2172 do_nodes $(comma_list $(mdts_nodes)) \
2173 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2174 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2175 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2179 run_test 43f "pdirops: unlink and rename (src) =============="
2184 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2185 do_nodes $(comma_list $(mdts_nodes)) \
2186 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2189 stat $DIR2/$tfile > /dev/null &
2191 do_nodes $(comma_list $(mdts_nodes)) \
2192 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2193 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2194 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2198 run_test 43g "pdirops: unlink vs getattr =============="
2203 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2204 do_nodes $(comma_list $(mdts_nodes)) \
2205 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2208 ls -lia $DIR2/ > /dev/null &
2210 do_nodes $(comma_list $(mdts_nodes)) \
2211 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2212 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2217 run_test 43h "pdirops: unlink vs readdir =============="
2220 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2223 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2224 do_nodes $(comma_list $(mdts_nodes)) \
2225 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2228 $LFS mkdir -i 1 $DIR2/$tfile &
2230 do_nodes $(comma_list $(mdts_nodes)) \
2231 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2232 check_pdo_conflict $PID1 &&
2233 { wait $PID1; error "remote mkdir isn't blocked"; }
2234 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2238 run_test 43i "pdirops: unlink vs remote mkdir"
2241 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2242 skip "Need MDS version newer than 2.13.52"
2244 for i in {1..100}; do
2245 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2246 do_nodes $(comma_list $(mdts_nodes)) \
2247 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2252 mkdir $DIR2/$tdir && ((OK++))
2253 wait $PID1 && ((OK++))
2254 (( OK == 1 )) || error "exactly one mkdir should succeed"
2256 rmdir $DIR1/$tdir || error "rmdir failed"
2260 run_test 43j "racy mkdir return EEXIST =============="
2267 # We test in a separate directory to be able to unblock server thread in
2268 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2269 test_mkdir $DIR2/$tdir
2270 touch $DIR2/$tdir/$tfile
2272 do_nodes $(comma_list $(mdts_nodes)) \
2273 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2274 echo content > $DIR1/$tdir/$tfile & PID1=$!
2276 multiop $DIR2/$tdir/$tfile u & PID2=$!
2280 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2283 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2286 do_nodes $(comma_list $(mdts_nodes)) \
2287 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2294 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2295 skip "Need MDS version newer than 2.13.56"
2298 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2299 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2300 for fail_loc in "0x80000169" "0x8000016a"; do
2301 echo "Begin 100 tests with fail_loc=$fail_loc"
2303 for i in {1..100}; do
2305 msg=$(sub_test_43k "$fail_loc") ||
2306 { echo; error "iter=$i : $msg"; }
2316 run_test 43k "unlink vs create"
2318 # test 44: rename tgt and blocking operations
2321 touch $DIR1/$tfile-2
2322 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2323 do_nodes $(comma_list $(mdts_nodes)) \
2324 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2325 mv $DIR1/$tfile-2 $DIR1/$tfile &
2327 mkdir $DIR2/$tfile &
2329 do_nodes $(comma_list $(mdts_nodes)) \
2330 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2331 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2332 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2337 run_test 44a "pdirops: rename tgt vs mkdir =============="
2341 touch $DIR1/$tfile-2
2342 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2343 do_nodes $(comma_list $(mdts_nodes)) \
2344 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2345 mv $DIR1/$tfile-2 $DIR1/$tfile &
2347 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2349 do_nodes $(comma_list $(mdts_nodes)) \
2350 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2351 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2352 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2356 run_test 44b "pdirops: rename tgt vs create =============="
2360 touch $DIR1/$tfile-2
2361 touch $DIR1/$tfile-3
2362 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2363 do_nodes $(comma_list $(mdts_nodes)) \
2364 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2365 mv $DIR1/$tfile-2 $DIR1/$tfile &
2367 link $DIR2/$tfile-3 $DIR2/$tfile &
2369 do_nodes $(comma_list $(mdts_nodes)) \
2370 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2371 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2372 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2376 run_test 44c "pdirops: rename tgt vs link =============="
2380 touch $DIR1/$tfile-2
2381 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2382 do_nodes $(comma_list $(mdts_nodes)) \
2383 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2384 mv $DIR1/$tfile-2 $DIR1/$tfile &
2388 do_nodes $(comma_list $(mdts_nodes)) \
2389 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2390 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2391 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2395 run_test 44d "pdirops: rename tgt vs unlink =============="
2400 touch $DIR1/$tfile-2
2401 touch $DIR1/$tfile-3
2402 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2403 do_nodes $(comma_list $(mdts_nodes)) \
2404 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2405 mv $DIR1/$tfile-2 $DIR1/$tfile &
2407 mv $DIR2/$tfile-3 $DIR2/$tfile &
2409 do_nodes $(comma_list $(mdts_nodes)) \
2410 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2411 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2412 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2416 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2420 touch $DIR1/$tfile-2
2421 touch $DIR1/$tfile-3
2422 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2423 do_nodes $(comma_list $(mdts_nodes)) \
2424 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2425 mv $DIR1/$tfile-2 $DIR1/$tfile &
2427 mv $DIR2/$tfile $DIR2/$tfile-3 &
2429 do_nodes $(comma_list $(mdts_nodes)) \
2430 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2431 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2432 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2436 run_test 44f "pdirops: rename tgt and rename (src) =============="
2440 touch $DIR1/$tfile-2
2441 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2442 do_nodes $(comma_list $(mdts_nodes)) \
2443 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2444 mv $DIR1/$tfile-2 $DIR1/$tfile &
2446 stat $DIR2/$tfile > /dev/null &
2448 do_nodes $(comma_list $(mdts_nodes)) \
2449 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2450 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2451 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2455 run_test 44g "pdirops: rename tgt vs getattr =============="
2459 touch $DIR1/$tfile-2
2460 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2461 do_nodes $(comma_list $(mdts_nodes)) \
2462 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2463 mv $DIR1/$tfile-2 $DIR1/$tfile &
2465 ls -lia $DIR2/ > /dev/null &
2467 do_nodes $(comma_list $(mdts_nodes)) \
2468 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2469 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2474 run_test 44h "pdirops: rename tgt vs readdir =============="
2476 # test 44: rename tgt and blocking operations
2478 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2480 touch $DIR1/$tfile-2
2481 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2482 do_nodes $(comma_list $(mdts_nodes)) \
2483 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2484 mv $DIR1/$tfile-2 $DIR1/$tfile &
2486 $LFS mkdir -i 1 $DIR2/$tfile &
2488 do_nodes $(comma_list $(mdts_nodes)) \
2489 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2490 check_pdo_conflict $PID1 && { wait $PID1;
2491 error "remote mkdir isn't blocked"; }
2492 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2496 run_test 44i "pdirops: rename tgt vs remote mkdir"
2498 # test 45: rename,mkdir doesn't fail with -EEXIST
2500 for i in {1..1000}; do
2501 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2502 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2503 error "mrename to $tdir.$i failed"
2508 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2513 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2514 do_nodes $(comma_list $(mdts_nodes)) \
2515 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2516 mv $DIR1/$tfile $DIR1/$tfile-2 &
2518 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2520 do_nodes $(comma_list $(mdts_nodes)) \
2521 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2522 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2523 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2527 run_test 45b "pdirops: rename src vs create =============="
2532 touch $DIR1/$tfile-3
2533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2534 do_nodes $(comma_list $(mdts_nodes)) \
2535 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2536 mv $DIR1/$tfile $DIR1/$tfile-2 &
2538 link $DIR2/$tfile-3 $DIR2/$tfile &
2540 do_nodes $(comma_list $(mdts_nodes)) \
2541 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2542 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2543 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2547 run_test 45c "pdirops: rename src vs link =============="
2552 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2553 do_nodes $(comma_list $(mdts_nodes)) \
2554 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2555 mv $DIR1/$tfile $DIR1/$tfile-2 &
2559 do_nodes $(comma_list $(mdts_nodes)) \
2560 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2561 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2562 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2566 run_test 45d "pdirops: rename src vs unlink =============="
2571 touch $DIR1/$tfile-3
2572 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2573 do_nodes $(comma_list $(mdts_nodes)) \
2574 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2575 mv $DIR1/$tfile $DIR1/$tfile-2 &
2577 mv $DIR2/$tfile-3 $DIR2/$tfile &
2579 do_nodes $(comma_list $(mdts_nodes)) \
2580 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2581 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2582 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2586 run_test 45e "pdirops: rename src and rename (tgt) =============="
2591 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2592 do_nodes $(comma_list $(mdts_nodes)) \
2593 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2594 mv $DIR1/$tfile $DIR1/$tfile-2 &
2596 mv $DIR2/$tfile $DIR2/$tfile-3 &
2598 do_nodes $(comma_list $(mdts_nodes)) \
2599 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2600 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2601 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2605 run_test 45f "pdirops: rename src and rename (src) =============="
2610 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2611 do_nodes $(comma_list $(mdts_nodes)) \
2612 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2613 mv $DIR1/$tfile $DIR1/$tfile-2 &
2615 stat $DIR2/$tfile > /dev/null &
2617 do_nodes $(comma_list $(mdts_nodes)) \
2618 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2619 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2620 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2624 run_test 45g "pdirops: rename src vs getattr =============="
2629 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2630 do_nodes $(comma_list $(mdts_nodes)) \
2631 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2632 mv $DIR1/$tfile $DIR1/$tfile-2 &
2634 ls -lia $DIR2/ > /dev/null &
2635 do_nodes $(comma_list $(mdts_nodes)) \
2636 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2637 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2642 run_test 45h "pdirops: unlink vs readdir =============="
2645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2648 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2649 do_nodes $(comma_list $(mdts_nodes)) \
2650 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2651 mv $DIR1/$tfile $DIR1/$tfile-2 &
2653 $LFS mkdir -i 1 $DIR2/$tfile &
2655 do_nodes $(comma_list $(mdts_nodes)) \
2656 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2657 check_pdo_conflict $PID1 && { wait $PID1;
2658 error "create remote dir isn't blocked"; }
2659 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2663 run_test 45i "pdirops: rename src vs remote mkdir"
2670 # We test in a sparate directory to be able to unblock server thread in
2671 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2672 test_mkdir $DIR2/$tdir
2673 echo file1 > $DIR2/$tdir/$tfile
2674 echo file2 > $DIR2/$tdir/$tfile-2
2676 do_nodes $(comma_list $(mdts_nodes)) \
2677 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2679 cat $DIR1/$tdir/$tfile >/dev/null &
2682 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2686 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2689 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2692 do_nodes $(comma_list $(mdts_nodes)) \
2693 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2700 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2701 skip "Need MDS version newer than 2.13.56"
2704 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2705 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2706 for fail_loc in "0x80000169" "0x8000016a"; do
2707 echo "Begin 100 tests with fail_loc=$fail_loc"
2709 for i in {1..100}; do
2711 msg=$(sub_test_45j "$fail_loc") ||
2712 { echo; error "iter=$i : $msg"; }
2717 run_test 45j "read vs rename =============="
2719 # test 46: link and blocking operations
2722 touch $DIR1/$tfile-2
2723 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2724 do_nodes $(comma_list $(mdts_nodes)) \
2725 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2726 link $DIR1/$tfile-2 $DIR1/$tfile &
2728 mkdir $DIR2/$tfile &
2730 do_nodes $(comma_list $(mdts_nodes)) \
2731 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2732 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2733 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2737 run_test 46a "pdirops: link vs mkdir =============="
2741 touch $DIR1/$tfile-2
2742 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2743 do_nodes $(comma_list $(mdts_nodes)) \
2744 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2745 link $DIR1/$tfile-2 $DIR1/$tfile &
2747 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2749 do_nodes $(comma_list $(mdts_nodes)) \
2750 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2751 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2752 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2756 run_test 46b "pdirops: link vs create =============="
2760 touch $DIR1/$tfile-2
2761 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2762 do_nodes $(comma_list $(mdts_nodes)) \
2763 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2764 link $DIR1/$tfile-2 $DIR1/$tfile &
2766 link $DIR2/$tfile $DIR2/$tfile &
2768 do_nodes $(comma_list $(mdts_nodes)) \
2769 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2770 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2771 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2775 run_test 46c "pdirops: link vs link =============="
2779 touch $DIR1/$tfile-2
2780 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2781 do_nodes $(comma_list $(mdts_nodes)) \
2782 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2783 link $DIR1/$tfile-2 $DIR1/$tfile &
2787 do_nodes $(comma_list $(mdts_nodes)) \
2788 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2789 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2790 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2794 run_test 46d "pdirops: link vs unlink =============="
2798 touch $DIR1/$tfile-2
2799 touch $DIR1/$tfile-3
2800 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2801 do_nodes $(comma_list $(mdts_nodes)) \
2802 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2803 link $DIR1/$tfile-2 $DIR1/$tfile &
2805 mv $DIR2/$tfile-3 $DIR2/$tfile &
2807 do_nodes $(comma_list $(mdts_nodes)) \
2808 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2809 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2810 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2814 run_test 46e "pdirops: link and rename (tgt) =============="
2818 touch $DIR1/$tfile-2
2819 touch $DIR1/$tfile-3
2820 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2821 do_nodes $(comma_list $(mdts_nodes)) \
2822 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2823 link $DIR1/$tfile-2 $DIR1/$tfile &
2825 mv $DIR2/$tfile $DIR2/$tfile-3 &
2827 do_nodes $(comma_list $(mdts_nodes)) \
2828 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2830 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2834 run_test 46f "pdirops: link and rename (src) =============="
2838 touch $DIR1/$tfile-2
2839 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2840 do_nodes $(comma_list $(mdts_nodes)) \
2841 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2842 link $DIR1/$tfile-2 $DIR1/$tfile &
2844 stat $DIR2/$tfile > /dev/null &
2846 do_nodes $(comma_list $(mdts_nodes)) \
2847 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2848 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2849 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2853 run_test 46g "pdirops: link vs getattr =============="
2857 touch $DIR1/$tfile-2
2858 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2859 do_nodes $(comma_list $(mdts_nodes)) \
2860 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2861 link $DIR1/$tfile-2 $DIR1/$tfile &
2863 ls -lia $DIR2/ > /dev/null &
2865 do_nodes $(comma_list $(mdts_nodes)) \
2866 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2867 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2872 run_test 46h "pdirops: link vs readdir =============="
2875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2877 touch $DIR1/$tfile-2
2878 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2879 do_nodes $(comma_list $(mdts_nodes)) \
2880 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2881 link $DIR1/$tfile-2 $DIR1/$tfile &
2883 $LFS mkdir -i 1 $DIR2/$tfile &
2885 do_nodes $(comma_list $(mdts_nodes)) \
2886 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2887 check_pdo_conflict $PID1 && { wait $PID1;
2888 error "remote mkdir isn't blocked"; }
2889 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2893 run_test 46i "pdirops: link vs remote mkdir"
2895 # test 47: remote mkdir and blocking operations
2897 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2900 do_nodes $(comma_list $(mdts_nodes)) \
2901 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2902 $LFS mkdir -i 1 $DIR1/$tfile &
2904 mkdir $DIR2/$tfile &
2906 do_nodes $(comma_list $(mdts_nodes)) \
2907 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2908 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2909 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2913 run_test 47a "pdirops: remote mkdir vs mkdir"
2916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2919 do_nodes $(comma_list $(mdts_nodes)) \
2920 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2921 $LFS mkdir -i 1 $DIR1/$tfile &
2923 sleep 1 # please do not remove this sleep, see LU-10754
2924 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2926 do_nodes $(comma_list $(mdts_nodes)) \
2927 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2928 check_pdo_conflict $PID1 && { wait $PID1;
2929 error "create isn't blocked"; }
2930 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2934 run_test 47b "pdirops: remote mkdir vs create"
2937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2939 touch $DIR1/$tfile-2
2940 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2941 do_nodes $(comma_list $(mdts_nodes)) \
2942 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2943 $LFS mkdir -i 1 $DIR1/$tfile &
2945 link $DIR2/$tfile-2 $DIR2/$tfile &
2947 do_nodes $(comma_list $(mdts_nodes)) \
2948 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2949 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2950 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2954 run_test 47c "pdirops: remote mkdir vs link"
2957 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2959 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2960 do_nodes $(comma_list $(mdts_nodes)) \
2961 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2962 $LFS mkdir -i 1 $DIR1/$tfile &
2964 rmdir $DIR2/$tfile &
2966 do_nodes $(comma_list $(mdts_nodes)) \
2967 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2968 check_pdo_conflict $PID1 && { wait $PID1;
2969 error "unlink isn't blocked"; }
2970 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2974 run_test 47d "pdirops: remote mkdir vs unlink"
2977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2979 touch $DIR1/$tfile-2
2980 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2981 do_nodes $(comma_list $(mdts_nodes)) \
2982 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2983 $LFS mkdir -i 1 $DIR1/$tfile &
2985 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2987 do_nodes $(comma_list $(mdts_nodes)) \
2988 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2989 check_pdo_conflict $PID1 && { wait $PID1;
2990 error "rename isn't blocked"; }
2991 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2995 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2998 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3000 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3001 do_nodes $(comma_list $(mdts_nodes)) \
3002 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3003 $LFS mkdir -i 1 $DIR1/$tfile &
3005 mv $DIR2/$tfile $DIR2/$tfile-2 &
3007 do_nodes $(comma_list $(mdts_nodes)) \
3008 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3009 check_pdo_conflict $PID1 && { wait $PID1;
3010 error "rename isn't blocked"; }
3011 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3015 run_test 47f "pdirops: remote mkdir and rename (src)"
3018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3022 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3023 do_nodes $(comma_list $(mdts_nodes)) \
3024 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3025 $LFS mkdir -i 1 $DIR1/$tfile &
3027 stat $DIR2/$tfile > /dev/null &
3029 do_nodes $(comma_list $(mdts_nodes)) \
3030 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3031 check_pdo_conflict $PID1 && { wait $PID1;
3032 error "getattr isn't blocked"; }
3033 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3037 run_test 47g "pdirops: remote mkdir vs getattr"
3041 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3042 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3043 do_facet client "lctl set_param fail_loc=0x410"
3044 $TRUNCATE $DIR2/$tfile $trunc_size
3045 do_facet client "lctl set_param fail_loc=0x0"
3047 size=`stat -c %s $DIR2/$tfile`
3048 [ $size -eq $trunc_size ] || error "wrong size"
3050 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3054 local origfile=/etc/hosts
3056 filesize=$(stat -c %s $origfile)
3058 # create an empty file
3059 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3060 # cache layout lock on both mount point
3061 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3062 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3064 # open and sleep 2 seconds then read
3065 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3069 # create the layout of testing file
3070 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3071 error "dd $DIR1/$tfile failed"
3073 # MULTIOP proc should be able to read enough bytes and exit
3074 for ((i = 0; i < 6; i++)); do
3076 kill -0 $pid || break
3078 kill -0 $pid 2> /dev/null && error "multiop is still there"
3079 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3083 run_test 51a "layout lock: refresh layout should work"
3086 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
3087 skip "Need MDS version at least 2.3.59"
3089 local tmpfile=`mktemp`
3091 $LFS setstripe -E 1M -c 1 -E -1 --extension-size 64M $DIR1/$tfile ||
3092 error "Create $DIR1/$tfile failed"
3094 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3095 error "dd $DIR1/$tfile failed"
3097 # delay glimpse so that layout has changed when glimpse finish
3098 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3099 $LCTL set_param fail_loc=0x1404 fail_val=4
3100 stat -c %s $DIR2/$tfile |tee $tmpfile &
3104 # extend layout of testing file
3105 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3106 error "dd $DIR1/$tfile failed"
3109 local fsize=$(cat $tmpfile)
3111 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3113 rm -f $DIR1/$tfile $tmpfile
3115 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3118 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3120 # set default layout to have 1 stripe
3122 $LFS setstripe -c 1 $DIR1/$tdir
3124 # create a file with empty layout
3125 $MCREATE $DIR1/$tdir/$tfile ||
3126 error "$MCREATE $DIR1/$tdir/$tfile failed"
3128 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3129 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3131 # change the layout of testing file
3132 echo "Setting layout to have $OSTCOUNT stripes ..."
3133 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3137 # write something to the file, it should be blocked on fetching layout
3138 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3139 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3142 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3143 # count to succeed with only 3/4 of the number of stripes (rounded up),
3144 # so creating striped files does not fail if an OST is offline or full
3145 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3146 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3150 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3153 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3154 cancel_lru_locks mdc
3156 # open should grant LAYOUT lock, mmap and read will install pages
3157 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3161 # rss before revoking
3162 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3163 echo "Before revoking layout lock: $br KB mapped"
3165 # cancel layout lock manually
3166 cancel_lru_locks mdc
3168 # rss after revoking
3169 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3172 wait $PID || error "wait PID $PID failed"
3174 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3176 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3181 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3185 $LFS getstripe $DIR2/$tfile
3187 wait $pid || error "multiop failed"
3189 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3193 $LFS getstripe $DIR2/$tfile
3195 wait $pid || error "multiop failed"
3197 run_test 51e "lfs getstripe does not break leases, part 2"
3201 echo "==> rename vs getattr vs setxattr 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 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3215 wait $PID1 || error "(3) mv failed"
3216 wait $PID2 || error "(4) stat failed"
3223 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3224 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3226 do_facet mds1 $LCTL set_param fail_loc=$1
3228 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3236 $MULTIOP $DIR2/d1/d2 Oc &
3240 stat $DIR/d1 || error "(2) stat failed"
3242 wait $PID1 || error "(3) mv failed"
3243 wait $PID2 || error "(4) stat failed"
3244 wait $PID3 && error "(5) multiop failed"
3250 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3251 save_lustre_params client "llite.*.xattr_cache" > $p
3252 lctl set_param llite.*.xattr_cache 1 ||
3253 { skip "xattr cache is not supported"; return 0; }
3255 #define OBD_FAIL_MDS_RENAME 0x153
3256 #define OBD_FAIL_MDS_RENAME2 0x154
3257 test_54_part1 0x80000153 || error 10
3258 test_54_part1 0x80000154 || error 11
3259 test_54_part2 0x80000153 || error 12
3260 test_54_part2 0x80000154 || error 13
3262 restore_lustre_params < $p
3265 run_test 54 "rename locking"
3268 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3270 #define OBD_FAIL_MDS_RENAME4 0x156
3271 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3273 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3278 wait $PID1 && error "(2) mv succeeded"
3282 run_test 55a "rename vs unlink target dir"
3286 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3288 #define OBD_FAIL_MDS_RENAME4 0x156
3289 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3291 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3296 wait $PID1 && error "(2) mv succeeded"
3300 run_test 55b "rename vs unlink source dir"
3304 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3306 #define OBD_FAIL_MDS_RENAME4 0x156
3307 do_facet mds1 $LCTL set_param fail_loc=0x156
3309 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3313 # while rename is sleeping, open and remove d3
3314 $MULTIOP $DIR2/d3 D_c &
3320 # while rename is sleeping 2nd time, close d3
3322 wait $PID2 || error "(3) multiop failed"
3324 wait $PID1 && error "(2) mv succeeded"
3328 run_test 55c "rename vs unlink orphan target dir"
3334 #define OBD_FAIL_MDS_RENAME3 0x155
3335 do_facet mds1 $LCTL set_param fail_loc=0x155
3336 mv $DIR/f1 $DIR/$tdir &
3340 # while rename is sleeping, create $tdir, but as a directory
3341 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
3343 # link in reverse locking order
3344 ln $DIR2/f1 $DIR2/$tdir/
3346 wait $PID1 && error "(2) mv succeeded"
3349 run_test 55d "rename file vs link"
3352 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3353 skip "MDS version must be >= 2.3.0"
3356 test_mkdir $DIR1/$tdir
3357 file1=$DIR1/$tdir/file
3358 file2=$DIR2/$tdir/file
3360 echo orig > $file2 || error "Could not create $file2"
3361 version=$($LFS data_version $file1)
3364 echo append >> $file2 || error "Could not append to $file2"
3365 version2=$($LFS data_version $file1)
3366 [ "$version" != "$version2" ] ||
3367 error "append did not change data version: $version"
3370 echo overwrite > $file2 || error "Could not overwrite $file2"
3371 version3=$($LFS data_version $file1)
3372 [ "$version2" != "$version3" ] ||
3373 error "overwrite did not change data version: $version2"
3375 # Truncate before EOF
3376 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3377 version4=$($LFS data_version $file1)
3378 [ "$version3" != "$version4" ] ||
3379 error "truncate did not change data version: $version3"
3381 # Truncate after EOF
3382 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3383 version5=$($LFS data_version $file1)
3384 [ "$version4" != "$version5" ] ||
3385 error "truncate did not change data version: $version4"
3387 # Chmod do not change version
3388 chmod 400 $file2 || error "Could not chmod 400 $file2"
3389 version6=$($LFS data_version $file1)
3390 [ "$version5" == "$version6" ] ||
3391 error "chmod should not change data version: $version5 != $version6"
3393 # Chown do not change version
3394 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3395 version7=$($LFS data_version $file1)
3396 [ "$version5" == "$version7" ] ||
3397 error "chown should not change data version: $version5 != $version7"
3399 run_test 60 "Verify data_version behaviour"
3402 local test_dir=$tdir/test_dir
3404 mkdir -p $DIR1/$tdir
3405 if [ $MDSCOUNT -ge 2 ]; then
3407 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3408 error "Create remote directory failed"
3410 mkdir -p $DIR1/$test_dir
3412 cd $DIR2/$test_dir || error "cd directory failed"
3413 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3415 cd $DIR2/$tdir || error "exit directory"
3417 run_test 70a "cd directory && rm directory"
3419 test_70b() { # LU-2781
3421 mkdir -p $DIR1/$tdir
3423 touch $DIR1/$tdir/file
3424 for ((i = 0; i < 32; i++)); do
3425 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3427 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3429 touch $DIR1/$tdir/file
3430 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3431 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3432 rm -rf $DIR1/$tdir/test_dir ||
3433 error "cannot remove directory after rm_entry"
3434 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3436 run_test 70b "remove files after calling rm_entry"
3439 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3440 skip "Need MDS version at least 2.1.6"
3442 # Patch not applied to 2.2 and 2.3 branches
3443 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3444 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3445 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3447 checkfiemap --test ||
3448 skip "checkfiemap not runnable: $?"
3449 # write data this way: hole - data - hole - data
3450 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3451 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3453 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3454 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3455 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3457 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3459 checkfiemap $DIR2/$tfile 81920 ||
3460 error "data is not flushed from client"
3461 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3464 # common case of "create file, copy file" on a single node
3465 # should not flush data from ost
3466 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3467 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3469 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3471 checkfiemap $DIR1/$tfile 81920 ||
3473 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3475 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3477 run_test 71a "correct file map just after write operation is finished"
3480 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3481 skip "Need MDS version at least 2.1.6"
3483 # Patch not applied to 2.2 and 2.3 branches
3484 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3485 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3486 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3487 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3489 checkfiemap --test ||
3490 skip "error $?: checkfiemap failed"
3492 mkdir -p $DIR1/$tdir
3494 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3495 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3496 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3498 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3499 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3501 run_test 71b "check fiemap support for stripecount > 1"
3504 local p="$TMP/sanityN-$TESTNAME.parameters"
3507 save_lustre_params client "llite.*.xattr_cache" > $p
3508 lctl set_param llite.*.xattr_cache 1 ||
3509 { skip "xattr cache is not supported"; return 0; }
3512 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3513 error "setfattr1 failed"
3514 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3515 error "getfattr1 failed"
3516 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3517 error "setfattr2 failed"
3518 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3519 error "getfattr2 failed"
3521 # check that trusted.link is consistent
3522 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3523 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3524 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3525 echo "$tlink1 $tlink2"
3526 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3530 restore_lustre_params < $p
3533 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3536 local p="$TMP/sanityN-$TESTNAME.parameters"
3537 save_lustre_params client "llite.*.xattr_cache" > $p
3538 lctl set_param llite.*.xattr_cache 1 ||
3539 { skip "xattr cache is not supported"; return 0; }
3542 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3543 error "setfattr1 failed"
3544 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3545 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3546 clear_stats llite.*.stats
3547 # PR lock should be cached by now on both clients
3548 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3549 # 2 hits for getfattr(0)+getfattr(size)
3550 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3551 error "not cached in $DIR1"
3552 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3553 # 4 hits for more getfattr(0)+getfattr(size)
3554 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3555 error "not cached in $DIR2"
3558 restore_lustre_params < $p
3561 run_test 73 "getxattr should not cause xattr lock cancellation"
3564 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3565 skip "Need MDS version at least 2.4.93"
3567 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3568 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3569 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3571 run_test 74 "flock deadlock: different mounts =============="
3575 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3576 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3577 cancel_lru_locks osc
3579 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3582 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3583 $LCTL set_param fail_loc=0x31d
3584 stat -c %s $DIR1/$tfile &
3589 # For bad lock error handler we should ASSERT and got kernel panic here
3591 $LCTL set_param fail_loc=0
3593 run_test 75 "osc: upcall after unuse lock==================="
3596 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3597 skip "Need MDS version at least 2.5.53"
3599 remote_mds_nodsh && skip "remote MDS with nodsh"
3600 local fcount=$((MDSCOUNT * 256))
3605 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3611 test_mkdir $DIR/$tdir
3613 # drop all open locks and close any cached "open" files on the client
3614 cancel_lru_locks mdc
3616 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3617 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3618 local already=${#fid_list[@]}
3619 for (( i = 0; i < $already; i++ )) ; do
3620 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3623 echo -n "opening files: "
3624 ulimit -n $((fcount + 50))
3625 for ((i = 0; i < $fcount; i++)); do
3626 touch $DIR/$tdir/f_$i
3627 local fd=$(free_fd ${fd_list[i]})
3628 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3633 (( $i % 32 == 0 )) && echo -n "."
3637 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3639 # Possible errors in openfiles FID list.
3640 # 1. Missing FIDs. Check 1
3641 # 2. Extra FIDs. Check 1
3642 # 3. Duplicated FID. Check 2
3643 # 4. Invalid FIDs. Check 2
3644 # 5. Valid FID, points to some other file. Check 3
3647 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3648 error "${#fid_list[@]} != $fcount (+$already old) open files"
3650 echo -n "closing files: "
3651 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3652 local close_cmd="exec ${fd_list[fd]}<&-"
3654 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3656 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3657 echo "skip old open file $filename"
3659 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3663 rm --interactive=no $filename
3665 error "Nonexisting fid ${fid_list[fid]} listed."
3666 (( $fd % 32 == 0 )) && echo -n "."
3671 ls_op=$(ls $DIR2/$tdir | wc -l)
3673 error "Some openfiles are missing in lproc output"
3677 run_test 76 "Verify MDT open_files listing"
3681 local dir=$DIR/$tdir
3684 mkdir $dir || error "mkdir $dir failed"
3685 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3688 do_nodes $CLIENTS $myRUNAS \
3689 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3690 error "dd at 0 on client failed (1)"
3692 do_nodes $CLIENTS $myRUNAS \
3694 for ((i = 0; i < $n; i++)); do
3695 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3696 seek=\\\$i count=1 conv=notrunc &
3697 pids_w[\\\$i]=\\\$!;
3700 for ((i = 0; i < $n; i++)); do
3701 wait \\\${pids_w[\\\$i]};
3703 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3707 do_nodes $CLIENTS sync;
3708 cancel_lru_locks osc
3710 do_nodes $CLIENTS $myRUNAS \
3712 for ((i = 0; i < $n; i++)); do
3713 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3714 seek=\\\$i count=1 &
3715 pids_r[\\\$i]=\\\$!;
3718 for ((i = 0; i < $n; i++)); do
3719 wait \\\${pids_r[\\\$i]};
3721 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3725 cancel_lru_locks osc
3727 wait $pid_w || error "dd (write) failed (2)"
3728 wait $pid_r || error "dd (read) failed (3)"
3729 rm -rvf $dir || error "rm -rf $dir failed"
3732 test_77a() { #LU-3266
3735 oss=$(comma_list $(osts_nodes))
3736 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3738 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3739 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3744 run_test 77a "check FIFO NRS policy"
3746 test_77b() { #LU-3266
3749 oss=$(comma_list $(osts_nodes))
3751 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3752 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3753 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3754 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3756 echo "policy: crr-n, crrn_quantum 1"
3759 do_nodes $oss lctl set_param \
3760 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3761 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3763 echo "policy: crr-n, crrn_quantum 64"
3767 do_nodes $oss lctl set_param \
3768 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3769 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3772 run_test 77b "check CRR-N NRS policy"
3777 oss=$(comma_list $(osts_nodes))
3779 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3780 ost.OSS.*.nrs_"$policy"_quantum=1 \
3781 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3782 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3784 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3785 "physical, ${policy}_supported reads"
3788 do_nodes $oss lctl set_param \
3789 ost.OSS.*.nrs_${policy}_supported="writes" \
3790 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3792 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3793 "physical, ${policy}_supported writes"
3796 do_nodes $oss lctl set_param \
3797 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3798 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3799 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3800 "logical, ${policy}_supported reads_and_writes"
3804 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3809 test_77c() { #LU-3266
3811 orr_trr "orr" || rc=$?
3812 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3813 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3816 run_test 77c "check ORR NRS policy"
3818 test_77d() { #LU-3266
3820 orr_trr "trr" || rc=$?
3821 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3822 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3825 run_test 77d "check TRR nrs policy"
3832 do_facet $facet lctl set_param \
3833 ost.OSS.ost_io.nrs_tbf_rule="$*"
3835 error "failed to run operate '$*' on TBF rules"
3838 cleanup_tbf_verify()
3842 echo "cleanup_tbf $DIR/$tdir"
3845 wait_delete_completed
3850 local dir=$DIR/$tdir
3851 local client1=${CLIENT1:-$(hostname)}
3854 local np=$(check_cpt_number ost1)
3855 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3856 echo "cpu_npartitions on ost1 is $np"
3858 mkdir $dir || error "mkdir $dir failed"
3859 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3862 trap cleanup_tbf_verify EXIT
3863 echo "Limited write rate: $1, read rate: $2"
3864 echo "Verify the write rate is under TBF control"
3865 local start=$SECONDS
3866 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3867 bs=1M count=100 oflag=direct 2>&1
3868 local runtime=$((SECONDS - start + 1))
3869 local rate=$(bc <<< "scale=6; 100 / $runtime")
3870 echo "Write runtime is $runtime s, speed is $rate IOPS"
3872 # verify the write rate does not exceed TBF rate limit
3873 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3874 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3876 cancel_lru_locks osc
3878 echo "Verify the read rate is under TBF control"
3880 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3881 bs=1M count=100 iflag=direct 2>&1
3882 runtime=$((SECONDS - start + 1))
3883 rate=$(bc <<< "scale=6; 100 / $runtime")
3884 echo "Read runtime is $runtime s, speed is $rate IOPS"
3886 # verify the read rate does not exceed TBF rate limit
3887 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3888 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3890 cancel_lru_locks osc
3891 cleanup_tbf_verify || error "rm -rf $dir failed"
3897 oss=$(comma_list $(osts_nodes))
3899 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3901 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3902 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3906 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3911 # Only operate rules on ost1 since OSTs might run on the same OSS
3913 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3914 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3915 local client_nids=$(nids_list $address "\\")
3916 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3917 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3921 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3922 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3923 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3927 tbf_rule_operate ost1 "stop\ localhost"
3928 tbf_rule_operate ost1 "stop\ clients"
3929 tbf_rule_operate ost1 "stop\ others"
3932 # Cleanup the TBF policy
3933 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3934 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3938 run_test 77e "check TBF NID nrs policy"
3943 oss=$(comma_list $(osts_nodes))
3945 do_nodes $oss $LCTL set_param \
3946 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3947 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3948 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3950 # Configure jobid_var
3951 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3953 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3954 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3955 if [ $saved_jobid_var != procname_uid ]; then
3956 set_persistent_param_and_check client \
3957 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3962 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3967 # Only operate rules on ost1 since OSTs might run on the same OSS
3969 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3970 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3971 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3972 nrs_write_read "$RUNAS"
3975 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3976 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3977 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3978 nrs_write_read "$RUNAS"
3981 tbf_rule_operate ost1 "stop\ runas"
3982 tbf_rule_operate ost1 "stop\ iozone_runas"
3983 tbf_rule_operate ost1 "stop\ dd_runas"
3984 nrs_write_read "$RUNAS"
3986 # Cleanup the TBF policy
3987 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3988 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3989 nrs_write_read "$RUNAS"
3991 local current_jobid_var=$($LCTL get_param -n jobid_var)
3992 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3993 if [ $saved_jobid_var != $current_jobid_var ]; then
3994 set_persistent_param_and_check client \
3995 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3999 run_test 77f "check TBF JobID nrs policy"
4004 oss=$(comma_list $(osts_nodes))
4006 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4008 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4009 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4011 do_nodes $oss lctl set_param \
4012 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4013 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4017 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4022 # Add a rule that only valid for Jobid TBF. If direct change between
4023 # TBF types is not supported, this operation will fail.
4024 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4026 # Cleanup the TBF policy
4027 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4028 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4031 run_test 77g "Change TBF type directly"
4034 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4035 skip "Need OST version at least 2.8.55"
4037 local old_policy=$(do_facet ost1 \
4038 lctl get_param ost.OSS.ost_io.nrs_policies)
4041 do_facet ost1 lctl set_param \
4042 ost.OSS.ost_io.nrs_policies="abc"
4043 [ $? -eq 0 ] && error "should return error"
4045 do_facet ost1 lctl set_param \
4046 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4047 [ $? -eq 0 ] && error "should return error"
4049 do_facet ost1 lctl set_param \
4050 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4051 [ $? -eq 0 ] && error "should return error"
4053 do_facet ost1 lctl set_param \
4054 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4055 [ $? -eq 0 ] && error "should return error"
4057 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4058 [ $? -eq 0 ] || error "shouldn't LBUG"
4060 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4064 run_test 77h "Wrong policy name should report error, not LBUG"
4070 local error_message=$3
4072 for rule in $expected; do
4073 rule_number=$((rule_number + 1))
4075 local stop_line=$(($rule_number + 3))
4076 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4078 local output=$(do_facet $facet lctl get_param \
4079 ost.OSS.ost_io.nrs_tbf_rule |
4083 if [ "$output" != "$expected" ]; then
4084 error "$error_message, expected '$expected', got '$output'"
4089 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4090 skip "Need OST version at least 2.8.55"
4092 for i in $(seq 1 $OSTCOUNT)
4094 do_facet ost"$i" lctl set_param \
4095 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4097 error "failed to set TBF policy"
4100 tbf_rule_check ost1 "default" "error before inserting any rule"
4102 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4103 tbf_rule_check ost1 "before default" \
4104 "error when inserting rule 'before'"
4106 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4107 tbf_rule_check ost1 "before after default" \
4108 "error when inserting rule 'after'"
4110 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4111 tbf_rule_check ost1 "before target after default" \
4112 "error when inserting rule 'target'"
4114 echo "Move before itself"
4115 tbf_rule_operate ost1 "change\ target\ rank=target"
4116 tbf_rule_check ost1 "before target after default" \
4117 "error when moving before itself"
4119 echo "Move to higher rank"
4120 tbf_rule_operate ost1 "change\ target\ rank=before"
4121 tbf_rule_check ost1 "target before after default" \
4122 "error when moving to higher rank"
4124 echo "Move to lower rank"
4125 tbf_rule_operate ost1 "change\ target\ rank=after"
4126 tbf_rule_check ost1 "before target after default" \
4127 "error when moving to lower rank"
4129 echo "Move before default"
4130 tbf_rule_operate ost1 "change\ target\ rank=default"
4131 tbf_rule_check ost1 "before after target default" \
4132 error "error when moving before default"
4134 # Cleanup the TBF policy
4135 do_nodes $(comma_list $(osts_nodes)) \
4136 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4139 run_test 77i "Change rank of TBF rule"
4145 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4146 skip "Need OST version at least 2.9.53"
4147 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4152 do_nodes $(comma_list $(osts_nodes)) \
4153 lctl set_param jobid_var=procname_uid \
4154 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4155 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4156 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4157 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4162 do_nodes $(comma_list $(osts_nodes)) \
4163 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4164 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4165 ost.OSS.ost_io.nrs_policies="fifo"
4167 # sleep 3 seconds to wait the tbf policy stop completely,
4168 # or the next test case is possible get -EAGAIN when
4169 # setting the tbf policy
4172 run_test 77j "check TBF-OPCode NRS policy"
4175 local idstr="${1}id"
4176 local policy="${idstr}={$2}"
4177 local rate="rate=$3"
4179 do_nodes $(comma_list $(osts_nodes)) \
4180 lctl set_param jobid_var=procname_uid \
4181 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4182 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4183 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4185 nrs_write_read "runas $4"
4186 tbf_verify $3 $3 "runas $4"
4188 do_nodes $(comma_list $(osts_nodes)) \
4189 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4190 ost.OSS.ost_io.nrs_policies="fifo"
4192 # sleep 3 seconds to wait the tbf policy stop completely,
4193 # or the next test case is possible get -eagain when
4194 # setting the tbf policy
4199 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4200 skip "Need OST version at least 2.11.50"
4203 test_id "u" "500" "5" "-u 500"
4204 test_id "g" "500" "5" "-u 500 -g 500"
4206 run_test 77ja "check TBF-UID/GID NRS policy"
4214 for rule in $rule_lists; do
4215 do_nodes $(comma_list $(osts_nodes)) \
4216 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4219 do_nodes $(comma_list $(osts_nodes)) \
4220 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4226 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4227 skip "Need OST version at least 2.9.53"
4229 do_nodes $(comma_list $(osts_nodes)) \
4230 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4231 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4232 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4234 nrs_write_read "$RUNAS"
4235 tbf_verify 20 10 "$RUNAS"
4237 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4238 local client_nids=$(nids_list $address "\\")
4239 do_nodes $(comma_list $(osts_nodes)) \
4240 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4241 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4242 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4243 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4248 do_nodes $(comma_list $(osts_nodes)) \
4249 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4250 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4251 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4253 nrs_write_read "$RUNAS"
4254 tbf_verify 20 20 "$RUNAS"
4256 do_nodes $(comma_list $(osts_nodes)) \
4257 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4258 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4259 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4261 nrs_write_read "$RUNAS"
4262 # with parameter "RUNAS", it will match the latest rule
4263 # "ext_b" first, so the limited write rate is 10.
4264 tbf_verify 10 10 "$RUNAS"
4267 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4269 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4270 skip "Need OST version at least 2.10.58"
4272 do_nodes $(comma_list $(osts_nodes)) \
4273 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4274 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4275 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4276 nrs_write_read "runas -u 500 -g 1000"
4277 tbf_verify 5 5 "runas -u 500 -g 1000"
4279 do_nodes $(comma_list $(osts_nodes)) \
4280 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4281 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4282 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4284 nrs_write_read "runas -u 500"
4285 tbf_verify 20 10 "runas -u 500"
4287 do_nodes $(comma_list $(osts_nodes)) \
4288 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4289 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4290 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4291 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4292 nrs_write_read "runas -u 500"
4293 tbf_verify 10 10 "runas -u 500"
4294 tbf_verify 20 10 "runas -u 500"
4295 cleanup_77k "ext_a ext_b" "fifo"
4297 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4300 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4301 skip "Need OST version at least 2.10.56"
4303 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4304 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4306 local output=$(do_facet ost1 lctl get_param \
4307 ost.OSS.ost_io.nrs_policies | \
4308 awk '/name: tbf/ {print;exit}' | \
4309 awk -F ': ' '{print $2}')
4311 if [ "$output" != "tbf" ]; then
4312 error "The generic TBF output is '$output', not 'tbf'"
4315 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4317 run_test 77l "check the output of NRS policies for generic TBF"
4320 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4321 skip "Need OST version at least 2.9.54"
4324 local dir=$DIR/$tdir
4326 mkdir $dir || error "mkdir $dir failed"
4327 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4330 local nodes=$(comma_list $(osts_nodes))
4331 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4332 ost.OSS.ost_io.nrs_delay_min=4 \
4333 ost.OSS.ost_io.nrs_delay_max=4 \
4334 ost.OSS.ost_io.nrs_delay_pct=100
4335 [ $? -ne 0 ] && error "Failed to set delay policy"
4337 local start=$SECONDS
4338 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4339 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4340 oflag=direct conv=fdatasync ||
4341 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4342 error "dd on client failed (1)"; }
4343 local elapsed=$((SECONDS - start))
4345 # NRS delay doesn't do sub-second timing, so a request enqueued at
4346 # 0.9 seconds can be dequeued at 4.0
4347 [ $elapsed -lt 3 ] &&
4348 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4349 error "Single 1M write should take at least 3 seconds"; }
4352 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4353 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4354 oflag=direct conv=fdatasync ||
4355 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4356 error "dd on client failed (2)"; }
4357 elapsed=$((SECONDS - start))
4359 [ $elapsed -lt 30 ] &&
4360 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4361 error "Ten 1M writes should take at least 30 seconds"; }
4363 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4364 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4368 run_test 77m "check NRS Delay slows write RPC processing"
4370 test_77n() { #LU-10802
4371 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4372 skip "Need OST version at least 2.10.58"
4375 # Configure jobid_var
4376 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4377 if [ $saved_jobid_var != procname_uid ]; then
4378 set_persistent_param_and_check client \
4379 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4382 do_nodes $(comma_list $(osts_nodes)) \
4383 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4384 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4385 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4388 tbf_verify 20 20 "$RUNAS"
4390 do_nodes $(comma_list $(osts_nodes)) \
4391 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4392 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4397 do_nodes $(comma_list $(osts_nodes)) \
4398 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4399 ost.OSS.ost_io.nrs_policies="fifo"
4403 local current_jobid_var=$($LCTL get_param -n jobid_var)
4404 if [ $saved_jobid_var != $current_jobid_var ]; then
4405 set_persistent_param_and_check client \
4406 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4409 run_test 77n "check wildcard support for TBF JobID NRS policy"
4411 test_78() { #LU-6673
4414 oss=$(comma_list $(osts_nodes))
4415 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4416 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4418 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4419 # Valid return codes are:
4420 # 0: Tuning succeeded
4421 # ENODEV: Policy is still stopped
4422 # EAGAIN: Policy is being initialized
4423 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4424 error "Expected set_param to return 0|ENODEV|EAGAIN"
4426 # Cleanup the ORR policy
4427 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4428 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4431 run_test 78 "Enable policy and specify tunings right away"
4434 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4435 test_mkdir $DIR/$tdir
4437 # Prevent interference from layout intent RPCs due to
4438 # asynchronous writeback. These will be tested in 130c below.
4439 do_nodes ${CLIENTS:-$HOSTNAME} sync
4441 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4442 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4444 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4445 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4446 local facet=mds$((mdtidx + 1))
4448 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4449 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4453 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4454 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4459 run_test 79 "xattr: intent error"
4462 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4469 mkdir -p $DIR1/$tdir/dir
4470 createmany -o $DIR1/$tdir/dir/f 10 ||
4471 error "create files under remote dir failed $i"
4473 cp /etc/passwd $DIR1/$tdir/$tfile
4475 #migrate open file should fails
4476 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4478 # give multiop a chance to open
4481 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4482 error "migrate open files should failed with open files"
4486 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4487 error "migrate remote dir error"
4489 echo "Finish migration, then checking.."
4490 for file in $(find $DIR1/$tdir); do
4491 mdt_index=$($LFS getstripe -m $file)
4492 [ $mdt_index == $MDTIDX ] ||
4493 error "$file is not on MDT${MDTIDX}"
4496 diff /etc/passwd $DIR1/$tdir/$tfile ||
4497 error "file different after migration"
4499 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4501 run_test 80a "migrate directory when some children is being opened"
4505 kill -9 $migrate_pid
4509 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4510 local migrate_dir1=$DIR1/$tdir/migrate_dir
4511 local migrate_dir2=$DIR2/$tdir/migrate_dir
4512 local migrate_run=$LUSTRE/tests/migrate.sh
4520 trap cleanup_80b EXIT
4521 #prepare migrate directory
4522 mkdir -p $migrate_dir1
4523 for F in {1,2,3,4,5}; do
4524 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4525 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4528 #migrate the directories among MDTs
4531 mdt_idx=$((RANDOM % MDSCOUNT))
4532 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4534 [ $rc -ne 0 -o $rc -ne 16 ] || break
4539 echo "start migration thread $migrate_pid"
4540 #Access the files at the same time
4541 start_time=$(date +%s)
4542 echo "accessing the migrating directory for 5 minutes..."
4544 ls $migrate_dir2 > /dev/null || {
4545 echo "read dir fails"
4548 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4549 echo "access file1 fails"
4553 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4554 echo "access file2/3 fails"
4558 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4559 echo "access file4 fails"
4563 stat $migrate_dir2/file5 > /dev/null || {
4564 echo "stat file5 fails"
4568 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4569 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4570 echo "touch file failed with $rc1"
4574 if [ -e $migrate_dir2/source_file ]; then
4575 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4576 &>/dev/null || rc1=$?
4577 if [ -e $migrate_dir2/link_file ]; then
4578 rm -rf $migrate_dir2/link_file
4581 mrename $migrate_dir2/source_file \
4582 $migrate_dir2/target_file &>/dev/null || rc1=$?
4583 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4584 echo "rename failed with $rc1"
4588 if [ -e $migrate_dir2/target_file ]; then
4589 rm -rf $migrate_dir2/target_file &>/dev/null ||
4592 rm -rf $migrate_dir2/source_file &>/dev/null ||
4595 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4596 echo "unlink failed with $rc1"
4601 end_time=$(date +%s)
4602 duration=$((end_time - start_time))
4603 if [ $((duration % 10)) -eq 0 ]; then
4604 if [ $show_time -eq 1 ]; then
4605 echo "...$duration seconds"
4612 kill -0 $migrate_pid || {
4613 echo "migration stopped 1"
4617 [ $duration -ge 300 ] && break
4620 #check migration are still there
4621 kill -0 $migrate_pid || error "migration stopped 2"
4624 run_test 80b "Accessing directory during migration"
4627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4631 mkdir -p $DIR1/$tdir
4633 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4634 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4637 touch d0/0 || error "create 0 failed"
4638 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4639 stat d0/0 && error "stat mv filed succeed"
4640 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4641 stat d0/0 || error "stat failed"
4643 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4645 if [ $t -ne 3 ]; then
4646 ls -ai $DIR1/$tdir/d0
4647 error "expect 3 get $t"
4652 run_test 81a "rename and stat under striped directory"
4655 [ $MDSCOUNT -lt 2 ] &&
4656 skip "We need at least 2 MDTs for this test"
4663 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4664 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4673 for i in $(seq $total); do
4674 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4678 kill -9 $setattr_pid
4680 run_test 81b "rename under striped directory doesn't deadlock"
4683 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4684 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4685 skip "Need MDS version at least 2.13.52"
4687 # source is local, source parent is remote
4688 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4689 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4690 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4691 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4692 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4693 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4694 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4695 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4697 # source is remote, source parent is local
4698 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4699 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4700 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4701 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4702 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4703 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4704 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4705 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4707 # source and source parent are remote
4708 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4709 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4710 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4711 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4712 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4713 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4714 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4715 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4717 # source and source parent are remote, and source is remote object
4718 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4719 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4720 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4721 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4722 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4723 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4724 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4726 run_test 81c "rename revoke LOOKUP lock for remote object"
4729 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4730 skip "Need MDS version at least 2.6.92"
4732 # Client 1 creates a file.
4733 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4735 # Client 2 opens the file.
4736 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4738 # Client 1 makes the file an orphan.
4739 rm $DIR1/$tfile || error "rm"
4740 # Client 2 sets EA "user.multiop".
4742 wait $pid2 || error "multiop 2"
4743 # Client 1 gets EA "user.multiop". This used to fail because the EA
4744 # cache refill would get "trusted.link" from mdd_xattr_list() but
4745 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4748 wait $pid1 || error "multiop 1"
4750 run_test 82 "fsetxattr and fgetxattr on orphan files"
4753 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4760 $LFS mkdir -i1 -c2 $tdir
4765 echo "start pid $pid1 to create/unlink striped directory"
4767 # Access the directory at the same time
4771 stat $tdir > /dev/null 2>&1
4775 echo "start pid $pid2 to stat striped directory"
4783 run_test 83 "access striped directory while it is being created/unlinked"
4786 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4787 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4791 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4792 error "create $tfile failed"
4793 mtime=$(stat -c%Y $DIR/$tfile)
4794 mtime=$((mtime + 200))
4796 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4797 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4799 touch -c -m $mtime $DIR/$tfile &
4801 # sleep a while to let 'touch' run first
4803 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4806 wait $setattr_pid || true
4808 run_test 84 "0-nlink race in lu_object_find()"
4811 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4816 [ "$SLOW" = "yes" ] && duration=600
4817 # Open/Create under striped directory
4821 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4822 touch $tdir/f{0..3} > /dev/null 2>&1
4826 echo "start pid $pid1 to open/create under striped directory"
4828 # unlink the striped directory at the same time
4832 rm -rf $tdir > /dev/null 2>&1
4836 echo "start pid $pid2 to unlink striped directory"
4845 run_test 90 "open/create and unlink striped directory"
4848 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4853 [ "$SLOW" = "yes" ] && duration=600
4854 # chmod striped directory
4858 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4859 chmod go+w $tdir > /dev/null 2>&1
4863 echo "start pid $pid1 to chmod striped directory"
4865 # unlink the striped directory at the same time
4869 rm -rf $tdir > /dev/null 2>&1
4873 echo "start pid $pid2 to unlink striped directory"
4882 run_test 91 "chmod and unlink striped directory"
4885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4888 local cmd="exec $fd<$DIR1/$tdir"
4889 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4892 trap "eval $cmd" EXIT
4893 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4894 rmdir ../$tdir || error "rmdir ../$tdir fails"
4896 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4897 $LCTL set_param fail_loc=0x1408
4898 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4899 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4900 error "create remote dir succeeds"
4901 $LCTL set_param fail_loc=0
4905 run_test 92 "create remote directory under orphan directory"
4912 mkdir -p $DIR1/$tfile-1/
4913 mkdir -p $DIR2/$tfile-2/
4914 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4915 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4916 do_facet $SINGLEMDS "$LCTL set_param -n \
4917 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4918 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4919 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4921 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4924 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4928 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4929 do_facet $SINGLEMDS "$LCTL set_param -n \
4930 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4932 $LFS getstripe $DIR1/$tfile-1/file1
4933 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4934 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4935 $LFS getstripe $DIR2/$tfile-2/file2
4936 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4937 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4938 echo "rc1=$rc1 and rc2=$rc2 "
4939 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4940 error "object allocate on same ost detected"
4942 run_test 93 "alloc_rr should not allocate on same ost"
4945 $LCTL set_param osc.*.idle_timeout=0
4946 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4948 local before=$(date +%s)
4952 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4953 $LCTL set_param fail_val=5 fail_loc=0x80000312
4954 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4958 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4959 $LCTL set_param fail_val=6 fail_loc=0x80000329
4960 $LCTL mark kill $pid
4963 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4966 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4968 evict=$(do_facet client $LCTL get_param \
4969 osc.$FSNAME-OST*-osc-*/state |
4970 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4972 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4973 (do_facet client $LCTL get_param \
4974 osc.$FSNAME-OST*-osc-*/state;
4975 error "eviction happened: $evict before:$before")
4976 $LCTL set_param osc.*.idle_timeout=debug
4978 run_test 94 "signal vs CP callback race"
4982 skip "Reserved for glimpse-ahead" && return
4983 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4984 skip "Need MDS version at least 2.10.55"
4988 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4990 lctl set_param -n mdc.*.stats=clear
4991 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4993 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4994 # first stat from server should return size data and save glimpse
4995 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4996 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4997 # second stat to check size is NOT cached on client without IO lock
4998 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5000 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5001 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5004 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5007 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5008 skip "Need MDS version at least 2.10.55"
5012 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5014 lctl set_param -n mdc.*.stats=clear
5015 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5016 cancel_lru_locks mdc
5017 # first stat data from server should have size
5018 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5019 # second stat to check size is cached on client
5020 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5022 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5023 # both stats should cause no glimpse requests
5024 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5027 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5030 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5031 skip "Need MDS version at least 2.10.55"
5035 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5037 lctl set_param -n mdc.*.stats=clear
5038 lctl set_param -n osc.*.stats=clear
5039 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5041 # check that size is merged from MDT and OST correctly
5042 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5043 error "Wrong size from stat #1"
5045 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5046 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5050 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5053 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5054 skip "Need MDS version at least 2.10.55"
5058 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5061 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5062 lctl set_param -n mdc.*.stats=clear
5063 $TRUNCATE $DIR2/$tdir/dom 4096
5065 # check that reported size is valid after file grows to OST and
5066 # is truncated back to MDT stripe size
5067 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5068 error "Wrong size from stat #1"
5070 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5071 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5075 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5078 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5079 skip "Need MDS version at least 2.11.50"
5081 local dom=$DIR/$tdir/dom
5082 local dom2=$DIR2/$tdir/dom
5085 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5087 cancel_lru_locks mdc
5088 dd if=/dev/urandom of=$dom bs=12000 count=1
5089 $TRUNCATE $dom2 6000
5090 cancel_lru_locks mdc
5091 lctl set_param -n mdc.*.stats=clear
5092 # expect read-on-open to return all data before write
5093 cat /etc/hosts >> $dom
5094 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5095 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5097 run_test 100e "DoM: read on open and file size"
5100 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5101 skip "Need MDS version at least 2.10.55"
5103 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5105 $CHECKSTAT -t file $DIR1/$tfile
5107 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5108 sysctl -wq vm.dirty_writeback_centisecs=0
5110 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5113 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5114 error_noexit "Write fails"
5115 # must discard pages
5116 lctl set_param -n mdc.*.stats=clear
5117 rm $DIR2/$tfile || error "Unlink fails"
5119 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5120 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5122 run_test 101a "Discard DoM data on unlink"
5125 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5126 skip "Need MDS version at least 2.10.55"
5128 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5129 touch $DIR1/${tfile}_2
5131 $CHECKSTAT -t file $DIR1/$tfile
5133 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5134 sysctl -wq vm.dirty_writeback_centisecs=0
5136 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5139 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5140 # must discard pages
5141 lctl set_param -n mdc.*.stats=clear
5142 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5144 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5145 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5147 run_test 101b "Discard DoM data on rename"
5150 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5151 skip "Need MDS version at least 2.10.55"
5153 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5155 $CHECKSTAT -t file $DIR1/$tfile
5157 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5158 sysctl -wq vm.dirty_writeback_centisecs=0
5160 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5163 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5164 $MULTIOP $DIR1/$tfile O_c &
5167 lctl set_param -n mdc.*.stats=clear
5168 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5169 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5171 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5172 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5174 run_test 101c "Discard DoM data on close-unlink"
5176 # test to verify file handle related system calls
5177 # (name_to_handle_at/open_by_handle_at)
5178 # The new system calls are supported in glibc >= 2.14.
5180 # test to verify we can open by handle an unlinked file from > 1 client
5181 # This test opens the file normally on $DIR1, which is on one mount, and then
5182 # opens it by handle on $DIR2, which is on a different mount.
5184 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
5185 skip "Needs MDS version 2.11.57 or later"
5187 echo "Test file_handle syscalls" > $DIR/$tfile ||
5188 error "write failed"
5189 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5190 error "check_fhandle_syscalls failed"
5193 run_test 102 "Test open by handle of unlinked file"
5195 # Compare file size between first & second mount, ensuring the client correctly
5196 # glimpses even with unused speculative locks - LU-11670
5198 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5199 skip "Lockahead needs OST version at least 2.10.50"
5203 test_mkdir -p $DIR/$tdir
5205 # Force file on to OST0
5206 $LFS setstripe -i 0 $DIR/$tdir
5208 # Do not check multiple locks on glimpse
5209 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5210 $LCTL set_param fail_loc=0x415
5212 # Delay write commit by 2 seconds to guarantee glimpse wins race
5213 # The same fail_loc is used on client & server so it can work in the
5214 # single node sanity setup
5215 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5217 echo "Incorrect size expected (no glimpse fix):"
5218 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5220 if [ $rc -eq 0 ]; then
5221 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5224 # guarantee write commit timeout has expired
5227 # Clear fail_loc on client
5228 $LCTL set_param fail_loc=0
5230 # Delay write commit by 2 seconds to guarantee glimpse wins race
5231 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5232 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5234 # Write commit is still delayed by 2 seconds
5235 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5237 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5239 # guarantee write commit timeout has expired
5242 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5244 run_test 103 "Test size correctness with lockahead"
5250 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5261 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5262 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5263 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5264 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5272 local xtimes=($(get_stat_xtimes))
5273 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5275 echo "STAT a|m|ctime ${xtimes[*]}"
5276 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5277 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5278 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5279 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5280 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5281 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5282 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5286 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5287 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5288 skip "Need MDS version at least 2.12.4"
5291 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5292 local atime_diff=$(do_facet $SINGLEMDS \
5293 lctl get_param -n mdd.*MDT0000*.atime_diff)
5295 do_facet $SINGLEMDS \
5296 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5298 stack_trap "do_facet $SINGLEMDS \
5299 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5301 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5302 check_mdt_xtimes $mdtdev
5305 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5306 check_mdt_xtimes $mdtdev
5308 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5311 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5313 kill -USR1 $pid && wait $pid || error "multiop failure"
5314 check_mdt_xtimes $mdtdev
5319 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5320 # on the client side
5321 xtimes=($(get_stat_xtimes))
5322 $MULTIOP $DIR/$tfile O_c &
5325 kill -USR1 $pid && wait $pid || error "multiop failure"
5326 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5327 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5328 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5329 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5330 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5331 check_mdt_xtimes $mdtdev
5334 # Change ctime via chmod
5335 $MULTIOP $DIR/$tfile o_tc &
5338 kill -USR1 $pid && wait $pid || error "multiop failure"
5339 check_mdt_xtimes $mdtdev
5341 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5344 test_mkdir -p $DIR/$tdir
5345 echo test > $DIR/$tdir/$tfile
5346 $LCTL set_param fail_loc=0x416
5347 cancel_lru_locks osc & sleep 1
5348 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5350 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5352 run_test 105 "Glimpse and lock cancel race"
5355 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5356 skip_env "Test only for ldiskfs and statx() supported"
5361 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5363 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5364 btime=$($STATX -c %W $DIR/$tfile)
5365 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5367 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5368 [[ $btime == $mdt_btime ]] ||
5369 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5372 run_test 106a "Verify the btime via statx()"
5375 statx_supported || skip_env "statx() only test"
5380 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5381 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5382 cancel_lru_locks $OSC
5383 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5385 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5386 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5387 error "$STATX should send 1 glimpse RPC to $OSC"
5389 cancel_lru_locks $OSC
5390 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5391 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5392 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5394 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5395 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5396 [ $rpcs_after -eq $rpcs_before ] ||
5397 error "$STATX should not send glimpse RPCs to $OSC"
5399 cancel_lru_locks $OSC
5400 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5401 $STATX --cached=always $DIR/$tfile
5402 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5403 [ $rpcs_after -eq $rpcs_before ] ||
5404 error "$STATX should not send glimpse RPCs to $OSC"
5406 cancel_lru_locks $OSC
5407 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5408 $STATX -c %Y $DIR/$tfile
5409 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5410 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5411 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5413 cancel_lru_locks $OSC
5414 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5415 $STATX -c %s $DIR/$tfile
5416 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5417 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5418 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5420 cancel_lru_locks $OSC
5421 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5422 $STATX -c %b $DIR/$tfile
5423 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5424 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5425 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5427 run_test 106b "Glimpse RPCs test for statx"
5430 statx_supported || skip_env "statx() only test"
5435 # Mask supported in stx_attributes by Lustre is
5436 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5437 mask=$($STATX -c %p $DIR/$tfile)
5438 [[ $mask == "30" ]] ||
5439 error "supported stx_attributes: got '$mask', expected '30'"
5440 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5441 mask=$($STATX -c %r $DIR/$tfile)
5442 [[ $mask == "10" ]] ||
5443 error "got immutable flags '$mask', expected '10'"
5444 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5445 mask=$($STATX -c %r $DIR/$tfile)
5446 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5447 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5448 mask=$($STATX -c %r $DIR/$tfile)
5449 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5450 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5451 mask=$($STATX -c %r $DIR/$tfile)
5452 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5453 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5454 mask=$($STATX -c %r $DIR/$tfile)
5455 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5456 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5457 mask=$($STATX -c %r $DIR/$tfile)
5458 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5460 run_test 106c "Verify statx attributes mask"
5462 test_107a() { # LU-1031
5463 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5467 $LFS getstripe $DIR1/$tfile
5469 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5471 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5473 kill -USR1 $MULTIPID2
5475 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5476 error "First grouplock does not block second one"
5478 echo "First grouplock blocks second one"
5480 kill -USR1 $MULTIPID1
5484 run_test 107a "Basic grouplock conflict"
5487 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5491 $LFS getstripe $DIR1/$tfile
5493 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5495 multiop $DIR2/$tfile Or10c &
5499 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5500 error "Grouplock does not block IO"
5502 echo "Grouplock blocks IO"
5505 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5508 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5509 error "First grouplock does not block second one"
5511 echo "First grouplock blocks second one"
5514 kill -USR1 $MULTIPID1
5517 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5518 error "Second grouplock thread disappeared"
5521 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5522 error "Second grouplock does not block IO"
5524 echo "Second grouplock blocks IO"
5527 kill -USR1 $MULTIPID3
5532 run_test 107b "Grouplock is added to the head of waiting list"
5537 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5538 error "Create $DIR1/$tfile failed"
5540 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5541 error "dd $DIR1/$tfile failed"
5542 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5543 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5545 $TRUNCATE $DIR1/$tfile 2000
5546 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5547 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5549 #define OBD_FAIL_OSC_DELAY_IO 0x414
5550 $LCTL set_param fail_val=4 fail_loc=0x80000414
5551 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5555 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5557 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5559 run_test 108a "lseek: parallel updates"
5561 log "cleanup: ======================================================"
5563 # kill and wait in each test only guarentee script finish, but command in script
5564 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5565 # otherwise umount below will fail
5566 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5571 check_and_cleanup_lustre