8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 # skip tests for PPC until they are fixed
26 if [[ $(uname -m) = ppc64 ]]; then
27 # bug number: LU-11787
31 if [ $mds1_FSTYPE = "zfs" ]; then
32 # bug number: LU-15757 (test_102() causes crash in umount later)
34 # LU-2829 / LU-2887 - make allowances for ZFS slowness
35 TEST33_NFILES=${TEST33_NFILES:-1000}
39 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
48 check_and_setup_lustre
53 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
55 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
56 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
58 # $RUNAS_ID may get set incorrectly somewhere else
59 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
61 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
65 [ -f $DIR2/$tfile ] || error "Check create"
66 chmod 777 $DIR2/$tfile
67 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
68 error "Check attribute update for 0777"
70 chmod a-x $DIR2/$tfile
71 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
72 error "Check attribute update for 0666"
75 $CHECKSTAT -a $DIR1/$tfile ||
76 error "Check unlink - removes file on other mountpoint"
78 run_test 1 "Check attribute updates on 2 mount points"
84 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
85 error "Either not file type or perms not 0777"
87 run_test 2a "check cached attribute updates on 2 mtpt's ========"
93 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
94 error "Either not file type or perms not 0777"
96 run_test 2b "check cached attribute updates on 2 mtpt's ========"
98 # NEED TO SAVE ROOT DIR MODE
101 $CHECKSTAT -t dir -p 0777 $DIR2 ||
102 error "Either not dir type or perms not 0777"
104 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
108 $CHECKSTAT -t dir -p 0755 $DIR2 ||
109 error "Either not file type or perms not 0775"
111 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
118 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
121 run_test 2e "check chmod on root is propagated to others"
124 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
126 local remote_dir=$tdir/remote_dir
129 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
130 error "Create remote directory failed"
132 touch $DIR1/$remote_dir/$tfile ||
133 error "Create file under remote directory failed"
134 chmod 777 $DIR1/$remote_dir/$tfile ||
135 error "Chmod file under remote directory failed"
137 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
138 error "Check attr of file under remote directory failed"
140 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
141 error "Chown file under remote directory failed"
143 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
144 error "Check owner of file under remote directory failed"
146 cd $DIR2/$remote_dir || error "enter remote dir"
147 rm -rf $DIR1/$remote_dir/$tfile ||
148 error "Unlink remote directory failed"
150 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
151 error "unlink file still exists!"
153 cd $DIR2/$tdir || error "exit remote dir"
154 rm -rf $DIR1/$tdir || error "unlink directory failed"
156 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
159 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
161 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
163 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
164 echo "$DIR1/$tfile has $block1 blocks"
165 echo "$DIR2/$tfile has $block2 blocks"
166 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
168 run_test 2g "check blocks update on sync write"
171 local target="this/is/good"
172 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
173 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
174 error "link $DIR2/$tfile not as expected"
176 run_test 3 "symlink on one mtpt, readlink on another ==========="
179 multifstat $DIR1/f4 $DIR2/f4
181 run_test 4 "fstat validation on multiple mount points =========="
185 $TRUNCATE $DIR2/f5 100
186 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
187 error "Either not file type or size not equal to 100 bytes"
190 run_test 5 "create a file on one mount, truncate it on the other"
193 openunlink $DIR1/$tfile $DIR2/$tfile || \
194 error "openunlink $DIR1/$tfile $DIR2/$tfile"
196 run_test 6 "remove of open file on other node =================="
200 opendirunlink $DIR1/$dir $DIR2/$dir || \
201 error "opendirunlink $DIR1/$dir $DIR2/$dir"
203 run_test 7 "remove of open directory on other node ============="
206 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
207 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
209 run_test 8 "remove of open special file on other node =========="
215 for C in a b c d e f g h i j k l; do
216 dir=`eval echo \\$DIR$MTPT`
217 echo -n $C >> $dir/f9
218 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
220 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
221 error "`od -a $DIR1/f9` != abcdefghijkl"
223 run_test 9a "append of file with sub-page size on multiple mounts"
225 #LU-10681 - tiny writes & appending to sparse striped file
227 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
229 $LFS setstripe -c 2 -S 1M $DIR/$tfile
230 echo "foo" >> $DIR/$tfile
231 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
232 error "sparse dd $DIR2/$tfile failed"
233 echo "foo" >> $DIR/$tfile
235 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
236 echo "Data read (expecting 'foo')": $data
237 [ "$data" = "foo" ] || error "append to sparse striped file failed"
239 run_test 9b "append to striped sparse file"
246 for C in a b c d e f g h i j k l; do
247 dir=`eval echo \\$DIR$MTPT`
248 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
249 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
250 OFFSET=`expr $OFFSET + 1`
252 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
253 error "`od -a $DIR1/f10` != abcdefghijkl"
255 run_test 10a "write of file with sub-page size on multiple mounts "
259 yes "R" | head -c 4000 >$TMP/f10b-seed
260 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
262 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
264 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
266 # create a test file locally to compare
267 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
268 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
269 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
270 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
272 run_test 10b "write of file with sub-page size on multiple mounts "
276 multiop_bg_pause $DIR1/d11/f O_c || return 1
278 cp -p /bin/ls $DIR1/d11/f
282 wait $MULTIPID || error "wait for PID $MULTIPID failed"
283 [ $RC -eq 0 ] && error || true
285 run_test 11 "execution of file opened for write should return error ===="
288 DIR=$DIR DIR2=$DIR2 bash lockorder.sh
290 run_test 12 "test lock ordering (link, stat, unlink)"
292 test_13() { # bug 2451 - directory coherency
294 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
296 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
298 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
299 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
300 # need to run it twice
301 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
303 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
304 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
306 run_test 13 "test directory page revocation"
309 test_mkdir $DIR1/$tdir
310 cp -p /bin/ls $DIR1/$tdir/$tfile
311 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
314 $DIR2/$tdir/$tfile && error || true
317 run_test 14aa "execution of file open for write returns -ETXTBSY"
320 test_mkdir $DIR1/$tdir
321 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
322 $DIR1/$tdir/sleep 60 &
324 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
327 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
329 test_14b() { # bug 3192, 7040
330 test_mkdir $DIR1/$tdir
331 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
332 $DIR1/$tdir/sleep 60 &
334 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
335 error "expected truncate error, got success"
337 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
339 run_test 14b "truncate of executing file returns -ETXTBSY ======"
341 test_14c() { # bug 3430, 7040
342 test_mkdir $DIR1/$tdir
343 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
344 $DIR1/$tdir/sleep 60 &
346 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
348 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
350 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
352 test_14d() { # bug 10921
353 test_mkdir $DIR1/$tdir
354 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
355 $DIR1/$tdir/sleep 60 &
358 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
360 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
362 run_test 14d "chmod of executing file is still possible ========"
364 test_15() { # bug 974 - ENOSPC
366 bash oos2.sh $MOUNT1 $MOUNT2
367 wait_delete_completed
368 grant_error=$(dmesg | grep "< tot_grant")
369 [ -z "$grant_error" ] || error "$grant_error"
371 run_test 15 "test out-of-space with multiple writers ==========="
374 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
375 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
376 # pass a 2500 operation dual-mount run within the time limit.
377 if [ "$ost1_FSTYPE" = "zfs" ]; then
378 FSXNUM=$((COUNT / 5))
380 elif [ "$SLOW" = "yes" ]; then
381 FSXNUM=$((COUNT * 5))
389 local file1=$DIR1/$tfile
390 local file2=$DIR2/$tfile
391 local stripe_size=$(do_facet $SINGLEMDS \
392 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
396 # to allocate grant because it may run out due to test_15.
397 $LFS setstripe -c -1 $file1
398 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
399 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
402 $LFS setstripe -c -1 $file1 # b=10919
403 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
407 # O_DIRECT reads and writes must be aligned to the PAGE_SIZE.
408 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r $PAGE_SIZE \
409 -w $PAGE_SIZE $file1 $file2 || error "fsx with O_DIRECT failed."
411 run_test 16a "$FSXNUM iterations of dual-mount fsx"
413 # Consistency check for tiny writes, LU-9409
415 local file1=$DIR1/$tfile
416 local file2=$DIR2/$tfile
417 local stripe_size=($($LFS getstripe -S $DIR))
421 # to allocate grant because it may run out due to test_15.
422 lfs setstripe -c -1 $file1
423 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
424 error "dd failed writing to file=$file1"
425 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
426 error "dd failed writing to file=$file2"
429 lfs setstripe -c -1 $file1 # b=10919
430 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
431 # create a mix of tiny writes & normal writes
432 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
433 $file1 $file2 || error "fsx with tiny write failed."
435 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
438 local file1=$DIR1/$tfile
439 local file2=$DIR2/$tfile
440 local stripe_size=$(do_facet $SINGLEMDS \
441 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
443 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
447 # to allocate grant because it may run out due to test_15.
448 $LFS setstripe -c -1 $file1
449 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
450 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
452 wait_delete_completed
454 local list=$(comma_list $(osts_nodes))
455 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
456 skip "not cache-capable obdfilter"
459 set_osd_param $list '' read_cache_enable 0
460 set_osd_param $list '' writethrough_cache_enable 0
462 $LFS setstripe -c -1 $file1 # b=10919
463 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
467 set_osd_param $list '' read_cache_enable 1
468 set_osd_param $list '' writethrough_cache_enable 1
472 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
475 local file1=$DIR1/$tfile
476 local file2=$DIR2/$tfile
477 local file3=$DIR1/file
478 local tmpfile=$(mktemp)
479 local stripe_size=$(do_facet $SINGLEMDS \
480 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
482 # to allocate grant because it may run out due to test_15.
483 $LFS setstripe -c -1 $file1
484 stack_trap "rm -f $file1 $file2 $file3 $tmpfile"
485 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
486 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
489 $LFS setstripe -c -1 $file1 # b=10919
490 $LCTL set_param ldlm.namespaces.*.lru_size=clear
492 # direct write on one client and direct read from another
493 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
494 dd if=$file2 of=$tmpfile iflag=direct bs=1M
495 diff $file1 $tmpfile || error "file different(1)"
498 # buffer write on one client, but direct read from another
499 dd if=$tmpfile of=$file1 bs=1M count=100
500 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
501 diff $file3 $tmpfile || error "file different(2)"
503 rm -f $file3 $file2 $file1
504 # direct write on one client
505 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
506 # buffer read from another client
507 dd if=$file2 of=$file3 bs=1M count=100
508 diff $file3 $tmpfile || error "file different(3)"
510 run_test 16d "Verify DIO and buffer IO with two clients"
512 test_16e() { # LU-13227
515 (( "$MDS1_VERSION" >= $(version_code 2.13.53) )) ||
516 skip "Need MDS version at least 2.13.53"
518 local file1=$DIR1/$tfile
519 local file2=$DIR2/$tfile
521 # client1 write 10M data
522 dd if=/dev/zero of=$file1 bs=1M count=10
524 cancel_lru_locks osc > /dev/null
525 # use lockahead to generate one PW lock to keep LVB loaded.
526 $LFS ladvise -a lockahead --start 0 --length 1M \
528 # direct write to extend file size on client2
529 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
530 oflag=direct conv=notrunc
531 local filesize=$(stat -c %s $file2)
532 [ "$filesize" -eq 22020096 ] ||
533 error "expected filesize 22020096 got $filesize"
536 run_test 16e "Verify size consistency for O_DIRECT write"
538 test_17() { # bug 3513, 3667
539 remote_ost_nodsh && skip "remote OST with nodsh" && return
541 lfs setstripe $DIR1/$tfile -i 0 -c 1
542 cp $SAMPLE_FILE $DIR1/$tfile
543 cancel_lru_locks osc > /dev/null
544 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
545 do_facet ost1 lctl set_param fail_loc=0x8000030a
546 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
547 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
549 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
551 run_test 17 "resource creation/LVB creation race ==============="
554 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
557 for idx in {a..z}; do
558 local ptr=EXCEPT_ALWAYS_18$idx
559 [ x${!ptr} = xtrue ] || continue
561 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
564 excepts="$excepts -e 7 -e 8 -e 9"
565 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
566 error "mmap_sanity test failed"
569 run_test 18 "mmap sanity check ================================="
571 test_19() { # bug3811
572 local node=$(facet_active_host ost1)
573 local device="$FSNAME-OST*"
575 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
576 device="$FSNAME-MDT*"
578 # check whether obdfilter is cache capable at all
579 get_osd_param $node $device read_cache_enable >/dev/null ||
580 skip "not cache-capable obdfilter"
582 local max=$(get_osd_param $node $device readcache_max_filesize |\
584 set_osd_param $node $device readcache_max_filesize 4096
585 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
586 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
587 cp $TMP/$tfile $DIR1/$tfile
588 for i in `seq 1 20`; do
589 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
590 cancel_lru_locks $OSC > /dev/null
591 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
592 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
594 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
595 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
596 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
597 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
599 set_osd_param $node $device readcache_max_filesize $max
602 run_test 19 "test concurrent uncached read races ==============="
605 test_mkdir $DIR1/$tdir
607 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
608 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
609 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
610 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
612 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
613 [[ $CNT2 == $CNT ]] ||
614 error $((CNT2 - CNT))" page left in cache after lock cancel"
616 run_test 20 "test extra readahead page left in cache ===="
623 test_21() { # Bug 5907
624 test_mkdir $DIR1/$tdir
625 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
627 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
628 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
629 test -d $DIR1/$tdir || error "Mounted directory disappeared"
631 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
634 run_test 21 " Try to remove mountpoint on another dir ===="
636 test_23() { # Bug 5972
637 local at_diff=$(do_facet $SINGLEMDS \
638 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
639 echo "atime should be updated while another read" > $DIR1/$tfile
641 # clear the lock(mode: LCK_PW) gotten from creating operation
642 cancel_lru_locks $OSC
645 sleep $((at_diff + 1))
647 echo "starting reads"
648 multiop_bg_pause $DIR1/$tfile or20_c || return 1
649 # with SOM and opencache enabled, we need to close a file and cancel
650 # open lock to get atime propogated to MDS
651 kill -USR1 $! || return 2
654 time2=$(stat -c "%X" $DIR/$tfile)
655 echo "new atime is $time2"
657 [ $time2 -gt $time1 ] || error "atime was not updated"
658 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
661 run_test 23 " others should see updated atime while another read===="
665 lfs df || error "lfs df failed"
666 lfs df -ih || error "lfs df -ih failed"
667 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
668 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
669 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
670 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
672 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
673 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
674 lctl --device %osc deactivate
675 lfs df -i || error "lfs df -i with deactivated OSC failed"
676 lctl --device %osc activate
677 lfs df || error "lfs df with reactivated OSC failed"
679 run_test 24a "lfs df [-ih] [path] test ========================="
683 fsnum=$(lfs_df | grep -c "summary")
684 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
686 run_test 24b "lfs df should show both filesystems ==============="
689 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
691 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
694 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
695 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
697 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
698 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
699 error "setfacl $DIR2/$tdir #1"
700 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
701 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
702 error "setfacl $DIR2/$tdir #2"
703 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
704 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
705 error "setfacl $DIR2/$tdir #3"
706 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
707 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
708 error "setfacl $DIR2/$tdir #4"
709 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
713 run_test 25a "change ACL on one mountpoint be seen on another ==="
716 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
718 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
720 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
723 $LFS mkdir -i 1 $DIR1/$tdir
724 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
725 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
727 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
728 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
729 error "setfacl $DIR2/$tdir #1"
730 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
731 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
732 error "setfacl $DIR2/$tdir #2"
733 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
734 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
735 error "setfacl $DIR2/$tdir #3"
736 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
737 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
738 error "setfacl $DIR2/$tdir #4"
739 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
743 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
746 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
748 run_test 26a "allow mtime to get older"
753 echo "aaa" >> $DIR1/$tfile
755 chmod a+x $DIR2/$tfile
756 mt1=`stat -c %Y $DIR1/$tfile`
757 mt2=`stat -c %Y $DIR2/$tfile`
759 if [ x"$mt1" != x"$mt2" ]; then
760 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
763 run_test 26b "sync mtime between ost and mds"
766 cancel_lru_locks $OSC
768 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
773 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
778 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
780 lctl set_param -n ldlm.dump_namespaces ""
781 wait $DD1_PID $DD2_PID
782 [ $? -ne 0 ] && lctl dk $TMP/debug || true
784 run_test 27 "align non-overlapping extent locks from request ==="
786 test_28() { # bug 9977
787 ECHO_UUID="ECHO_osc1_UUID"
788 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
790 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
791 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
792 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
796 attach echo_client ECHO_osc1 $ECHO_UUID
800 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
801 $LCTL --device $tECHOID destroy "${tOBJID}:0"
809 # reading of 1st stripe should pass
810 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
811 # reading of 2nd stripe should fail (this stripe was destroyed)
812 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
814 # now, recreating test file
815 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
816 # reading of 1st stripe should pass
817 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
818 # reading of 2nd stripe should pass
819 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
822 run_test 28 "read/write/truncate file with lost stripes"
824 test_30() { #b=11110, LU-2523
825 test_mkdir $DIR1/$tdir
826 cp -f /bin/bash $DIR1/$tdir/bash
827 bash -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
828 $DIR1/$tdir/bash -c 'sleep 2;
829 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
833 run_test 30 "recreate file race"
836 test_mkdir $DIR1/$tdir
837 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
838 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
839 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
840 lctl set_param fail_loc=0x314
841 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
842 awk 'BEGIN { FS="+" } /in/ {print $1}')
843 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
845 run_test 31a "voluntary cancel / blocking ast race=============="
848 remote_ost || { skip "local OST" && return 0; }
849 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
851 # make sure there is no local locks due to destroy
852 wait_mds_ost_sync || error "wait_mds_ost_sync()"
853 wait_delete_completed || error "wait_delete_completed()"
855 test_mkdir $DIR1/$tdir
856 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
857 cp /etc/hosts $DIR/$tdir/$tfile
858 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
859 lctl set_param fail_loc=0x314
860 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
861 do_facet ost1 lctl set_param fail_loc=0x316
863 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
864 lctl set_param fail_loc=0
865 do_facet ost1 lctl set_param fail_loc=0
866 # cleanup: reconnect the client back
869 run_test 31b "voluntary OST cancel / blocking ast race=============="
871 #LU-14949 - multi-client version of the test 31r in sanity.
873 touch $DIR/$tfile.target
874 touch $DIR/$tfile.source
876 ls -l $DIR/$tfile.target # cache it for sure
878 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
879 $LCTL set_param fail_loc=0x1419 fail_val=3
880 cat $DIR/$tfile.target &
883 # Guarantee open is waiting before we get here
885 mv $DIR2/$tfile.source $DIR2/$tfile.target
889 if [[ $RC -ne 0 ]]; then
890 error "open with cat failed, rc=$RC"
893 run_test 31r "open-rename(replace) race"
895 test_32b() { # bug 11270
896 remote_ost_nodsh && skip "remote OST with nodsh" && return
899 local facets=$(get_facets OST)
900 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
902 save_lustre_params client "osc.*.contention_seconds" > $p
903 save_lustre_params $facets \
904 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
905 save_lustre_params $facets \
906 "ldlm.namespaces.filter-*.contended_locks" >> $p
907 save_lustre_params $facets \
908 "ldlm.namespaces.filter-*.contention_seconds" >> $p
909 clear_stats $OSC.*.${OSC}_stats
911 # agressive lockless i/o settings
912 do_nodes $(comma_list $(osts_nodes)) \
913 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
914 ldlm.namespaces.filter-*.contended_locks=0 \
915 ldlm.namespaces.filter-*.contention_seconds=60"
916 lctl set_param -n $OSC.*.contention_seconds=60
918 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
920 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
923 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
924 error "lockless i/o was not triggered"
925 # disable lockless i/o (it is disabled by default)
926 do_nodes $(comma_list $(osts_nodes)) \
927 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
928 ldlm.namespaces.filter-*.contended_locks=32 \
929 ldlm.namespaces.filter-*.contention_seconds=0"
930 # set contention_seconds to 0 at client too, otherwise Lustre still
931 # remembers lock contention
932 lctl set_param -n $OSC.*.contention_seconds=0
933 clear_stats $OSC.*.${OSC}_stats
935 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
937 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
940 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
941 error "lockless i/o works when disabled"
943 restore_lustre_params <$p
946 # Disable test 32b prior to full removal
947 #run_test 32b "lockless i/o"
950 local mdts=$(get_facets MDS)
956 for mds in ${mdts//,/ }; do
959 dev=$(basename $(do_facet $mds "lctl get_param -n \
960 osd*.${!varsvc}.mntdev | xargs readlink -f"))
961 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
962 2>/dev/null | head -n1")
969 # commit on sharing tests
971 remote_mds_nodsh && skip "remote MDS with nodsh" && return
973 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
974 [ $CLIENTCOUNT -lt 2 ] &&
975 skip "Need two or more clients, have $CLIENTCOUNT"
977 local nfiles=${TEST33_NFILES:-10000}
978 local param_file=$TMP/$tfile-params
984 save_lustre_params $(get_facets MDS) \
985 "mdt.*.commit_on_sharing" > $param_file
988 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
992 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
994 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
995 echo "=== START createmany old: $jbdold transaction"
996 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")
997 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
998 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
999 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1000 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1001 avgtime=$(( avgtime + elapsed ))
1003 eval cos${COS}_jbd=$((avgjbd / 3))
1004 eval cos${COS}_time=$((avgtime / 3))
1007 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1008 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1009 [ "$cos0_jbd" != 0 ] &&
1010 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1011 [ "$cos0_time" != 0 ] &&
1012 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1014 restore_lustre_params < $param_file
1018 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1020 # commit on sharing tests
1022 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1024 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1025 [ $CLIENTCOUNT -ge 2 ] ||
1026 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1028 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1030 local nfiles=${TEST33_NFILES:-10000}
1031 local param_file=$TMP/$tfile-params
1033 save_lustre_params $(get_facets MDS) \
1034 "mdt.*.commit_on_sharing" > $param_file
1043 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1047 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1048 $DIR1/$tdir-\\\$(hostname)-$i"
1050 jbdold=$(print_jbd_stat)
1051 echo "=== START createmany old: $jbdold transaction"
1052 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1053 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1054 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1056 jbdnew=$(print_jbd_stat)
1057 jbd=$(( jbdnew - jbdold ))
1058 echo "=== END createmany new: $jbdnew transaction : \
1059 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1060 avgjbd=$(( avgjbd + jbd ))
1061 avgtime=$(( avgtime + elapsed ))
1063 eval cos${COS}_jbd=$((avgjbd / 3))
1064 eval cos${COS}_time=$((avgtime / 3))
1067 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1068 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1069 [ "$cos0_jbd" != 0 ] &&
1070 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1071 [ "$cos0_time" != 0 ] &&
1072 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1074 restore_lustre_params < $param_file
1078 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1081 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1082 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1083 skip "DNE CoS not supported"
1087 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1091 mkdir_on_mdt0 $DIR/$tdir
1093 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1094 # do twice in case transaction is committed before unlock, see LU-8200
1096 # remote dir is created on MDT1, which enqueued lock of $tdir on
1098 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1099 mkdir $DIR/$tdir/local.$i
1101 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1102 echo "sync_count $sync_count"
1103 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1106 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1107 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1108 # during sleep remote mkdir should have been committed and canceled
1109 # remote lock spontaneously, which shouldn't trigger sync
1111 mkdir $DIR/$tdir/local.3
1112 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1113 echo "sync_count $sync_count"
1114 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1116 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1118 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1122 local nodes=$(comma_list $(mdts_nodes))
1126 # trigger CoS twice in case transaction commit before unlock
1129 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1131 commit_nr=$(do_nodes $nodes \
1132 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1133 total=$((total + commit_nr));
1138 echo "CoS count $total"
1139 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1143 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1144 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1145 skip "DNE CoS not supported"
1147 # remote directory create
1148 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1149 # remote directory unlink
1150 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1151 # striped directory create
1152 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1153 # striped directory setattr
1154 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1155 "chmod 713 $DIR/$tdir"
1156 # striped directory unlink
1157 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1160 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1161 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1162 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1163 touch $DIR/$tdir/d1/tgt" \
1164 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1166 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1167 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1168 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1169 touch $DIR/$tdir/d1/src" \
1170 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1172 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1173 "$LFS migrate -m 1 $DIR/$tdir"
1177 run_test 33d "DNE distributed operation should trigger COS"
1180 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1181 [ $CLIENTCOUNT -ge 2 ] ||
1182 skip "Need two or more clients, have $CLIENTCOUNT"
1183 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1184 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1185 skip "DNE CoS not supported"
1187 local client2=${CLIENT2:-$(hostname)}
1191 local nodes=$(comma_list $(mdts_nodes))
1192 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1194 $LFS mkdir -c 2 $DIR/$tdir
1195 mkdir $DIR/$tdir/subdir
1196 echo abc > $DIR/$tdir/$tfile
1197 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1198 do_node $client2 touch $DIR/$tdir/subdir
1200 local async_commit_count=$(do_nodes $nodes \
1201 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1202 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1206 run_test 33e "DNE local operation shouldn't trigger COS"
1208 # End commit on sharing tests
1210 get_ost_lock_timeouts() {
1211 local nodes=${1:-$(comma_list $(osts_nodes))}
1213 local locks=$(do_nodes $nodes \
1214 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1222 do_nodes $(comma_list $(osts_nodes)) \
1223 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1224 for i in $(seq $OSTCOUNT); do
1225 wait_osc_import_ready client ost$i
1230 remote_ost_nodsh && skip "remote OST with nodsh" && return
1234 trap cleanup_34 EXIT RETURN
1235 for OPER in notimeout timeout ; do
1236 rm $DIR1/$tfile 2>/dev/null
1237 lock_in=$(get_ost_lock_timeouts)
1238 if [ $OPER == "timeout" ] ; then
1239 for j in `seq $OSTCOUNT`; do
1240 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1241 do_facet ost$j lctl set_param fail_loc=0x511
1243 echo lock should expire
1245 for j in `seq $OSTCOUNT`; do
1246 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1247 do_facet ost$j lctl set_param fail_loc=0x512
1249 echo lock should not expire
1251 echo writing on client1
1252 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1254 echo reading on client2
1255 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1256 # wait for a lock timeout
1258 lock_out=$(get_ost_lock_timeouts)
1259 if [ $OPER == "timeout" ] ; then
1260 if [ $lock_in == $lock_out ]; then
1261 error "no lock timeout happened"
1266 if [ $lock_in != $lock_out ]; then
1267 error "lock timeout happened"
1275 run_test 34 "no lock timeout under IO"
1277 test_35() { # bug 17645
1280 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1281 awk '/generation/{print $2}')
1283 generation[count]=$g
1287 test_mkdir $MOUNT1/$tdir
1288 cancel_lru_locks mdc
1290 # Let's initiate -EINTR situation by setting fail_loc and take
1291 # write lock on same file from same client. This will not cause
1292 # bl_ast yet as lock is already in local cache.
1293 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1294 do_facet client "lctl set_param fail_loc=0x80000317"
1295 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1296 let timeout=timeout*3
1298 while test $nr -lt 10; do
1299 log "Race attempt $nr"
1300 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1301 awk '/ldlm_bl_callback/ { print $2 }')
1302 test "x$blk1" = "x" && blk1=0
1303 createmany -o $MOUNT2/$tdir/a 4000 &
1307 # Let's make conflict and bl_ast
1308 ls -la $MOUNT1/$tdir > /dev/null &
1311 log "Wait for $pid1 $pid2 for $timeout sec..."
1313 kill -9 $pid1 $pid2 > /dev/null 2>&1
1315 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1316 awk '/ldlm_bl_callback/ { print $2 }')
1317 test "x$blk2" = "x" && blk2=0
1318 test $blk2 -gt $blk1 && break
1319 rm -fr $MOUNT1/$tdir
1320 cancel_lru_locks mdc
1323 do_facet client "lctl set_param fail_loc=0x0"
1324 df -h $MOUNT1 $MOUNT2
1326 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1327 awk '/generation/{print $2}')
1329 if ! test "$g" -eq "${generation[count]}"; then
1330 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1332 for imp in $list; do
1333 if [ $c = $count ]; then
1338 imp=$(echo "$imp" | awk -F"." '{print $2}')
1339 error "Eviction happened on import $imp"
1344 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1346 test_36() { #bug 16417
1351 test_mkdir $DIR1/$tdir
1352 $LFS setstripe -c -1 $DIR1/$tdir
1355 let SIZE_B=SIZE*1024*1024
1356 sync; sleep 2; sync # wait for delete thread
1357 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1358 wait_destroy_complete || error "wait_destroy_complete failed"
1360 while [ $i -le 10 ]; do
1361 lctl mark "start test - cycle ($i)"
1362 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1363 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1364 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1365 sync # sync data from client cache
1366 sync_all_data # sync data from server cache (delayed allocation)
1368 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1369 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1371 rm -f $DIR1/$tdir/$tfile
1372 kill -USR1 $read_pid
1374 sync; sleep 2; sync # Ensure new statfs
1375 wait_delete_completed
1376 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1377 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1379 # this free space! not used
1380 (( $after_dd <= $after)) ||
1381 error "space leaked after_dd:$after_dd > after:$after"
1385 run_test 36 "handle ESTALE/open-unlink correctly"
1387 test_37() { # bug 18695
1388 test_mkdir $DIR1/$tdir
1389 multiop_bg_pause $DIR1/$tdir D_c || return 1
1391 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1392 createmany -m $DIR2/$tdir/f 10000
1393 # set mtime/atime backward
1394 touch -t 198001010000 $DIR2/$tdir
1395 kill -USR1 $MULTIPID
1396 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1397 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1400 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1402 # this should be set to past
1403 TEST_39_MTIME=`date -d "1 year ago" +%s`
1407 local client1=${CLIENT1:-`hostname`}
1408 local client2=${CLIENT2:-`hostname`}
1410 do_node $client1 "touch $DIR1/$tfile"
1412 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1413 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1414 [ "$mtime1" = $TEST_39_MTIME ] || \
1415 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1417 local d1=`do_node $client1 date +%s`
1418 do_node $client1 'echo hello >> '$DIR1/$tfile
1419 local d2=`do_node $client1 date +%s`
1421 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1422 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1423 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1425 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1427 for (( i=0; i < 2; i++ )) ; do
1428 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1429 [ "$mtime2" = "$mtime3" ] || \
1430 error "mtime ($mtime2) changed (to $mtime3) on rename"
1432 cancel_lru_locks osc
1433 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1436 run_test 39a "test from 11063 =================================="
1439 local client1=${CLIENT1:-`hostname`}
1440 local client2=${CLIENT2:-`hostname`}
1444 local mtime1=`stat -c %Y $DIR1/$tfile`
1445 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1448 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1450 for (( i=0; i < 2; i++ )) ; do
1451 local mtime3=`stat -c %Y $DIR1/$tfile`
1452 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1454 [ "$mtime3" = "$mtime4" ] || \
1455 error "different mtime on clients: $mtime3, $mtime4"
1456 [ "$mtime3" = $TEST_39_MTIME ] || \
1457 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1459 cancel_lru_locks osc
1460 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1463 run_test 39b "11063 problem 1 =================================="
1466 local client1=${CLIENT1:-`hostname`}
1467 local client2=${CLIENT2:-`hostname`}
1469 echo hello > $DIR1/$tfile
1471 local mtime1=`stat -c %Y $DIR1/$tfile`
1472 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1473 [ "$mtime1" = "$mtime2" ] || \
1474 error "create: different mtime on clients: $mtime1, $mtime2"
1477 $TRUNCATE $DIR1/$tfile 1
1479 for (( i=0; i < 2; i++ )) ; do
1480 local mtime3=`stat -c %Y $DIR1/$tfile`
1481 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1483 [ "$mtime3" = "$mtime4" ] || \
1484 error "different mtime on clients: $mtime3, $mtime4"
1485 [ "$mtime3" -gt $mtime2 ] || \
1486 error "truncate did not update mtime: $mtime2, $mtime3"
1488 cancel_lru_locks osc
1489 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1492 run_test 39c "check truncate mtime update ======================"
1494 test_39d() { # LU-7310
1496 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1498 local mtime1=$(stat -c %Y $DIR2/$tfile)
1499 [ "$mtime1" = $TEST_39_MTIME ] ||
1500 error "mtime: $mtime1, should be $TEST_39_MTIME"
1503 # define OBD_FAIL_OSC_NO_GRANT 0x411
1504 $LCTL set_param fail_loc=0x411
1506 local d1=$(date +%s)
1507 echo hello >> $DIR1/$tfile
1508 local d2=$(date +%s)
1510 $LCTL set_param fail_loc=0
1512 cancel_lru_locks $OSC
1514 local mtime2=$(stat -c %Y $DIR2/$tfile)
1515 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1516 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1518 run_test 39d "sync write should update mtime"
1521 # how long 40-47 take with specific delay
1528 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1529 # avoid unexpected delays due to previous tests
1531 cancel_lru_locks mdc
1532 do_nodes $(comma_list $(mdts_nodes)) \
1533 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1534 do_nodes $(comma_list $(mdts_nodes)) \
1535 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1536 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1539 # check that pid exists hence second operation wasn't blocked by first one
1540 # if it is so then there is no conflict, return 0
1541 # else second operation is conflicting with first one, return 1
1542 check_pdo_conflict() {
1545 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1546 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1556 # test 40: check non-blocking operations
1558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1560 mkdir_on_mdt0 $DIR2/$tdir
1562 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1563 do_nodes $(comma_list $(mdts_nodes)) \
1564 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1565 mkdir $DIR1/$tdir/$tfile &
1567 touch $DIR2/$tdir/$tfile-2
1568 check_pdo_conflict $PID1 || error "create is blocked"
1569 mkdir $DIR2/$tdir/$tfile-3
1570 check_pdo_conflict $PID1 || error "mkdir is blocked"
1571 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1572 check_pdo_conflict $PID1 || error "link is blocked"
1573 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1574 check_pdo_conflict $PID1 || error "rename is blocked"
1575 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1576 check_pdo_conflict $PID1 || error "getattr is blocked"
1577 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1578 rmdir $DIR2/$tdir/$tfile-3
1579 check_pdo_conflict $PID1 || error "unlink is blocked"
1581 # all operations above shouldn't wait the first one
1582 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1583 do_nodes $(comma_list $(mdts_nodes)) \
1584 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1589 run_test 40a "pdirops: create vs others =============="
1592 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1594 mkdir_on_mdt0 $DIR2/$tdir
1596 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1597 do_nodes $(comma_list $(mdts_nodes)) \
1598 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1599 touch $DIR1/$tdir/$tfile &
1602 touch $DIR2/$tdir/$tfile-2
1603 check_pdo_conflict $PID1 || error "create is blocked"
1604 mkdir $DIR2/$tdir/$tfile-3
1605 check_pdo_conflict $PID1 || error "mkdir is blocked"
1606 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1607 check_pdo_conflict $PID1 || error "link is blocked"
1608 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1609 check_pdo_conflict $PID1 || error "rename is blocked"
1610 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1611 check_pdo_conflict $PID1 || error "getattr is blocked"
1612 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1613 rmdir $DIR2/$tdir/$tfile-3
1614 check_pdo_conflict $PID1 || error "unlink is blocked"
1615 # all operations above shouldn't wait the first one
1617 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1618 do_nodes $(comma_list $(mdts_nodes)) \
1619 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1624 run_test 40b "pdirops: open|create and others =============="
1627 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1629 mkdir_on_mdt0 $DIR2/$tdir
1631 touch $DIR1/$tdir/$tfile
1632 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1633 do_nodes $(comma_list $(mdts_nodes)) \
1634 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1635 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1638 touch $DIR2/$tdir/$tfile-2
1639 check_pdo_conflict $PID1 || error "create is blocked"
1640 mkdir $DIR2/$tdir/$tfile-3
1641 check_pdo_conflict $PID1 || error "mkdir is blocked"
1642 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1643 check_pdo_conflict $PID1 || error "link is blocked"
1644 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1645 check_pdo_conflict $PID1 || error "rename is blocked"
1646 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1647 check_pdo_conflict $PID1 || error "getattr is blocked"
1648 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1649 rmdir $DIR2/$tdir/$tfile-3
1650 check_pdo_conflict $PID1 || error "unlink is blocked"
1652 # all operations above shouldn't wait the first one
1653 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1654 do_nodes $(comma_list $(mdts_nodes)) \
1655 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1660 run_test 40c "pdirops: link and others =============="
1663 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1665 mkdir_on_mdt0 $DIR2/$tdir
1667 touch $DIR1/$tdir/$tfile
1668 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1669 do_nodes $(comma_list $(mdts_nodes)) \
1670 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1671 rm $DIR1/$tdir/$tfile &
1674 touch $DIR2/$tdir/$tfile-2
1675 check_pdo_conflict $PID1 || error "create is blocked"
1676 mkdir $DIR2/$tdir/$tfile-3
1677 check_pdo_conflict $PID1 || error "mkdir is blocked"
1678 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1679 check_pdo_conflict $PID1 || error "link is blocked"
1680 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1681 check_pdo_conflict $PID1 || error "rename is blocked"
1682 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1683 check_pdo_conflict $PID1 || error "getattr is blocked"
1684 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1685 rmdir $DIR2/$tdir/$tfile-3
1686 check_pdo_conflict $PID1 || error "unlink is blocked"
1688 # all operations above shouldn't wait the first one
1689 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1690 do_nodes $(comma_list $(mdts_nodes)) \
1691 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1695 run_test 40d "pdirops: unlink and others =============="
1698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1700 mkdir_on_mdt0 $DIR2/$tdir
1702 touch $DIR1/$tdir/$tfile
1703 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1704 do_nodes $(comma_list $(mdts_nodes)) \
1705 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1706 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1709 touch $DIR2/$tdir/$tfile-2
1710 check_pdo_conflict $PID1 || error "create is blocked"
1711 mkdir $DIR2/$tdir/$tfile-3
1712 check_pdo_conflict $PID1 || error "mkdir is blocked"
1713 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1714 check_pdo_conflict $PID1 || error "link is blocked"
1715 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1716 check_pdo_conflict $PID1 || error "getattr is blocked"
1717 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1718 rmdir $DIR2/$tdir/$tfile-3
1719 check_pdo_conflict $PID1 || error "unlink is blocked"
1721 # all operations above shouldn't wait the first one
1722 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1723 do_nodes $(comma_list $(mdts_nodes)) \
1724 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1729 run_test 40e "pdirops: rename and others =============="
1731 # test 41: create blocking operations
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 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1739 mkdir $DIR2/$tfile &
1741 do_nodes $(comma_list $(mdts_nodes)) \
1742 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1743 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1744 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1748 run_test 41a "pdirops: create vs mkdir =============="
1752 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1753 do_nodes $(comma_list $(mdts_nodes)) \
1754 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1755 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1757 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1759 do_nodes $(comma_list $(mdts_nodes)) \
1760 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1761 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1762 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1766 run_test 41b "pdirops: create vs create =============="
1770 touch $DIR1/$tfile-2
1771 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1772 do_nodes $(comma_list $(mdts_nodes)) \
1773 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1774 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1776 link $DIR2/$tfile-2 $DIR2/$tfile &
1778 do_nodes $(comma_list $(mdts_nodes)) \
1779 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1780 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1781 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1785 run_test 41c "pdirops: create vs link =============="
1789 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1790 do_nodes $(comma_list $(mdts_nodes)) \
1791 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1792 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1796 do_nodes $(comma_list $(mdts_nodes)) \
1797 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1798 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1799 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1803 run_test 41d "pdirops: create vs unlink =============="
1807 touch $DIR1/$tfile-2
1808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1809 do_nodes $(comma_list $(mdts_nodes)) \
1810 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1811 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1813 mv $DIR2/$tfile-2 $DIR2/$tfile &
1815 do_nodes $(comma_list $(mdts_nodes)) \
1816 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1817 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1818 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1822 run_test 41e "pdirops: create and rename (tgt) =============="
1826 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1827 do_nodes $(comma_list $(mdts_nodes)) \
1828 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1829 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1831 mv $DIR2/$tfile $DIR2/$tfile-2 &
1833 do_nodes $(comma_list $(mdts_nodes)) \
1834 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1835 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1836 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1840 run_test 41f "pdirops: create and rename (src) =============="
1844 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1845 do_nodes $(comma_list $(mdts_nodes)) \
1846 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1847 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1849 stat $DIR2/$tfile > /dev/null &
1851 do_nodes $(comma_list $(mdts_nodes)) \
1852 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1853 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1854 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1858 run_test 41g "pdirops: create vs getattr =============="
1862 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1863 do_nodes $(comma_list $(mdts_nodes)) \
1864 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1865 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1867 ls -lia $DIR2/ > /dev/null &
1869 do_nodes $(comma_list $(mdts_nodes)) \
1870 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1871 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1876 run_test 41h "pdirops: create vs readdir =============="
1883 do_nodes $(comma_list $(mdts_nodes)) \
1884 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1886 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1889 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1892 if ! wait $PID1 && ! wait $PID2; then
1893 echo "Both creates failed (1 should fail, 1 should succeed)"
1895 elif wait $PID1 && wait $PID2; then
1896 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1901 do_nodes $(comma_list $(mdts_nodes)) \
1902 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1909 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
1910 skip "Need MDS version newer than 2.13.56"
1913 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1914 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1915 for fail_loc in "0x80000169" "0x8000016a"; do
1916 echo "Begin 100 tests with fail_loc=$fail_loc"
1918 for i in {1..100}; do
1920 msg=$(sub_test_41i "$fail_loc") ||
1921 { echo; error "iter=$i : $msg"; }
1926 run_test 41i "reint_open: create vs create"
1929 # test 42: unlink and blocking operations
1932 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1933 do_nodes $(comma_list $(mdts_nodes)) \
1934 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1935 mkdir $DIR1/$tfile &
1937 mkdir $DIR2/$tfile &
1939 do_nodes $(comma_list $(mdts_nodes)) \
1940 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1941 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1942 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1946 run_test 42a "pdirops: mkdir vs mkdir =============="
1950 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1951 do_nodes $(comma_list $(mdts_nodes)) \
1952 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1953 mkdir $DIR1/$tfile &
1955 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1957 do_nodes $(comma_list $(mdts_nodes)) \
1958 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1959 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1960 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1964 run_test 42b "pdirops: mkdir vs create =============="
1968 touch $DIR1/$tfile-2
1969 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1970 do_nodes $(comma_list $(mdts_nodes)) \
1971 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1972 mkdir $DIR1/$tfile &
1974 link $DIR2/$tfile-2 $DIR2/$tfile &
1976 do_nodes $(comma_list $(mdts_nodes)) \
1977 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1978 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1979 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1983 run_test 42c "pdirops: mkdir vs link =============="
1987 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1988 do_nodes $(comma_list $(mdts_nodes)) \
1989 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1990 mkdir $DIR1/$tfile &
1992 rmdir $DIR2/$tfile &
1994 do_nodes $(comma_list $(mdts_nodes)) \
1995 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1996 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1997 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2001 run_test 42d "pdirops: mkdir vs unlink =============="
2005 touch $DIR1/$tfile-2
2006 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2007 do_nodes $(comma_list $(mdts_nodes)) \
2008 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2009 mkdir $DIR1/$tfile &
2011 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2013 do_nodes $(comma_list $(mdts_nodes)) \
2014 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2015 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2016 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2020 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2024 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2025 do_nodes $(comma_list $(mdts_nodes)) \
2026 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2027 mkdir $DIR1/$tfile &
2029 mv $DIR2/$tfile $DIR2/$tfile-2 &
2031 do_nodes $(comma_list $(mdts_nodes)) \
2032 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2033 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2034 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2038 run_test 42f "pdirops: mkdir and rename (src) =============="
2041 mkdir_on_mdt0 $DIR1/$tdir
2043 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2044 do_nodes $(comma_list $(mdts_nodes)) \
2045 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2046 mkdir $DIR1/$tdir/$tfile &
2048 stat $DIR2/$tdir/$tfile > /dev/null &
2050 do_nodes $(comma_list $(mdts_nodes)) \
2051 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2052 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2053 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2056 run_test 42g "pdirops: mkdir vs getattr =============="
2060 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2061 do_nodes $(comma_list $(mdts_nodes)) \
2062 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2063 mkdir $DIR1/$tfile &
2065 ls -lia $DIR2/ > /dev/null &
2067 do_nodes $(comma_list $(mdts_nodes)) \
2068 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2069 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2074 run_test 42h "pdirops: mkdir vs readdir =============="
2076 # test 43: rmdir,mkdir won't return -EEXIST
2078 for i in {1..1000}; do
2079 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2080 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2084 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2089 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2090 do_nodes $(comma_list $(mdts_nodes)) \
2091 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2094 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2096 do_nodes $(comma_list $(mdts_nodes)) \
2097 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2098 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2099 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2103 run_test 43b "pdirops: unlink vs create =============="
2108 touch $DIR1/$tfile-2
2109 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2110 do_nodes $(comma_list $(mdts_nodes)) \
2111 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2114 link $DIR2/$tfile-2 $DIR2/$tfile &
2116 do_nodes $(comma_list $(mdts_nodes)) \
2117 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2118 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2119 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2123 run_test 43c "pdirops: unlink vs link =============="
2128 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2129 do_nodes $(comma_list $(mdts_nodes)) \
2130 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2135 do_nodes $(comma_list $(mdts_nodes)) \
2136 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2137 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2138 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2142 run_test 43d "pdirops: unlink vs unlink =============="
2147 touch $DIR1/$tfile-2
2148 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2149 do_nodes $(comma_list $(mdts_nodes)) \
2150 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2153 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2155 do_nodes $(comma_list $(mdts_nodes)) \
2156 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2157 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2158 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2162 run_test 43e "pdirops: unlink and rename (tgt) =============="
2167 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2168 do_nodes $(comma_list $(mdts_nodes)) \
2169 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2172 mv $DIR2/$tfile $DIR2/$tfile-2 &
2174 do_nodes $(comma_list $(mdts_nodes)) \
2175 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2176 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2177 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2181 run_test 43f "pdirops: unlink and rename (src) =============="
2186 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2187 do_nodes $(comma_list $(mdts_nodes)) \
2188 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2191 stat $DIR2/$tfile > /dev/null &
2193 do_nodes $(comma_list $(mdts_nodes)) \
2194 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2195 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2196 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2200 run_test 43g "pdirops: unlink vs getattr =============="
2205 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2206 do_nodes $(comma_list $(mdts_nodes)) \
2207 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2210 ls -lia $DIR2/ > /dev/null &
2212 do_nodes $(comma_list $(mdts_nodes)) \
2213 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2214 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2219 run_test 43h "pdirops: unlink vs readdir =============="
2222 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2225 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2226 do_nodes $(comma_list $(mdts_nodes)) \
2227 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2230 $LFS mkdir -i 1 $DIR2/$tfile &
2232 do_nodes $(comma_list $(mdts_nodes)) \
2233 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2234 check_pdo_conflict $PID1 &&
2235 { wait $PID1; error "remote mkdir isn't blocked"; }
2236 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2240 run_test 43i "pdirops: unlink vs remote mkdir"
2243 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2244 skip "Need MDS version newer than 2.13.52"
2246 mkdir_on_mdt0 $DIR1/$tdir
2247 for i in {1..100}; do
2248 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2249 do_nodes $(comma_list $(mdts_nodes)) \
2250 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2253 mkdir $DIR1/$tdir/sub &
2255 mkdir $DIR2/$tdir/sub && ((OK++))
2256 wait $PID1 && ((OK++))
2257 (( OK == 1 )) || error "exactly one mkdir should succeed"
2259 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2263 run_test 43j "racy mkdir return EEXIST =============="
2270 # We test in a separate directory to be able to unblock server thread in
2271 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2272 test_mkdir $DIR2/$tdir
2273 touch $DIR2/$tdir/$tfile
2276 do_nodes $(comma_list $(mdts_nodes)) \
2277 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2278 echo content > $DIR1/$tdir/$tfile & PID1=$!
2280 multiop $DIR2/$tdir/$tfile u & PID2=$!
2284 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2287 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2290 do_nodes $(comma_list $(mdts_nodes)) \
2291 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2298 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2299 skip "Need MDS version newer than 2.13.56"
2302 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2303 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2304 for fail_loc in "0x80000169" "0x8000016a"; do
2305 echo "Begin 100 tests with fail_loc=$fail_loc"
2307 for i in {1..100}; do
2309 msg=$(sub_test_43k "$fail_loc") ||
2310 { echo; error "iter=$i : $msg"; }
2320 run_test 43k "unlink vs create"
2322 # test 44: rename tgt and blocking operations
2325 touch $DIR1/$tfile-2
2326 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2327 do_nodes $(comma_list $(mdts_nodes)) \
2328 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2329 mv $DIR1/$tfile-2 $DIR1/$tfile &
2331 mkdir $DIR2/$tfile &
2333 do_nodes $(comma_list $(mdts_nodes)) \
2334 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2335 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2336 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2341 run_test 44a "pdirops: rename tgt vs mkdir =============="
2345 touch $DIR1/$tfile-2
2346 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2347 do_nodes $(comma_list $(mdts_nodes)) \
2348 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2349 mv $DIR1/$tfile-2 $DIR1/$tfile &
2351 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2353 do_nodes $(comma_list $(mdts_nodes)) \
2354 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2355 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2356 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2360 run_test 44b "pdirops: rename tgt vs create =============="
2364 touch $DIR1/$tfile-2
2365 touch $DIR1/$tfile-3
2366 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2367 do_nodes $(comma_list $(mdts_nodes)) \
2368 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2369 mv $DIR1/$tfile-2 $DIR1/$tfile &
2371 link $DIR2/$tfile-3 $DIR2/$tfile &
2373 do_nodes $(comma_list $(mdts_nodes)) \
2374 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2375 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2376 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2380 run_test 44c "pdirops: rename tgt vs link =============="
2384 touch $DIR1/$tfile-2
2385 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2386 do_nodes $(comma_list $(mdts_nodes)) \
2387 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2388 mv $DIR1/$tfile-2 $DIR1/$tfile &
2392 do_nodes $(comma_list $(mdts_nodes)) \
2393 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2394 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2395 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2399 run_test 44d "pdirops: rename tgt vs unlink =============="
2404 touch $DIR1/$tfile-2
2405 touch $DIR1/$tfile-3
2406 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2407 do_nodes $(comma_list $(mdts_nodes)) \
2408 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2409 mv $DIR1/$tfile-2 $DIR1/$tfile &
2411 mv $DIR2/$tfile-3 $DIR2/$tfile &
2413 do_nodes $(comma_list $(mdts_nodes)) \
2414 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2415 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2416 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2420 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2424 touch $DIR1/$tfile-2
2425 touch $DIR1/$tfile-3
2426 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2427 do_nodes $(comma_list $(mdts_nodes)) \
2428 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2429 mv $DIR1/$tfile-2 $DIR1/$tfile &
2431 mv $DIR2/$tfile $DIR2/$tfile-3 &
2433 do_nodes $(comma_list $(mdts_nodes)) \
2434 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2435 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2436 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2440 run_test 44f "pdirops: rename tgt and rename (src) =============="
2444 touch $DIR1/$tfile-2
2445 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2446 do_nodes $(comma_list $(mdts_nodes)) \
2447 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2448 mv $DIR1/$tfile-2 $DIR1/$tfile &
2450 stat $DIR2/$tfile > /dev/null &
2452 do_nodes $(comma_list $(mdts_nodes)) \
2453 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2454 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2455 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2459 run_test 44g "pdirops: rename tgt vs getattr =============="
2463 touch $DIR1/$tfile-2
2464 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2465 do_nodes $(comma_list $(mdts_nodes)) \
2466 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2467 mv $DIR1/$tfile-2 $DIR1/$tfile &
2469 ls -lia $DIR2/ > /dev/null &
2471 do_nodes $(comma_list $(mdts_nodes)) \
2472 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2473 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2478 run_test 44h "pdirops: rename tgt vs readdir =============="
2480 # test 44: rename tgt and blocking operations
2482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2484 touch $DIR1/$tfile-2
2485 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2486 do_nodes $(comma_list $(mdts_nodes)) \
2487 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2488 mv $DIR1/$tfile-2 $DIR1/$tfile &
2490 $LFS mkdir -i 1 $DIR2/$tfile &
2492 do_nodes $(comma_list $(mdts_nodes)) \
2493 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2494 check_pdo_conflict $PID1 && { wait $PID1;
2495 error "remote mkdir isn't blocked"; }
2496 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2500 run_test 44i "pdirops: rename tgt vs remote mkdir"
2502 # test 45: rename,mkdir doesn't fail with -EEXIST
2504 for i in {1..1000}; do
2505 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2506 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2507 error "mrename to $tdir.$i failed"
2512 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2517 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2518 do_nodes $(comma_list $(mdts_nodes)) \
2519 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2520 mv $DIR1/$tfile $DIR1/$tfile-2 &
2522 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2524 do_nodes $(comma_list $(mdts_nodes)) \
2525 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2526 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2527 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2531 run_test 45b "pdirops: rename src vs create =============="
2536 touch $DIR1/$tfile-3
2537 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2538 do_nodes $(comma_list $(mdts_nodes)) \
2539 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2540 mv $DIR1/$tfile $DIR1/$tfile-2 &
2542 link $DIR2/$tfile-3 $DIR2/$tfile &
2544 do_nodes $(comma_list $(mdts_nodes)) \
2545 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2546 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2547 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2551 run_test 45c "pdirops: rename src vs link =============="
2556 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2557 do_nodes $(comma_list $(mdts_nodes)) \
2558 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2559 mv $DIR1/$tfile $DIR1/$tfile-2 &
2563 do_nodes $(comma_list $(mdts_nodes)) \
2564 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2565 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2566 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2570 run_test 45d "pdirops: rename src vs unlink =============="
2575 touch $DIR1/$tfile-3
2576 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2577 do_nodes $(comma_list $(mdts_nodes)) \
2578 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2579 mv $DIR1/$tfile $DIR1/$tfile-2 &
2581 mv $DIR2/$tfile-3 $DIR2/$tfile &
2583 do_nodes $(comma_list $(mdts_nodes)) \
2584 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2585 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2586 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2590 run_test 45e "pdirops: rename src and rename (tgt) =============="
2595 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2596 do_nodes $(comma_list $(mdts_nodes)) \
2597 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2598 mv $DIR1/$tfile $DIR1/$tfile-2 &
2600 mv $DIR2/$tfile $DIR2/$tfile-3 &
2602 do_nodes $(comma_list $(mdts_nodes)) \
2603 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2604 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2605 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2609 run_test 45f "pdirops: rename src and rename (src) =============="
2614 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2615 do_nodes $(comma_list $(mdts_nodes)) \
2616 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2617 mv $DIR1/$tfile $DIR1/$tfile-2 &
2619 stat $DIR2/$tfile > /dev/null &
2621 do_nodes $(comma_list $(mdts_nodes)) \
2622 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2623 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2624 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2628 run_test 45g "pdirops: rename src vs getattr =============="
2633 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2634 do_nodes $(comma_list $(mdts_nodes)) \
2635 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2636 mv $DIR1/$tfile $DIR1/$tfile-2 &
2638 ls -lia $DIR2/ > /dev/null &
2639 do_nodes $(comma_list $(mdts_nodes)) \
2640 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2641 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2646 run_test 45h "pdirops: unlink vs readdir =============="
2649 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2652 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2653 do_nodes $(comma_list $(mdts_nodes)) \
2654 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2655 mv $DIR1/$tfile $DIR1/$tfile-2 &
2657 $LFS mkdir -i 1 $DIR2/$tfile &
2659 do_nodes $(comma_list $(mdts_nodes)) \
2660 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2661 check_pdo_conflict $PID1 && { wait $PID1;
2662 error "create remote dir isn't blocked"; }
2663 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2667 run_test 45i "pdirops: rename src vs remote mkdir"
2674 # We test in a sparate directory to be able to unblock server thread in
2675 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2676 test_mkdir $DIR2/$tdir
2677 echo file1 > $DIR2/$tdir/$tfile
2678 echo file2 > $DIR2/$tdir/$tfile-2
2681 do_nodes $(comma_list $(mdts_nodes)) \
2682 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2684 cat $DIR1/$tdir/$tfile >/dev/null &
2687 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2691 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2694 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2697 do_nodes $(comma_list $(mdts_nodes)) \
2698 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2705 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2706 skip "Need MDS version newer than 2.13.56"
2709 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2710 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2711 for fail_loc in "0x80000169" "0x8000016a"; do
2712 echo "Begin 100 tests with fail_loc=$fail_loc"
2714 for i in {1..100}; do
2716 msg=$(sub_test_45j "$fail_loc") ||
2717 { echo; error "iter=$i : $msg"; }
2722 run_test 45j "read vs rename =============="
2724 # test 46: link and blocking operations
2727 touch $DIR1/$tfile-2
2728 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2729 do_nodes $(comma_list $(mdts_nodes)) \
2730 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2731 link $DIR1/$tfile-2 $DIR1/$tfile &
2733 mkdir $DIR2/$tfile &
2735 do_nodes $(comma_list $(mdts_nodes)) \
2736 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2737 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2738 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2742 run_test 46a "pdirops: link vs mkdir =============="
2746 touch $DIR1/$tfile-2
2747 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2748 do_nodes $(comma_list $(mdts_nodes)) \
2749 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2750 link $DIR1/$tfile-2 $DIR1/$tfile &
2752 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2754 do_nodes $(comma_list $(mdts_nodes)) \
2755 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2756 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2757 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2761 run_test 46b "pdirops: link vs create =============="
2765 touch $DIR1/$tfile-2
2766 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2767 do_nodes $(comma_list $(mdts_nodes)) \
2768 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2769 link $DIR1/$tfile-2 $DIR1/$tfile &
2771 link $DIR2/$tfile $DIR2/$tfile &
2773 do_nodes $(comma_list $(mdts_nodes)) \
2774 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2775 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2776 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2780 run_test 46c "pdirops: link vs link =============="
2784 touch $DIR1/$tfile-2
2785 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2786 do_nodes $(comma_list $(mdts_nodes)) \
2787 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2788 link $DIR1/$tfile-2 $DIR1/$tfile &
2792 do_nodes $(comma_list $(mdts_nodes)) \
2793 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2794 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2795 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2799 run_test 46d "pdirops: link vs unlink =============="
2803 touch $DIR1/$tfile-2
2804 touch $DIR1/$tfile-3
2805 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2806 do_nodes $(comma_list $(mdts_nodes)) \
2807 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2808 link $DIR1/$tfile-2 $DIR1/$tfile &
2810 mv $DIR2/$tfile-3 $DIR2/$tfile &
2812 do_nodes $(comma_list $(mdts_nodes)) \
2813 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2814 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2815 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2819 run_test 46e "pdirops: link and rename (tgt) =============="
2823 touch $DIR1/$tfile-2
2824 touch $DIR1/$tfile-3
2825 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2826 do_nodes $(comma_list $(mdts_nodes)) \
2827 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2828 link $DIR1/$tfile-2 $DIR1/$tfile &
2830 mv $DIR2/$tfile $DIR2/$tfile-3 &
2832 do_nodes $(comma_list $(mdts_nodes)) \
2833 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2834 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2835 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2839 run_test 46f "pdirops: link and rename (src) =============="
2843 touch $DIR1/$tfile-2
2844 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2845 do_nodes $(comma_list $(mdts_nodes)) \
2846 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2847 link $DIR1/$tfile-2 $DIR1/$tfile &
2849 stat $DIR2/$tfile > /dev/null &
2851 do_nodes $(comma_list $(mdts_nodes)) \
2852 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2853 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2854 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2858 run_test 46g "pdirops: link vs getattr =============="
2862 touch $DIR1/$tfile-2
2863 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2864 do_nodes $(comma_list $(mdts_nodes)) \
2865 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2866 link $DIR1/$tfile-2 $DIR1/$tfile &
2868 ls -lia $DIR2/ > /dev/null &
2870 do_nodes $(comma_list $(mdts_nodes)) \
2871 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2872 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2877 run_test 46h "pdirops: link vs readdir =============="
2880 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2882 touch $DIR1/$tfile-2
2883 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2884 do_nodes $(comma_list $(mdts_nodes)) \
2885 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2886 link $DIR1/$tfile-2 $DIR1/$tfile &
2888 $LFS mkdir -i 1 $DIR2/$tfile &
2890 do_nodes $(comma_list $(mdts_nodes)) \
2891 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2892 check_pdo_conflict $PID1 && { wait $PID1;
2893 error "remote mkdir isn't blocked"; }
2894 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2898 run_test 46i "pdirops: link vs remote mkdir"
2900 # test 47: remote mkdir and blocking operations
2902 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2903 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2905 do_nodes $(comma_list $(mdts_nodes)) \
2906 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2907 $LFS mkdir -i 1 $DIR1/$tfile &
2909 mkdir $DIR2/$tfile &
2911 do_nodes $(comma_list $(mdts_nodes)) \
2912 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2913 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2914 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2918 run_test 47a "pdirops: remote mkdir vs mkdir"
2921 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2922 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2924 do_nodes $(comma_list $(mdts_nodes)) \
2925 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2926 $LFS mkdir -i 1 $DIR1/$tfile &
2928 sleep 1 # please do not remove this sleep, see LU-10754
2929 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2931 do_nodes $(comma_list $(mdts_nodes)) \
2932 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2933 check_pdo_conflict $PID1 && { wait $PID1;
2934 error "create isn't blocked"; }
2935 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2939 run_test 47b "pdirops: remote mkdir vs create"
2942 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2944 touch $DIR1/$tfile-2
2945 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2946 do_nodes $(comma_list $(mdts_nodes)) \
2947 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2948 $LFS mkdir -i 1 $DIR1/$tfile &
2950 link $DIR2/$tfile-2 $DIR2/$tfile &
2952 do_nodes $(comma_list $(mdts_nodes)) \
2953 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2954 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2955 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2959 run_test 47c "pdirops: remote mkdir vs link"
2962 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2964 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2965 do_nodes $(comma_list $(mdts_nodes)) \
2966 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2967 $LFS mkdir -i 1 $DIR1/$tfile &
2969 rmdir $DIR2/$tfile &
2971 do_nodes $(comma_list $(mdts_nodes)) \
2972 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2973 check_pdo_conflict $PID1 && { wait $PID1;
2974 error "unlink isn't blocked"; }
2975 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2979 run_test 47d "pdirops: remote mkdir vs unlink"
2982 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2984 touch $DIR1/$tfile-2
2985 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2986 do_nodes $(comma_list $(mdts_nodes)) \
2987 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2988 $LFS mkdir -i 1 $DIR1/$tfile &
2990 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2992 do_nodes $(comma_list $(mdts_nodes)) \
2993 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2994 check_pdo_conflict $PID1 && { wait $PID1;
2995 error "rename isn't blocked"; }
2996 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
3000 run_test 47e "pdirops: remote mkdir and rename (tgt)"
3003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3005 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3006 do_nodes $(comma_list $(mdts_nodes)) \
3007 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3008 $LFS mkdir -i 1 $DIR1/$tfile &
3010 mv $DIR2/$tfile $DIR2/$tfile-2 &
3012 do_nodes $(comma_list $(mdts_nodes)) \
3013 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3014 check_pdo_conflict $PID1 && { wait $PID1;
3015 error "rename isn't blocked"; }
3016 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3020 run_test 47f "pdirops: remote mkdir and rename (src)"
3023 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3027 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3028 do_nodes $(comma_list $(mdts_nodes)) \
3029 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3030 $LFS mkdir -i 1 $DIR1/$tfile &
3032 stat $DIR2/$tfile > /dev/null &
3034 do_nodes $(comma_list $(mdts_nodes)) \
3035 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3036 check_pdo_conflict $PID1 && { wait $PID1;
3037 error "getattr isn't blocked"; }
3038 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3042 run_test 47g "pdirops: remote mkdir vs getattr"
3046 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3047 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3048 do_facet client "lctl set_param fail_loc=0x410"
3049 $TRUNCATE $DIR2/$tfile $trunc_size
3050 do_facet client "lctl set_param fail_loc=0x0"
3052 size=`stat -c %s $DIR2/$tfile`
3053 [ $size -eq $trunc_size ] || error "wrong size"
3055 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3059 local origfile=/etc/hosts
3061 filesize=$(stat -c %s $origfile)
3063 # create an empty file
3064 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3065 # cache layout lock on both mount point
3066 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3067 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3069 # open and sleep 2 seconds then read
3070 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3074 # create the layout of testing file
3075 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3076 error "dd $DIR1/$tfile failed"
3078 # MULTIOP proc should be able to read enough bytes and exit
3079 for ((i = 0; i < 6; i++)); do
3081 kill -0 $pid || break
3083 kill -0 $pid 2> /dev/null && error "multiop is still there"
3084 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3088 run_test 51a "layout lock: refresh layout should work"
3091 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3092 skip "Need MDS version at least 2.3.59"
3094 local tmpfile=`mktemp`
3096 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3097 error "Create $DIR1/$tfile failed"
3099 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3100 error "dd $DIR1/$tfile failed"
3102 # delay glimpse so that layout has changed when glimpse finish
3103 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3104 $LCTL set_param fail_loc=0x1404 fail_val=4
3105 stat -c %s $DIR2/$tfile |tee $tmpfile &
3109 # extend layout of testing file
3110 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3111 error "dd $DIR1/$tfile failed"
3114 local fsize=$(cat $tmpfile)
3116 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3118 rm -f $DIR1/$tfile $tmpfile
3120 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3123 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3125 # set default layout to have 1 stripe
3127 $LFS setstripe -c 1 $DIR1/$tdir
3129 # create a file with empty layout
3130 $MCREATE $DIR1/$tdir/$tfile ||
3131 error "$MCREATE $DIR1/$tdir/$tfile failed"
3133 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3134 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3136 # change the layout of testing file
3137 echo "Setting layout to have $OSTCOUNT stripes ..."
3138 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3142 # write something to the file, it should be blocked on fetching layout
3143 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3144 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3147 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3148 # count to succeed with only 3/4 of the number of stripes (rounded up),
3149 # so creating striped files does not fail if an OST is offline or full
3150 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3151 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3155 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3158 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3159 cancel_lru_locks mdc
3161 # open should grant LAYOUT lock, mmap and read will install pages
3162 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3166 # rss before revoking
3167 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3168 echo "Before revoking layout lock: $br KB mapped"
3170 # cancel layout lock manually
3171 cancel_lru_locks mdc
3173 # rss after revoking
3174 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3177 wait $PID || error "wait PID $PID failed"
3179 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3181 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3184 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3185 skip "MDS version must be at least 2.13.54.148"
3189 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3193 $LFS getstripe $DIR2/$tfile
3195 wait $pid || error "multiop failed"
3197 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3201 $LFS getstripe $DIR2/$tfile
3203 wait $pid || error "multiop failed"
3205 run_test 51e "lfs getstripe does not break leases, part 2"
3209 echo "==> rename vs getattr vs setxattr should not deadlock"
3210 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3212 do_facet mds1 $LCTL set_param fail_loc=$1
3214 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3222 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3223 wait $PID1 || error "(3) mv failed"
3224 wait $PID2 || error "(4) stat failed"
3231 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3232 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3234 do_facet mds1 $LCTL set_param fail_loc=$1
3236 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3244 $MULTIOP $DIR2/d1/d2 Oc &
3248 stat $DIR/d1 || error "(2) stat failed"
3250 wait $PID1 || error "(3) mv failed"
3251 wait $PID2 || error "(4) stat failed"
3252 wait $PID3 && error "(5) multiop failed"
3258 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3259 save_lustre_params client "llite.*.xattr_cache" > $p
3260 lctl set_param llite.*.xattr_cache 1 ||
3261 { skip "xattr cache is not supported"; return 0; }
3263 #define OBD_FAIL_MDS_RENAME 0x153
3264 #define OBD_FAIL_MDS_RENAME2 0x154
3265 test_54_part1 0x80000153 || error 10
3266 test_54_part1 0x80000154 || error 11
3267 test_54_part2 0x80000153 || error 12
3268 test_54_part2 0x80000154 || error 13
3270 restore_lustre_params < $p
3273 run_test 54 "rename locking"
3276 mkdir_on_mdt0 $DIR/$tdir
3277 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3279 #define OBD_FAIL_MDS_RENAME4 0x156
3280 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3282 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3286 rm -r $DIR2/$tdir/d3
3287 wait $PID1 && error "(2) mv succeeded"
3291 run_test 55a "rename vs unlink target dir"
3295 mkdir_on_mdt0 $DIR/$tdir
3296 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3298 #define OBD_FAIL_MDS_RENAME4 0x156
3299 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3301 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3305 rm -r $DIR2/$tdir/d1
3306 wait $PID1 && error "(2) mv succeeded"
3310 run_test 55b "rename vs unlink source dir"
3314 mkdir_on_mdt0 $DIR/$tdir
3315 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3317 #define OBD_FAIL_MDS_RENAME4 0x156
3318 do_facet mds1 $LCTL set_param fail_loc=0x156
3320 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3324 # while rename is sleeping, open and remove d3
3325 $MULTIOP $DIR2/$tdir/d3 D_c &
3328 rm -rf $DIR2/$tdir/d3
3331 # while rename is sleeping 2nd time, close d3
3333 wait $PID2 || error "(3) multiop failed"
3335 wait $PID1 && error "(2) mv succeeded"
3339 run_test 55c "rename vs unlink orphan target dir"
3343 mkdir_on_mdt0 $DIR/$tdir
3347 #define OBD_FAIL_MDS_RENAME3 0x155
3348 do_facet mds1 $LCTL set_param fail_loc=0x155
3349 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3353 # while rename is sleeping, create $tdir, but as a directory
3354 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3356 # link in reverse locking order
3357 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3359 wait $PID1 && error "(2) mv succeeded"
3362 run_test 55d "rename file vs link"
3365 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3366 skip "MDS version must be >= 2.3.0"
3369 test_mkdir $DIR1/$tdir
3370 file1=$DIR1/$tdir/file
3371 file2=$DIR2/$tdir/file
3373 echo orig > $file2 || error "Could not create $file2"
3374 version=$($LFS data_version $file1)
3377 echo append >> $file2 || error "Could not append to $file2"
3378 version2=$($LFS data_version $file1)
3379 [ "$version" != "$version2" ] ||
3380 error "append did not change data version: $version"
3383 echo overwrite > $file2 || error "Could not overwrite $file2"
3384 version3=$($LFS data_version $file1)
3385 [ "$version2" != "$version3" ] ||
3386 error "overwrite did not change data version: $version2"
3388 # Truncate before EOF
3389 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3390 version4=$($LFS data_version $file1)
3391 [ "$version3" != "$version4" ] ||
3392 error "truncate did not change data version: $version3"
3394 # Truncate after EOF
3395 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3396 version5=$($LFS data_version $file1)
3397 [ "$version4" != "$version5" ] ||
3398 error "truncate did not change data version: $version4"
3400 # Chmod do not change version
3401 chmod 400 $file2 || error "Could not chmod 400 $file2"
3402 version6=$($LFS data_version $file1)
3403 [ "$version5" == "$version6" ] ||
3404 error "chmod should not change data version: $version5 != $version6"
3406 # Chown do not change version
3407 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3408 version7=$($LFS data_version $file1)
3409 [ "$version5" == "$version7" ] ||
3410 error "chown should not change data version: $version5 != $version7"
3412 run_test 60 "Verify data_version behaviour"
3415 local test_dir=$tdir/test_dir
3417 mkdir -p $DIR1/$tdir
3418 if [ $MDSCOUNT -ge 2 ]; then
3420 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3421 error "Create remote directory failed"
3423 mkdir -p $DIR1/$test_dir
3425 cd $DIR2/$test_dir || error "cd directory failed"
3426 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3428 cd $DIR2/$tdir || error "exit directory"
3430 run_test 70a "cd directory && rm directory"
3432 test_70b() { # LU-2781
3434 mkdir -p $DIR1/$tdir
3436 touch $DIR1/$tdir/file
3437 for ((i = 0; i < 32; i++)); do
3438 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3440 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3442 touch $DIR1/$tdir/file
3443 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3444 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3445 rm -rf $DIR1/$tdir/test_dir ||
3446 error "cannot remove directory after rm_entry"
3447 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3449 run_test 70b "remove files after calling rm_entry"
3452 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3453 skip "Need MDS version at least 2.1.6"
3455 # Patch not applied to 2.2 and 2.3 branches
3456 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3457 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3458 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3460 checkfiemap --test ||
3461 skip "checkfiemap not runnable: $?"
3462 # write data this way: hole - data - hole - data
3463 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3464 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3466 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3467 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3468 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3470 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3472 checkfiemap $DIR2/$tfile 81920 ||
3473 error "data is not flushed from client"
3474 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3477 # common case of "create file, copy file" on a single node
3478 # should not flush data from ost
3479 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3480 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3482 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3484 checkfiemap $DIR1/$tfile 81920 ||
3486 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3488 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3490 run_test 71a "correct file map just after write operation is finished"
3493 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3494 skip "Need MDS version at least 2.1.6"
3496 # Patch not applied to 2.2 and 2.3 branches
3497 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3498 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3499 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3500 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3502 checkfiemap --test ||
3503 skip "error $?: checkfiemap failed"
3505 mkdir -p $DIR1/$tdir
3507 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3508 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3509 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3511 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3512 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3514 run_test 71b "check fiemap support for stripecount > 1"
3517 local p="$TMP/sanityN-$TESTNAME.parameters"
3520 save_lustre_params client "llite.*.xattr_cache" > $p
3521 lctl set_param llite.*.xattr_cache 1 ||
3522 { skip "xattr cache is not supported"; return 0; }
3525 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3526 error "setfattr1 failed"
3527 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3528 error "getfattr1 failed"
3529 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3530 error "setfattr2 failed"
3531 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3532 error "getfattr2 failed"
3534 # check that trusted.link is consistent
3535 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3536 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3537 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3538 echo "$tlink1 $tlink2"
3539 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3543 restore_lustre_params < $p
3546 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3549 local p="$TMP/sanityN-$TESTNAME.parameters"
3550 save_lustre_params client "llite.*.xattr_cache" > $p
3551 lctl set_param llite.*.xattr_cache 1 ||
3552 { skip "xattr cache is not supported"; return 0; }
3555 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3556 error "setfattr1 failed"
3557 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3558 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3559 clear_stats llite.*.stats
3560 # PR lock should be cached by now on both clients
3561 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3562 # 2 hits for getfattr(0)+getfattr(size)
3563 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3564 error "not cached in $DIR1"
3565 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3566 # 4 hits for more getfattr(0)+getfattr(size)
3567 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3568 error "not cached in $DIR2"
3571 restore_lustre_params < $p
3574 run_test 73 "getxattr should not cause xattr lock cancellation"
3577 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3578 skip "Need MDS version at least 2.4.93"
3580 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3581 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3582 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3584 run_test 74 "flock deadlock: different mounts =============="
3588 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3589 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3590 cancel_lru_locks osc
3592 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3595 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3596 $LCTL set_param fail_loc=0x31d
3597 stat -c %s $DIR1/$tfile &
3602 # For bad lock error handler we should ASSERT and got kernel panic here
3604 $LCTL set_param fail_loc=0
3606 run_test 75 "osc: upcall after unuse lock==================="
3609 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3610 skip "Need MDS version at least 2.5.53"
3612 remote_mds_nodsh && skip "remote MDS with nodsh"
3613 local fcount=$((MDSCOUNT * 256))
3618 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3624 test_mkdir $DIR/$tdir
3626 # drop all open locks and close any cached "open" files on the client
3627 cancel_lru_locks mdc
3629 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3630 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3631 local already=${#fid_list[@]}
3632 for (( i = 0; i < $already; i++ )) ; do
3633 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3636 echo -n "opening files: "
3637 ulimit -n $((fcount + 50))
3638 for ((i = 0; i < $fcount; i++)); do
3639 touch $DIR/$tdir/f_$i
3640 local fd=$(free_fd ${fd_list[i]})
3641 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3646 (( $i % 32 == 0 )) && echo -n "."
3650 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3652 # Possible errors in openfiles FID list.
3653 # 1. Missing FIDs. Check 1
3654 # 2. Extra FIDs. Check 1
3655 # 3. Duplicated FID. Check 2
3656 # 4. Invalid FIDs. Check 2
3657 # 5. Valid FID, points to some other file. Check 3
3660 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3661 error "${#fid_list[@]} != $fcount (+$already old) open files"
3663 echo -n "closing files: "
3664 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3665 local close_cmd="exec ${fd_list[fd]}<&-"
3667 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3669 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3670 echo "skip old open file $filename"
3672 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3676 rm --interactive=no $filename
3678 error "Nonexisting fid ${fid_list[fid]} listed."
3679 (( $fd % 32 == 0 )) && echo -n "."
3684 ls_op=$(ls $DIR2/$tdir | wc -l)
3686 error "Some openfiles are missing in lproc output"
3690 run_test 76 "Verify MDT open_files listing"
3694 local dir=$DIR/$tdir
3697 mkdir $dir || error "mkdir $dir failed"
3698 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3701 do_nodes $CLIENTS $myRUNAS \
3702 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3703 error "dd at 0 on client failed (1)"
3705 do_nodes $CLIENTS $myRUNAS \
3707 for ((i = 0; i < $n; i++)); do
3708 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3709 seek=\\\$i count=1 conv=notrunc &
3710 pids_w[\\\$i]=\\\$!;
3713 for ((i = 0; i < $n; i++)); do
3714 wait \\\${pids_w[\\\$i]};
3716 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3720 do_nodes $CLIENTS sync;
3721 cancel_lru_locks osc
3723 do_nodes $CLIENTS $myRUNAS \
3725 for ((i = 0; i < $n; i++)); do
3726 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3727 seek=\\\$i count=1 &
3728 pids_r[\\\$i]=\\\$!;
3731 for ((i = 0; i < $n; i++)); do
3732 wait \\\${pids_r[\\\$i]};
3734 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3738 cancel_lru_locks osc
3740 wait $pid_w || error "dd (write) failed (2)"
3741 wait $pid_r || error "dd (read) failed (3)"
3742 rm -rvf $dir || error "rm -rf $dir failed"
3745 test_77a() { #LU-3266
3748 oss=$(comma_list $(osts_nodes))
3749 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3751 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3752 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3757 run_test 77a "check FIFO NRS policy"
3759 test_77b() { #LU-3266
3762 oss=$(comma_list $(osts_nodes))
3764 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3765 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3766 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3767 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3769 echo "policy: crr-n, crrn_quantum 1"
3772 do_nodes $oss lctl set_param \
3773 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3774 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3776 echo "policy: crr-n, crrn_quantum 64"
3780 do_nodes $oss lctl set_param \
3781 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3782 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3785 run_test 77b "check CRR-N NRS policy"
3790 oss=$(comma_list $(osts_nodes))
3792 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3793 ost.OSS.*.nrs_"$policy"_quantum=1 \
3794 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3795 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3797 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3798 "physical, ${policy}_supported reads"
3801 do_nodes $oss lctl set_param \
3802 ost.OSS.*.nrs_${policy}_supported="writes" \
3803 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3805 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3806 "physical, ${policy}_supported writes"
3809 do_nodes $oss lctl set_param \
3810 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3811 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3812 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3813 "logical, ${policy}_supported reads_and_writes"
3817 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3822 test_77c() { #LU-3266
3824 orr_trr "orr" || rc=$?
3825 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3826 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3829 run_test 77c "check ORR NRS policy"
3831 test_77d() { #LU-3266
3833 orr_trr "trr" || rc=$?
3834 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3835 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3838 run_test 77d "check TRR nrs policy"
3845 do_facet $facet lctl set_param \
3846 ost.OSS.ost_io.nrs_tbf_rule="$*"
3848 error "failed to run operate '$*' on TBF rules"
3851 cleanup_tbf_verify()
3855 echo "cleanup_tbf $DIR/$tdir"
3858 wait_delete_completed
3863 local dir=$DIR/$tdir
3864 local client1=${CLIENT1:-$(hostname)}
3867 local np=$(check_cpt_number ost1)
3868 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3869 echo "cpu_npartitions on ost1 is $np"
3871 mkdir $dir || error "mkdir $dir failed"
3872 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3875 trap cleanup_tbf_verify EXIT
3876 echo "Limited write rate: $1, read rate: $2"
3877 echo "Verify the write rate is under TBF control"
3878 local start=$SECONDS
3879 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3880 bs=1M count=100 oflag=direct 2>&1
3881 local runtime=$((SECONDS - start + 1))
3882 local rate=$(bc <<< "scale=6; 100 / $runtime")
3883 echo "Write runtime is $runtime s, speed is $rate IOPS"
3885 # verify the write rate does not exceed TBF rate limit
3886 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3887 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3889 cancel_lru_locks osc
3891 echo "Verify the read rate is under TBF control"
3893 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3894 bs=1M count=100 iflag=direct 2>&1
3895 runtime=$((SECONDS - start + 1))
3896 rate=$(bc <<< "scale=6; 100 / $runtime")
3897 echo "Read runtime is $runtime s, speed is $rate IOPS"
3899 # verify the read rate does not exceed TBF rate limit
3900 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3901 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3903 cancel_lru_locks osc
3904 cleanup_tbf_verify || error "rm -rf $dir failed"
3910 oss=$(comma_list $(osts_nodes))
3912 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3914 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3915 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3919 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3924 # Only operate rules on ost1 since OSTs might run on the same OSS
3926 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3927 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3928 local client_nids=$(nids_list $address "\\")
3929 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3930 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3934 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3935 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3936 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3940 tbf_rule_operate ost1 "stop\ localhost"
3941 tbf_rule_operate ost1 "stop\ clients"
3942 tbf_rule_operate ost1 "stop\ others"
3945 # Cleanup the TBF policy
3946 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3947 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3951 run_test 77e "check TBF NID nrs policy"
3956 oss=$(comma_list $(osts_nodes))
3958 do_nodes $oss $LCTL set_param \
3959 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3960 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3961 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3963 # Configure jobid_var
3964 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3966 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3967 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3968 if [ $saved_jobid_var != procname_uid ]; then
3969 set_persistent_param_and_check client \
3970 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3975 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3980 # Only operate rules on ost1 since OSTs might run on the same OSS
3982 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3983 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3984 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3985 nrs_write_read "$RUNAS"
3988 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3989 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3990 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3991 nrs_write_read "$RUNAS"
3994 tbf_rule_operate ost1 "stop\ runas"
3995 tbf_rule_operate ost1 "stop\ iozone_runas"
3996 tbf_rule_operate ost1 "stop\ dd_runas"
3997 nrs_write_read "$RUNAS"
3999 # Cleanup the TBF policy
4000 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4001 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4002 nrs_write_read "$RUNAS"
4004 local current_jobid_var=$($LCTL get_param -n jobid_var)
4005 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4006 if [ $saved_jobid_var != $current_jobid_var ]; then
4007 set_persistent_param_and_check client \
4008 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4012 run_test 77f "check TBF JobID nrs policy"
4017 oss=$(comma_list $(osts_nodes))
4019 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4021 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4022 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4024 do_nodes $oss lctl set_param \
4025 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4026 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4030 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4035 # Add a rule that only valid for Jobid TBF. If direct change between
4036 # TBF types is not supported, this operation will fail.
4037 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4039 # Cleanup the TBF policy
4040 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4041 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4044 run_test 77g "Change TBF type directly"
4047 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4048 skip "Need OST version at least 2.8.55"
4050 local old_policy=$(do_facet ost1 \
4051 lctl get_param ost.OSS.ost_io.nrs_policies)
4054 do_facet ost1 lctl set_param \
4055 ost.OSS.ost_io.nrs_policies="abc"
4056 [ $? -eq 0 ] && error "should return error"
4058 do_facet ost1 lctl set_param \
4059 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4060 [ $? -eq 0 ] && error "should return error"
4062 do_facet ost1 lctl set_param \
4063 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4064 [ $? -eq 0 ] && error "should return error"
4066 do_facet ost1 lctl set_param \
4067 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4068 [ $? -eq 0 ] && error "should return error"
4070 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4071 [ $? -eq 0 ] || error "shouldn't LBUG"
4073 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4077 run_test 77h "Wrong policy name should report error, not LBUG"
4083 local error_message=$3
4085 for rule in $expected; do
4086 rule_number=$((rule_number + 1))
4088 local stop_line=$(($rule_number + 3))
4089 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4091 local output=$(do_facet $facet lctl get_param \
4092 ost.OSS.ost_io.nrs_tbf_rule |
4096 if [ "$output" != "$expected" ]; then
4097 error "$error_message, expected '$expected', got '$output'"
4102 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4103 skip "Need OST version at least 2.8.55"
4105 for i in $(seq 1 $OSTCOUNT)
4107 do_facet ost"$i" lctl set_param \
4108 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4110 error "failed to set TBF policy"
4113 tbf_rule_check ost1 "default" "error before inserting any rule"
4115 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4116 tbf_rule_check ost1 "before default" \
4117 "error when inserting rule 'before'"
4119 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4120 tbf_rule_check ost1 "before after default" \
4121 "error when inserting rule 'after'"
4123 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4124 tbf_rule_check ost1 "before target after default" \
4125 "error when inserting rule 'target'"
4127 echo "Move before itself"
4128 tbf_rule_operate ost1 "change\ target\ rank=target"
4129 tbf_rule_check ost1 "before target after default" \
4130 "error when moving before itself"
4132 echo "Move to higher rank"
4133 tbf_rule_operate ost1 "change\ target\ rank=before"
4134 tbf_rule_check ost1 "target before after default" \
4135 "error when moving to higher rank"
4137 echo "Move to lower rank"
4138 tbf_rule_operate ost1 "change\ target\ rank=after"
4139 tbf_rule_check ost1 "before target after default" \
4140 "error when moving to lower rank"
4142 echo "Move before default"
4143 tbf_rule_operate ost1 "change\ target\ rank=default"
4144 tbf_rule_check ost1 "before after target default" \
4145 error "error when moving before default"
4147 # Cleanup the TBF policy
4148 do_nodes $(comma_list $(osts_nodes)) \
4149 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4152 run_test 77i "Change rank of TBF rule"
4158 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4159 skip "Need OST version at least 2.9.53"
4160 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4165 do_nodes $(comma_list $(osts_nodes)) \
4166 lctl set_param jobid_var=procname_uid \
4167 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4168 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4169 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4170 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4175 do_nodes $(comma_list $(osts_nodes)) \
4176 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4177 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4178 ost.OSS.ost_io.nrs_policies="fifo"
4180 # sleep 3 seconds to wait the tbf policy stop completely,
4181 # or the next test case is possible get -EAGAIN when
4182 # setting the tbf policy
4185 run_test 77j "check TBF-OPCode NRS policy"
4188 local idstr="${1}id"
4189 local policy="${idstr}={$2}"
4190 local rate="rate=$3"
4192 do_nodes $(comma_list $(osts_nodes)) \
4193 lctl set_param jobid_var=procname_uid \
4194 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4195 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4196 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4198 nrs_write_read "runas $4"
4199 tbf_verify $3 $3 "runas $4"
4201 do_nodes $(comma_list $(osts_nodes)) \
4202 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4203 ost.OSS.ost_io.nrs_policies="fifo"
4205 # sleep 3 seconds to wait the tbf policy stop completely,
4206 # or the next test case is possible get -eagain when
4207 # setting the tbf policy
4212 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4213 skip "Need OST version at least 2.11.50"
4216 test_id "u" "500" "5" "-u 500"
4217 test_id "g" "500" "5" "-u 500 -g 500"
4219 run_test 77ja "check TBF-UID/GID NRS policy"
4227 for rule in $rule_lists; do
4228 do_nodes $(comma_list $(osts_nodes)) \
4229 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4232 do_nodes $(comma_list $(osts_nodes)) \
4233 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4239 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4240 skip "Need OST version at least 2.9.53"
4242 do_nodes $(comma_list $(osts_nodes)) \
4243 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4244 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4245 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4247 nrs_write_read "$RUNAS"
4248 tbf_verify 20 10 "$RUNAS"
4250 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4251 local client_nids=$(nids_list $address "\\")
4252 do_nodes $(comma_list $(osts_nodes)) \
4253 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4254 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4255 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4256 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4261 do_nodes $(comma_list $(osts_nodes)) \
4262 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4263 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4264 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4266 nrs_write_read "$RUNAS"
4267 tbf_verify 20 20 "$RUNAS"
4269 do_nodes $(comma_list $(osts_nodes)) \
4270 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4271 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4272 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4274 nrs_write_read "$RUNAS"
4275 # with parameter "RUNAS", it will match the latest rule
4276 # "ext_b" first, so the limited write rate is 10.
4277 tbf_verify 10 10 "$RUNAS"
4280 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4282 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4283 skip "Need OST version at least 2.10.58"
4285 do_nodes $(comma_list $(osts_nodes)) \
4286 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4287 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4288 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4289 nrs_write_read "runas -u 500 -g 1000"
4290 tbf_verify 5 5 "runas -u 500 -g 1000"
4292 do_nodes $(comma_list $(osts_nodes)) \
4293 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4294 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4295 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4297 nrs_write_read "runas -u 500"
4298 tbf_verify 20 10 "runas -u 500"
4300 do_nodes $(comma_list $(osts_nodes)) \
4301 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4302 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4303 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4304 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4305 nrs_write_read "runas -u 500"
4306 tbf_verify 10 10 "runas -u 500"
4307 tbf_verify 20 10 "runas -u 500"
4308 cleanup_77k "ext_a ext_b" "fifo"
4310 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4313 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4314 skip "Need OST version at least 2.10.56"
4316 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4317 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4319 local output=$(do_facet ost1 lctl get_param \
4320 ost.OSS.ost_io.nrs_policies | \
4321 awk '/name: tbf/ {print;exit}' | \
4322 awk -F ': ' '{print $2}')
4324 if [ "$output" != "tbf" ]; then
4325 error "The generic TBF output is '$output', not 'tbf'"
4328 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4330 run_test 77l "check the output of NRS policies for generic TBF"
4333 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4334 skip "Need OST version at least 2.9.54"
4337 local dir=$DIR/$tdir
4339 mkdir $dir || error "mkdir $dir failed"
4340 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4343 local nodes=$(comma_list $(osts_nodes))
4344 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4345 ost.OSS.ost_io.nrs_delay_min=4 \
4346 ost.OSS.ost_io.nrs_delay_max=4 \
4347 ost.OSS.ost_io.nrs_delay_pct=100
4348 [ $? -ne 0 ] && error "Failed to set delay policy"
4350 local start=$SECONDS
4351 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4352 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4353 oflag=direct conv=fdatasync ||
4354 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4355 error "dd on client failed (1)"; }
4356 local elapsed=$((SECONDS - start))
4358 # NRS delay doesn't do sub-second timing, so a request enqueued at
4359 # 0.9 seconds can be dequeued at 4.0
4360 [ $elapsed -lt 3 ] &&
4361 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4362 error "Single 1M write should take at least 3 seconds"; }
4365 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4366 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4367 oflag=direct conv=fdatasync ||
4368 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4369 error "dd on client failed (2)"; }
4370 elapsed=$((SECONDS - start))
4372 [ $elapsed -lt 30 ] &&
4373 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4374 error "Ten 1M writes should take at least 30 seconds"; }
4376 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4377 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4381 run_test 77m "check NRS Delay slows write RPC processing"
4383 test_77n() { #LU-10802
4384 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4385 skip "Need OST version at least 2.10.58"
4388 # Configure jobid_var
4389 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4390 if [ $saved_jobid_var != procname_uid ]; then
4391 set_persistent_param_and_check client \
4392 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4395 do_nodes $(comma_list $(osts_nodes)) \
4396 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4397 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4398 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4401 tbf_verify 20 20 "$RUNAS"
4403 do_nodes $(comma_list $(osts_nodes)) \
4404 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4405 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4410 do_nodes $(comma_list $(osts_nodes)) \
4411 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4412 ost.OSS.ost_io.nrs_policies="fifo"
4416 local current_jobid_var=$($LCTL get_param -n jobid_var)
4417 if [ $saved_jobid_var != $current_jobid_var ]; then
4418 set_persistent_param_and_check client \
4419 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4422 run_test 77n "check wildcard support for TBF JobID NRS policy"
4425 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
4426 skip "need OST > 2.14.54"
4428 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
4429 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
4430 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
4431 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
4432 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
4433 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
4435 run_test 77o "Changing rank should not panic"
4440 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4441 skip "need MDS >= 2.14.54"
4443 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4444 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4446 for i in {1..50}; do
4449 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={500}&gid={500} rate=100'" &
4451 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
4453 wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
4454 wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
4456 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
4458 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
4460 wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
4461 wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
4464 run_test 77q "Parallel TBF rule definitions should not panic"
4468 local -a spec_chars=(
4469 '@' '.' '~' '#' '/' '^' '%' '*' ';' ',' '?' '<' '>' ':'
4470 '+' '=' ')' '(' '{' '}' '|' '[' ']' '!' '&' '\$' '\`' '\\')
4472 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4473 skip "need MDS >= 2.14.54"
4475 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4476 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4478 # TBF rule name size is 16 bytes
4479 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_overflo\ uid={500}\ rate=500" &&
4480 error "The length of tbf rule name is not checked" || true
4481 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ \ uid={500}\ rate=500" &&
4482 error "The server should not accept empty tbf rule name" || true
4483 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_empty" &&
4484 error "The server should not accept 'start <tbf_rule_name>' without an expression" || true
4486 # Test with special chars
4487 for c in "${spec_chars[@]}"; do
4488 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start test77p${c}spec uid={500} rate=500'" &&
4489 error "Special char '${c}' should not be accepted in a tbf rule name" || true
4493 run_test 77p "Check validity of rule names for TBF policies"
4495 test_78() { #LU-6673
4498 oss=$(comma_list $(osts_nodes))
4499 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4500 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4502 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4503 # Valid return codes are:
4504 # 0: Tuning succeeded
4505 # ENODEV: Policy is still stopped
4506 # EAGAIN: Policy is being initialized
4507 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4508 error "Expected set_param to return 0|ENODEV|EAGAIN"
4510 # Cleanup the ORR policy
4511 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4512 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4515 run_test 78 "Enable policy and specify tunings right away"
4518 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4519 test_mkdir $DIR/$tdir
4521 # Prevent interference from layout intent RPCs due to
4522 # asynchronous writeback. These will be tested in 130c below.
4523 do_nodes ${CLIENTS:-$HOSTNAME} sync
4525 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4526 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4528 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4529 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4530 local facet=mds$((mdtidx + 1))
4532 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4533 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4537 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4538 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4543 run_test 79 "xattr: intent error"
4546 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4553 mkdir_on_mdt0 $DIR1/$tdir
4554 mkdir -p $DIR1/$tdir/dir
4555 createmany -o $DIR1/$tdir/dir/f 10 ||
4556 error "create files under remote dir failed $i"
4558 cp /etc/passwd $DIR1/$tdir/$tfile
4560 #migrate open file should fails
4561 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4563 # give multiop a chance to open
4566 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4567 error "migrate open files should failed with open files"
4571 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4572 error "migrate remote dir error"
4574 echo "Finish migration, then checking.."
4575 for file in $(find $DIR1/$tdir); do
4576 mdt_index=$($LFS getstripe -m $file)
4577 [ $mdt_index == $MDTIDX ] ||
4578 error "$file is not on MDT${MDTIDX}"
4581 diff /etc/passwd $DIR1/$tdir/$tfile ||
4582 error "file different after migration"
4584 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4586 run_test 80a "migrate directory when some children is being opened"
4590 kill -9 $migrate_pid
4594 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4595 local migrate_dir1=$DIR1/$tdir/migrate_dir
4596 local migrate_dir2=$DIR2/$tdir/migrate_dir
4597 local migrate_run=$LUSTRE/tests/migrate.sh
4604 trap cleanup_80b EXIT
4605 #prepare migrate directory
4606 mkdir -p $migrate_dir1
4607 for F in {1,2,3,4,5}; do
4608 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4609 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4612 #migrate the directories among MDTs
4615 mdt_idx=$((RANDOM % MDSCOUNT))
4616 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4618 (( $rc != 0 && $rc != 16 )) || break
4623 echo "start migration thread $migrate_pid"
4624 #Access the files at the same time
4626 echo "accessing the migrating directory for 5 minutes..."
4628 ls $migrate_dir2 > /dev/null || {
4629 echo "read dir fails"
4632 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4633 echo "access file1 fails"
4637 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4638 echo "access file2/3 fails"
4642 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4643 echo "access file4 fails"
4647 stat $migrate_dir2/file5 > /dev/null || {
4648 echo "stat file5 fails"
4652 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4653 (( $rc != 0 && $rc != 1 )) || {
4654 echo "touch file failed with $rc1"
4658 if [ -e $migrate_dir2/source_file ]; then
4659 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4660 &>/dev/null || rc1=$?
4661 if [ -e $migrate_dir2/link_file ]; then
4662 rm -rf $migrate_dir2/link_file
4665 mrename $migrate_dir2/source_file \
4666 $migrate_dir2/target_file &>/dev/null || rc1=$?
4667 (( $rc != 0 && $rc != 1 )) || {
4668 echo "rename failed with $rc1"
4672 if [ -e $migrate_dir2/target_file ]; then
4673 rm -rf $migrate_dir2/target_file &>/dev/null ||
4676 rm -rf $migrate_dir2/source_file &>/dev/null ||
4679 (( $rc != 0 && $rc != 1 )) || {
4680 echo "unlink failed with $rc1"
4685 local duration=$((SECONDS - start_time))
4686 if (( duration % 10 == 0 )); then
4687 if (( $show_time == 1 )); then
4688 echo "...$duration seconds"
4695 kill -0 $migrate_pid || {
4696 echo "migration stopped 1"
4700 (( $duration < 300 )) || break
4703 #check migration are still there
4704 kill -0 $migrate_pid || error "migration stopped 2"
4707 run_test 80b "Accessing directory during migration"
4710 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4714 mkdir -p $DIR1/$tdir
4716 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4717 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4720 touch d0/0 || error "create 0 failed"
4721 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4722 stat d0/0 && error "stat mv filed succeed"
4723 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4724 stat d0/0 || error "stat failed"
4726 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4728 if [ $t -ne 3 ]; then
4729 ls -ai $DIR1/$tdir/d0
4730 error "expect 3 get $t"
4735 run_test 81a "rename and stat under striped directory"
4738 [ $MDSCOUNT -lt 2 ] &&
4739 skip "We need at least 2 MDTs for this test"
4746 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4747 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4756 for i in $(seq $total); do
4757 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4761 kill -9 $setattr_pid
4763 run_test 81b "rename under striped directory doesn't deadlock"
4766 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4767 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4768 skip "Need MDS version at least 2.13.52"
4770 # source is local, source parent is remote
4771 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4772 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4773 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4774 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4775 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4776 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4777 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4778 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4780 # source is remote, source parent is local
4781 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4782 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4783 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4784 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4785 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4786 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4787 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4788 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4790 # source and source parent are remote
4791 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4792 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4793 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4794 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4795 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4796 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4797 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4798 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4800 # source and source parent are remote, and source is remote object
4801 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4802 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4803 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4804 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4805 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4806 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4807 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4809 run_test 81c "rename revoke LOOKUP lock for remote object"
4812 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4813 skip "Need MDS version at least 2.6.92"
4815 # Client 1 creates a file.
4816 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4818 # Client 2 opens the file.
4819 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4821 # Client 1 makes the file an orphan.
4822 rm $DIR1/$tfile || error "rm"
4823 # Client 2 sets EA "user.multiop".
4825 wait $pid2 || error "multiop 2"
4826 # Client 1 gets EA "user.multiop". This used to fail because the EA
4827 # cache refill would get "trusted.link" from mdd_xattr_list() but
4828 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4831 wait $pid1 || error "multiop 1"
4833 run_test 82 "fsetxattr and fgetxattr on orphan files"
4836 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4843 $LFS mkdir -i1 -c2 $tdir
4848 echo "start pid $pid1 to create/unlink striped directory"
4850 # Access the directory at the same time
4854 stat $tdir > /dev/null 2>&1
4858 echo "start pid $pid2 to stat striped directory"
4866 run_test 83 "access striped directory while it is being created/unlinked"
4869 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4870 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4874 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4875 error "create $tfile failed"
4876 mtime=$(stat -c%Y $DIR/$tfile)
4877 mtime=$((mtime + 200))
4879 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4880 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4882 touch -c -m $mtime $DIR/$tfile &
4884 # sleep a while to let 'touch' run first
4886 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4889 wait $setattr_pid || true
4891 run_test 84 "0-nlink race in lu_object_find()"
4894 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4899 [ "$SLOW" = "yes" ] && duration=600
4900 # Open/Create under striped directory
4904 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4905 touch $tdir/f{0..3} > /dev/null 2>&1
4909 echo "start pid $pid1 to open/create under striped directory"
4911 # unlink the striped directory at the same time
4915 rm -rf $tdir > /dev/null 2>&1
4919 echo "start pid $pid2 to unlink striped directory"
4928 run_test 90 "open/create and unlink striped directory"
4931 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4936 [ "$SLOW" = "yes" ] && duration=600
4937 # chmod striped directory
4941 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4942 chmod go+w $tdir > /dev/null 2>&1
4946 echo "start pid $pid1 to chmod striped directory"
4948 # unlink the striped directory at the same time
4952 rm -rf $tdir > /dev/null 2>&1
4956 echo "start pid $pid2 to unlink striped directory"
4965 run_test 91 "chmod and unlink striped directory"
4968 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4971 local cmd="exec $fd<$DIR1/$tdir"
4972 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4975 trap "eval $cmd" EXIT
4976 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4977 rmdir ../$tdir || error "rmdir ../$tdir fails"
4979 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4980 $LCTL set_param fail_loc=0x1408
4981 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4982 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4983 error "create remote dir succeeds"
4984 $LCTL set_param fail_loc=0
4988 run_test 92 "create remote directory under orphan directory"
4995 mkdir -p $DIR1/$tfile-1/
4996 mkdir -p $DIR2/$tfile-2/
4997 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4998 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4999 do_facet $SINGLEMDS "$LCTL set_param -n \
5000 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
5001 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
5002 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
5004 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
5007 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
5011 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
5012 do_facet $SINGLEMDS "$LCTL set_param -n \
5013 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
5015 $LFS getstripe $DIR1/$tfile-1/file1
5016 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
5017 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5018 $LFS getstripe $DIR2/$tfile-2/file2
5019 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
5020 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5021 echo "rc1=$rc1 and rc2=$rc2 "
5022 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
5023 error "object allocate on same ost detected"
5025 run_test 93 "alloc_rr should not allocate on same ost"
5028 $LCTL set_param osc.*.idle_timeout=0
5029 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
5031 local before=$(date +%s)
5035 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
5036 $LCTL set_param fail_val=5 fail_loc=0x80000312
5037 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
5041 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
5042 $LCTL set_param fail_val=6 fail_loc=0x80000329
5043 $LCTL mark kill $pid
5046 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
5049 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
5051 evict=$(do_facet client $LCTL get_param \
5052 osc.$FSNAME-OST*-osc-*/state |
5053 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
5055 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5056 (do_facet client $LCTL get_param \
5057 osc.$FSNAME-OST*-osc-*/state;
5058 error "eviction happened: $evict before:$before")
5059 $LCTL set_param osc.*.idle_timeout=debug
5061 run_test 94 "signal vs CP callback race"
5065 skip "Reserved for glimpse-ahead" && return
5066 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5067 skip "Need MDS version at least 2.10.55"
5071 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5073 lctl set_param -n mdc.*.stats=clear
5074 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5076 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5077 # first stat from server should return size data and save glimpse
5078 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5079 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5080 # second stat to check size is NOT cached on client without IO lock
5081 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5083 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5084 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5087 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5090 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5091 skip "Need MDS version at least 2.10.55"
5095 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5097 lctl set_param -n mdc.*.stats=clear
5098 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5099 cancel_lru_locks mdc
5100 # first stat data from server should have size
5101 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5102 # second stat to check size is cached on client
5103 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5105 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5106 # both stats should cause no glimpse requests
5107 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5110 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5113 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5114 skip "Need MDS version at least 2.10.55"
5118 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5120 lctl set_param -n mdc.*.stats=clear
5121 lctl set_param -n osc.*.stats=clear
5122 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5124 # check that size is merged from MDT and OST correctly
5125 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5126 error "Wrong size from stat #1"
5128 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5129 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5133 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5136 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5137 skip "Need MDS version at least 2.10.55"
5141 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5144 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5145 lctl set_param -n mdc.*.stats=clear
5146 $TRUNCATE $DIR2/$tdir/dom 4096
5148 # check that reported size is valid after file grows to OST and
5149 # is truncated back to MDT stripe size
5150 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5151 error "Wrong size from stat #1"
5153 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5154 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5158 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5161 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5162 skip "Need MDS version at least 2.11.50"
5164 local dom=$DIR/$tdir/dom
5165 local dom2=$DIR2/$tdir/dom
5168 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5170 cancel_lru_locks mdc
5171 dd if=/dev/urandom of=$dom bs=12000 count=1
5172 $TRUNCATE $dom2 6000
5173 cancel_lru_locks mdc
5174 lctl set_param -n mdc.*.stats=clear
5175 # expect read-on-open to return all data before write
5176 cat /etc/hosts >> $dom
5177 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5178 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5180 run_test 100e "DoM: read on open and file size"
5183 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5184 skip "Need MDS version at least 2.10.55"
5186 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5188 $CHECKSTAT -t file $DIR1/$tfile
5190 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5191 sysctl -wq vm.dirty_writeback_centisecs=0
5193 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5196 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5197 error_noexit "Write fails"
5198 # must discard pages
5199 lctl set_param -n mdc.*.stats=clear
5200 rm $DIR2/$tfile || error "Unlink fails"
5202 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5203 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5205 run_test 101a "Discard DoM data on unlink"
5208 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5209 skip "Need MDS version at least 2.10.55"
5211 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5212 touch $DIR1/${tfile}_2
5214 $CHECKSTAT -t file $DIR1/$tfile
5216 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5217 sysctl -wq vm.dirty_writeback_centisecs=0
5219 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5222 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5223 # must discard pages
5224 lctl set_param -n mdc.*.stats=clear
5225 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5227 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5228 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5230 run_test 101b "Discard DoM data on rename"
5233 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5234 skip "Need MDS version at least 2.10.55"
5236 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5238 $CHECKSTAT -t file $DIR1/$tfile
5240 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5241 sysctl -wq vm.dirty_writeback_centisecs=0
5243 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5246 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5247 $MULTIOP $DIR1/$tfile O_c &
5250 lctl set_param -n mdc.*.stats=clear
5251 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5252 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5254 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5255 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5257 run_test 101c "Discard DoM data on close-unlink"
5259 # test to verify file handle related system calls
5260 # (name_to_handle_at/open_by_handle_at)
5261 # The new system calls are supported in glibc >= 2.14.
5263 # test to verify we can open by handle an unlinked file from > 1 client
5264 # This test opens the file normally on $DIR1, which is on one mount, and then
5265 # opens it by handle on $DIR2, which is on a different mount.
5267 (( "$MDS1_VERSION" >= $(version_code 2.11.57) )) ||
5268 skip "Needs MDS version 2.11.57 or later"
5270 echo "Test file_handle syscalls" > $DIR/$tfile ||
5271 error "write failed"
5272 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5273 error "check_fhandle_syscalls $tfile failed"
5275 # test this is working on DNE directories also
5276 if (( MDSCOUNT > 1 && MDS1_VERSION >= $(version_code 2.14.52) )); then
5277 $LFS mkdir -i 1 $DIR/$tdir.remote
5278 cancel_lru_locks mdc
5279 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5280 error "check_fhandle_syscalls $tdir.remote failed"
5281 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5282 cancel_lru_locks mdc
5283 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5284 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5286 $LFS mkdir -c -1 $DIR/$tdir.stripe
5287 cancel_lru_locks mdc
5288 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5289 error "check_fhandle_syscalls $tdir.stripe failed"
5290 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5291 cancel_lru_locks mdc
5292 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5293 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5296 run_test 102 "Test open by handle of unlinked file"
5298 # Compare file size between first & second mount, ensuring the client correctly
5299 # glimpses even with unused speculative locks - LU-11670
5301 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5302 skip "Lockahead needs OST version at least 2.10.50"
5306 test_mkdir -p $DIR/$tdir
5308 # Force file on to OST0
5309 $LFS setstripe -i 0 $DIR/$tdir
5311 # Do not check multiple locks on glimpse
5312 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5313 $LCTL set_param fail_loc=0x415
5315 # Delay write commit by 2 seconds to guarantee glimpse wins race
5316 # The same fail_loc is used on client & server so it can work in the
5317 # single node sanity setup
5318 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5320 echo "Incorrect size expected (no glimpse fix):"
5321 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5323 if [ $rc -eq 0 ]; then
5324 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5327 # guarantee write commit timeout has expired
5330 # Clear fail_loc on client
5331 $LCTL set_param fail_loc=0
5333 # Delay write commit by 2 seconds to guarantee glimpse wins race
5334 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5335 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5337 # Write commit is still delayed by 2 seconds
5338 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5340 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5342 # guarantee write commit timeout has expired
5345 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5347 run_test 103 "Test size correctness with lockahead"
5353 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5364 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5365 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5366 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5367 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5375 local xtimes=($(get_stat_xtimes))
5376 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5378 echo "STAT a|m|ctime ${xtimes[*]}"
5379 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5380 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5381 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5382 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5383 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5384 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5385 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5389 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5390 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5391 skip "Need MDS version at least 2.12.4"
5394 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5395 local atime_diff=$(do_facet $SINGLEMDS \
5396 lctl get_param -n mdd.*MDT0000*.atime_diff)
5398 do_facet $SINGLEMDS \
5399 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5401 stack_trap "do_facet $SINGLEMDS \
5402 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5404 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5405 check_mdt_xtimes $mdtdev
5408 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5409 check_mdt_xtimes $mdtdev
5411 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5414 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5416 kill -USR1 $pid && wait $pid || error "multiop failure"
5417 check_mdt_xtimes $mdtdev
5422 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5423 # on the client side
5424 xtimes=($(get_stat_xtimes))
5425 $MULTIOP $DIR/$tfile O_c &
5428 kill -USR1 $pid && wait $pid || error "multiop failure"
5429 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5430 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5431 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5432 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5433 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5434 check_mdt_xtimes $mdtdev
5437 # Change ctime via chmod
5438 $MULTIOP $DIR/$tfile o_tc &
5441 kill -USR1 $pid && wait $pid || error "multiop failure"
5442 check_mdt_xtimes $mdtdev
5444 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5447 test_mkdir -p $DIR/$tdir
5448 echo test > $DIR/$tdir/$tfile
5449 $LCTL set_param fail_loc=0x416
5450 cancel_lru_locks osc & sleep 1
5451 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5453 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5455 run_test 105 "Glimpse and lock cancel race"
5458 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5459 skip_env "Test only for ldiskfs and statx() supported"
5464 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5466 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5467 btime=$($STATX -c %W $DIR/$tfile)
5468 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5470 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5471 [[ $btime == $mdt_btime ]] ||
5472 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5475 run_test 106a "Verify the btime via statx()"
5478 statx_supported || skip_env "statx() only test"
5483 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5484 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5485 cancel_lru_locks $OSC
5486 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5488 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5489 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5490 error "$STATX should send 1 glimpse RPC to $OSC"
5492 cancel_lru_locks $OSC
5493 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5494 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5495 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5497 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5498 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5499 [ $rpcs_after -eq $rpcs_before ] ||
5500 error "$STATX should not send glimpse RPCs to $OSC"
5502 cancel_lru_locks $OSC
5503 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5504 $STATX --cached=always $DIR/$tfile
5505 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5506 [ $rpcs_after -eq $rpcs_before ] ||
5507 error "$STATX should not send glimpse RPCs to $OSC"
5509 cancel_lru_locks $OSC
5510 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5511 $STATX -c %Y $DIR/$tfile
5512 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5513 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5514 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5516 cancel_lru_locks $OSC
5517 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5518 $STATX -c %s $DIR/$tfile
5519 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5520 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5521 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5523 cancel_lru_locks $OSC
5524 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5525 $STATX -c %b $DIR/$tfile
5526 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5527 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5528 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5530 run_test 106b "Glimpse RPCs test for statx"
5533 statx_supported || skip_env "statx() only test"
5538 # Mask supported in stx_attributes by Lustre is
5539 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5540 mask=$($STATX -c %p $DIR/$tfile)
5541 [[ $mask == "30" ]] ||
5542 error "supported stx_attributes: got '$mask', expected '30'"
5543 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5544 mask=$($STATX -c %r $DIR/$tfile)
5545 [[ $mask == "10" ]] ||
5546 error "got immutable flags '$mask', expected '10'"
5547 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5548 mask=$($STATX -c %r $DIR/$tfile)
5549 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5550 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5551 mask=$($STATX -c %r $DIR/$tfile)
5552 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5553 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5554 mask=$($STATX -c %r $DIR/$tfile)
5555 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5556 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5557 mask=$($STATX -c %r $DIR/$tfile)
5558 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5559 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5560 mask=$($STATX -c %r $DIR/$tfile)
5561 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5563 run_test 106c "Verify statx attributes mask"
5565 test_107a() { # LU-1031
5566 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5570 $LFS getstripe $DIR1/$tfile
5572 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5574 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5576 kill -USR1 $MULTIPID2
5578 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5579 error "First grouplock does not block second one"
5581 echo "First grouplock blocks second one"
5583 kill -USR1 $MULTIPID1
5587 run_test 107a "Basic grouplock conflict"
5590 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5594 $LFS getstripe $DIR1/$tfile
5596 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5598 multiop $DIR2/$tfile Or10c &
5602 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5603 error "Grouplock does not block IO"
5605 echo "Grouplock blocks IO"
5608 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5611 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5612 error "First grouplock does not block second one"
5614 echo "First grouplock blocks second one"
5617 kill -USR1 $MULTIPID1
5620 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5621 error "Second grouplock thread disappeared"
5624 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5625 error "Second grouplock does not block IO"
5627 echo "Second grouplock blocks IO"
5630 kill -USR1 $MULTIPID3
5635 run_test 107b "Grouplock is added to the head of waiting list"
5640 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5641 error "Create $DIR1/$tfile failed"
5643 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5644 error "dd $DIR1/$tfile failed"
5645 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5646 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5648 $TRUNCATE $DIR1/$tfile 2000
5649 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5650 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5652 #define OBD_FAIL_OSC_DELAY_IO 0x414
5653 $LCTL set_param fail_val=4 fail_loc=0x80000414
5654 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5658 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5660 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5662 run_test 108a "lseek: parallel updates"
5670 skip "Clients need to be on different nodes than the servers"
5672 umount_client $MOUNT
5673 umount_client $MOUNT2
5675 echo "Starting race between client mount instances (50 iterations):"
5676 for i in {1..50}; do
5679 #define OBD_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
5680 $LCTL set_param -n fail_loc=0x80001417
5682 mount_client $MOUNT & pid1=$!
5683 mount_client $MOUNT2 & pid2=$!
5684 wait $pid1 || error "Mount $MOUNT fails with $?"
5685 wait $pid2 || error "Mount $MOUNT2 fails with $?"
5687 umount_client $MOUNT & pid1=$!
5688 umount_client $MOUNT2 & pid2=$!
5689 wait $pid1 || error "Umount $MOUNT fails with $?"
5690 wait $pid2 || error "Umount $MOUNT2 fails with $?"
5692 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
5698 mount_client $MOUNT2
5701 run_test 109 "Race with several mount instances on 1 node"
5704 local before=$(date +%s)
5711 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
5712 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
5714 # disable last_xid logic by dropping link reply
5715 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
5718 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
5719 do_facet mds1 lctl set_param fail_loc=0x534
5721 # RPC will race with its Resend and the Resend will sleep to let
5722 # the original lock to get granted & cancelled.
5724 # AST_SENT is set artificially, so an explicit conflict is not needed
5726 # The woken up Resend gets a new lock, but client does not wait for it
5729 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
5731 # Take a conflict to wait long enough to see the eviction
5734 # let the client reconnect
5736 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
5737 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
5739 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5740 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
5741 error "eviction happened: $evict before:$before")
5743 run_test 110 "do not grant another lock on resend"
5746 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
5747 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
5748 skip "MDT0 and MDT1 should be on the same node"
5751 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
5752 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
5754 mkdir $DIR1/$tdir/mdt0dir/foodir
5755 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
5757 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
5759 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
5761 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
5762 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
5764 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
5767 rm $DIR2/$tdir/mdt1dir/file2
5770 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
5775 rm -r $DIR1/$tdir || error "Removing test dir failed"
5777 run_test 111 "A racy rename/link an open file should not cause fs corruption"
5780 (( MDSCOUNT >= 2 )) ||
5781 skip "We need at least 2 MDTs for this test"
5783 (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
5784 skip "Need server version at least 2.14.54"
5789 rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
5791 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
5793 mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
5794 $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
5795 $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
5796 error "setdirstripe s3 failed"
5797 $LCTL set_param lmv.*.qos_threshold_rr=90
5798 mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
5799 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
5800 (( count == 64 )) || error "only $count subdirs created on MDT0"
5802 $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
5803 error "setdirstripe s3 failed"
5804 mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
5805 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
5806 (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
5808 run_test 112 "update max-inherit in default LMV"
5810 log "cleanup: ======================================================"
5812 # kill and wait in each test only guarentee script finish, but command in script
5813 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5814 # otherwise umount below will fail
5815 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5820 check_and_cleanup_lustre