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 # bug number for skipped test: LU-14541
25 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
27 # skip tests for PPC until they are fixed
28 if [[ $(uname -m) = ppc64 ]]; then
29 # bug number: LU-11787
33 if [ $mds1_FSTYPE = "zfs" ]; then
34 # bug number: LU-15757 (test_102() causes crash in umount later)
36 # LU-2829 / LU-2887 - make allowances for ZFS slowness
37 TEST33_NFILES=${TEST33_NFILES:-1000}
41 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
50 check_and_setup_lustre
55 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
57 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
58 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
60 # $RUNAS_ID may get set incorrectly somewhere else
61 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
63 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
67 [ -f $DIR2/$tfile ] || error "Check create"
68 chmod 777 $DIR2/$tfile
69 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
70 error "Check attribute update for 0777"
72 chmod a-x $DIR2/$tfile
73 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
74 error "Check attribute update for 0666"
77 $CHECKSTAT -a $DIR1/$tfile ||
78 error "Check unlink - removes file on other mountpoint"
80 run_test 1 "Check attribute updates on 2 mount points"
86 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
87 error "Either not file type or perms not 0777"
89 run_test 2a "check cached attribute updates on 2 mtpt's ========"
95 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
96 error "Either not file type or perms not 0777"
98 run_test 2b "check cached attribute updates on 2 mtpt's ========"
100 # NEED TO SAVE ROOT DIR MODE
103 $CHECKSTAT -t dir -p 0777 $DIR2 ||
104 error "Either not dir type or perms not 0777"
106 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
110 $CHECKSTAT -t dir -p 0755 $DIR2 ||
111 error "Either not file type or perms not 0775"
113 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
120 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
123 run_test 2e "check chmod on root is propagated to others"
126 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
128 local remote_dir=$tdir/remote_dir
131 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
132 error "Create remote directory failed"
134 touch $DIR1/$remote_dir/$tfile ||
135 error "Create file under remote directory failed"
136 chmod 777 $DIR1/$remote_dir/$tfile ||
137 error "Chmod file under remote directory failed"
139 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
140 error "Check attr of file under remote directory failed"
142 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
143 error "Chown file under remote directory failed"
145 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
146 error "Check owner of file under remote directory failed"
148 cd $DIR2/$remote_dir || error "enter remote dir"
149 rm -rf $DIR1/$remote_dir/$tfile ||
150 error "Unlink remote directory failed"
152 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
153 error "unlink file still exists!"
155 cd $DIR2/$tdir || error "exit remote dir"
156 rm -rf $DIR1/$tdir || error "unlink directory failed"
158 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
161 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
163 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
165 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
166 echo "$DIR1/$tfile has $block1 blocks"
167 echo "$DIR2/$tfile has $block2 blocks"
168 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
170 run_test 2g "check blocks update on sync write"
173 local target="this/is/good"
174 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
175 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
176 error "link $DIR2/$tfile not as expected"
178 run_test 3 "symlink on one mtpt, readlink on another ==========="
181 multifstat $DIR1/f4 $DIR2/f4
183 run_test 4 "fstat validation on multiple mount points =========="
187 $TRUNCATE $DIR2/f5 100
188 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
189 error "Either not file type or size not equal to 100 bytes"
192 run_test 5 "create a file on one mount, truncate it on the other"
195 openunlink $DIR1/$tfile $DIR2/$tfile || \
196 error "openunlink $DIR1/$tfile $DIR2/$tfile"
198 run_test 6 "remove of open file on other node =================="
202 opendirunlink $DIR1/$dir $DIR2/$dir || \
203 error "opendirunlink $DIR1/$dir $DIR2/$dir"
205 run_test 7 "remove of open directory on other node ============="
208 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
209 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
211 run_test 8 "remove of open special file on other node =========="
217 for C in a b c d e f g h i j k l; do
218 dir=`eval echo \\$DIR$MTPT`
219 echo -n $C >> $dir/f9
220 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
222 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
223 error "`od -a $DIR1/f9` != abcdefghijkl"
225 run_test 9a "append of file with sub-page size on multiple mounts"
227 #LU-10681 - tiny writes & appending to sparse striped file
229 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
231 $LFS setstripe -c 2 -S 1M $DIR/$tfile
232 echo "foo" >> $DIR/$tfile
233 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
234 error "sparse dd $DIR2/$tfile failed"
235 echo "foo" >> $DIR/$tfile
237 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
238 echo "Data read (expecting 'foo')": $data
239 [ "$data" = "foo" ] || error "append to sparse striped file failed"
241 run_test 9b "append to striped sparse file"
248 for C in a b c d e f g h i j k l; do
249 dir=`eval echo \\$DIR$MTPT`
250 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
251 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
252 OFFSET=`expr $OFFSET + 1`
254 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
255 error "`od -a $DIR1/f10` != abcdefghijkl"
257 run_test 10a "write of file with sub-page size on multiple mounts "
261 yes "R" | head -c 4000 >$TMP/f10b-seed
262 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
264 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
266 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
268 # create a test file locally to compare
269 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
270 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
271 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
272 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
274 run_test 10b "write of file with sub-page size on multiple mounts "
278 multiop_bg_pause $DIR1/d11/f O_c || return 1
280 cp -p /bin/ls $DIR1/d11/f
284 wait $MULTIPID || error "wait for PID $MULTIPID failed"
285 [ $RC -eq 0 ] && error || true
287 run_test 11 "execution of file opened for write should return error ===="
290 DIR=$DIR DIR2=$DIR2 bash lockorder.sh
292 run_test 12 "test lock ordering (link, stat, unlink)"
294 test_13() { # bug 2451 - directory coherency
296 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
298 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
300 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
301 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
302 # need to run it twice
303 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
305 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
306 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
308 run_test 13 "test directory page revocation"
311 test_mkdir $DIR1/$tdir
312 cp -p /bin/ls $DIR1/$tdir/$tfile
313 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
316 $DIR2/$tdir/$tfile && error || true
319 run_test 14aa "execution of file open for write returns -ETXTBSY"
322 test_mkdir $DIR1/$tdir
323 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
324 $DIR1/$tdir/sleep 60 &
326 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
329 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
331 test_14b() { # bug 3192, 7040
332 test_mkdir $DIR1/$tdir
333 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
334 $DIR1/$tdir/sleep 60 &
336 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
337 error "expected truncate error, got success"
339 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
341 run_test 14b "truncate of executing file returns -ETXTBSY ======"
343 test_14c() { # bug 3430, 7040
344 test_mkdir $DIR1/$tdir
345 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
346 $DIR1/$tdir/sleep 60 &
348 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
350 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
352 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
354 test_14d() { # bug 10921
355 test_mkdir $DIR1/$tdir
356 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
357 $DIR1/$tdir/sleep 60 &
360 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
362 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
364 run_test 14d "chmod of executing file is still possible ========"
366 test_15() { # bug 974 - ENOSPC
368 bash oos2.sh $MOUNT1 $MOUNT2
369 wait_delete_completed
370 grant_error=$(dmesg | grep "< tot_grant")
371 [ -z "$grant_error" ] || error "$grant_error"
373 run_test 15 "test out-of-space with multiple writers ==========="
376 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
377 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
378 # pass a 2500 operation dual-mount run within the time limit.
379 if [ "$ost1_FSTYPE" = "zfs" ]; then
380 FSXNUM=$((COUNT / 5))
382 elif [ "$SLOW" = "yes" ]; then
383 FSXNUM=$((COUNT * 5))
391 local file1=$DIR1/$tfile
392 local file2=$DIR2/$tfile
393 local stripe_size=$(do_facet $SINGLEMDS \
394 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
398 # to allocate grant because it may run out due to test_15.
399 $LFS setstripe -c -1 $file1
400 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
401 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
404 $LFS setstripe -c -1 $file1 # b=10919
405 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
409 # O_DIRECT reads and writes must be aligned to the PAGE_SIZE.
410 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r $PAGE_SIZE \
411 -w $PAGE_SIZE $file1 $file2 || error "fsx with O_DIRECT failed."
413 run_test 16a "$FSXNUM iterations of dual-mount fsx"
415 # Consistency check for tiny writes, LU-9409
417 local file1=$DIR1/$tfile
418 local file2=$DIR2/$tfile
419 local stripe_size=($($LFS getstripe -S $DIR))
423 # to allocate grant because it may run out due to test_15.
424 lfs setstripe -c -1 $file1
425 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
426 error "dd failed writing to file=$file1"
427 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
428 error "dd failed writing to file=$file2"
431 lfs setstripe -c -1 $file1 # b=10919
432 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
433 # create a mix of tiny writes & normal writes
434 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
435 $file1 $file2 || error "fsx with tiny write failed."
437 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
440 local file1=$DIR1/$tfile
441 local file2=$DIR2/$tfile
442 local stripe_size=$(do_facet $SINGLEMDS \
443 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
445 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
449 # to allocate grant because it may run out due to test_15.
450 $LFS setstripe -c -1 $file1
451 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
452 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
454 wait_delete_completed
456 local list=$(comma_list $(osts_nodes))
457 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
458 skip "not cache-capable obdfilter"
461 set_osd_param $list '' read_cache_enable 0
462 set_osd_param $list '' writethrough_cache_enable 0
464 $LFS setstripe -c -1 $file1 # b=10919
465 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
469 set_osd_param $list '' read_cache_enable 1
470 set_osd_param $list '' writethrough_cache_enable 1
474 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
477 local file1=$DIR1/$tfile
478 local file2=$DIR2/$tfile
479 local file3=$DIR1/file
480 local tmpfile=$(mktemp)
481 local stripe_size=$(do_facet $SINGLEMDS \
482 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
484 # to allocate grant because it may run out due to test_15.
485 $LFS setstripe -c -1 $file1
486 stack_trap "rm -f $file1 $file2 $file3 $tmpfile"
487 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
488 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
491 $LFS setstripe -c -1 $file1 # b=10919
492 $LCTL set_param ldlm.namespaces.*.lru_size=clear
494 # direct write on one client and direct read from another
495 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
496 dd if=$file2 of=$tmpfile iflag=direct bs=1M
497 diff $file1 $tmpfile || error "file different(1)"
500 # buffer write on one client, but direct read from another
501 dd if=$tmpfile of=$file1 bs=1M count=100
502 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
503 diff $file3 $tmpfile || error "file different(2)"
505 rm -f $file3 $file2 $file1
506 # direct write on one client
507 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
508 # buffer read from another client
509 dd if=$file2 of=$file3 bs=1M count=100
510 diff $file3 $tmpfile || error "file different(3)"
512 run_test 16d "Verify DIO and buffer IO with two clients"
514 test_16e() { # LU-13227
517 (( "$MDS1_VERSION" >= $(version_code 2.13.53) )) ||
518 skip "Need MDS version at least 2.13.53"
520 local file1=$DIR1/$tfile
521 local file2=$DIR2/$tfile
523 # client1 write 10M data
524 dd if=/dev/zero of=$file1 bs=1M count=10
526 cancel_lru_locks osc > /dev/null
527 # use lockahead to generate one PW lock to keep LVB loaded.
528 $LFS ladvise -a lockahead --start 0 --length 1M \
530 # direct write to extend file size on client2
531 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
532 oflag=direct conv=notrunc
533 local filesize=$(stat -c %s $file2)
534 [ "$filesize" -eq 22020096 ] ||
535 error "expected filesize 22020096 got $filesize"
538 run_test 16e "Verify size consistency for O_DIRECT write"
540 test_16f() { # LU-14541
541 local file1=$DIR1/$tfile
542 local file2=$DIR2/$tfile
546 timeout --preserve-status --signal=USR1 $duration \
547 rw_seq_cst_vs_drop_caches $file1 $file2
550 case $((status & 0x7f)) in
552 echo OK # Computers must be fast now.
555 error "sequential consistency violation detected"
558 echo TIMEOUT # This is fine.
561 error "strange status '$status'"
567 run_test 16f "rw sequential consistency vs drop_caches"
569 test_17() { # bug 3513, 3667
570 remote_ost_nodsh && skip "remote OST with nodsh" && return
572 lfs setstripe $DIR1/$tfile -i 0 -c 1
573 cp $SAMPLE_FILE $DIR1/$tfile
574 cancel_lru_locks osc > /dev/null
575 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
576 do_facet ost1 lctl set_param fail_loc=0x8000030a
577 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
578 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
580 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
582 run_test 17 "resource creation/LVB creation race ==============="
585 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
588 for idx in {a..z}; do
589 local ptr=EXCEPT_ALWAYS_18$idx
590 [ x${!ptr} = xtrue ] || continue
592 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
595 excepts="$excepts -e 7 -e 8 -e 9"
596 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
597 error "mmap_sanity test failed"
600 run_test 18 "mmap sanity check ================================="
602 test_19() { # bug3811
603 local node=$(facet_active_host ost1)
604 local device="$FSNAME-OST*"
606 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
607 device="$FSNAME-MDT*"
609 # check whether obdfilter is cache capable at all
610 get_osd_param $node $device read_cache_enable >/dev/null ||
611 skip "not cache-capable obdfilter"
613 local max=$(get_osd_param $node $device readcache_max_filesize |\
615 set_osd_param $node $device readcache_max_filesize 4096
616 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
617 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
618 cp $TMP/$tfile $DIR1/$tfile
619 for i in `seq 1 20`; do
620 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
621 cancel_lru_locks $OSC > /dev/null
622 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
623 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
625 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
626 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
627 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
628 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
630 set_osd_param $node $device readcache_max_filesize $max
633 run_test 19 "test concurrent uncached read races ==============="
636 test_mkdir $DIR1/$tdir
638 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
639 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
640 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
641 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
643 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
644 [[ $CNT2 == $CNT ]] ||
645 error $((CNT2 - CNT))" page left in cache after lock cancel"
647 run_test 20 "test extra readahead page left in cache ===="
654 test_21() { # Bug 5907
655 test_mkdir $DIR1/$tdir
656 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
658 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
659 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
660 test -d $DIR1/$tdir || error "Mounted directory disappeared"
662 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
665 run_test 21 " Try to remove mountpoint on another dir ===="
667 test_23() { # Bug 5972
668 local at_diff=$(do_facet $SINGLEMDS \
669 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
670 echo "atime should be updated while another read" > $DIR1/$tfile
672 # clear the lock(mode: LCK_PW) gotten from creating operation
673 cancel_lru_locks $OSC
676 sleep $((at_diff + 1))
678 echo "starting reads"
679 multiop_bg_pause $DIR1/$tfile or20_c || return 1
680 # with SOM and opencache enabled, we need to close a file and cancel
681 # open lock to get atime propogated to MDS
682 kill -USR1 $! || return 2
685 time2=$(stat -c "%X" $DIR/$tfile)
686 echo "new atime is $time2"
688 [ $time2 -gt $time1 ] || error "atime was not updated"
689 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
692 run_test 23 " others should see updated atime while another read===="
696 lfs df || error "lfs df failed"
697 lfs df -ih || error "lfs df -ih failed"
698 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
699 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
700 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
701 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
703 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
704 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
705 lctl --device %osc deactivate
706 lfs df -i || error "lfs df -i with deactivated OSC failed"
707 lctl --device %osc activate
708 lfs df || error "lfs df with reactivated OSC failed"
710 run_test 24a "lfs df [-ih] [path] test ========================="
714 fsnum=$(lfs_df | grep -c "summary")
715 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
717 run_test 24b "lfs df should show both filesystems ==============="
720 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
722 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
725 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
726 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
728 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
729 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
730 error "setfacl $DIR2/$tdir #1"
731 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
732 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
733 error "setfacl $DIR2/$tdir #2"
734 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
735 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
736 error "setfacl $DIR2/$tdir #3"
737 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
738 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
739 error "setfacl $DIR2/$tdir #4"
740 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
744 run_test 25a "change ACL on one mountpoint be seen on another ==="
747 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
749 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
751 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
754 $LFS mkdir -i 1 $DIR1/$tdir
755 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
756 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
758 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
759 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
760 error "setfacl $DIR2/$tdir #1"
761 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
762 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
763 error "setfacl $DIR2/$tdir #2"
764 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
765 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
766 error "setfacl $DIR2/$tdir #3"
767 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
768 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
769 error "setfacl $DIR2/$tdir #4"
770 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
774 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
777 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
779 run_test 26a "allow mtime to get older"
784 echo "aaa" >> $DIR1/$tfile
786 chmod a+x $DIR2/$tfile
787 mt1=`stat -c %Y $DIR1/$tfile`
788 mt2=`stat -c %Y $DIR2/$tfile`
790 if [ x"$mt1" != x"$mt2" ]; then
791 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
794 run_test 26b "sync mtime between ost and mds"
797 cancel_lru_locks $OSC
799 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
804 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
809 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
811 lctl set_param -n ldlm.dump_namespaces ""
812 wait $DD1_PID $DD2_PID
813 [ $? -ne 0 ] && lctl dk $TMP/debug || true
815 run_test 27 "align non-overlapping extent locks from request ==="
817 test_28() { # bug 9977
818 ECHO_UUID="ECHO_osc1_UUID"
819 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
821 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
822 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
823 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
827 attach echo_client ECHO_osc1 $ECHO_UUID
831 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
832 $LCTL --device $tECHOID destroy "${tOBJID}:0"
840 # reading of 1st stripe should pass
841 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
842 # reading of 2nd stripe should fail (this stripe was destroyed)
843 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
845 # now, recreating test file
846 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
847 # reading of 1st stripe should pass
848 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
849 # reading of 2nd stripe should pass
850 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
853 run_test 28 "read/write/truncate file with lost stripes"
855 test_30() { #b=11110, LU-2523
856 test_mkdir $DIR1/$tdir
857 cp -f /bin/bash $DIR1/$tdir/bash
858 bash -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
859 $DIR1/$tdir/bash -c 'sleep 2;
860 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
864 run_test 30 "recreate file race"
867 test_mkdir $DIR1/$tdir
868 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
869 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
870 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
871 lctl set_param fail_loc=0x314
872 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
873 awk 'BEGIN { FS="+" } /in/ {print $1}')
874 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
876 run_test 31a "voluntary cancel / blocking ast race=============="
879 remote_ost || { skip "local OST" && return 0; }
880 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
882 # make sure there is no local locks due to destroy
883 wait_mds_ost_sync || error "wait_mds_ost_sync()"
884 wait_delete_completed || error "wait_delete_completed()"
886 test_mkdir $DIR1/$tdir
887 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
888 cp /etc/hosts $DIR/$tdir/$tfile
889 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
890 lctl set_param fail_loc=0x314
891 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
892 do_facet ost1 lctl set_param fail_loc=0x316
894 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
895 lctl set_param fail_loc=0
896 do_facet ost1 lctl set_param fail_loc=0
897 # cleanup: reconnect the client back
900 run_test 31b "voluntary OST cancel / blocking ast race=============="
902 #LU-14949 - multi-client version of the test 31r in sanity.
904 touch $DIR/$tfile.target
905 touch $DIR/$tfile.source
907 ls -l $DIR/$tfile.target # cache it for sure
909 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
910 $LCTL set_param fail_loc=0x1419 fail_val=3
911 cat $DIR/$tfile.target &
914 # Guarantee open is waiting before we get here
916 mv $DIR2/$tfile.source $DIR2/$tfile.target
920 if [[ $RC -ne 0 ]]; then
921 error "open with cat failed, rc=$RC"
924 run_test 31r "open-rename(replace) race"
926 test_32b() { # bug 11270
927 remote_ost_nodsh && skip "remote OST with nodsh" && return
930 local facets=$(get_facets OST)
931 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
933 save_lustre_params client "osc.*.contention_seconds" > $p
934 save_lustre_params $facets \
935 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
936 save_lustre_params $facets \
937 "ldlm.namespaces.filter-*.contended_locks" >> $p
938 save_lustre_params $facets \
939 "ldlm.namespaces.filter-*.contention_seconds" >> $p
940 clear_stats $OSC.*.${OSC}_stats
942 # agressive lockless i/o settings
943 do_nodes $(comma_list $(osts_nodes)) \
944 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
945 ldlm.namespaces.filter-*.contended_locks=0 \
946 ldlm.namespaces.filter-*.contention_seconds=60"
947 lctl set_param -n $OSC.*.contention_seconds=60
949 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
951 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
954 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
955 error "lockless i/o was not triggered"
956 # disable lockless i/o (it is disabled by default)
957 do_nodes $(comma_list $(osts_nodes)) \
958 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
959 ldlm.namespaces.filter-*.contended_locks=32 \
960 ldlm.namespaces.filter-*.contention_seconds=0"
961 # set contention_seconds to 0 at client too, otherwise Lustre still
962 # remembers lock contention
963 lctl set_param -n $OSC.*.contention_seconds=0
964 clear_stats $OSC.*.${OSC}_stats
966 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
968 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
971 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
972 error "lockless i/o works when disabled"
974 restore_lustre_params <$p
977 # Disable test 32b prior to full removal
978 #run_test 32b "lockless i/o"
981 local mdts=$(get_facets MDS)
987 for mds in ${mdts//,/ }; do
990 dev=$(basename $(do_facet $mds "lctl get_param -n \
991 osd*.${!varsvc}.mntdev | xargs readlink -f"))
992 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
993 2>/dev/null | head -n1")
1000 # commit on sharing tests
1002 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1004 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
1005 [ $CLIENTCOUNT -lt 2 ] &&
1006 skip "Need two or more clients, have $CLIENTCOUNT"
1008 local nfiles=${TEST33_NFILES:-10000}
1009 local param_file=$TMP/$tfile-params
1015 save_lustre_params $(get_facets MDS) \
1016 "mdt.*.commit_on_sharing" > $param_file
1019 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1023 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1025 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1026 echo "=== START createmany old: $jbdold transaction"
1027 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")
1028 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1029 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1030 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1031 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1032 avgtime=$(( avgtime + elapsed ))
1034 eval cos${COS}_jbd=$((avgjbd / 3))
1035 eval cos${COS}_time=$((avgtime / 3))
1038 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1039 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1040 [ "$cos0_jbd" != 0 ] &&
1041 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1042 [ "$cos0_time" != 0 ] &&
1043 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1045 restore_lustre_params < $param_file
1049 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1051 # commit on sharing tests
1053 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1055 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1056 [ $CLIENTCOUNT -ge 2 ] ||
1057 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1059 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1061 local nfiles=${TEST33_NFILES:-10000}
1062 local param_file=$TMP/$tfile-params
1064 save_lustre_params $(get_facets MDS) \
1065 "mdt.*.commit_on_sharing" > $param_file
1074 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1078 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1079 $DIR1/$tdir-\\\$(hostname)-$i"
1081 jbdold=$(print_jbd_stat)
1082 echo "=== START createmany old: $jbdold transaction"
1083 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1084 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1085 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1087 jbdnew=$(print_jbd_stat)
1088 jbd=$(( jbdnew - jbdold ))
1089 echo "=== END createmany new: $jbdnew transaction : \
1090 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1091 avgjbd=$(( avgjbd + jbd ))
1092 avgtime=$(( avgtime + elapsed ))
1094 eval cos${COS}_jbd=$((avgjbd / 3))
1095 eval cos${COS}_time=$((avgtime / 3))
1098 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1099 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1100 [ "$cos0_jbd" != 0 ] &&
1101 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1102 [ "$cos0_time" != 0 ] &&
1103 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1105 restore_lustre_params < $param_file
1109 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1112 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1113 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1114 skip "DNE CoS not supported"
1118 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1122 mkdir_on_mdt0 $DIR/$tdir
1124 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1125 # do twice in case transaction is committed before unlock, see LU-8200
1127 # remote dir is created on MDT1, which enqueued lock of $tdir on
1129 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1130 mkdir $DIR/$tdir/local.$i
1132 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1133 echo "sync_count $sync_count"
1134 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1137 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1138 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1139 # during sleep remote mkdir should have been committed and canceled
1140 # remote lock spontaneously, which shouldn't trigger sync
1142 mkdir $DIR/$tdir/local.3
1143 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1144 echo "sync_count $sync_count"
1145 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1147 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1149 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1153 local nodes=$(comma_list $(mdts_nodes))
1157 # trigger CoS twice in case transaction commit before unlock
1160 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1162 commit_nr=$(do_nodes $nodes \
1163 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1164 total=$((total + commit_nr));
1169 echo "CoS count $total"
1170 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1174 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1175 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1176 skip "DNE CoS not supported"
1178 # remote directory create
1179 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1180 # remote directory unlink
1181 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1182 # striped directory create
1183 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1184 # striped directory setattr
1185 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1186 "chmod 713 $DIR/$tdir"
1187 # striped directory unlink
1188 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1191 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1192 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1193 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1194 touch $DIR/$tdir/d1/tgt" \
1195 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1197 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1198 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1199 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1200 touch $DIR/$tdir/d1/src" \
1201 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1203 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1204 "$LFS migrate -m 1 $DIR/$tdir"
1208 run_test 33d "DNE distributed operation should trigger COS"
1211 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1212 [ $CLIENTCOUNT -ge 2 ] ||
1213 skip "Need two or more clients, have $CLIENTCOUNT"
1214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1215 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1216 skip "DNE CoS not supported"
1218 local client2=${CLIENT2:-$(hostname)}
1222 local nodes=$(comma_list $(mdts_nodes))
1223 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1225 $LFS mkdir -c 2 $DIR/$tdir
1226 mkdir $DIR/$tdir/subdir
1227 echo abc > $DIR/$tdir/$tfile
1228 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1229 do_node $client2 touch $DIR/$tdir/subdir
1231 local async_commit_count=$(do_nodes $nodes \
1232 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1233 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1237 run_test 33e "DNE local operation shouldn't trigger COS"
1239 # End commit on sharing tests
1241 get_ost_lock_timeouts() {
1242 local nodes=${1:-$(comma_list $(osts_nodes))}
1244 local locks=$(do_nodes $nodes \
1245 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1253 do_nodes $(comma_list $(osts_nodes)) \
1254 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1255 for i in $(seq $OSTCOUNT); do
1256 wait_osc_import_ready client ost$i
1261 remote_ost_nodsh && skip "remote OST with nodsh" && return
1265 trap cleanup_34 EXIT RETURN
1266 for OPER in notimeout timeout ; do
1267 rm $DIR1/$tfile 2>/dev/null
1268 lock_in=$(get_ost_lock_timeouts)
1269 if [ $OPER == "timeout" ] ; then
1270 for j in `seq $OSTCOUNT`; do
1271 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1272 do_facet ost$j lctl set_param fail_loc=0x511
1274 echo lock should expire
1276 for j in `seq $OSTCOUNT`; do
1277 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1278 do_facet ost$j lctl set_param fail_loc=0x512
1280 echo lock should not expire
1282 echo writing on client1
1283 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1285 echo reading on client2
1286 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1287 # wait for a lock timeout
1289 lock_out=$(get_ost_lock_timeouts)
1290 if [ $OPER == "timeout" ] ; then
1291 if [ $lock_in == $lock_out ]; then
1292 error "no lock timeout happened"
1297 if [ $lock_in != $lock_out ]; then
1298 error "lock timeout happened"
1306 run_test 34 "no lock timeout under IO"
1308 test_35() { # bug 17645
1311 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1312 awk '/generation/{print $2}')
1314 generation[count]=$g
1318 test_mkdir $MOUNT1/$tdir
1319 cancel_lru_locks mdc
1321 # Let's initiate -EINTR situation by setting fail_loc and take
1322 # write lock on same file from same client. This will not cause
1323 # bl_ast yet as lock is already in local cache.
1324 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1325 do_facet client "lctl set_param fail_loc=0x80000317"
1326 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1327 let timeout=timeout*3
1329 while test $nr -lt 10; do
1330 log "Race attempt $nr"
1331 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1332 awk '/ldlm_bl_callback/ { print $2 }')
1333 test "x$blk1" = "x" && blk1=0
1334 createmany -o $MOUNT2/$tdir/a 4000 &
1338 # Let's make conflict and bl_ast
1339 ls -la $MOUNT1/$tdir > /dev/null &
1342 log "Wait for $pid1 $pid2 for $timeout sec..."
1344 kill -9 $pid1 $pid2 > /dev/null 2>&1
1346 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1347 awk '/ldlm_bl_callback/ { print $2 }')
1348 test "x$blk2" = "x" && blk2=0
1349 test $blk2 -gt $blk1 && break
1350 rm -fr $MOUNT1/$tdir
1351 cancel_lru_locks mdc
1354 do_facet client "lctl set_param fail_loc=0x0"
1355 df -h $MOUNT1 $MOUNT2
1357 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1358 awk '/generation/{print $2}')
1360 if ! test "$g" -eq "${generation[count]}"; then
1361 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1363 for imp in $list; do
1364 if [ $c = $count ]; then
1369 imp=$(echo "$imp" | awk -F"." '{print $2}')
1370 error "Eviction happened on import $imp"
1375 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1377 test_36() { #bug 16417
1382 test_mkdir $DIR1/$tdir
1383 $LFS setstripe -c -1 $DIR1/$tdir
1386 let SIZE_B=SIZE*1024*1024
1387 sync; sleep 2; sync # wait for delete thread
1388 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1389 wait_destroy_complete || error "wait_destroy_complete failed"
1391 while [ $i -le 10 ]; do
1392 lctl mark "start test - cycle ($i)"
1393 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1394 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1395 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1396 sync # sync data from client cache
1397 sync_all_data # sync data from server cache (delayed allocation)
1399 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1400 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1402 rm -f $DIR1/$tdir/$tfile
1403 kill -USR1 $read_pid
1405 sync; sleep 2; sync # Ensure new statfs
1406 wait_delete_completed
1407 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1408 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1410 # this free space! not used
1411 (( $after_dd <= $after)) ||
1412 error "space leaked after_dd:$after_dd > after:$after"
1416 run_test 36 "handle ESTALE/open-unlink correctly"
1418 test_37() { # bug 18695
1419 test_mkdir $DIR1/$tdir
1420 multiop_bg_pause $DIR1/$tdir D_c || return 1
1422 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1423 createmany -m $DIR2/$tdir/f 10000
1424 # set mtime/atime backward
1425 touch -t 198001010000 $DIR2/$tdir
1426 kill -USR1 $MULTIPID
1427 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1428 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1431 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1433 # this should be set to past
1434 TEST_39_MTIME=`date -d "1 year ago" +%s`
1438 local client1=${CLIENT1:-`hostname`}
1439 local client2=${CLIENT2:-`hostname`}
1441 do_node $client1 "touch $DIR1/$tfile"
1443 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1444 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1445 [ "$mtime1" = $TEST_39_MTIME ] || \
1446 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1448 local d1=`do_node $client1 date +%s`
1449 do_node $client1 'echo hello >> '$DIR1/$tfile
1450 local d2=`do_node $client1 date +%s`
1452 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1453 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1454 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1456 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1458 for (( i=0; i < 2; i++ )) ; do
1459 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1460 [ "$mtime2" = "$mtime3" ] || \
1461 error "mtime ($mtime2) changed (to $mtime3) on rename"
1463 cancel_lru_locks osc
1464 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1467 run_test 39a "test from 11063 =================================="
1470 local client1=${CLIENT1:-`hostname`}
1471 local client2=${CLIENT2:-`hostname`}
1475 local mtime1=`stat -c %Y $DIR1/$tfile`
1476 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1479 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1481 for (( i=0; i < 2; i++ )) ; do
1482 local mtime3=`stat -c %Y $DIR1/$tfile`
1483 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1485 [ "$mtime3" = "$mtime4" ] || \
1486 error "different mtime on clients: $mtime3, $mtime4"
1487 [ "$mtime3" = $TEST_39_MTIME ] || \
1488 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1490 cancel_lru_locks osc
1491 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1494 run_test 39b "11063 problem 1 =================================="
1497 local client1=${CLIENT1:-`hostname`}
1498 local client2=${CLIENT2:-`hostname`}
1500 echo hello > $DIR1/$tfile
1502 local mtime1=`stat -c %Y $DIR1/$tfile`
1503 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1504 [ "$mtime1" = "$mtime2" ] || \
1505 error "create: different mtime on clients: $mtime1, $mtime2"
1508 $TRUNCATE $DIR1/$tfile 1
1510 for (( i=0; i < 2; i++ )) ; do
1511 local mtime3=`stat -c %Y $DIR1/$tfile`
1512 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1514 [ "$mtime3" = "$mtime4" ] || \
1515 error "different mtime on clients: $mtime3, $mtime4"
1516 [ "$mtime3" -gt $mtime2 ] || \
1517 error "truncate did not update mtime: $mtime2, $mtime3"
1519 cancel_lru_locks osc
1520 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1523 run_test 39c "check truncate mtime update ======================"
1525 test_39d() { # LU-7310
1527 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1529 local mtime1=$(stat -c %Y $DIR2/$tfile)
1530 [ "$mtime1" = $TEST_39_MTIME ] ||
1531 error "mtime: $mtime1, should be $TEST_39_MTIME"
1534 # define OBD_FAIL_OSC_NO_GRANT 0x411
1535 $LCTL set_param fail_loc=0x411
1537 local d1=$(date +%s)
1538 echo hello >> $DIR1/$tfile
1539 local d2=$(date +%s)
1541 $LCTL set_param fail_loc=0
1543 cancel_lru_locks $OSC
1545 local mtime2=$(stat -c %Y $DIR2/$tfile)
1546 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1547 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1549 run_test 39d "sync write should update mtime"
1552 # how long 40-47 take with specific delay
1559 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1560 # avoid unexpected delays due to previous tests
1562 cancel_lru_locks mdc
1563 do_nodes $(comma_list $(mdts_nodes)) \
1564 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1565 do_nodes $(comma_list $(mdts_nodes)) \
1566 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1567 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1570 # check that pid exists hence second operation wasn't blocked by first one
1571 # if it is so then there is no conflict, return 0
1572 # else second operation is conflicting with first one, return 1
1573 check_pdo_conflict() {
1576 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1577 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1587 # test 40: check non-blocking operations
1589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1591 mkdir_on_mdt0 $DIR2/$tdir
1593 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1594 do_nodes $(comma_list $(mdts_nodes)) \
1595 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1596 mkdir $DIR1/$tdir/$tfile &
1598 touch $DIR2/$tdir/$tfile-2
1599 check_pdo_conflict $PID1 || error "create is blocked"
1600 mkdir $DIR2/$tdir/$tfile-3
1601 check_pdo_conflict $PID1 || error "mkdir is blocked"
1602 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1603 check_pdo_conflict $PID1 || error "link is blocked"
1604 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1605 check_pdo_conflict $PID1 || error "rename is blocked"
1606 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1607 check_pdo_conflict $PID1 || error "getattr is blocked"
1608 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1609 rmdir $DIR2/$tdir/$tfile-3
1610 check_pdo_conflict $PID1 || error "unlink is blocked"
1612 # all operations above shouldn't wait the first one
1613 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1614 do_nodes $(comma_list $(mdts_nodes)) \
1615 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1620 run_test 40a "pdirops: create vs others =============="
1623 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1625 mkdir_on_mdt0 $DIR2/$tdir
1627 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1628 do_nodes $(comma_list $(mdts_nodes)) \
1629 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1630 touch $DIR1/$tdir/$tfile &
1633 touch $DIR2/$tdir/$tfile-2
1634 check_pdo_conflict $PID1 || error "create is blocked"
1635 mkdir $DIR2/$tdir/$tfile-3
1636 check_pdo_conflict $PID1 || error "mkdir is blocked"
1637 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1638 check_pdo_conflict $PID1 || error "link is blocked"
1639 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1640 check_pdo_conflict $PID1 || error "rename is blocked"
1641 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1642 check_pdo_conflict $PID1 || error "getattr is blocked"
1643 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1644 rmdir $DIR2/$tdir/$tfile-3
1645 check_pdo_conflict $PID1 || error "unlink is blocked"
1646 # all operations above shouldn't wait the first one
1648 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1649 do_nodes $(comma_list $(mdts_nodes)) \
1650 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1655 run_test 40b "pdirops: open|create and others =============="
1658 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1660 mkdir_on_mdt0 $DIR2/$tdir
1662 touch $DIR1/$tdir/$tfile
1663 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1664 do_nodes $(comma_list $(mdts_nodes)) \
1665 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1666 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1669 touch $DIR2/$tdir/$tfile-2
1670 check_pdo_conflict $PID1 || error "create is blocked"
1671 mkdir $DIR2/$tdir/$tfile-3
1672 check_pdo_conflict $PID1 || error "mkdir is blocked"
1673 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1674 check_pdo_conflict $PID1 || error "link is blocked"
1675 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1676 check_pdo_conflict $PID1 || error "rename is blocked"
1677 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1678 check_pdo_conflict $PID1 || error "getattr is blocked"
1679 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1680 rmdir $DIR2/$tdir/$tfile-3
1681 check_pdo_conflict $PID1 || error "unlink is blocked"
1683 # all operations above shouldn't wait the first one
1684 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1685 do_nodes $(comma_list $(mdts_nodes)) \
1686 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1691 run_test 40c "pdirops: link and others =============="
1694 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1696 mkdir_on_mdt0 $DIR2/$tdir
1698 touch $DIR1/$tdir/$tfile
1699 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1700 do_nodes $(comma_list $(mdts_nodes)) \
1701 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1702 rm $DIR1/$tdir/$tfile &
1705 touch $DIR2/$tdir/$tfile-2
1706 check_pdo_conflict $PID1 || error "create is blocked"
1707 mkdir $DIR2/$tdir/$tfile-3
1708 check_pdo_conflict $PID1 || error "mkdir is blocked"
1709 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1710 check_pdo_conflict $PID1 || error "link is blocked"
1711 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1712 check_pdo_conflict $PID1 || error "rename is blocked"
1713 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1714 check_pdo_conflict $PID1 || error "getattr is blocked"
1715 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1716 rmdir $DIR2/$tdir/$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"
1726 run_test 40d "pdirops: unlink and others =============="
1729 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1731 mkdir_on_mdt0 $DIR2/$tdir
1733 touch $DIR1/$tdir/$tfile
1734 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1735 do_nodes $(comma_list $(mdts_nodes)) \
1736 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1737 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1740 touch $DIR2/$tdir/$tfile-2
1741 check_pdo_conflict $PID1 || error "create is blocked"
1742 mkdir $DIR2/$tdir/$tfile-3
1743 check_pdo_conflict $PID1 || error "mkdir is blocked"
1744 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1745 check_pdo_conflict $PID1 || error "link is blocked"
1746 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1747 check_pdo_conflict $PID1 || error "getattr is blocked"
1748 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1749 rmdir $DIR2/$tdir/$tfile-3
1750 check_pdo_conflict $PID1 || error "unlink is blocked"
1752 # all operations above shouldn't wait the first one
1753 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1754 do_nodes $(comma_list $(mdts_nodes)) \
1755 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1760 run_test 40e "pdirops: rename and others =============="
1762 # test 41: create blocking operations
1765 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1766 do_nodes $(comma_list $(mdts_nodes)) \
1767 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1768 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1770 mkdir $DIR2/$tfile &
1772 do_nodes $(comma_list $(mdts_nodes)) \
1773 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1774 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1775 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1779 run_test 41a "pdirops: create vs mkdir =============="
1783 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1784 do_nodes $(comma_list $(mdts_nodes)) \
1785 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1786 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1788 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1790 do_nodes $(comma_list $(mdts_nodes)) \
1791 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1792 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1793 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1797 run_test 41b "pdirops: create vs create =============="
1801 touch $DIR1/$tfile-2
1802 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1803 do_nodes $(comma_list $(mdts_nodes)) \
1804 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1805 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1807 link $DIR2/$tfile-2 $DIR2/$tfile &
1809 do_nodes $(comma_list $(mdts_nodes)) \
1810 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1811 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1812 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1816 run_test 41c "pdirops: create vs link =============="
1820 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1821 do_nodes $(comma_list $(mdts_nodes)) \
1822 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1823 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1827 do_nodes $(comma_list $(mdts_nodes)) \
1828 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1830 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1834 run_test 41d "pdirops: create vs unlink =============="
1838 touch $DIR1/$tfile-2
1839 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1840 do_nodes $(comma_list $(mdts_nodes)) \
1841 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1842 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1844 mv $DIR2/$tfile-2 $DIR2/$tfile &
1846 do_nodes $(comma_list $(mdts_nodes)) \
1847 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1848 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1849 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1853 run_test 41e "pdirops: create and rename (tgt) =============="
1857 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1858 do_nodes $(comma_list $(mdts_nodes)) \
1859 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1860 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1862 mv $DIR2/$tfile $DIR2/$tfile-2 &
1864 do_nodes $(comma_list $(mdts_nodes)) \
1865 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1866 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1867 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1871 run_test 41f "pdirops: create and rename (src) =============="
1875 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1876 do_nodes $(comma_list $(mdts_nodes)) \
1877 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1878 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1880 stat $DIR2/$tfile > /dev/null &
1882 do_nodes $(comma_list $(mdts_nodes)) \
1883 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1884 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1885 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1889 run_test 41g "pdirops: create vs getattr =============="
1893 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1894 do_nodes $(comma_list $(mdts_nodes)) \
1895 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1896 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1898 ls -lia $DIR2/ > /dev/null &
1900 do_nodes $(comma_list $(mdts_nodes)) \
1901 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1902 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1907 run_test 41h "pdirops: create vs readdir =============="
1914 do_nodes $(comma_list $(mdts_nodes)) \
1915 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1917 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1920 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1923 if ! wait $PID1 && ! wait $PID2; then
1924 echo "Both creates failed (1 should fail, 1 should succeed)"
1926 elif wait $PID1 && wait $PID2; then
1927 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1932 do_nodes $(comma_list $(mdts_nodes)) \
1933 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1940 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
1941 skip "Need MDS version newer than 2.13.56"
1944 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1945 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1946 for fail_loc in "0x80000169" "0x8000016a"; do
1947 echo "Begin 100 tests with fail_loc=$fail_loc"
1949 for i in {1..100}; do
1951 msg=$(sub_test_41i "$fail_loc") ||
1952 { echo; error "iter=$i : $msg"; }
1957 run_test 41i "reint_open: create vs create"
1960 # test 42: unlink and blocking operations
1963 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1964 do_nodes $(comma_list $(mdts_nodes)) \
1965 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1966 mkdir $DIR1/$tfile &
1968 mkdir $DIR2/$tfile &
1970 do_nodes $(comma_list $(mdts_nodes)) \
1971 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1972 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1973 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1977 run_test 42a "pdirops: mkdir vs mkdir =============="
1981 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1982 do_nodes $(comma_list $(mdts_nodes)) \
1983 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1984 mkdir $DIR1/$tfile &
1986 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1988 do_nodes $(comma_list $(mdts_nodes)) \
1989 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1990 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1991 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1995 run_test 42b "pdirops: mkdir vs create =============="
1999 touch $DIR1/$tfile-2
2000 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2001 do_nodes $(comma_list $(mdts_nodes)) \
2002 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2003 mkdir $DIR1/$tfile &
2005 link $DIR2/$tfile-2 $DIR2/$tfile &
2007 do_nodes $(comma_list $(mdts_nodes)) \
2008 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2009 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2010 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2014 run_test 42c "pdirops: mkdir vs link =============="
2018 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2019 do_nodes $(comma_list $(mdts_nodes)) \
2020 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2021 mkdir $DIR1/$tfile &
2023 rmdir $DIR2/$tfile &
2025 do_nodes $(comma_list $(mdts_nodes)) \
2026 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2027 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2028 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2032 run_test 42d "pdirops: mkdir vs unlink =============="
2036 touch $DIR1/$tfile-2
2037 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2038 do_nodes $(comma_list $(mdts_nodes)) \
2039 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2040 mkdir $DIR1/$tfile &
2042 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2044 do_nodes $(comma_list $(mdts_nodes)) \
2045 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2046 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2047 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2051 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2055 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2056 do_nodes $(comma_list $(mdts_nodes)) \
2057 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2058 mkdir $DIR1/$tfile &
2060 mv $DIR2/$tfile $DIR2/$tfile-2 &
2062 do_nodes $(comma_list $(mdts_nodes)) \
2063 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2064 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2065 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2069 run_test 42f "pdirops: mkdir and rename (src) =============="
2072 mkdir_on_mdt0 $DIR1/$tdir
2074 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2075 do_nodes $(comma_list $(mdts_nodes)) \
2076 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2077 mkdir $DIR1/$tdir/$tfile &
2079 stat $DIR2/$tdir/$tfile > /dev/null &
2081 do_nodes $(comma_list $(mdts_nodes)) \
2082 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2083 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2084 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2087 run_test 42g "pdirops: mkdir vs getattr =============="
2091 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2092 do_nodes $(comma_list $(mdts_nodes)) \
2093 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2094 mkdir $DIR1/$tfile &
2096 ls -lia $DIR2/ > /dev/null &
2098 do_nodes $(comma_list $(mdts_nodes)) \
2099 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2100 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2105 run_test 42h "pdirops: mkdir vs readdir =============="
2107 # test 43: rmdir,mkdir won't return -EEXIST
2109 for i in {1..1000}; do
2110 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2111 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2115 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2120 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2121 do_nodes $(comma_list $(mdts_nodes)) \
2122 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2125 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2127 do_nodes $(comma_list $(mdts_nodes)) \
2128 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2129 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2130 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2134 run_test 43b "pdirops: unlink vs create =============="
2139 touch $DIR1/$tfile-2
2140 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2141 do_nodes $(comma_list $(mdts_nodes)) \
2142 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2145 link $DIR2/$tfile-2 $DIR2/$tfile &
2147 do_nodes $(comma_list $(mdts_nodes)) \
2148 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2149 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2150 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2154 run_test 43c "pdirops: unlink vs link =============="
2159 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2160 do_nodes $(comma_list $(mdts_nodes)) \
2161 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2166 do_nodes $(comma_list $(mdts_nodes)) \
2167 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2168 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2169 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2173 run_test 43d "pdirops: unlink vs unlink =============="
2178 touch $DIR1/$tfile-2
2179 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2180 do_nodes $(comma_list $(mdts_nodes)) \
2181 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2184 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2186 do_nodes $(comma_list $(mdts_nodes)) \
2187 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2188 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2189 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2193 run_test 43e "pdirops: unlink and rename (tgt) =============="
2198 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2199 do_nodes $(comma_list $(mdts_nodes)) \
2200 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2203 mv $DIR2/$tfile $DIR2/$tfile-2 &
2205 do_nodes $(comma_list $(mdts_nodes)) \
2206 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2207 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2208 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2212 run_test 43f "pdirops: unlink and rename (src) =============="
2217 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2218 do_nodes $(comma_list $(mdts_nodes)) \
2219 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2222 stat $DIR2/$tfile > /dev/null &
2224 do_nodes $(comma_list $(mdts_nodes)) \
2225 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2226 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2227 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2231 run_test 43g "pdirops: unlink vs getattr =============="
2236 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2237 do_nodes $(comma_list $(mdts_nodes)) \
2238 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2241 ls -lia $DIR2/ > /dev/null &
2243 do_nodes $(comma_list $(mdts_nodes)) \
2244 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2245 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2250 run_test 43h "pdirops: unlink vs readdir =============="
2253 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2256 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2257 do_nodes $(comma_list $(mdts_nodes)) \
2258 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2261 $LFS mkdir -i 1 $DIR2/$tfile &
2263 do_nodes $(comma_list $(mdts_nodes)) \
2264 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2265 check_pdo_conflict $PID1 &&
2266 { wait $PID1; error "remote mkdir isn't blocked"; }
2267 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2271 run_test 43i "pdirops: unlink vs remote mkdir"
2274 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2275 skip "Need MDS version newer than 2.13.52"
2277 mkdir_on_mdt0 $DIR1/$tdir
2278 for i in {1..100}; do
2279 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2280 do_nodes $(comma_list $(mdts_nodes)) \
2281 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2284 mkdir $DIR1/$tdir/sub &
2286 mkdir $DIR2/$tdir/sub && ((OK++))
2287 wait $PID1 && ((OK++))
2288 (( OK == 1 )) || error "exactly one mkdir should succeed"
2290 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2294 run_test 43j "racy mkdir return EEXIST =============="
2301 # We test in a separate directory to be able to unblock server thread in
2302 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2303 test_mkdir $DIR2/$tdir
2304 touch $DIR2/$tdir/$tfile
2307 do_nodes $(comma_list $(mdts_nodes)) \
2308 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2309 echo content > $DIR1/$tdir/$tfile & PID1=$!
2311 multiop $DIR2/$tdir/$tfile u & PID2=$!
2315 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2318 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2321 do_nodes $(comma_list $(mdts_nodes)) \
2322 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2329 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2330 skip "Need MDS version newer than 2.13.56"
2333 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2334 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2335 for fail_loc in "0x80000169" "0x8000016a"; do
2336 echo "Begin 100 tests with fail_loc=$fail_loc"
2338 for i in {1..100}; do
2340 msg=$(sub_test_43k "$fail_loc") ||
2341 { echo; error "iter=$i : $msg"; }
2351 run_test 43k "unlink vs create"
2353 # test 44: rename tgt and blocking operations
2356 touch $DIR1/$tfile-2
2357 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2358 do_nodes $(comma_list $(mdts_nodes)) \
2359 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2360 mv $DIR1/$tfile-2 $DIR1/$tfile &
2362 mkdir $DIR2/$tfile &
2364 do_nodes $(comma_list $(mdts_nodes)) \
2365 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2366 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2367 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2372 run_test 44a "pdirops: rename tgt vs mkdir =============="
2376 touch $DIR1/$tfile-2
2377 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2378 do_nodes $(comma_list $(mdts_nodes)) \
2379 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2380 mv $DIR1/$tfile-2 $DIR1/$tfile &
2382 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2384 do_nodes $(comma_list $(mdts_nodes)) \
2385 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2386 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2387 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2391 run_test 44b "pdirops: rename tgt vs create =============="
2395 touch $DIR1/$tfile-2
2396 touch $DIR1/$tfile-3
2397 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2398 do_nodes $(comma_list $(mdts_nodes)) \
2399 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2400 mv $DIR1/$tfile-2 $DIR1/$tfile &
2402 link $DIR2/$tfile-3 $DIR2/$tfile &
2404 do_nodes $(comma_list $(mdts_nodes)) \
2405 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2406 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2407 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2411 run_test 44c "pdirops: rename tgt vs link =============="
2415 touch $DIR1/$tfile-2
2416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2417 do_nodes $(comma_list $(mdts_nodes)) \
2418 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2419 mv $DIR1/$tfile-2 $DIR1/$tfile &
2423 do_nodes $(comma_list $(mdts_nodes)) \
2424 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2425 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2426 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2430 run_test 44d "pdirops: rename tgt vs unlink =============="
2435 touch $DIR1/$tfile-2
2436 touch $DIR1/$tfile-3
2437 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2438 do_nodes $(comma_list $(mdts_nodes)) \
2439 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2440 mv $DIR1/$tfile-2 $DIR1/$tfile &
2442 mv $DIR2/$tfile-3 $DIR2/$tfile &
2444 do_nodes $(comma_list $(mdts_nodes)) \
2445 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2446 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2447 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2451 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2455 touch $DIR1/$tfile-2
2456 touch $DIR1/$tfile-3
2457 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2458 do_nodes $(comma_list $(mdts_nodes)) \
2459 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2460 mv $DIR1/$tfile-2 $DIR1/$tfile &
2462 mv $DIR2/$tfile $DIR2/$tfile-3 &
2464 do_nodes $(comma_list $(mdts_nodes)) \
2465 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2466 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2467 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2471 run_test 44f "pdirops: rename tgt and rename (src) =============="
2475 touch $DIR1/$tfile-2
2476 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2477 do_nodes $(comma_list $(mdts_nodes)) \
2478 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2479 mv $DIR1/$tfile-2 $DIR1/$tfile &
2481 stat $DIR2/$tfile > /dev/null &
2483 do_nodes $(comma_list $(mdts_nodes)) \
2484 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2485 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2486 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2490 run_test 44g "pdirops: rename tgt vs getattr =============="
2494 touch $DIR1/$tfile-2
2495 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2496 do_nodes $(comma_list $(mdts_nodes)) \
2497 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2498 mv $DIR1/$tfile-2 $DIR1/$tfile &
2500 ls -lia $DIR2/ > /dev/null &
2502 do_nodes $(comma_list $(mdts_nodes)) \
2503 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2504 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2509 run_test 44h "pdirops: rename tgt vs readdir =============="
2511 # test 44: rename tgt and blocking operations
2513 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2515 touch $DIR1/$tfile-2
2516 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2517 do_nodes $(comma_list $(mdts_nodes)) \
2518 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2519 mv $DIR1/$tfile-2 $DIR1/$tfile &
2521 $LFS mkdir -i 1 $DIR2/$tfile &
2523 do_nodes $(comma_list $(mdts_nodes)) \
2524 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2525 check_pdo_conflict $PID1 && { wait $PID1;
2526 error "remote mkdir isn't blocked"; }
2527 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2531 run_test 44i "pdirops: rename tgt vs remote mkdir"
2533 # test 45: rename,mkdir doesn't fail with -EEXIST
2535 for i in {1..1000}; do
2536 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2537 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2538 error "mrename to $tdir.$i failed"
2543 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2548 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2549 do_nodes $(comma_list $(mdts_nodes)) \
2550 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2551 mv $DIR1/$tfile $DIR1/$tfile-2 &
2553 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2555 do_nodes $(comma_list $(mdts_nodes)) \
2556 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2557 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2558 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2562 run_test 45b "pdirops: rename src vs create =============="
2567 touch $DIR1/$tfile-3
2568 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2569 do_nodes $(comma_list $(mdts_nodes)) \
2570 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2571 mv $DIR1/$tfile $DIR1/$tfile-2 &
2573 link $DIR2/$tfile-3 $DIR2/$tfile &
2575 do_nodes $(comma_list $(mdts_nodes)) \
2576 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2577 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2578 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2582 run_test 45c "pdirops: rename src vs link =============="
2587 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2588 do_nodes $(comma_list $(mdts_nodes)) \
2589 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2590 mv $DIR1/$tfile $DIR1/$tfile-2 &
2594 do_nodes $(comma_list $(mdts_nodes)) \
2595 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2596 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2597 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2601 run_test 45d "pdirops: rename src vs unlink =============="
2606 touch $DIR1/$tfile-3
2607 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2608 do_nodes $(comma_list $(mdts_nodes)) \
2609 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2610 mv $DIR1/$tfile $DIR1/$tfile-2 &
2612 mv $DIR2/$tfile-3 $DIR2/$tfile &
2614 do_nodes $(comma_list $(mdts_nodes)) \
2615 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2616 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2617 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2621 run_test 45e "pdirops: rename src and rename (tgt) =============="
2626 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2627 do_nodes $(comma_list $(mdts_nodes)) \
2628 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2629 mv $DIR1/$tfile $DIR1/$tfile-2 &
2631 mv $DIR2/$tfile $DIR2/$tfile-3 &
2633 do_nodes $(comma_list $(mdts_nodes)) \
2634 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2635 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2636 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2640 run_test 45f "pdirops: rename src and rename (src) =============="
2645 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2646 do_nodes $(comma_list $(mdts_nodes)) \
2647 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2648 mv $DIR1/$tfile $DIR1/$tfile-2 &
2650 stat $DIR2/$tfile > /dev/null &
2652 do_nodes $(comma_list $(mdts_nodes)) \
2653 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2654 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2655 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2659 run_test 45g "pdirops: rename src vs getattr =============="
2664 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2665 do_nodes $(comma_list $(mdts_nodes)) \
2666 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2667 mv $DIR1/$tfile $DIR1/$tfile-2 &
2669 ls -lia $DIR2/ > /dev/null &
2670 do_nodes $(comma_list $(mdts_nodes)) \
2671 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2672 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2677 run_test 45h "pdirops: unlink vs readdir =============="
2680 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2683 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2684 do_nodes $(comma_list $(mdts_nodes)) \
2685 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2686 mv $DIR1/$tfile $DIR1/$tfile-2 &
2688 $LFS mkdir -i 1 $DIR2/$tfile &
2690 do_nodes $(comma_list $(mdts_nodes)) \
2691 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2692 check_pdo_conflict $PID1 && { wait $PID1;
2693 error "create remote dir isn't blocked"; }
2694 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2698 run_test 45i "pdirops: rename src vs remote mkdir"
2705 # We test in a sparate directory to be able to unblock server thread in
2706 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2707 test_mkdir $DIR2/$tdir
2708 echo file1 > $DIR2/$tdir/$tfile
2709 echo file2 > $DIR2/$tdir/$tfile-2
2712 do_nodes $(comma_list $(mdts_nodes)) \
2713 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2715 cat $DIR1/$tdir/$tfile >/dev/null &
2718 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2722 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2725 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2728 do_nodes $(comma_list $(mdts_nodes)) \
2729 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2736 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2737 skip "Need MDS version newer than 2.13.56"
2740 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2741 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2742 for fail_loc in "0x80000169" "0x8000016a"; do
2743 echo "Begin 100 tests with fail_loc=$fail_loc"
2745 for i in {1..100}; do
2747 msg=$(sub_test_45j "$fail_loc") ||
2748 { echo; error "iter=$i : $msg"; }
2753 run_test 45j "read vs rename =============="
2755 # test 46: link and blocking operations
2758 touch $DIR1/$tfile-2
2759 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2760 do_nodes $(comma_list $(mdts_nodes)) \
2761 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2762 link $DIR1/$tfile-2 $DIR1/$tfile &
2764 mkdir $DIR2/$tfile &
2766 do_nodes $(comma_list $(mdts_nodes)) \
2767 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2768 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2769 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2773 run_test 46a "pdirops: link vs mkdir =============="
2777 touch $DIR1/$tfile-2
2778 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2779 do_nodes $(comma_list $(mdts_nodes)) \
2780 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2781 link $DIR1/$tfile-2 $DIR1/$tfile &
2783 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2785 do_nodes $(comma_list $(mdts_nodes)) \
2786 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2787 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2788 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2792 run_test 46b "pdirops: link vs create =============="
2796 touch $DIR1/$tfile-2
2797 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2798 do_nodes $(comma_list $(mdts_nodes)) \
2799 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2800 link $DIR1/$tfile-2 $DIR1/$tfile &
2802 link $DIR2/$tfile $DIR2/$tfile &
2804 do_nodes $(comma_list $(mdts_nodes)) \
2805 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2806 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2807 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2811 run_test 46c "pdirops: link vs link =============="
2815 touch $DIR1/$tfile-2
2816 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2817 do_nodes $(comma_list $(mdts_nodes)) \
2818 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2819 link $DIR1/$tfile-2 $DIR1/$tfile &
2823 do_nodes $(comma_list $(mdts_nodes)) \
2824 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2825 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2826 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2830 run_test 46d "pdirops: link vs unlink =============="
2834 touch $DIR1/$tfile-2
2835 touch $DIR1/$tfile-3
2836 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2837 do_nodes $(comma_list $(mdts_nodes)) \
2838 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2839 link $DIR1/$tfile-2 $DIR1/$tfile &
2841 mv $DIR2/$tfile-3 $DIR2/$tfile &
2843 do_nodes $(comma_list $(mdts_nodes)) \
2844 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2845 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2846 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2850 run_test 46e "pdirops: link and rename (tgt) =============="
2854 touch $DIR1/$tfile-2
2855 touch $DIR1/$tfile-3
2856 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2857 do_nodes $(comma_list $(mdts_nodes)) \
2858 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2859 link $DIR1/$tfile-2 $DIR1/$tfile &
2861 mv $DIR2/$tfile $DIR2/$tfile-3 &
2863 do_nodes $(comma_list $(mdts_nodes)) \
2864 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2865 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2866 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2870 run_test 46f "pdirops: link and rename (src) =============="
2874 touch $DIR1/$tfile-2
2875 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2876 do_nodes $(comma_list $(mdts_nodes)) \
2877 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2878 link $DIR1/$tfile-2 $DIR1/$tfile &
2880 stat $DIR2/$tfile > /dev/null &
2882 do_nodes $(comma_list $(mdts_nodes)) \
2883 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2884 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2885 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2889 run_test 46g "pdirops: link vs getattr =============="
2893 touch $DIR1/$tfile-2
2894 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2895 do_nodes $(comma_list $(mdts_nodes)) \
2896 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2897 link $DIR1/$tfile-2 $DIR1/$tfile &
2899 ls -lia $DIR2/ > /dev/null &
2901 do_nodes $(comma_list $(mdts_nodes)) \
2902 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2903 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2908 run_test 46h "pdirops: link vs readdir =============="
2911 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2913 touch $DIR1/$tfile-2
2914 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2915 do_nodes $(comma_list $(mdts_nodes)) \
2916 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2917 link $DIR1/$tfile-2 $DIR1/$tfile &
2919 $LFS mkdir -i 1 $DIR2/$tfile &
2921 do_nodes $(comma_list $(mdts_nodes)) \
2922 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2923 check_pdo_conflict $PID1 && { wait $PID1;
2924 error "remote mkdir isn't blocked"; }
2925 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2929 run_test 46i "pdirops: link vs remote mkdir"
2931 # test 47: remote mkdir and blocking operations
2933 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2934 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2936 do_nodes $(comma_list $(mdts_nodes)) \
2937 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2938 $LFS mkdir -i 1 $DIR1/$tfile &
2940 mkdir $DIR2/$tfile &
2942 do_nodes $(comma_list $(mdts_nodes)) \
2943 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2944 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2945 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2949 run_test 47a "pdirops: remote mkdir vs mkdir"
2952 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2953 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2955 do_nodes $(comma_list $(mdts_nodes)) \
2956 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2957 $LFS mkdir -i 1 $DIR1/$tfile &
2959 sleep 1 # please do not remove this sleep, see LU-10754
2960 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2962 do_nodes $(comma_list $(mdts_nodes)) \
2963 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2964 check_pdo_conflict $PID1 && { wait $PID1;
2965 error "create isn't blocked"; }
2966 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2970 run_test 47b "pdirops: remote mkdir vs create"
2973 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2975 touch $DIR1/$tfile-2
2976 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2977 do_nodes $(comma_list $(mdts_nodes)) \
2978 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2979 $LFS mkdir -i 1 $DIR1/$tfile &
2981 link $DIR2/$tfile-2 $DIR2/$tfile &
2983 do_nodes $(comma_list $(mdts_nodes)) \
2984 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2985 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2986 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2990 run_test 47c "pdirops: remote mkdir vs link"
2993 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2995 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2996 do_nodes $(comma_list $(mdts_nodes)) \
2997 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2998 $LFS mkdir -i 1 $DIR1/$tfile &
3000 rmdir $DIR2/$tfile &
3002 do_nodes $(comma_list $(mdts_nodes)) \
3003 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3004 check_pdo_conflict $PID1 && { wait $PID1;
3005 error "unlink isn't blocked"; }
3006 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
3010 run_test 47d "pdirops: remote mkdir vs unlink"
3013 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3015 touch $DIR1/$tfile-2
3016 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3017 do_nodes $(comma_list $(mdts_nodes)) \
3018 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3019 $LFS mkdir -i 1 $DIR1/$tfile &
3021 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
3023 do_nodes $(comma_list $(mdts_nodes)) \
3024 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3025 check_pdo_conflict $PID1 && { wait $PID1;
3026 error "rename isn't blocked"; }
3027 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
3031 run_test 47e "pdirops: remote mkdir and rename (tgt)"
3034 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3036 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3037 do_nodes $(comma_list $(mdts_nodes)) \
3038 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3039 $LFS mkdir -i 1 $DIR1/$tfile &
3041 mv $DIR2/$tfile $DIR2/$tfile-2 &
3043 do_nodes $(comma_list $(mdts_nodes)) \
3044 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3045 check_pdo_conflict $PID1 && { wait $PID1;
3046 error "rename isn't blocked"; }
3047 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3051 run_test 47f "pdirops: remote mkdir and rename (src)"
3054 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3058 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3059 do_nodes $(comma_list $(mdts_nodes)) \
3060 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3061 $LFS mkdir -i 1 $DIR1/$tfile &
3063 stat $DIR2/$tfile > /dev/null &
3065 do_nodes $(comma_list $(mdts_nodes)) \
3066 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3067 check_pdo_conflict $PID1 && { wait $PID1;
3068 error "getattr isn't blocked"; }
3069 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3073 run_test 47g "pdirops: remote mkdir vs getattr"
3077 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3078 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3079 do_facet client "lctl set_param fail_loc=0x410"
3080 $TRUNCATE $DIR2/$tfile $trunc_size
3081 do_facet client "lctl set_param fail_loc=0x0"
3083 size=`stat -c %s $DIR2/$tfile`
3084 [ $size -eq $trunc_size ] || error "wrong size"
3086 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3090 local origfile=/etc/hosts
3092 filesize=$(stat -c %s $origfile)
3094 # create an empty file
3095 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3096 # cache layout lock on both mount point
3097 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3098 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3100 # open and sleep 2 seconds then read
3101 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3105 # create the layout of testing file
3106 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3107 error "dd $DIR1/$tfile failed"
3109 # MULTIOP proc should be able to read enough bytes and exit
3110 for ((i = 0; i < 6; i++)); do
3112 kill -0 $pid || break
3114 kill -0 $pid 2> /dev/null && error "multiop is still there"
3115 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3119 run_test 51a "layout lock: refresh layout should work"
3122 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3123 skip "Need MDS version at least 2.3.59"
3125 local tmpfile=`mktemp`
3127 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3128 error "Create $DIR1/$tfile failed"
3130 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3131 error "dd $DIR1/$tfile failed"
3133 # delay glimpse so that layout has changed when glimpse finish
3134 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3135 $LCTL set_param fail_loc=0x1404 fail_val=4
3136 stat -c %s $DIR2/$tfile |tee $tmpfile &
3140 # extend layout of testing file
3141 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3142 error "dd $DIR1/$tfile failed"
3145 local fsize=$(cat $tmpfile)
3147 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3149 rm -f $DIR1/$tfile $tmpfile
3151 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3154 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3156 # set default layout to have 1 stripe
3158 $LFS setstripe -c 1 $DIR1/$tdir
3160 # create a file with empty layout
3161 $MCREATE $DIR1/$tdir/$tfile ||
3162 error "$MCREATE $DIR1/$tdir/$tfile failed"
3164 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3165 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3167 # change the layout of testing file
3168 echo "Setting layout to have $OSTCOUNT stripes ..."
3169 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3173 # write something to the file, it should be blocked on fetching layout
3174 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3175 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3178 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3179 # count to succeed with only 3/4 of the number of stripes (rounded up),
3180 # so creating striped files does not fail if an OST is offline or full
3181 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3182 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3186 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3189 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3190 cancel_lru_locks mdc
3192 # open should grant LAYOUT lock, mmap and read will install pages
3193 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3197 # rss before revoking
3198 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3199 echo "Before revoking layout lock: $br KB mapped"
3201 # cancel layout lock manually
3202 cancel_lru_locks mdc
3204 # rss after revoking
3205 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3208 wait $PID || error "wait PID $PID failed"
3210 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3212 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3215 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3216 skip "MDS version must be at least 2.13.54.148"
3220 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3224 $LFS getstripe $DIR2/$tfile
3226 wait $pid || error "multiop failed"
3228 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3232 $LFS getstripe $DIR2/$tfile
3234 wait $pid || error "multiop failed"
3236 run_test 51e "lfs getstripe does not break leases, part 2"
3240 echo "==> rename vs getattr vs setxattr should not deadlock"
3241 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3243 do_facet mds1 $LCTL set_param fail_loc=$1
3245 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3253 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3254 wait $PID1 || error "(3) mv failed"
3255 wait $PID2 || error "(4) stat failed"
3262 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3263 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3265 do_facet mds1 $LCTL set_param fail_loc=$1
3267 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3275 $MULTIOP $DIR2/d1/d2 Oc &
3279 stat $DIR/d1 || error "(2) stat failed"
3281 wait $PID1 || error "(3) mv failed"
3282 wait $PID2 || error "(4) stat failed"
3283 wait $PID3 && error "(5) multiop failed"
3289 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3290 save_lustre_params client "llite.*.xattr_cache" > $p
3291 lctl set_param llite.*.xattr_cache 1 ||
3292 { skip "xattr cache is not supported"; return 0; }
3294 #define OBD_FAIL_MDS_RENAME 0x153
3295 #define OBD_FAIL_MDS_RENAME2 0x154
3296 test_54_part1 0x80000153 || error 10
3297 test_54_part1 0x80000154 || error 11
3298 test_54_part2 0x80000153 || error 12
3299 test_54_part2 0x80000154 || error 13
3301 restore_lustre_params < $p
3304 run_test 54 "rename locking"
3307 mkdir_on_mdt0 $DIR/$tdir
3308 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3310 #define OBD_FAIL_MDS_RENAME4 0x156
3311 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3313 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3317 rm -r $DIR2/$tdir/d3
3318 wait $PID1 && error "(2) mv succeeded"
3322 run_test 55a "rename vs unlink target dir"
3326 mkdir_on_mdt0 $DIR/$tdir
3327 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3329 #define OBD_FAIL_MDS_RENAME4 0x156
3330 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3332 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3336 rm -r $DIR2/$tdir/d1
3337 wait $PID1 && error "(2) mv succeeded"
3341 run_test 55b "rename vs unlink source dir"
3345 mkdir_on_mdt0 $DIR/$tdir
3346 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3348 #define OBD_FAIL_MDS_RENAME4 0x156
3349 do_facet mds1 $LCTL set_param fail_loc=0x156
3351 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3355 # while rename is sleeping, open and remove d3
3356 $MULTIOP $DIR2/$tdir/d3 D_c &
3359 rm -rf $DIR2/$tdir/d3
3362 # while rename is sleeping 2nd time, close d3
3364 wait $PID2 || error "(3) multiop failed"
3366 wait $PID1 && error "(2) mv succeeded"
3370 run_test 55c "rename vs unlink orphan target dir"
3374 mkdir_on_mdt0 $DIR/$tdir
3378 #define OBD_FAIL_MDS_RENAME3 0x155
3379 do_facet mds1 $LCTL set_param fail_loc=0x155
3380 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3384 # while rename is sleeping, create $tdir, but as a directory
3385 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3387 # link in reverse locking order
3388 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3390 wait $PID1 && error "(2) mv succeeded"
3393 run_test 55d "rename file vs link"
3396 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3397 skip "MDS version must be >= 2.3.0"
3400 test_mkdir $DIR1/$tdir
3401 file1=$DIR1/$tdir/file
3402 file2=$DIR2/$tdir/file
3404 echo orig > $file2 || error "Could not create $file2"
3405 version=$($LFS data_version $file1)
3408 echo append >> $file2 || error "Could not append to $file2"
3409 version2=$($LFS data_version $file1)
3410 [ "$version" != "$version2" ] ||
3411 error "append did not change data version: $version"
3414 echo overwrite > $file2 || error "Could not overwrite $file2"
3415 version3=$($LFS data_version $file1)
3416 [ "$version2" != "$version3" ] ||
3417 error "overwrite did not change data version: $version2"
3419 # Truncate before EOF
3420 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3421 version4=$($LFS data_version $file1)
3422 [ "$version3" != "$version4" ] ||
3423 error "truncate did not change data version: $version3"
3425 # Truncate after EOF
3426 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3427 version5=$($LFS data_version $file1)
3428 [ "$version4" != "$version5" ] ||
3429 error "truncate did not change data version: $version4"
3431 # Chmod do not change version
3432 chmod 400 $file2 || error "Could not chmod 400 $file2"
3433 version6=$($LFS data_version $file1)
3434 [ "$version5" == "$version6" ] ||
3435 error "chmod should not change data version: $version5 != $version6"
3437 # Chown do not change version
3438 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3439 version7=$($LFS data_version $file1)
3440 [ "$version5" == "$version7" ] ||
3441 error "chown should not change data version: $version5 != $version7"
3443 run_test 60 "Verify data_version behaviour"
3446 local test_dir=$tdir/test_dir
3448 mkdir -p $DIR1/$tdir
3449 if [ $MDSCOUNT -ge 2 ]; then
3451 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3452 error "Create remote directory failed"
3454 mkdir -p $DIR1/$test_dir
3456 cd $DIR2/$test_dir || error "cd directory failed"
3457 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3459 cd $DIR2/$tdir || error "exit directory"
3461 run_test 70a "cd directory && rm directory"
3463 test_70b() { # LU-2781
3465 mkdir -p $DIR1/$tdir
3467 touch $DIR1/$tdir/file
3468 for ((i = 0; i < 32; i++)); do
3469 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3471 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3473 touch $DIR1/$tdir/file
3474 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3475 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3476 rm -rf $DIR1/$tdir/test_dir ||
3477 error "cannot remove directory after rm_entry"
3478 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3480 run_test 70b "remove files after calling rm_entry"
3483 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3484 skip "Need MDS version at least 2.1.6"
3486 # Patch not applied to 2.2 and 2.3 branches
3487 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3488 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3489 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3491 checkfiemap --test ||
3492 skip "checkfiemap not runnable: $?"
3493 # write data this way: hole - data - hole - data
3494 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3495 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3497 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3498 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3499 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3501 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3503 checkfiemap $DIR2/$tfile 81920 ||
3504 error "data is not flushed from client"
3505 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3508 # common case of "create file, copy file" on a single node
3509 # should not flush data from ost
3510 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3511 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3513 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3515 checkfiemap $DIR1/$tfile 81920 ||
3517 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3519 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3521 run_test 71a "correct file map just after write operation is finished"
3524 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3525 skip "Need MDS version at least 2.1.6"
3527 # Patch not applied to 2.2 and 2.3 branches
3528 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3529 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3530 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3531 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3533 checkfiemap --test ||
3534 skip "error $?: checkfiemap failed"
3536 mkdir -p $DIR1/$tdir
3538 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3539 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3540 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3542 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3543 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3545 run_test 71b "check fiemap support for stripecount > 1"
3548 local p="$TMP/sanityN-$TESTNAME.parameters"
3551 save_lustre_params client "llite.*.xattr_cache" > $p
3552 lctl set_param llite.*.xattr_cache 1 ||
3553 { skip "xattr cache is not supported"; return 0; }
3556 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3557 error "setfattr1 failed"
3558 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3559 error "getfattr1 failed"
3560 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3561 error "setfattr2 failed"
3562 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3563 error "getfattr2 failed"
3565 # check that trusted.link is consistent
3566 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3567 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3568 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3569 echo "$tlink1 $tlink2"
3570 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3574 restore_lustre_params < $p
3577 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3580 local p="$TMP/sanityN-$TESTNAME.parameters"
3581 save_lustre_params client "llite.*.xattr_cache" > $p
3582 lctl set_param llite.*.xattr_cache 1 ||
3583 { skip "xattr cache is not supported"; return 0; }
3586 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3587 error "setfattr1 failed"
3588 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3589 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3590 clear_stats llite.*.stats
3591 # PR lock should be cached by now on both clients
3592 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3593 # 2 hits for getfattr(0)+getfattr(size)
3594 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3595 error "not cached in $DIR1"
3596 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3597 # 4 hits for more getfattr(0)+getfattr(size)
3598 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3599 error "not cached in $DIR2"
3602 restore_lustre_params < $p
3605 run_test 73 "getxattr should not cause xattr lock cancellation"
3608 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3609 skip "Need MDS version at least 2.4.93"
3611 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3612 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3613 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3615 run_test 74 "flock deadlock: different mounts =============="
3619 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3620 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3621 cancel_lru_locks osc
3623 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3626 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3627 $LCTL set_param fail_loc=0x31d
3628 stat -c %s $DIR1/$tfile &
3633 # For bad lock error handler we should ASSERT and got kernel panic here
3635 $LCTL set_param fail_loc=0
3637 run_test 75 "osc: upcall after unuse lock==================="
3640 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3641 skip "Need MDS version at least 2.5.53"
3643 remote_mds_nodsh && skip "remote MDS with nodsh"
3644 local fcount=$((MDSCOUNT * 256))
3649 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3655 test_mkdir $DIR/$tdir
3657 # drop all open locks and close any cached "open" files on the client
3658 cancel_lru_locks mdc
3660 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3661 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3662 local already=${#fid_list[@]}
3663 for (( i = 0; i < $already; i++ )) ; do
3664 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3667 echo -n "opening files: "
3668 ulimit -n $((fcount + 50))
3669 for ((i = 0; i < $fcount; i++)); do
3670 touch $DIR/$tdir/f_$i
3671 local fd=$(free_fd ${fd_list[i]})
3672 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3677 (( $i % 32 == 0 )) && echo -n "."
3681 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3683 # Possible errors in openfiles FID list.
3684 # 1. Missing FIDs. Check 1
3685 # 2. Extra FIDs. Check 1
3686 # 3. Duplicated FID. Check 2
3687 # 4. Invalid FIDs. Check 2
3688 # 5. Valid FID, points to some other file. Check 3
3691 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3692 error "${#fid_list[@]} != $fcount (+$already old) open files"
3694 echo -n "closing files: "
3695 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3696 local close_cmd="exec ${fd_list[fd]}<&-"
3698 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3700 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3701 echo "skip old open file $filename"
3703 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3707 rm --interactive=no $filename
3709 error "Nonexisting fid ${fid_list[fid]} listed."
3710 (( $fd % 32 == 0 )) && echo -n "."
3715 ls_op=$(ls $DIR2/$tdir | wc -l)
3717 error "Some openfiles are missing in lproc output"
3721 run_test 76 "Verify MDT open_files listing"
3725 local dir=$DIR/$tdir
3728 mkdir $dir || error "mkdir $dir failed"
3729 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3732 do_nodes $CLIENTS $myRUNAS \
3733 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3734 error "dd at 0 on client failed (1)"
3736 do_nodes $CLIENTS $myRUNAS \
3738 for ((i = 0; i < $n; i++)); do
3739 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3740 seek=\\\$i count=1 conv=notrunc &
3741 pids_w[\\\$i]=\\\$!;
3744 for ((i = 0; i < $n; i++)); do
3745 wait \\\${pids_w[\\\$i]};
3747 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3751 do_nodes $CLIENTS sync;
3752 cancel_lru_locks osc
3754 do_nodes $CLIENTS $myRUNAS \
3756 for ((i = 0; i < $n; i++)); do
3757 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3758 seek=\\\$i count=1 &
3759 pids_r[\\\$i]=\\\$!;
3762 for ((i = 0; i < $n; i++)); do
3763 wait \\\${pids_r[\\\$i]};
3765 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3769 cancel_lru_locks osc
3771 wait $pid_w || error "dd (write) failed (2)"
3772 wait $pid_r || error "dd (read) failed (3)"
3773 rm -rvf $dir || error "rm -rf $dir failed"
3776 test_77a() { #LU-3266
3779 oss=$(comma_list $(osts_nodes))
3780 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3782 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3783 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3788 run_test 77a "check FIFO NRS policy"
3790 test_77b() { #LU-3266
3793 oss=$(comma_list $(osts_nodes))
3795 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3796 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3797 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3798 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3800 echo "policy: crr-n, crrn_quantum 1"
3803 do_nodes $oss lctl set_param \
3804 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3805 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3807 echo "policy: crr-n, crrn_quantum 64"
3811 do_nodes $oss lctl set_param \
3812 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3813 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3816 run_test 77b "check CRR-N NRS policy"
3821 oss=$(comma_list $(osts_nodes))
3823 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3824 ost.OSS.*.nrs_"$policy"_quantum=1 \
3825 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3826 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3828 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3829 "physical, ${policy}_supported reads"
3832 do_nodes $oss lctl set_param \
3833 ost.OSS.*.nrs_${policy}_supported="writes" \
3834 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3836 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3837 "physical, ${policy}_supported writes"
3840 do_nodes $oss lctl set_param \
3841 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3842 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3843 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3844 "logical, ${policy}_supported reads_and_writes"
3848 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3853 test_77c() { #LU-3266
3855 orr_trr "orr" || rc=$?
3856 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3857 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3860 run_test 77c "check ORR NRS policy"
3862 test_77d() { #LU-3266
3864 orr_trr "trr" || rc=$?
3865 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3866 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3869 run_test 77d "check TRR nrs policy"
3876 do_facet $facet lctl set_param \
3877 ost.OSS.ost_io.nrs_tbf_rule="$*"
3879 error "failed to run operate '$*' on TBF rules"
3882 cleanup_tbf_verify()
3886 echo "cleanup_tbf $DIR/$tdir"
3889 wait_delete_completed
3894 local dir=$DIR/$tdir
3895 local client1=${CLIENT1:-$(hostname)}
3898 local np=$(check_cpt_number ost1)
3899 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3900 echo "cpu_npartitions on ost1 is $np"
3902 mkdir $dir || error "mkdir $dir failed"
3903 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3906 trap cleanup_tbf_verify EXIT
3907 echo "Limited write rate: $1, read rate: $2"
3908 echo "Verify the write rate is under TBF control"
3909 local start=$SECONDS
3910 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3911 bs=1M count=100 oflag=direct 2>&1
3912 local runtime=$((SECONDS - start + 1))
3913 local rate=$(bc <<< "scale=6; 100 / $runtime")
3914 echo "Write runtime is $runtime s, speed is $rate IOPS"
3916 # verify the write rate does not exceed TBF rate limit
3917 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3918 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3920 cancel_lru_locks osc
3922 echo "Verify the read rate is under TBF control"
3924 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3925 bs=1M count=100 iflag=direct 2>&1
3926 runtime=$((SECONDS - start + 1))
3927 rate=$(bc <<< "scale=6; 100 / $runtime")
3928 echo "Read runtime is $runtime s, speed is $rate IOPS"
3930 # verify the read rate does not exceed TBF rate limit
3931 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3932 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3934 cancel_lru_locks osc
3935 cleanup_tbf_verify || error "rm -rf $dir failed"
3941 oss=$(comma_list $(osts_nodes))
3943 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3945 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3946 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3950 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3955 # Only operate rules on ost1 since OSTs might run on the same OSS
3957 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3958 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3959 local client_nids=$(nids_list $address "\\")
3960 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3961 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3965 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3966 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3967 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3971 tbf_rule_operate ost1 "stop\ localhost"
3972 tbf_rule_operate ost1 "stop\ clients"
3973 tbf_rule_operate ost1 "stop\ others"
3976 # Cleanup the TBF policy
3977 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3978 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3982 run_test 77e "check TBF NID nrs policy"
3987 oss=$(comma_list $(osts_nodes))
3989 do_nodes $oss $LCTL set_param \
3990 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3991 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3992 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3994 # Configure jobid_var
3995 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3997 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3998 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3999 if [ $saved_jobid_var != procname_uid ]; then
4000 set_persistent_param_and_check client \
4001 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4006 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4011 # Only operate rules on ost1 since OSTs might run on the same OSS
4013 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
4014 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
4015 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4016 nrs_write_read "$RUNAS"
4019 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
4020 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
4021 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
4022 nrs_write_read "$RUNAS"
4025 tbf_rule_operate ost1 "stop\ runas"
4026 tbf_rule_operate ost1 "stop\ iozone_runas"
4027 tbf_rule_operate ost1 "stop\ dd_runas"
4028 nrs_write_read "$RUNAS"
4030 # Cleanup the TBF policy
4031 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4032 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4033 nrs_write_read "$RUNAS"
4035 local current_jobid_var=$($LCTL get_param -n jobid_var)
4036 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4037 if [ $saved_jobid_var != $current_jobid_var ]; then
4038 set_persistent_param_and_check client \
4039 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4043 run_test 77f "check TBF JobID nrs policy"
4048 oss=$(comma_list $(osts_nodes))
4050 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4052 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4053 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4055 do_nodes $oss lctl set_param \
4056 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4057 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4061 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4066 # Add a rule that only valid for Jobid TBF. If direct change between
4067 # TBF types is not supported, this operation will fail.
4068 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4070 # Cleanup the TBF policy
4071 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4072 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4075 run_test 77g "Change TBF type directly"
4078 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4079 skip "Need OST version at least 2.8.55"
4081 local old_policy=$(do_facet ost1 \
4082 lctl get_param ost.OSS.ost_io.nrs_policies)
4085 do_facet ost1 lctl set_param \
4086 ost.OSS.ost_io.nrs_policies="abc"
4087 [ $? -eq 0 ] && error "should return error"
4089 do_facet ost1 lctl set_param \
4090 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4091 [ $? -eq 0 ] && error "should return error"
4093 do_facet ost1 lctl set_param \
4094 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4095 [ $? -eq 0 ] && error "should return error"
4097 do_facet ost1 lctl set_param \
4098 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4099 [ $? -eq 0 ] && error "should return error"
4101 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4102 [ $? -eq 0 ] || error "shouldn't LBUG"
4104 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4108 run_test 77h "Wrong policy name should report error, not LBUG"
4114 local error_message=$3
4116 for rule in $expected; do
4117 rule_number=$((rule_number + 1))
4119 local stop_line=$(($rule_number + 3))
4120 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4122 local output=$(do_facet $facet lctl get_param \
4123 ost.OSS.ost_io.nrs_tbf_rule |
4127 if [ "$output" != "$expected" ]; then
4128 error "$error_message, expected '$expected', got '$output'"
4133 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4134 skip "Need OST version at least 2.8.55"
4136 for i in $(seq 1 $OSTCOUNT)
4138 do_facet ost"$i" lctl set_param \
4139 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4141 error "failed to set TBF policy"
4144 tbf_rule_check ost1 "default" "error before inserting any rule"
4146 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4147 tbf_rule_check ost1 "before default" \
4148 "error when inserting rule 'before'"
4150 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4151 tbf_rule_check ost1 "before after default" \
4152 "error when inserting rule 'after'"
4154 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4155 tbf_rule_check ost1 "before target after default" \
4156 "error when inserting rule 'target'"
4158 echo "Move before itself"
4159 tbf_rule_operate ost1 "change\ target\ rank=target"
4160 tbf_rule_check ost1 "before target after default" \
4161 "error when moving before itself"
4163 echo "Move to higher rank"
4164 tbf_rule_operate ost1 "change\ target\ rank=before"
4165 tbf_rule_check ost1 "target before after default" \
4166 "error when moving to higher rank"
4168 echo "Move to lower rank"
4169 tbf_rule_operate ost1 "change\ target\ rank=after"
4170 tbf_rule_check ost1 "before target after default" \
4171 "error when moving to lower rank"
4173 echo "Move before default"
4174 tbf_rule_operate ost1 "change\ target\ rank=default"
4175 tbf_rule_check ost1 "before after target default" \
4176 error "error when moving before default"
4178 # Cleanup the TBF policy
4179 do_nodes $(comma_list $(osts_nodes)) \
4180 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4183 run_test 77i "Change rank of TBF rule"
4189 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4190 skip "Need OST version at least 2.9.53"
4191 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4196 do_nodes $(comma_list $(osts_nodes)) \
4197 lctl set_param jobid_var=procname_uid \
4198 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4199 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4200 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4201 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4206 do_nodes $(comma_list $(osts_nodes)) \
4207 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4208 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4209 ost.OSS.ost_io.nrs_policies="fifo"
4211 # sleep 3 seconds to wait the tbf policy stop completely,
4212 # or the next test case is possible get -EAGAIN when
4213 # setting the tbf policy
4216 run_test 77j "check TBF-OPCode NRS policy"
4219 local idstr="${1}id"
4220 local policy="${idstr}={$2}"
4221 local rate="rate=$3"
4223 do_nodes $(comma_list $(osts_nodes)) \
4224 lctl set_param jobid_var=procname_uid \
4225 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4226 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4227 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4229 nrs_write_read "runas $4"
4230 tbf_verify $3 $3 "runas $4"
4232 do_nodes $(comma_list $(osts_nodes)) \
4233 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4234 ost.OSS.ost_io.nrs_policies="fifo"
4236 # sleep 3 seconds to wait the tbf policy stop completely,
4237 # or the next test case is possible get -eagain when
4238 # setting the tbf policy
4243 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4244 skip "Need OST version at least 2.11.50"
4247 test_id "u" "500" "5" "-u 500"
4248 test_id "g" "500" "5" "-u 500 -g 500"
4250 run_test 77ja "check TBF-UID/GID NRS policy"
4258 for rule in $rule_lists; do
4259 do_nodes $(comma_list $(osts_nodes)) \
4260 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4263 do_nodes $(comma_list $(osts_nodes)) \
4264 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4270 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4271 skip "Need OST version at least 2.9.53"
4273 do_nodes $(comma_list $(osts_nodes)) \
4274 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4275 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4276 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4278 nrs_write_read "$RUNAS"
4279 tbf_verify 20 10 "$RUNAS"
4281 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4282 local client_nids=$(nids_list $address "\\")
4283 do_nodes $(comma_list $(osts_nodes)) \
4284 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4285 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4286 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4287 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4292 do_nodes $(comma_list $(osts_nodes)) \
4293 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4294 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4295 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4297 nrs_write_read "$RUNAS"
4298 tbf_verify 20 20 "$RUNAS"
4300 do_nodes $(comma_list $(osts_nodes)) \
4301 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4302 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4303 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4305 nrs_write_read "$RUNAS"
4306 # with parameter "RUNAS", it will match the latest rule
4307 # "ext_b" first, so the limited write rate is 10.
4308 tbf_verify 10 10 "$RUNAS"
4311 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4313 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4314 skip "Need OST version at least 2.10.58"
4316 do_nodes $(comma_list $(osts_nodes)) \
4317 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4318 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4319 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4320 nrs_write_read "runas -u 500 -g 1000"
4321 tbf_verify 5 5 "runas -u 500 -g 1000"
4323 do_nodes $(comma_list $(osts_nodes)) \
4324 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4325 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4326 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4328 nrs_write_read "runas -u 500"
4329 tbf_verify 20 10 "runas -u 500"
4331 do_nodes $(comma_list $(osts_nodes)) \
4332 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4333 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4334 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4335 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4336 nrs_write_read "runas -u 500"
4337 tbf_verify 10 10 "runas -u 500"
4338 tbf_verify 20 10 "runas -u 500"
4339 cleanup_77k "ext_a ext_b" "fifo"
4341 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4344 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4345 skip "Need OST version at least 2.10.56"
4347 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4348 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4350 local output=$(do_facet ost1 lctl get_param \
4351 ost.OSS.ost_io.nrs_policies | \
4352 awk '/name: tbf/ {print;exit}' | \
4353 awk -F ': ' '{print $2}')
4355 if [ "$output" != "tbf" ]; then
4356 error "The generic TBF output is '$output', not 'tbf'"
4359 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4361 run_test 77l "check the output of NRS policies for generic TBF"
4364 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4365 skip "Need OST version at least 2.9.54"
4368 local dir=$DIR/$tdir
4370 mkdir $dir || error "mkdir $dir failed"
4371 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4374 local nodes=$(comma_list $(osts_nodes))
4375 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4376 ost.OSS.ost_io.nrs_delay_min=4 \
4377 ost.OSS.ost_io.nrs_delay_max=4 \
4378 ost.OSS.ost_io.nrs_delay_pct=100
4379 [ $? -ne 0 ] && error "Failed to set delay policy"
4381 local start=$SECONDS
4382 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4383 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4384 oflag=direct conv=fdatasync ||
4385 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4386 error "dd on client failed (1)"; }
4387 local elapsed=$((SECONDS - start))
4389 # NRS delay doesn't do sub-second timing, so a request enqueued at
4390 # 0.9 seconds can be dequeued at 4.0
4391 [ $elapsed -lt 3 ] &&
4392 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4393 error "Single 1M write should take at least 3 seconds"; }
4396 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4397 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4398 oflag=direct conv=fdatasync ||
4399 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4400 error "dd on client failed (2)"; }
4401 elapsed=$((SECONDS - start))
4403 [ $elapsed -lt 30 ] &&
4404 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4405 error "Ten 1M writes should take at least 30 seconds"; }
4407 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4408 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4412 run_test 77m "check NRS Delay slows write RPC processing"
4414 test_77n() { #LU-10802
4415 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4416 skip "Need OST version at least 2.10.58"
4419 # Configure jobid_var
4420 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4421 if [ $saved_jobid_var != procname_uid ]; then
4422 set_persistent_param_and_check client \
4423 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4426 do_nodes $(comma_list $(osts_nodes)) \
4427 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4428 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4429 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4432 tbf_verify 20 20 "$RUNAS"
4434 do_nodes $(comma_list $(osts_nodes)) \
4435 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4436 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4441 do_nodes $(comma_list $(osts_nodes)) \
4442 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4443 ost.OSS.ost_io.nrs_policies="fifo"
4447 local current_jobid_var=$($LCTL get_param -n jobid_var)
4448 if [ $saved_jobid_var != $current_jobid_var ]; then
4449 set_persistent_param_and_check client \
4450 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4453 run_test 77n "check wildcard support for TBF JobID NRS policy"
4456 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
4457 skip "need OST > 2.14.54"
4459 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
4460 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
4461 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
4462 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
4463 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
4464 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
4466 run_test 77o "Changing rank should not panic"
4471 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4472 skip "need MDS >= 2.14.54"
4474 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4475 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4477 for i in {1..50}; do
4480 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={500}&gid={500} rate=100'" &
4482 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
4484 wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
4485 wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
4487 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
4489 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
4491 wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
4492 wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
4495 run_test 77q "Parallel TBF rule definitions should not panic"
4499 local -a spec_chars=(
4500 '@' '.' '~' '#' '/' '^' '%' '*' ';' ',' '?' '<' '>' ':'
4501 '+' '=' ')' '(' '{' '}' '|' '[' ']' '!' '&' '\$' '\`' '\\')
4503 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4504 skip "need MDS >= 2.14.54"
4506 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4507 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4509 # TBF rule name size is 16 bytes
4510 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_overflo\ uid={500}\ rate=500" &&
4511 error "The length of tbf rule name is not checked" || true
4512 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ \ uid={500}\ rate=500" &&
4513 error "The server should not accept empty tbf rule name" || true
4514 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_empty" &&
4515 error "The server should not accept 'start <tbf_rule_name>' without an expression" || true
4517 # Test with special chars
4518 for c in "${spec_chars[@]}"; do
4519 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start test77p${c}spec uid={500} rate=500'" &&
4520 error "Special char '${c}' should not be accepted in a tbf rule name" || true
4524 run_test 77p "Check validity of rule names for TBF policies"
4526 test_78() { #LU-6673
4529 oss=$(comma_list $(osts_nodes))
4530 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4531 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4533 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4534 # Valid return codes are:
4535 # 0: Tuning succeeded
4536 # ENODEV: Policy is still stopped
4537 # EAGAIN: Policy is being initialized
4538 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4539 error "Expected set_param to return 0|ENODEV|EAGAIN"
4541 # Cleanup the ORR policy
4542 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4543 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4546 run_test 78 "Enable policy and specify tunings right away"
4549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4550 test_mkdir $DIR/$tdir
4552 # Prevent interference from layout intent RPCs due to
4553 # asynchronous writeback. These will be tested in 130c below.
4554 do_nodes ${CLIENTS:-$HOSTNAME} sync
4556 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4557 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4559 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4560 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4561 local facet=mds$((mdtidx + 1))
4563 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4564 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4568 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4569 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4574 run_test 79 "xattr: intent error"
4577 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4584 mkdir_on_mdt0 $DIR1/$tdir
4585 mkdir -p $DIR1/$tdir/dir
4586 createmany -o $DIR1/$tdir/dir/f 10 ||
4587 error "create files under remote dir failed $i"
4589 cp /etc/passwd $DIR1/$tdir/$tfile
4591 #migrate open file should fails
4592 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4594 # give multiop a chance to open
4597 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4598 error "migrate open files should failed with open files"
4602 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4603 error "migrate remote dir error"
4605 echo "Finish migration, then checking.."
4606 for file in $(find $DIR1/$tdir); do
4607 mdt_index=$($LFS getstripe -m $file)
4608 [ $mdt_index == $MDTIDX ] ||
4609 error "$file is not on MDT${MDTIDX}"
4612 diff /etc/passwd $DIR1/$tdir/$tfile ||
4613 error "file different after migration"
4615 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4617 run_test 80a "migrate directory when some children is being opened"
4621 kill -9 $migrate_pid
4625 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4626 local migrate_dir1=$DIR1/$tdir/migrate_dir
4627 local migrate_dir2=$DIR2/$tdir/migrate_dir
4628 local migrate_run=$LUSTRE/tests/migrate.sh
4635 trap cleanup_80b EXIT
4636 #prepare migrate directory
4637 mkdir -p $migrate_dir1
4638 for F in {1,2,3,4,5}; do
4639 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4640 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4643 #migrate the directories among MDTs
4646 mdt_idx=$((RANDOM % MDSCOUNT))
4647 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4649 (( $rc != 0 && $rc != 16 )) || break
4654 echo "start migration thread $migrate_pid"
4655 #Access the files at the same time
4657 echo "accessing the migrating directory for 5 minutes..."
4659 ls $migrate_dir2 > /dev/null || {
4660 echo "read dir fails"
4663 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4664 echo "access file1 fails"
4668 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4669 echo "access file2/3 fails"
4673 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4674 echo "access file4 fails"
4678 stat $migrate_dir2/file5 > /dev/null || {
4679 echo "stat file5 fails"
4683 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4684 (( $rc != 0 && $rc != 1 )) || {
4685 echo "touch file failed with $rc1"
4689 if [ -e $migrate_dir2/source_file ]; then
4690 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4691 &>/dev/null || rc1=$?
4692 if [ -e $migrate_dir2/link_file ]; then
4693 rm -rf $migrate_dir2/link_file
4696 mrename $migrate_dir2/source_file \
4697 $migrate_dir2/target_file &>/dev/null || rc1=$?
4698 (( $rc != 0 && $rc != 1 )) || {
4699 echo "rename failed with $rc1"
4703 if [ -e $migrate_dir2/target_file ]; then
4704 rm -rf $migrate_dir2/target_file &>/dev/null ||
4707 rm -rf $migrate_dir2/source_file &>/dev/null ||
4710 (( $rc != 0 && $rc != 1 )) || {
4711 echo "unlink failed with $rc1"
4716 local duration=$((SECONDS - start_time))
4717 if (( duration % 10 == 0 )); then
4718 if (( $show_time == 1 )); then
4719 echo "...$duration seconds"
4726 kill -0 $migrate_pid || {
4727 echo "migration stopped 1"
4731 (( $duration < 300 )) || break
4734 #check migration are still there
4735 kill -0 $migrate_pid || error "migration stopped 2"
4738 run_test 80b "Accessing directory during migration"
4741 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4745 mkdir -p $DIR1/$tdir
4747 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4748 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4751 touch d0/0 || error "create 0 failed"
4752 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4753 stat d0/0 && error "stat mv filed succeed"
4754 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4755 stat d0/0 || error "stat failed"
4757 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4759 if [ $t -ne 3 ]; then
4760 ls -ai $DIR1/$tdir/d0
4761 error "expect 3 get $t"
4766 run_test 81a "rename and stat under striped directory"
4769 [ $MDSCOUNT -lt 2 ] &&
4770 skip "We need at least 2 MDTs for this test"
4777 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4778 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4787 for i in $(seq $total); do
4788 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4792 kill -9 $setattr_pid
4794 run_test 81b "rename under striped directory doesn't deadlock"
4797 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4798 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4799 skip "Need MDS version at least 2.13.52"
4801 # source is local, source parent is remote
4802 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4803 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4804 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4805 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4806 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4807 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4808 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4809 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4811 # source is remote, source parent is local
4812 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4813 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4814 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4815 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4816 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4817 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4818 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4819 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4821 # source and source parent are remote
4822 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4823 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4824 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4825 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4826 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4827 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4828 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4829 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4831 # source and source parent are remote, and source is remote object
4832 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4833 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4834 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4835 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4836 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4837 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4838 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4840 run_test 81c "rename revoke LOOKUP lock for remote object"
4843 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4844 skip "Need MDS version at least 2.6.92"
4846 # Client 1 creates a file.
4847 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4849 # Client 2 opens the file.
4850 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4852 # Client 1 makes the file an orphan.
4853 rm $DIR1/$tfile || error "rm"
4854 # Client 2 sets EA "user.multiop".
4856 wait $pid2 || error "multiop 2"
4857 # Client 1 gets EA "user.multiop". This used to fail because the EA
4858 # cache refill would get "trusted.link" from mdd_xattr_list() but
4859 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4862 wait $pid1 || error "multiop 1"
4864 run_test 82 "fsetxattr and fgetxattr on orphan files"
4867 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4874 $LFS mkdir -i1 -c2 $tdir
4879 echo "start pid $pid1 to create/unlink striped directory"
4881 # Access the directory at the same time
4885 stat $tdir > /dev/null 2>&1
4889 echo "start pid $pid2 to stat striped directory"
4897 run_test 83 "access striped directory while it is being created/unlinked"
4900 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4901 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4905 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4906 error "create $tfile failed"
4907 mtime=$(stat -c%Y $DIR/$tfile)
4908 mtime=$((mtime + 200))
4910 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4911 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4913 touch -c -m $mtime $DIR/$tfile &
4915 # sleep a while to let 'touch' run first
4917 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4920 wait $setattr_pid || true
4922 run_test 84 "0-nlink race in lu_object_find()"
4925 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4930 [ "$SLOW" = "yes" ] && duration=600
4931 # Open/Create under striped directory
4935 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4936 touch $tdir/f{0..3} > /dev/null 2>&1
4940 echo "start pid $pid1 to open/create under striped directory"
4942 # unlink the striped directory at the same time
4946 rm -rf $tdir > /dev/null 2>&1
4950 echo "start pid $pid2 to unlink striped directory"
4959 run_test 90 "open/create and unlink striped directory"
4962 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4967 [ "$SLOW" = "yes" ] && duration=600
4968 # chmod striped directory
4972 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4973 chmod go+w $tdir > /dev/null 2>&1
4977 echo "start pid $pid1 to chmod striped directory"
4979 # unlink the striped directory at the same time
4983 rm -rf $tdir > /dev/null 2>&1
4987 echo "start pid $pid2 to unlink striped directory"
4996 run_test 91 "chmod and unlink striped directory"
4999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5002 local cmd="exec $fd<$DIR1/$tdir"
5003 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
5006 trap "eval $cmd" EXIT
5007 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
5008 rmdir ../$tdir || error "rmdir ../$tdir fails"
5010 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
5011 $LCTL set_param fail_loc=0x1408
5012 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
5013 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
5014 error "create remote dir succeeds"
5015 $LCTL set_param fail_loc=0
5019 run_test 92 "create remote directory under orphan directory"
5026 mkdir -p $DIR1/$tfile-1/
5027 mkdir -p $DIR2/$tfile-2/
5028 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
5029 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
5030 do_facet $SINGLEMDS "$LCTL set_param -n \
5031 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
5032 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
5033 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
5035 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
5038 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
5042 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
5043 do_facet $SINGLEMDS "$LCTL set_param -n \
5044 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
5046 $LFS getstripe $DIR1/$tfile-1/file1
5047 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
5048 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5049 $LFS getstripe $DIR2/$tfile-2/file2
5050 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
5051 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5052 echo "rc1=$rc1 and rc2=$rc2 "
5053 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
5054 error "object allocate on same ost detected"
5056 run_test 93 "alloc_rr should not allocate on same ost"
5059 $LCTL set_param osc.*.idle_timeout=0
5060 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
5062 local before=$(date +%s)
5066 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
5067 $LCTL set_param fail_val=5 fail_loc=0x80000312
5068 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
5072 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
5073 $LCTL set_param fail_val=6 fail_loc=0x80000329
5074 $LCTL mark kill $pid
5077 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
5080 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
5082 evict=$(do_facet client $LCTL get_param \
5083 osc.$FSNAME-OST*-osc-*/state |
5084 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
5086 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5087 (do_facet client $LCTL get_param \
5088 osc.$FSNAME-OST*-osc-*/state;
5089 error "eviction happened: $evict before:$before")
5090 $LCTL set_param osc.*.idle_timeout=debug
5092 run_test 94 "signal vs CP callback race"
5096 skip "Reserved for glimpse-ahead" && return
5097 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5098 skip "Need MDS version at least 2.10.55"
5102 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5104 lctl set_param -n mdc.*.stats=clear
5105 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5107 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5108 # first stat from server should return size data and save glimpse
5109 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5110 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5111 # second stat to check size is NOT cached on client without IO lock
5112 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5114 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5115 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5118 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5121 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5122 skip "Need MDS version at least 2.10.55"
5126 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5128 lctl set_param -n mdc.*.stats=clear
5129 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5130 cancel_lru_locks mdc
5131 # first stat data from server should have size
5132 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5133 # second stat to check size is cached on client
5134 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5136 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5137 # both stats should cause no glimpse requests
5138 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5141 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5144 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5145 skip "Need MDS version at least 2.10.55"
5149 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5151 lctl set_param -n mdc.*.stats=clear
5152 lctl set_param -n osc.*.stats=clear
5153 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5155 # check that size is merged from MDT and OST correctly
5156 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5157 error "Wrong size from stat #1"
5159 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5160 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5164 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5167 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5168 skip "Need MDS version at least 2.10.55"
5172 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5175 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5176 lctl set_param -n mdc.*.stats=clear
5177 $TRUNCATE $DIR2/$tdir/dom 4096
5179 # check that reported size is valid after file grows to OST and
5180 # is truncated back to MDT stripe size
5181 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5182 error "Wrong size from stat #1"
5184 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5185 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5189 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5192 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5193 skip "Need MDS version at least 2.11.50"
5195 local dom=$DIR/$tdir/dom
5196 local dom2=$DIR2/$tdir/dom
5199 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5201 cancel_lru_locks mdc
5202 dd if=/dev/urandom of=$dom bs=12000 count=1
5203 $TRUNCATE $dom2 6000
5204 cancel_lru_locks mdc
5205 lctl set_param -n mdc.*.stats=clear
5206 # expect read-on-open to return all data before write
5207 cat /etc/hosts >> $dom
5208 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5209 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5211 run_test 100e "DoM: read on open and file size"
5214 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5215 skip "Need MDS version at least 2.10.55"
5217 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5219 $CHECKSTAT -t file $DIR1/$tfile
5221 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5222 sysctl -wq vm.dirty_writeback_centisecs=0
5224 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5227 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5228 error_noexit "Write fails"
5229 # must discard pages
5230 lctl set_param -n mdc.*.stats=clear
5231 rm $DIR2/$tfile || error "Unlink fails"
5233 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5234 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5236 run_test 101a "Discard DoM data on unlink"
5239 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5240 skip "Need MDS version at least 2.10.55"
5242 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5243 touch $DIR1/${tfile}_2
5245 $CHECKSTAT -t file $DIR1/$tfile
5247 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5248 sysctl -wq vm.dirty_writeback_centisecs=0
5250 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5253 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5254 # must discard pages
5255 lctl set_param -n mdc.*.stats=clear
5256 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5258 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5259 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5261 run_test 101b "Discard DoM data on rename"
5264 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5265 skip "Need MDS version at least 2.10.55"
5267 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5269 $CHECKSTAT -t file $DIR1/$tfile
5271 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5272 sysctl -wq vm.dirty_writeback_centisecs=0
5274 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5277 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5278 $MULTIOP $DIR1/$tfile O_c &
5281 lctl set_param -n mdc.*.stats=clear
5282 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5283 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5285 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5286 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5288 run_test 101c "Discard DoM data on close-unlink"
5290 # test to verify file handle related system calls
5291 # (name_to_handle_at/open_by_handle_at)
5292 # The new system calls are supported in glibc >= 2.14.
5294 # test to verify we can open by handle an unlinked file from > 1 client
5295 # This test opens the file normally on $DIR1, which is on one mount, and then
5296 # opens it by handle on $DIR2, which is on a different mount.
5298 (( "$MDS1_VERSION" >= $(version_code 2.11.57) )) ||
5299 skip "Needs MDS version 2.11.57 or later"
5301 echo "Test file_handle syscalls" > $DIR/$tfile ||
5302 error "write failed"
5303 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5304 error "check_fhandle_syscalls $tfile failed"
5306 # test this is working on DNE directories also
5307 if (( MDSCOUNT > 1 && MDS1_VERSION >= $(version_code 2.14.52) )); then
5308 $LFS mkdir -i 1 $DIR/$tdir.remote
5309 cancel_lru_locks mdc
5310 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5311 error "check_fhandle_syscalls $tdir.remote failed"
5312 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5313 cancel_lru_locks mdc
5314 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5315 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5317 $LFS mkdir -c -1 $DIR/$tdir.stripe
5318 cancel_lru_locks mdc
5319 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5320 error "check_fhandle_syscalls $tdir.stripe failed"
5321 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5322 cancel_lru_locks mdc
5323 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5324 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5327 run_test 102 "Test open by handle of unlinked file"
5329 # Compare file size between first & second mount, ensuring the client correctly
5330 # glimpses even with unused speculative locks - LU-11670
5332 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5333 skip "Lockahead needs OST version at least 2.10.50"
5337 test_mkdir -p $DIR/$tdir
5339 # Force file on to OST0
5340 $LFS setstripe -i 0 $DIR/$tdir
5342 # Do not check multiple locks on glimpse
5343 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5344 $LCTL set_param fail_loc=0x415
5346 # Delay write commit by 2 seconds to guarantee glimpse wins race
5347 # The same fail_loc is used on client & server so it can work in the
5348 # single node sanity setup
5349 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5351 echo "Incorrect size expected (no glimpse fix):"
5352 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5354 if [ $rc -eq 0 ]; then
5355 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5358 # guarantee write commit timeout has expired
5361 # Clear fail_loc on client
5362 $LCTL set_param fail_loc=0
5364 # Delay write commit by 2 seconds to guarantee glimpse wins race
5365 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5366 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5368 # Write commit is still delayed by 2 seconds
5369 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5371 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5373 # guarantee write commit timeout has expired
5376 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5378 run_test 103 "Test size correctness with lockahead"
5384 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5395 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5396 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5397 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5398 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5406 local xtimes=($(get_stat_xtimes))
5407 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5409 echo "STAT a|m|ctime ${xtimes[*]}"
5410 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5411 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5412 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5413 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5414 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5415 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5416 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5420 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5421 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5422 skip "Need MDS version at least 2.12.4"
5425 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5426 local atime_diff=$(do_facet $SINGLEMDS \
5427 lctl get_param -n mdd.*MDT0000*.atime_diff)
5429 do_facet $SINGLEMDS \
5430 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5432 stack_trap "do_facet $SINGLEMDS \
5433 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5435 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5436 check_mdt_xtimes $mdtdev
5439 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5440 check_mdt_xtimes $mdtdev
5442 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5445 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5447 kill -USR1 $pid && wait $pid || error "multiop failure"
5448 check_mdt_xtimes $mdtdev
5453 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5454 # on the client side
5455 xtimes=($(get_stat_xtimes))
5456 $MULTIOP $DIR/$tfile O_c &
5459 kill -USR1 $pid && wait $pid || error "multiop failure"
5460 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5461 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5462 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5463 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5464 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5465 check_mdt_xtimes $mdtdev
5468 # Change ctime via chmod
5469 $MULTIOP $DIR/$tfile o_tc &
5472 kill -USR1 $pid && wait $pid || error "multiop failure"
5473 check_mdt_xtimes $mdtdev
5475 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5478 test_mkdir -p $DIR/$tdir
5479 echo test > $DIR/$tdir/$tfile
5480 $LCTL set_param fail_loc=0x416
5481 cancel_lru_locks osc & sleep 1
5482 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5484 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5486 run_test 105 "Glimpse and lock cancel race"
5489 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5490 skip_env "Test only for ldiskfs and statx() supported"
5495 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5497 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5498 btime=$($STATX -c %W $DIR/$tfile)
5499 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5501 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5502 [[ $btime == $mdt_btime ]] ||
5503 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5506 run_test 106a "Verify the btime via statx()"
5509 statx_supported || skip_env "statx() only test"
5514 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5515 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5516 cancel_lru_locks $OSC
5517 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5519 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5520 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5521 error "$STATX should send 1 glimpse RPC to $OSC"
5523 cancel_lru_locks $OSC
5524 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5525 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5526 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5528 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5529 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5530 [ $rpcs_after -eq $rpcs_before ] ||
5531 error "$STATX should not send glimpse RPCs to $OSC"
5533 cancel_lru_locks $OSC
5534 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5535 $STATX --cached=always $DIR/$tfile
5536 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5537 [ $rpcs_after -eq $rpcs_before ] ||
5538 error "$STATX should not send glimpse RPCs to $OSC"
5540 cancel_lru_locks $OSC
5541 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5542 $STATX -c %Y $DIR/$tfile
5543 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5544 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5545 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5547 cancel_lru_locks $OSC
5548 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5549 $STATX -c %s $DIR/$tfile
5550 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5551 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5552 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5554 cancel_lru_locks $OSC
5555 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5556 $STATX -c %b $DIR/$tfile
5557 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5558 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5559 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5561 run_test 106b "Glimpse RPCs test for statx"
5564 statx_supported || skip_env "statx() only test"
5569 # Mask supported in stx_attributes by Lustre is
5570 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5571 mask=$($STATX -c %p $DIR/$tfile)
5572 [[ $mask == "30" ]] ||
5573 error "supported stx_attributes: got '$mask', expected '30'"
5574 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5575 mask=$($STATX -c %r $DIR/$tfile)
5576 [[ $mask == "10" ]] ||
5577 error "got immutable flags '$mask', expected '10'"
5578 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5579 mask=$($STATX -c %r $DIR/$tfile)
5580 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5581 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5582 mask=$($STATX -c %r $DIR/$tfile)
5583 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5584 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5585 mask=$($STATX -c %r $DIR/$tfile)
5586 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5587 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5588 mask=$($STATX -c %r $DIR/$tfile)
5589 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5590 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5591 mask=$($STATX -c %r $DIR/$tfile)
5592 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5594 run_test 106c "Verify statx attributes mask"
5596 test_107a() { # LU-1031
5597 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5601 $LFS getstripe $DIR1/$tfile
5603 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5605 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5607 kill -USR1 $MULTIPID2
5609 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5610 error "First grouplock does not block second one"
5612 echo "First grouplock blocks second one"
5614 kill -USR1 $MULTIPID1
5618 run_test 107a "Basic grouplock conflict"
5621 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5625 $LFS getstripe $DIR1/$tfile
5627 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5629 multiop $DIR2/$tfile Or10c &
5633 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5634 error "Grouplock does not block IO"
5636 echo "Grouplock blocks IO"
5639 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5642 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5643 error "First grouplock does not block second one"
5645 echo "First grouplock blocks second one"
5648 kill -USR1 $MULTIPID1
5651 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5652 error "Second grouplock thread disappeared"
5655 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5656 error "Second grouplock does not block IO"
5658 echo "Second grouplock blocks IO"
5661 kill -USR1 $MULTIPID3
5666 run_test 107b "Grouplock is added to the head of waiting list"
5671 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5672 error "Create $DIR1/$tfile failed"
5674 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5675 error "dd $DIR1/$tfile failed"
5676 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5677 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5679 $TRUNCATE $DIR1/$tfile 2000
5680 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5681 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5683 #define OBD_FAIL_OSC_DELAY_IO 0x414
5684 $LCTL set_param fail_val=4 fail_loc=0x80000414
5685 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5689 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5691 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5693 run_test 108a "lseek: parallel updates"
5701 skip "Clients need to be on different nodes than the servers"
5703 umount_client $MOUNT
5704 umount_client $MOUNT2
5706 echo "Starting race between client mount instances (50 iterations):"
5707 for i in {1..50}; do
5710 #define OBD_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
5711 $LCTL set_param -n fail_loc=0x80001417
5713 mount_client $MOUNT & pid1=$!
5714 mount_client $MOUNT2 & pid2=$!
5715 wait $pid1 || error "Mount $MOUNT fails with $?"
5716 wait $pid2 || error "Mount $MOUNT2 fails with $?"
5718 umount_client $MOUNT & pid1=$!
5719 umount_client $MOUNT2 & pid2=$!
5720 wait $pid1 || error "Umount $MOUNT fails with $?"
5721 wait $pid2 || error "Umount $MOUNT2 fails with $?"
5723 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
5729 mount_client $MOUNT2
5732 run_test 109 "Race with several mount instances on 1 node"
5735 local before=$(date +%s)
5742 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
5743 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
5745 # disable last_xid logic by dropping link reply
5746 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
5749 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
5750 do_facet mds1 lctl set_param fail_loc=0x534
5752 # RPC will race with its Resend and the Resend will sleep to let
5753 # the original lock to get granted & cancelled.
5755 # AST_SENT is set artificially, so an explicit conflict is not needed
5757 # The woken up Resend gets a new lock, but client does not wait for it
5760 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
5762 # Take a conflict to wait long enough to see the eviction
5765 # let the client reconnect
5767 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
5768 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
5770 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5771 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
5772 error "eviction happened: $evict before:$before")
5774 run_test 110 "do not grant another lock on resend"
5777 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
5778 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
5779 skip "MDT0 and MDT1 should be on the same node"
5782 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
5783 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
5785 mkdir $DIR1/$tdir/mdt0dir/foodir
5786 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
5788 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
5790 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
5792 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
5793 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
5795 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
5798 rm $DIR2/$tdir/mdt1dir/file2
5801 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
5806 rm -r $DIR1/$tdir || error "Removing test dir failed"
5808 run_test 111 "A racy rename/link an open file should not cause fs corruption"
5811 (( MDSCOUNT >= 2 )) ||
5812 skip "We need at least 2 MDTs for this test"
5814 (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
5815 skip "Need server version at least 2.14.54"
5820 rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
5822 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
5824 mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
5825 $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
5826 $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
5827 error "setdirstripe s3 failed"
5828 $LCTL set_param lmv.*.qos_threshold_rr=90
5829 mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
5830 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
5831 (( count == 64 )) || error "only $count subdirs created on MDT0"
5833 $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
5834 error "setdirstripe s3 failed"
5835 mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
5836 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
5837 (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
5839 run_test 112 "update max-inherit in default LMV"
5841 log "cleanup: ======================================================"
5843 # kill and wait in each test only guarentee script finish, but command in script
5844 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5845 # otherwise umount below will fail
5846 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5851 check_and_cleanup_lustre