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 if [ $mds1_FSTYPE = "zfs" ]; then
26 # LU-2829 / LU-2887 - make allowances for ZFS slowness
27 TEST33_NFILES=${TEST33_NFILES:-1000}
31 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
40 check_and_setup_lustre
45 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
47 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
48 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
50 # $RUNAS_ID may get set incorrectly somewhere else
51 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
53 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
57 [ -f $DIR2/$tfile ] || error "Check create"
58 chmod 777 $DIR2/$tfile
59 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
60 error "Check attribute update for 0777"
62 chmod a-x $DIR2/$tfile
63 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
64 error "Check attribute update for 0666"
67 $CHECKSTAT -a $DIR1/$tfile ||
68 error "Check unlink - removes file on other mountpoint"
70 run_test 1 "Check attribute updates on 2 mount points"
76 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
77 error "Either not file type or perms not 0777"
79 run_test 2a "check cached attribute updates on 2 mtpt's ========"
85 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
86 error "Either not file type or perms not 0777"
88 run_test 2b "check cached attribute updates on 2 mtpt's ========"
90 # NEED TO SAVE ROOT DIR MODE
93 $CHECKSTAT -t dir -p 0777 $DIR2 ||
94 error "Either not dir type or perms not 0777"
96 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
100 $CHECKSTAT -t dir -p 0755 $DIR2 ||
101 error "Either not file type or perms not 0775"
103 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
110 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
113 run_test 2e "check chmod on root is propagated to others"
116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
118 local remote_dir=$tdir/remote_dir
121 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
122 error "Create remote directory failed"
124 touch $DIR1/$remote_dir/$tfile ||
125 error "Create file under remote directory failed"
126 chmod 777 $DIR1/$remote_dir/$tfile ||
127 error "Chmod file under remote directory failed"
129 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
130 error "Check attr of file under remote directory failed"
132 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
133 error "Chown file under remote directory failed"
135 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
136 error "Check owner of file under remote directory failed"
138 cd $DIR2/$remote_dir || error "enter remote dir"
139 rm -rf $DIR1/$remote_dir/$tfile ||
140 error "Unlink remote directory failed"
142 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
143 error "unlink file still exists!"
145 cd $DIR2/$tdir || error "exit remote dir"
146 rm -rf $DIR1/$tdir || error "unlink directory failed"
148 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
151 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
153 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
155 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
156 echo "$DIR1/$tfile has $block1 blocks"
157 echo "$DIR2/$tfile has $block2 blocks"
158 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
160 run_test 2g "check blocks update on sync write"
163 local target="this/is/good"
164 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
165 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
166 error "link $DIR2/$tfile not as expected"
168 run_test 3 "symlink on one mtpt, readlink on another ==========="
171 multifstat $DIR1/f4 $DIR2/f4
173 run_test 4 "fstat validation on multiple mount points =========="
177 $TRUNCATE $DIR2/f5 100
178 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
179 error "Either not file type or size not equal to 100 bytes"
182 run_test 5 "create a file on one mount, truncate it on the other"
185 openunlink $DIR1/$tfile $DIR2/$tfile || \
186 error "openunlink $DIR1/$tfile $DIR2/$tfile"
188 run_test 6 "remove of open file on other node =================="
192 opendirunlink $DIR1/$dir $DIR2/$dir || \
193 error "opendirunlink $DIR1/$dir $DIR2/$dir"
195 run_test 7 "remove of open directory on other node ============="
198 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
199 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
201 run_test 8 "remove of open special file on other node =========="
207 for C in a b c d e f g h i j k l; do
208 dir=`eval echo \\$DIR$MTPT`
209 echo -n $C >> $dir/f9
210 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
212 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
213 error "`od -a $DIR1/f9` != abcdefghijkl"
215 run_test 9a "append of file with sub-page size on multiple mounts"
217 #LU-10681 - tiny writes & appending to sparse striped file
219 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
221 $LFS setstripe -c 2 -S 1M $DIR/$tfile
222 echo "foo" >> $DIR/$tfile
223 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
224 error "sparse dd $DIR2/$tfile failed"
225 echo "foo" >> $DIR/$tfile
227 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
228 echo "Data read (expecting 'foo')": $data
229 [ "$data" = "foo" ] || error "append to sparse striped file failed"
231 run_test 9b "append to striped sparse file"
238 for C in a b c d e f g h i j k l; do
239 dir=`eval echo \\$DIR$MTPT`
240 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
241 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
242 OFFSET=`expr $OFFSET + 1`
244 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
245 error "`od -a $DIR1/f10` != abcdefghijkl"
247 run_test 10a "write of file with sub-page size on multiple mounts "
251 yes "R" | head -c 4000 >$TMP/f10b-seed
252 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
254 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
256 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
258 # create a test file locally to compare
259 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
260 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
261 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
262 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
264 run_test 10b "write of file with sub-page size on multiple mounts "
268 multiop_bg_pause $DIR1/d11/f O_c || return 1
270 cp -p /bin/ls $DIR1/d11/f
274 wait $MULTIPID || error "wait for PID $MULTIPID failed"
275 [ $RC -eq 0 ] && error || true
277 run_test 11 "execution of file opened for write should return error ===="
280 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
282 run_test 12 "test lock ordering (link, stat, unlink)"
284 test_13() { # bug 2451 - directory coherency
286 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
288 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
290 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
291 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
292 # need to run it twice
293 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
295 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
296 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
298 run_test 13 "test directory page revocation"
301 test_mkdir $DIR1/$tdir
302 cp -p /bin/ls $DIR1/$tdir/$tfile
303 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
306 $DIR2/$tdir/$tfile && error || true
309 run_test 14aa "execution of file open for write returns -ETXTBSY"
312 test_mkdir $DIR1/$tdir
313 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
314 $DIR1/$tdir/sleep 60 &
316 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
319 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
321 test_14b() { # bug 3192, 7040
322 test_mkdir $DIR1/$tdir
323 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
324 $DIR1/$tdir/sleep 60 &
326 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
327 error "expected truncate error, got success"
329 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
331 run_test 14b "truncate of executing file returns -ETXTBSY ======"
333 test_14c() { # bug 3430, 7040
334 test_mkdir $DIR1/$tdir
335 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
336 $DIR1/$tdir/sleep 60 &
338 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
340 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
342 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
344 test_14d() { # bug 10921
345 test_mkdir $DIR1/$tdir
346 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
347 $DIR1/$tdir/sleep 60 &
350 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
352 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
354 run_test 14d "chmod of executing file is still possible ========"
356 test_15() { # bug 974 - ENOSPC
358 sh oos2.sh $MOUNT1 $MOUNT2
359 wait_delete_completed
360 grant_error=$(dmesg | grep "< tot_grant")
361 [ -z "$grant_error" ] || error "$grant_error"
363 run_test 15 "test out-of-space with multiple writers ==========="
366 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
367 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
368 # pass a 2500 operation dual-mount run within the time limit.
369 if [ "$ost1_FSTYPE" = "zfs" ]; then
370 FSXNUM=$((COUNT / 5))
372 elif [ "$SLOW" = "yes" ]; then
373 FSXNUM=$((COUNT * 5))
381 local file1=$DIR1/$tfile
382 local file2=$DIR2/$tfile
383 local stripe_size=$(do_facet $SINGLEMDS \
384 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
386 # to allocate grant because it may run out due to test_15.
387 $LFS setstripe -c -1 $file1
388 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
389 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
392 $LFS setstripe -c -1 $file1 # b=10919
393 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
394 || error "fsx failed"
397 # O_DIRECT reads and writes must be aligned to the device block size.
398 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
399 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
401 run_test 16a "$FSXNUM iterations of dual-mount fsx"
403 # Consistency check for tiny writes, LU-9409
405 local file1=$DIR1/$tfile
406 local file2=$DIR2/$tfile
407 local stripe_size=($($LFS getstripe -S $DIR))
409 # to allocate grant because it may run out due to test_15.
410 lfs setstripe -c -1 $file1
411 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
412 error "dd failed writing to file=$file1"
413 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
414 error "dd failed writing to file=$file2"
417 lfs setstripe -c -1 $file1 # b=10919
418 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
419 # create a mix of tiny writes & normal writes
420 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
421 $file2 || error "fsx with tiny write failed."
423 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
426 local file1=$DIR1/$tfile
427 local file2=$DIR2/$tfile
428 local stripe_size=$(do_facet $SINGLEMDS \
429 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
431 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
433 # to allocate grant because it may run out due to test_15.
434 $LFS setstripe -c -1 $file1
435 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
436 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
438 wait_delete_completed
440 local list=$(comma_list $(osts_nodes))
441 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
442 skip "not cache-capable obdfilter"
445 set_osd_param $list '' read_cache_enable 0
446 set_osd_param $list '' writethrough_cache_enable 0
448 $LFS setstripe -c -1 $file1 # b=10919
449 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
450 || error "fsx failed"
453 set_osd_param $list '' read_cache_enable 1
454 set_osd_param $list '' writethrough_cache_enable 1
458 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
461 local file1=$DIR1/$tfile
462 local file2=$DIR2/$tfile
463 local file3=$DIR1/file
464 local stripe_size=$(do_facet $SINGLEMDS \
465 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
467 # to allocate grant because it may run out due to test_15.
468 $LFS setstripe -c -1 $file1
469 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
470 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
473 local tmpfile=`mktemp`
474 $LFS setstripe -c -1 $file1 # b=10919
475 $LCTL set_param ldlm.namespaces.*.lru_size=clear
477 # direct write on one client and direct read from another
478 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
479 dd if=$file2 of=$tmpfile iflag=direct bs=1M
480 diff $file1 $tmpfile || error "file different(1)"
483 # buffer write on one client, but direct read from another
484 dd if=$tmpfile of=$file1 bs=1M count=100
485 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
486 diff $file3 $tmpfile || error "file different(2)"
488 rm -f $file3 $file2 $file1
489 # direct write on one client
490 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
491 # buffer read from another client
492 dd if=$file2 of=$file3 bs=1M count=100
493 diff $file3 $tmpfile || error "file different(3)"
495 rm -f $file1 $file2 $file3 $tmpfile
498 run_test 16d "Verify DIO and buffer IO with two clients"
501 test_17() { # bug 3513, 3667
502 remote_ost_nodsh && skip "remote OST with nodsh" && return
504 lfs setstripe $DIR1/$tfile -i 0 -c 1
505 cp $SAMPLE_FILE $DIR1/$tfile
506 cancel_lru_locks osc > /dev/null
507 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
508 do_facet ost1 lctl set_param fail_loc=0x8000030a
509 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
510 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
512 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
514 run_test 17 "resource creation/LVB creation race ==============="
517 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
520 for idx in {a..z}; do
521 local ptr=EXCEPT_ALWAYS_18$idx
522 [ x${!ptr} = xtrue ] || continue
524 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
527 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
530 run_test 18 "mmap sanity check ================================="
532 test_19() { # bug3811
533 local node=$(facet_active_host ost1)
535 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
537 # check whether obdfilter is cache capable at all
538 get_osd_param $node '' read_cache_enable >/dev/null ||
539 skip "not cache-capable obdfilter"
541 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
542 set_osd_param $node '' readcache_max_filesize 4096
543 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
544 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
545 cp $TMP/$tfile $DIR1/$tfile
546 for i in `seq 1 20`; do
547 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
548 cancel_lru_locks $OSC > /dev/null
549 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
550 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
552 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
553 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
554 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
555 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
557 set_osd_param $node '' readcache_max_filesize $MAX
560 run_test 19 "test concurrent uncached read races ==============="
564 cancel_lru_locks $OSC
565 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
566 $MULTIOP $DIR1/f20 Ow8190c
567 $MULTIOP $DIR2/f20 Oz8194w8190c
568 $MULTIOP $DIR1/f20 Oz0r8190c
569 cancel_lru_locks $OSC
570 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
572 error $CNTD" page left in cache after lock cancel" || true
574 run_test 20 "test extra readahead page left in cache ===="
581 test_21() { # Bug 5907
582 test_mkdir $DIR1/$tdir
583 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
585 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
586 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
587 test -d $DIR1/$tdir || error "Mounted directory disappeared"
589 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
592 run_test 21 " Try to remove mountpoint on another dir ===="
594 test_23() { # Bug 5972
595 local at_diff=$(do_facet $SINGLEMDS \
596 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
597 echo "atime should be updated while another read" > $DIR1/$tfile
599 # clear the lock(mode: LCK_PW) gotten from creating operation
600 cancel_lru_locks $OSC
603 sleep $((at_diff + 1))
605 echo "starting reads"
606 multiop_bg_pause $DIR1/$tfile or20_c || return 1
607 # with SOM and opencache enabled, we need to close a file and cancel
608 # open lock to get atime propogated to MDS
609 kill -USR1 $! || return 2
612 time2=$(stat -c "%X" $DIR/$tfile)
613 echo "new atime is $time2"
615 [ $time2 -gt $time1 ] || error "atime was not updated"
616 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
619 run_test 23 " others should see updated atime while another read===="
623 lfs df || error "lfs df failed"
624 lfs df -ih || error "lfs df -ih failed"
625 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
626 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
627 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
628 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
630 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
631 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
632 lctl --device %osc deactivate
633 lfs df -i || error "lfs df -i with deactivated OSC failed"
634 lctl --device %osc activate
635 lfs df || error "lfs df with reactivated OSC failed"
637 run_test 24a "lfs df [-ih] [path] test ========================="
641 fsnum=$(lfs_df | grep -c "summary")
642 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
644 run_test 24b "lfs df should show both filesystems ==============="
647 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
649 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
652 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
653 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
655 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
656 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
657 error "setfacl $DIR2/$tdir #1"
658 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
659 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
660 error "setfacl $DIR2/$tdir #2"
661 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
662 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
663 error "setfacl $DIR2/$tdir #3"
664 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
665 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
666 error "setfacl $DIR2/$tdir #4"
667 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
671 run_test 25a "change ACL on one mountpoint be seen on another ==="
674 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
676 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
678 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
681 $LFS mkdir -i 1 $DIR1/$tdir
682 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
683 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
685 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
686 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
687 error "setfacl $DIR2/$tdir #1"
688 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
689 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
690 error "setfacl $DIR2/$tdir #2"
691 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
692 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
693 error "setfacl $DIR2/$tdir #3"
694 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
695 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
696 error "setfacl $DIR2/$tdir #4"
697 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
701 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
704 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
706 run_test 26a "allow mtime to get older"
711 echo "aaa" >> $DIR1/$tfile
713 chmod a+x $DIR2/$tfile
714 mt1=`stat -c %Y $DIR1/$tfile`
715 mt2=`stat -c %Y $DIR2/$tfile`
717 if [ x"$mt1" != x"$mt2" ]; then
718 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
721 run_test 26b "sync mtime between ost and mds"
724 cancel_lru_locks $OSC
726 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
731 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
736 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
738 lctl set_param -n ldlm.dump_namespaces ""
739 wait $DD1_PID $DD2_PID
740 [ $? -ne 0 ] && lctl dk $TMP/debug || true
742 run_test 27 "align non-overlapping extent locks from request ==="
744 test_28() { # bug 9977
745 ECHO_UUID="ECHO_osc1_UUID"
746 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
748 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
749 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
750 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
754 attach echo_client ECHO_osc1 $ECHO_UUID
758 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
759 $LCTL --device $tECHOID destroy "${tOBJID}:0"
767 # reading of 1st stripe should pass
768 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
769 # reading of 2nd stripe should fail (this stripe was destroyed)
770 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
772 # now, recreating test file
773 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
774 # reading of 1st stripe should pass
775 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
776 # reading of 2nd stripe should pass
777 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
780 run_test 28 "read/write/truncate file with lost stripes"
782 test_30() { #b=11110, LU-2523
783 test_mkdir $DIR1/$tdir
784 cp -f /bin/bash $DIR1/$tdir/bash
785 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
786 $DIR1/$tdir/bash -c 'sleep 2;
787 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
791 run_test 30 "recreate file race"
794 test_mkdir $DIR1/$tdir
795 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
796 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
797 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
798 lctl set_param fail_loc=0x314
799 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
800 awk 'BEGIN { FS="+" } /in/ {print $1}')
801 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
803 run_test 31a "voluntary cancel / blocking ast race=============="
806 remote_ost || { skip "local OST" && return 0; }
807 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
809 # make sure there is no local locks due to destroy
810 wait_mds_ost_sync || error "wait_mds_ost_sync()"
811 wait_delete_completed || error "wait_delete_completed()"
813 test_mkdir $DIR1/$tdir
814 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
815 cp /etc/hosts $DIR/$tdir/$tfile
816 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
817 lctl set_param fail_loc=0x314
818 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
819 do_facet ost1 lctl set_param fail_loc=0x316
821 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
822 lctl set_param fail_loc=0
823 do_facet ost1 lctl set_param fail_loc=0
824 # cleanup: reconnect the client back
827 run_test 31b "voluntary OST cancel / blocking ast race=============="
829 # enable/disable lockless truncate feature, depending on the arg 0/1
830 enable_lockless_truncate() {
831 lctl set_param -n $OSC.*.lockless_truncate $1
834 test_32a() { # bug 11270
835 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
836 local stripe_size=$(do_facet $SINGLEMDS \
837 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
839 save_lustre_params client "$OSC.*.lockless_truncate" > $save
840 # restore lockless_truncate default values on exit
841 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
842 cancel_lru_locks $OSC
843 enable_lockless_truncate 1
845 lfs setstripe -c -1 $DIR1/$tfile
846 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
848 clear_stats $OSC.*.${OSC}_stats
850 log "checking cached lockless truncate"
851 $TRUNCATE $DIR1/$tfile 8000000
852 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
853 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
854 error "cached truncate isn't lockless"
856 log "checking not cached lockless truncate"
857 $TRUNCATE $DIR2/$tfile 5000000
858 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
859 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
860 error "not cached truncate isn't lockless"
862 log "disabled lockless truncate"
863 enable_lockless_truncate 0
864 clear_stats $OSC.*.${OSC}_stats
865 $TRUNCATE $DIR2/$tfile 3000000
866 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
867 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
868 error "lockless truncate disabling failed"
871 run_test 32a "lockless truncate"
873 test_32b() { # bug 11270
874 remote_ost_nodsh && skip "remote OST with nodsh" && return
877 local facets=$(get_facets OST)
878 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
880 save_lustre_params client "osc.*.contention_seconds" > $p
881 save_lustre_params $facets \
882 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
883 save_lustre_params $facets \
884 "ldlm.namespaces.filter-*.contended_locks" >> $p
885 save_lustre_params $facets \
886 "ldlm.namespaces.filter-*.contention_seconds" >> $p
887 clear_stats $OSC.*.${OSC}_stats
889 # agressive lockless i/o settings
890 do_nodes $(comma_list $(osts_nodes)) \
891 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
892 ldlm.namespaces.filter-*.contended_locks=0 \
893 ldlm.namespaces.filter-*.contention_seconds=60"
894 lctl set_param -n $OSC.*.contention_seconds=60
896 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
898 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
901 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
902 error "lockless i/o was not triggered"
903 # disable lockless i/o (it is disabled by default)
904 do_nodes $(comma_list $(osts_nodes)) \
905 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
906 ldlm.namespaces.filter-*.contended_locks=32 \
907 ldlm.namespaces.filter-*.contention_seconds=0"
908 # set contention_seconds to 0 at client too, otherwise Lustre still
909 # remembers lock contention
910 lctl set_param -n $OSC.*.contention_seconds=0
911 clear_stats $OSC.*.${OSC}_stats
913 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
915 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
918 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
919 error "lockless i/o works when disabled"
921 restore_lustre_params <$p
924 run_test 32b "lockless i/o"
928 local mdts=$(get_facets MDS)
933 for mds in ${mdts//,/ }; do
935 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
936 xargs readlink -f" ))
937 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
940 stat=$(( stat + val))
945 # commit on sharing tests
947 remote_mds_nodsh && skip "remote MDS with nodsh" && return
949 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
950 [ $CLIENTCOUNT -lt 2 ] &&
951 skip "Need two or more clients, have $CLIENTCOUNT"
953 local nfiles=${TEST33_NFILES:-10000}
954 local param_file=$TMP/$tfile-params
960 save_lustre_params $(get_facets MDS) \
961 "mdt.*.commit_on_sharing" > $param_file
964 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
968 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
970 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
971 echo "=== START createmany old: $jbdold transaction"
972 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")
973 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
974 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
975 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
976 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
977 avgtime=$(( avgtime + elapsed ))
979 eval cos${COS}_jbd=$((avgjbd / 3))
980 eval cos${COS}_time=$((avgtime / 3))
983 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
984 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
985 [ "$cos0_jbd" != 0 ] &&
986 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
987 [ "$cos0_time" != 0 ] &&
988 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
990 restore_lustre_params < $param_file
994 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
996 # commit on sharing tests
998 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1000 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1001 [ $CLIENTCOUNT -ge 2 ] ||
1002 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1004 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1006 local nfiles=${TEST33_NFILES:-10000}
1007 local param_file=$TMP/$tfile-params
1009 save_lustre_params $(get_facets MDS) \
1010 "mdt.*.commit_on_sharing" > $param_file
1019 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1023 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1024 $DIR1/$tdir-\\\$(hostname)-$i"
1026 jbdold=$(print_jbd_stat)
1027 echo "=== START createmany old: $jbdold transaction"
1028 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1029 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1030 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1032 jbdnew=$(print_jbd_stat)
1033 jbd=$(( jbdnew - jbdold ))
1034 echo "=== END createmany new: $jbdnew transaction : \
1035 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1036 avgjbd=$(( avgjbd + jbd ))
1037 avgtime=$(( avgtime + elapsed ))
1039 eval cos${COS}_jbd=$((avgjbd / 3))
1040 eval cos${COS}_time=$((avgtime / 3))
1043 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1044 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1045 [ "$cos0_jbd" != 0 ] &&
1046 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1047 [ "$cos0_time" != 0 ] &&
1048 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1050 restore_lustre_params < $param_file
1054 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1057 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1058 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1059 skip "DNE CoS not supported"
1065 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1066 # do twice in case transaction is committed before unlock, see LU-8200
1068 # remote dir is created on MDT1, which enqueued lock of $tdir on
1070 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1071 mkdir $DIR/$tdir/local.$i
1073 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1074 echo "sync_count $sync_count"
1075 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1078 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1079 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1080 # during sleep remote mkdir should have been committed and canceled
1081 # remote lock spontaneously, which shouldn't trigger sync
1083 mkdir $DIR/$tdir/local.3
1084 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1085 echo "sync_count $sync_count"
1086 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1088 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1090 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1094 local nodes=$(comma_list $(mdts_nodes))
1098 # trigger CoS twice in case transaction commit before unlock
1101 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1103 commit_nr=$(do_nodes $nodes \
1104 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1105 total=$((total + commit_nr));
1110 echo "CoS count $total"
1111 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1115 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1116 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1117 skip "DNE CoS not supported"
1119 # remote directory create
1120 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1121 # remote directory unlink
1122 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1123 # striped directory create
1124 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1125 # striped directory setattr
1126 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1127 "chmod 713 $DIR/$tdir"
1128 # striped directory unlink
1129 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1132 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1133 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1134 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1135 touch $DIR/$tdir/d1/tgt" \
1136 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1138 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1139 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1140 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1141 touch $DIR/$tdir/d1/src" \
1142 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1144 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1145 "$LFS migrate -m 1 $DIR/$tdir"
1149 run_test 33d "DNE distributed operation should trigger COS"
1152 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1153 [ $CLIENTCOUNT -ge 2 ] ||
1154 skip "Need two or more clients, have $CLIENTCOUNT"
1155 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1156 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1157 skip "DNE CoS not supported"
1159 local client2=${CLIENT2:-$(hostname)}
1163 local nodes=$(comma_list $(mdts_nodes))
1164 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1166 $LFS mkdir -c 2 $DIR/$tdir
1167 mkdir $DIR/$tdir/subdir
1168 echo abc > $DIR/$tdir/$tfile
1169 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1170 do_node $client2 touch $DIR/$tdir/subdir
1172 local async_commit_count=$(do_nodes $nodes \
1173 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1174 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1178 run_test 33e "DNE local operation shouldn't trigger COS"
1180 # End commit on sharing tests
1182 get_ost_lock_timeouts() {
1183 local nodes=${1:-$(comma_list $(osts_nodes))}
1185 local locks=$(do_nodes $nodes \
1186 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1194 do_nodes $(comma_list $(osts_nodes)) \
1195 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1196 for i in $(seq $OSTCOUNT); do
1197 wait_osc_import_ready client ost$i
1202 remote_ost_nodsh && skip "remote OST with nodsh" && return
1206 trap cleanup_34 EXIT RETURN
1207 for OPER in notimeout timeout ; do
1208 rm $DIR1/$tfile 2>/dev/null
1209 lock_in=$(get_ost_lock_timeouts)
1210 if [ $OPER == "timeout" ] ; then
1211 for j in `seq $OSTCOUNT`; do
1212 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1213 do_facet ost$j lctl set_param fail_loc=0x511
1215 echo lock should expire
1217 for j in `seq $OSTCOUNT`; do
1218 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1219 do_facet ost$j lctl set_param fail_loc=0x512
1221 echo lock should not expire
1223 echo writing on client1
1224 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1226 echo reading on client2
1227 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1228 # wait for a lock timeout
1230 lock_out=$(get_ost_lock_timeouts)
1231 if [ $OPER == "timeout" ] ; then
1232 if [ $lock_in == $lock_out ]; then
1233 error "no lock timeout happened"
1238 if [ $lock_in != $lock_out ]; then
1239 error "lock timeout happened"
1247 run_test 34 "no lock timeout under IO"
1249 test_35() { # bug 17645
1252 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1253 awk '/generation/{print $2}')
1255 generation[count]=$g
1259 test_mkdir $MOUNT1/$tdir
1260 cancel_lru_locks mdc
1262 # Let's initiate -EINTR situation by setting fail_loc and take
1263 # write lock on same file from same client. This will not cause
1264 # bl_ast yet as lock is already in local cache.
1265 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1266 do_facet client "lctl set_param fail_loc=0x80000317"
1267 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1268 let timeout=timeout*3
1270 while test $nr -lt 10; do
1271 log "Race attempt $nr"
1272 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1273 awk '/ldlm_bl_callback/ { print $2 }')
1274 test "x$blk1" = "x" && blk1=0
1275 createmany -o $MOUNT2/$tdir/a 4000 &
1279 # Let's make conflict and bl_ast
1280 ls -la $MOUNT1/$tdir > /dev/null &
1283 log "Wait for $pid1 $pid2 for $timeout sec..."
1285 kill -9 $pid1 $pid2 > /dev/null 2>&1
1287 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1288 awk '/ldlm_bl_callback/ { print $2 }')
1289 test "x$blk2" = "x" && blk2=0
1290 test $blk2 -gt $blk1 && break
1291 rm -fr $MOUNT1/$tdir
1292 cancel_lru_locks mdc
1295 do_facet client "lctl set_param fail_loc=0x0"
1296 df -h $MOUNT1 $MOUNT2
1298 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1299 awk '/generation/{print $2}')
1301 if ! test "$g" -eq "${generation[count]}"; then
1302 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1304 for imp in $list; do
1305 if [ $c = $count ]; then
1310 imp=$(echo "$imp" | awk -F"." '{print $2}')
1311 error "Eviction happened on import $imp"
1316 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1318 test_36() { #bug 16417
1323 test_mkdir $DIR1/$tdir
1324 $LFS setstripe -c -1 $DIR1/$tdir
1327 let SIZE_B=SIZE*1024*1024
1328 sync; sleep 2; sync # wait for delete thread
1329 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1330 wait_destroy_complete || error "wait_destroy_complete failed"
1332 while [ $i -le 10 ]; do
1333 lctl mark "start test - cycle ($i)"
1334 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1335 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1336 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1337 sync # sync data from client cache
1338 sync_all_data # sync data from server cache (delayed allocation)
1340 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1341 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1343 rm -f $DIR1/$tdir/$tfile
1344 kill -USR1 $read_pid
1346 sync; sleep 2; sync # Ensure new statfs
1347 wait_delete_completed
1348 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1349 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1351 # this free space! not used
1352 (( $after_dd <= $after)) ||
1353 error "space leaked after_dd:$after_dd > after:$after"
1357 run_test 36 "handle ESTALE/open-unlink correctly"
1359 test_37() { # bug 18695
1360 test_mkdir $DIR1/$tdir
1361 multiop_bg_pause $DIR1/$tdir D_c || return 1
1363 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1364 createmany -m $DIR2/$tdir/f 10000
1365 # set mtime/atime backward
1366 touch -t 198001010000 $DIR2/$tdir
1367 kill -USR1 $MULTIPID
1368 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1369 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1372 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1374 # this should be set to past
1375 TEST_39_MTIME=`date -d "1 year ago" +%s`
1379 local client1=${CLIENT1:-`hostname`}
1380 local client2=${CLIENT2:-`hostname`}
1382 do_node $client1 "touch $DIR1/$tfile"
1384 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1385 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1386 [ "$mtime1" = $TEST_39_MTIME ] || \
1387 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1389 local d1=`do_node $client1 date +%s`
1390 do_node $client1 'echo hello >> '$DIR1/$tfile
1391 local d2=`do_node $client1 date +%s`
1393 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1394 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1395 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1397 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1399 for (( i=0; i < 2; i++ )) ; do
1400 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1401 [ "$mtime2" = "$mtime3" ] || \
1402 error "mtime ($mtime2) changed (to $mtime3) on rename"
1404 cancel_lru_locks osc
1405 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1408 run_test 39a "test from 11063 =================================="
1411 local client1=${CLIENT1:-`hostname`}
1412 local client2=${CLIENT2:-`hostname`}
1416 local mtime1=`stat -c %Y $DIR1/$tfile`
1417 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1420 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1422 for (( i=0; i < 2; i++ )) ; do
1423 local mtime3=`stat -c %Y $DIR1/$tfile`
1424 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1426 [ "$mtime3" = "$mtime4" ] || \
1427 error "different mtime on clients: $mtime3, $mtime4"
1428 [ "$mtime3" = $TEST_39_MTIME ] || \
1429 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1431 cancel_lru_locks osc
1432 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1435 run_test 39b "11063 problem 1 =================================="
1438 local client1=${CLIENT1:-`hostname`}
1439 local client2=${CLIENT2:-`hostname`}
1441 echo hello > $DIR1/$tfile
1443 local mtime1=`stat -c %Y $DIR1/$tfile`
1444 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1445 [ "$mtime1" = "$mtime2" ] || \
1446 error "create: different mtime on clients: $mtime1, $mtime2"
1449 $TRUNCATE $DIR1/$tfile 1
1451 for (( i=0; i < 2; i++ )) ; do
1452 local mtime3=`stat -c %Y $DIR1/$tfile`
1453 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1455 [ "$mtime3" = "$mtime4" ] || \
1456 error "different mtime on clients: $mtime3, $mtime4"
1457 [ "$mtime3" -gt $mtime2 ] || \
1458 error "truncate did not update mtime: $mtime2, $mtime3"
1460 cancel_lru_locks osc
1461 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1464 run_test 39c "check truncate mtime update ======================"
1466 test_39d() { # LU-7310
1468 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1470 local mtime1=$(stat -c %Y $DIR2/$tfile)
1471 [ "$mtime1" = $TEST_39_MTIME ] ||
1472 error "mtime: $mtime1, should be $TEST_39_MTIME"
1475 # define OBD_FAIL_OSC_NO_GRANT 0x411
1476 $LCTL set_param fail_loc=0x411
1478 local d1=$(date +%s)
1479 echo hello >> $DIR1/$tfile
1480 local d2=$(date +%s)
1482 $LCTL set_param fail_loc=0
1484 cancel_lru_locks $OSC
1486 local mtime2=$(stat -c %Y $DIR2/$tfile)
1487 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1488 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1490 run_test 39d "sync write should update mtime"
1493 # how long 40-47 take with specific delay
1500 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1501 # avoid unexpected delays due to previous tests
1503 cancel_lru_locks mdc
1504 do_nodes $(comma_list $(mdts_nodes)) \
1505 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1506 do_nodes $(comma_list $(mdts_nodes)) \
1507 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1508 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1511 # check that pid exists hence second operation wasn't blocked by first one
1512 # if it is so then there is no conflict, return 0
1513 # else second operation is conflicting with first one, return 1
1514 check_pdo_conflict() {
1517 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1518 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1528 # test 40: check non-blocking operations
1530 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1532 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1533 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1535 mkdir $DIR1/$tfile &
1537 touch $DIR2/$tfile-2
1538 check_pdo_conflict $PID1 || error "create is blocked"
1539 mkdir $DIR2/$tfile-3
1540 check_pdo_conflict $PID1 || error "mkdir is blocked"
1541 link $DIR2/$tfile-2 $DIR2/$tfile-4
1542 check_pdo_conflict $PID1 || error "link is blocked"
1543 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1544 check_pdo_conflict $PID1 || error "rename is blocked"
1545 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1546 check_pdo_conflict $PID1 || error "getattr is blocked"
1547 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1548 rmdir $DIR2/$tfile-3
1549 check_pdo_conflict $PID1 || error "unlink is blocked"
1551 # all operations above shouldn't wait the first one
1552 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1553 do_facet $SINGLEMDS lctl set_param fail_loc=0
1558 run_test 40a "pdirops: create vs others =============="
1561 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1563 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1564 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1565 touch $DIR1/$tfile &
1568 touch $DIR2/$tfile-2
1569 check_pdo_conflict $PID1 || error "create is blocked"
1570 mkdir $DIR2/$tfile-3
1571 check_pdo_conflict $PID1 || error "mkdir is blocked"
1572 link $DIR2/$tfile-2 $DIR2/$tfile-4
1573 check_pdo_conflict $PID1 || error "link is blocked"
1574 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1575 check_pdo_conflict $PID1 || error "rename is blocked"
1576 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1577 check_pdo_conflict $PID1 || error "getattr is blocked"
1578 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1579 rmdir $DIR2/$tfile-3
1580 check_pdo_conflict $PID1 || error "unlink is blocked"
1581 # all operations above shouldn't wait the first one
1583 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1584 do_facet $SINGLEMDS lctl set_param fail_loc=0
1589 run_test 40b "pdirops: open|create and others =============="
1592 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1595 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1596 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1597 link $DIR1/$tfile $DIR1/$tfile-0 &
1600 touch $DIR2/$tfile-2
1601 check_pdo_conflict $PID1 || error "create is blocked"
1602 mkdir $DIR2/$tfile-3
1603 check_pdo_conflict $PID1 || error "mkdir is blocked"
1604 link $DIR2/$tfile-2 $DIR2/$tfile-4
1605 check_pdo_conflict $PID1 || error "link is blocked"
1606 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1607 check_pdo_conflict $PID1 || error "rename is blocked"
1608 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1609 check_pdo_conflict $PID1 || error "getattr is blocked"
1610 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1611 rmdir $DIR2/$tfile-3
1612 check_pdo_conflict $PID1 || error "unlink is blocked"
1614 # all operations above shouldn't wait the first one
1615 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1616 do_facet $SINGLEMDS lctl set_param fail_loc=0
1621 run_test 40c "pdirops: link and others =============="
1624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1627 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1628 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1632 touch $DIR2/$tfile-2
1633 check_pdo_conflict $PID1 || error "create is blocked"
1634 mkdir $DIR2/$tfile-3
1635 check_pdo_conflict $PID1 || error "mkdir is blocked"
1636 link $DIR2/$tfile-2 $DIR2/$tfile-4
1637 check_pdo_conflict $PID1 || error "link is blocked"
1638 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1639 check_pdo_conflict $PID1 || error "rename is blocked"
1640 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1641 check_pdo_conflict $PID1 || error "getattr is blocked"
1642 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1643 rmdir $DIR2/$tfile-3
1644 check_pdo_conflict $PID1 || error "unlink is blocked"
1646 # all operations above shouldn't wait the first one
1647 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1648 do_facet $SINGLEMDS lctl set_param fail_loc=0
1652 run_test 40d "pdirops: unlink and others =============="
1655 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1658 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1659 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1660 mv $DIR1/$tfile $DIR1/$tfile-0 &
1663 touch $DIR2/$tfile-2
1664 check_pdo_conflict $PID1 || error "create is blocked"
1665 mkdir $DIR2/$tfile-3
1666 check_pdo_conflict $PID1 || error "mkdir is blocked"
1667 link $DIR2/$tfile-2 $DIR2/$tfile-4
1668 check_pdo_conflict $PID1 || error "link is blocked"
1669 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1670 check_pdo_conflict $PID1 || error "getattr is blocked"
1671 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1672 rmdir $DIR2/$tfile-3
1673 check_pdo_conflict $PID1 || error "unlink is blocked"
1675 # all operations above shouldn't wait the first one
1676 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1677 do_facet $SINGLEMDS lctl set_param fail_loc=0
1682 run_test 40e "pdirops: rename and others =============="
1684 # test 41: create blocking operations
1687 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1688 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1689 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1691 mkdir $DIR2/$tfile &
1693 do_facet $SINGLEMDS lctl set_param fail_loc=0
1694 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1695 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1699 run_test 41a "pdirops: create vs mkdir =============="
1703 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1704 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1705 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1707 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1709 do_facet $SINGLEMDS lctl set_param fail_loc=0
1710 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1711 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1715 run_test 41b "pdirops: create vs create =============="
1719 touch $DIR1/$tfile-2
1720 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1721 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1722 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1724 link $DIR2/$tfile-2 $DIR2/$tfile &
1726 do_facet $SINGLEMDS lctl set_param fail_loc=0
1727 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1728 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1732 run_test 41c "pdirops: create vs link =============="
1736 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1737 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1738 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1742 do_facet $SINGLEMDS lctl set_param fail_loc=0
1743 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1744 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1748 run_test 41d "pdirops: create vs unlink =============="
1752 touch $DIR1/$tfile-2
1753 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1754 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1755 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1757 mv $DIR2/$tfile-2 $DIR2/$tfile &
1759 do_facet $SINGLEMDS lctl set_param fail_loc=0
1760 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1761 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1765 run_test 41e "pdirops: create and rename (tgt) =============="
1769 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1770 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1771 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1773 mv $DIR2/$tfile $DIR2/$tfile-2 &
1775 do_facet $SINGLEMDS lctl set_param fail_loc=0
1776 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1777 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1781 run_test 41f "pdirops: create and rename (src) =============="
1785 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1786 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1787 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1789 stat $DIR2/$tfile > /dev/null &
1791 do_facet $SINGLEMDS lctl set_param fail_loc=0
1792 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1793 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1797 run_test 41g "pdirops: create vs getattr =============="
1801 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1802 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1803 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1805 ls -lia $DIR2/ > /dev/null &
1807 do_facet $SINGLEMDS lctl set_param fail_loc=0
1808 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1813 run_test 41h "pdirops: create vs readdir =============="
1815 # test 42: unlink and blocking operations
1818 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1819 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1820 mkdir $DIR1/$tfile &
1822 mkdir $DIR2/$tfile &
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0
1825 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1826 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1830 run_test 42a "pdirops: mkdir vs mkdir =============="
1834 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1835 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1836 mkdir $DIR1/$tfile &
1838 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1840 do_facet $SINGLEMDS lctl set_param fail_loc=0
1841 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1842 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1846 run_test 42b "pdirops: mkdir vs create =============="
1850 touch $DIR1/$tfile-2
1851 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1852 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1853 mkdir $DIR1/$tfile &
1855 link $DIR2/$tfile-2 $DIR2/$tfile &
1857 do_facet $SINGLEMDS lctl set_param fail_loc=0
1858 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1859 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1863 run_test 42c "pdirops: mkdir vs link =============="
1867 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1868 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1869 mkdir $DIR1/$tfile &
1871 rmdir $DIR2/$tfile &
1873 do_facet $SINGLEMDS lctl set_param fail_loc=0
1874 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1875 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1879 run_test 42d "pdirops: mkdir vs unlink =============="
1883 touch $DIR1/$tfile-2
1884 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1885 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1886 mkdir $DIR1/$tfile &
1888 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1890 do_facet $SINGLEMDS lctl set_param fail_loc=0
1891 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1892 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1896 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1900 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1901 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1902 mkdir $DIR1/$tfile &
1904 mv $DIR2/$tfile $DIR2/$tfile-2 &
1906 do_facet $SINGLEMDS lctl set_param fail_loc=0
1907 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1908 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1912 run_test 42f "pdirops: mkdir and rename (src) =============="
1916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1917 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1918 mkdir $DIR1/$tfile &
1920 stat $DIR2/$tfile > /dev/null &
1922 do_facet $SINGLEMDS lctl set_param fail_loc=0
1923 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1924 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1928 run_test 42g "pdirops: mkdir vs getattr =============="
1932 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1933 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1934 mkdir $DIR1/$tfile &
1936 ls -lia $DIR2/ > /dev/null &
1938 do_facet $SINGLEMDS lctl set_param fail_loc=0
1939 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1944 run_test 42h "pdirops: mkdir vs readdir =============="
1946 # test 43: unlink and blocking operations
1950 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1951 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1954 mkdir $DIR2/$tfile &
1956 do_facet $SINGLEMDS lctl set_param fail_loc=0
1957 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1958 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
1962 run_test 43a "pdirops: unlink vs mkdir =============="
1967 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1968 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1971 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1973 do_facet $SINGLEMDS lctl set_param fail_loc=0
1974 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1975 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
1979 run_test 43b "pdirops: unlink vs create =============="
1984 touch $DIR1/$tfile-2
1985 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1986 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1989 link $DIR2/$tfile-2 $DIR2/$tfile &
1991 do_facet $SINGLEMDS lctl set_param fail_loc=0
1992 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1993 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
1997 run_test 43c "pdirops: unlink vs link =============="
2002 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2003 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2008 do_facet $SINGLEMDS lctl set_param fail_loc=0
2009 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2010 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2014 run_test 43d "pdirops: unlink vs unlink =============="
2019 touch $DIR1/$tfile-2
2020 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2021 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2024 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2026 do_facet $SINGLEMDS lctl set_param fail_loc=0
2027 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2028 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2032 run_test 43e "pdirops: unlink and rename (tgt) =============="
2037 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2038 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2041 mv $DIR2/$tfile $DIR2/$tfile-2 &
2043 do_facet $SINGLEMDS lctl set_param fail_loc=0
2044 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2045 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2049 run_test 43f "pdirops: unlink and rename (src) =============="
2054 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2055 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2058 stat $DIR2/$tfile > /dev/null &
2060 do_facet $SINGLEMDS lctl set_param fail_loc=0
2061 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2062 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2066 run_test 43g "pdirops: unlink vs getattr =============="
2071 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2072 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2075 ls -lia $DIR2/ > /dev/null &
2077 do_facet $SINGLEMDS lctl set_param fail_loc=0
2078 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2083 run_test 43h "pdirops: unlink vs readdir =============="
2086 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2089 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2090 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2093 $LFS mkdir -i 1 $DIR2/$tfile &
2095 do_facet $SINGLEMDS lctl set_param fail_loc=0
2096 check_pdo_conflict $PID1 &&
2097 { wait $PID1; error "remote mkdir isn't blocked"; }
2098 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2102 run_test 43i "pdirops: unlink vs remote mkdir"
2104 # test 44: rename tgt and blocking operations
2107 touch $DIR1/$tfile-2
2108 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2109 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2110 mv $DIR1/$tfile-2 $DIR1/$tfile &
2112 mkdir $DIR2/$tfile &
2114 do_facet $SINGLEMDS lctl set_param fail_loc=0
2115 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2116 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2121 run_test 44a "pdirops: rename tgt vs mkdir =============="
2125 touch $DIR1/$tfile-2
2126 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2127 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2128 mv $DIR1/$tfile-2 $DIR1/$tfile &
2130 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2132 do_facet $SINGLEMDS lctl set_param fail_loc=0
2133 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2134 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2138 run_test 44b "pdirops: rename tgt vs create =============="
2142 touch $DIR1/$tfile-2
2143 touch $DIR1/$tfile-3
2144 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2145 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2146 mv $DIR1/$tfile-2 $DIR1/$tfile &
2148 link $DIR2/$tfile-3 $DIR2/$tfile &
2150 do_facet $SINGLEMDS lctl set_param fail_loc=0
2151 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2152 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2156 run_test 44c "pdirops: rename tgt vs link =============="
2160 touch $DIR1/$tfile-2
2161 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2162 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2163 mv $DIR1/$tfile-2 $DIR1/$tfile &
2167 do_facet $SINGLEMDS lctl set_param fail_loc=0
2168 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2169 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2173 run_test 44d "pdirops: rename tgt vs unlink =============="
2178 touch $DIR1/$tfile-2
2179 touch $DIR1/$tfile-3
2180 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2181 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2182 mv $DIR1/$tfile-2 $DIR1/$tfile &
2184 mv $DIR2/$tfile-3 $DIR2/$tfile &
2186 do_facet $SINGLEMDS lctl set_param fail_loc=0
2187 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2188 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2192 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2196 touch $DIR1/$tfile-2
2197 touch $DIR1/$tfile-3
2198 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2199 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2200 mv $DIR1/$tfile-2 $DIR1/$tfile &
2202 mv $DIR2/$tfile $DIR2/$tfile-3 &
2204 do_facet $SINGLEMDS lctl set_param fail_loc=0
2205 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2206 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2210 run_test 44f "pdirops: rename tgt and rename (src) =============="
2214 touch $DIR1/$tfile-2
2215 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2216 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2217 mv $DIR1/$tfile-2 $DIR1/$tfile &
2219 stat $DIR2/$tfile > /dev/null &
2221 do_facet $SINGLEMDS lctl set_param fail_loc=0
2222 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2223 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2227 run_test 44g "pdirops: rename tgt vs getattr =============="
2231 touch $DIR1/$tfile-2
2232 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2233 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2234 mv $DIR1/$tfile-2 $DIR1/$tfile &
2236 ls -lia $DIR2/ > /dev/null &
2238 do_facet $SINGLEMDS lctl set_param fail_loc=0
2239 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2244 run_test 44h "pdirops: rename tgt vs readdir =============="
2246 # test 44: rename tgt and blocking operations
2248 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2250 touch $DIR1/$tfile-2
2251 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2252 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2253 mv $DIR1/$tfile-2 $DIR1/$tfile &
2255 $LFS mkdir -i 1 $DIR2/$tfile &
2257 do_facet $SINGLEMDS lctl set_param fail_loc=0
2258 check_pdo_conflict $PID1 && { wait $PID1;
2259 error "remote mkdir isn't blocked"; }
2260 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2264 run_test 44i "pdirops: rename tgt vs remote mkdir"
2266 # test 45: rename src and blocking operations
2270 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2271 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2272 mv $DIR1/$tfile $DIR1/$tfile-2 &
2274 mkdir $DIR2/$tfile &
2276 do_facet $SINGLEMDS lctl set_param fail_loc=0
2277 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2278 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
2282 run_test 45a "pdirops: rename src vs mkdir =============="
2287 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2288 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2289 mv $DIR1/$tfile $DIR1/$tfile-2 &
2291 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2293 do_facet $SINGLEMDS lctl set_param fail_loc=0
2294 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2295 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2299 run_test 45b "pdirops: rename src vs create =============="
2304 touch $DIR1/$tfile-3
2305 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2306 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2307 mv $DIR1/$tfile $DIR1/$tfile-2 &
2309 link $DIR2/$tfile-3 $DIR2/$tfile &
2311 do_facet $SINGLEMDS lctl set_param fail_loc=0
2312 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2313 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2317 run_test 45c "pdirops: rename src vs link =============="
2322 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2323 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2324 mv $DIR1/$tfile $DIR1/$tfile-2 &
2328 do_facet $SINGLEMDS lctl set_param fail_loc=0
2329 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2330 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2334 run_test 45d "pdirops: rename src vs unlink =============="
2339 touch $DIR1/$tfile-3
2340 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2341 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2342 mv $DIR1/$tfile $DIR1/$tfile-2 &
2344 mv $DIR2/$tfile-3 $DIR2/$tfile &
2346 do_facet $SINGLEMDS lctl set_param fail_loc=0
2347 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2348 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2352 run_test 45e "pdirops: rename src and rename (tgt) =============="
2357 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2358 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2359 mv $DIR1/$tfile $DIR1/$tfile-2 &
2361 mv $DIR2/$tfile $DIR2/$tfile-3 &
2363 do_facet $SINGLEMDS lctl set_param fail_loc=0
2364 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2365 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2369 run_test 45f "pdirops: rename src and rename (src) =============="
2374 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2375 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2376 mv $DIR1/$tfile $DIR1/$tfile-2 &
2378 stat $DIR2/$tfile > /dev/null &
2380 do_facet $SINGLEMDS lctl set_param fail_loc=0
2381 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2382 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2386 run_test 45g "pdirops: rename src vs getattr =============="
2391 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2392 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2393 mv $DIR1/$tfile $DIR1/$tfile-2 &
2395 ls -lia $DIR2/ > /dev/null &
2396 do_facet $SINGLEMDS lctl set_param fail_loc=0
2397 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2402 run_test 45h "pdirops: unlink vs readdir =============="
2405 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2408 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2409 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2410 mv $DIR1/$tfile $DIR1/$tfile-2 &
2412 $LFS mkdir -i 1 $DIR2/$tfile &
2414 do_facet $SINGLEMDS lctl set_param fail_loc=0
2415 check_pdo_conflict $PID1 && { wait $PID1;
2416 error "create remote dir isn't blocked"; }
2417 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2421 run_test 45i "pdirops: rename src vs remote mkdir"
2423 # test 46: link and blocking operations
2426 touch $DIR1/$tfile-2
2427 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2428 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2429 link $DIR1/$tfile-2 $DIR1/$tfile &
2431 mkdir $DIR2/$tfile &
2433 do_facet $SINGLEMDS lctl set_param fail_loc=0
2434 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2435 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2439 run_test 46a "pdirops: link vs mkdir =============="
2443 touch $DIR1/$tfile-2
2444 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2445 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2446 link $DIR1/$tfile-2 $DIR1/$tfile &
2448 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2450 do_facet $SINGLEMDS lctl set_param fail_loc=0
2451 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2452 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2456 run_test 46b "pdirops: link vs create =============="
2460 touch $DIR1/$tfile-2
2461 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2462 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2463 link $DIR1/$tfile-2 $DIR1/$tfile &
2465 link $DIR2/$tfile $DIR2/$tfile &
2467 do_facet $SINGLEMDS lctl set_param fail_loc=0
2468 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2469 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2473 run_test 46c "pdirops: link vs link =============="
2477 touch $DIR1/$tfile-2
2478 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2479 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2480 link $DIR1/$tfile-2 $DIR1/$tfile &
2484 do_facet $SINGLEMDS lctl set_param fail_loc=0
2485 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2486 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2490 run_test 46d "pdirops: link vs unlink =============="
2494 touch $DIR1/$tfile-2
2495 touch $DIR1/$tfile-3
2496 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2497 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2498 link $DIR1/$tfile-2 $DIR1/$tfile &
2500 mv $DIR2/$tfile-3 $DIR2/$tfile &
2502 do_facet $SINGLEMDS lctl set_param fail_loc=0
2503 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2504 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2508 run_test 46e "pdirops: link and rename (tgt) =============="
2512 touch $DIR1/$tfile-2
2513 touch $DIR1/$tfile-3
2514 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2515 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2516 link $DIR1/$tfile-2 $DIR1/$tfile &
2518 mv $DIR2/$tfile $DIR2/$tfile-3 &
2520 do_facet $SINGLEMDS lctl set_param fail_loc=0
2521 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2522 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2526 run_test 46f "pdirops: link and rename (src) =============="
2530 touch $DIR1/$tfile-2
2531 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2532 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2533 link $DIR1/$tfile-2 $DIR1/$tfile &
2535 stat $DIR2/$tfile > /dev/null &
2537 do_facet $SINGLEMDS lctl set_param fail_loc=0
2538 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2539 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2543 run_test 46g "pdirops: link vs getattr =============="
2547 touch $DIR1/$tfile-2
2548 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2549 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2550 link $DIR1/$tfile-2 $DIR1/$tfile &
2552 ls -lia $DIR2/ > /dev/null &
2554 do_facet $SINGLEMDS lctl set_param fail_loc=0
2555 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2560 run_test 46h "pdirops: link vs readdir =============="
2563 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2565 touch $DIR1/$tfile-2
2566 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2567 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2568 link $DIR1/$tfile-2 $DIR1/$tfile &
2570 $LFS mkdir -i 1 $DIR2/$tfile &
2572 do_facet $SINGLEMDS lctl set_param fail_loc=0
2573 check_pdo_conflict $PID1 && { wait $PID1;
2574 error "remote mkdir isn't blocked"; }
2575 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2579 run_test 46i "pdirops: link vs remote mkdir"
2581 # test 47: remote mkdir and blocking operations
2583 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2584 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2586 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2587 $LFS mkdir -i 1 $DIR1/$tfile &
2589 mkdir $DIR2/$tfile &
2591 do_facet $SINGLEMDS lctl set_param fail_loc=0
2592 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2593 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2597 run_test 47a "pdirops: remote mkdir vs mkdir"
2600 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2601 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2603 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2604 $LFS mkdir -i 1 $DIR1/$tfile &
2606 sleep 1 # please do not remove this sleep, see LU-10754
2607 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2609 do_facet $SINGLEMDS lctl set_param fail_loc=0
2610 check_pdo_conflict $PID1 && { wait $PID1;
2611 error "create isn't blocked"; }
2612 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2616 run_test 47b "pdirops: remote mkdir vs create"
2619 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2621 touch $DIR1/$tfile-2
2622 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2623 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2624 $LFS mkdir -i 1 $DIR1/$tfile &
2626 link $DIR2/$tfile-2 $DIR2/$tfile &
2628 do_facet $SINGLEMDS lctl set_param fail_loc=0
2629 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2630 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2634 run_test 47c "pdirops: remote mkdir vs link"
2637 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2639 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2640 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2641 $LFS mkdir -i 1 $DIR1/$tfile &
2643 rmdir $DIR2/$tfile &
2645 do_facet $SINGLEMDS lctl set_param fail_loc=0
2646 check_pdo_conflict $PID1 && { wait $PID1;
2647 error "unlink isn't blocked"; }
2648 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2652 run_test 47d "pdirops: remote mkdir vs unlink"
2655 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2657 touch $DIR1/$tfile-2
2658 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2659 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2660 $LFS mkdir -i 1 $DIR1/$tfile &
2662 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2664 do_facet $SINGLEMDS lctl set_param fail_loc=0
2665 check_pdo_conflict $PID1 && { wait $PID1;
2666 error "rename isn't blocked"; }
2667 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2671 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2674 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2676 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2677 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2678 $LFS mkdir -i 1 $DIR1/$tfile &
2680 mv $DIR2/$tfile $DIR2/$tfile-2 &
2682 do_facet $SINGLEMDS lctl set_param fail_loc=0
2683 check_pdo_conflict $PID1 && { wait $PID1;
2684 error "rename isn't blocked"; }
2685 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2689 run_test 47f "pdirops: remote mkdir and rename (src)"
2692 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2696 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2697 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2698 $LFS mkdir -i 1 $DIR1/$tfile &
2700 stat $DIR2/$tfile > /dev/null &
2702 do_facet $SINGLEMDS lctl set_param fail_loc=0
2703 check_pdo_conflict $PID1 && { wait $PID1;
2704 error "getattr isn't blocked"; }
2705 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2709 run_test 47g "pdirops: remote mkdir vs getattr"
2713 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2714 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2715 do_facet client "lctl set_param fail_loc=0x410"
2716 $TRUNCATE $DIR2/$tfile $trunc_size
2717 do_facet client "lctl set_param fail_loc=0x0"
2719 size=`stat -c %s $DIR2/$tfile`
2720 [ $size -eq $trunc_size ] || error "wrong size"
2722 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2726 local origfile=/etc/hosts
2728 filesize=$(stat -c %s $origfile)
2730 # create an empty file
2731 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2732 # cache layout lock on both mount point
2733 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2734 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2736 # open and sleep 2 seconds then read
2737 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2741 # create the layout of testing file
2742 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2743 error "dd $DIR1/$tfile failed"
2745 # MULTIOP proc should be able to read enough bytes and exit
2746 for ((i = 0; i < 6; i++)); do
2748 kill -0 $pid || break
2750 kill -0 $pid 2> /dev/null && error "multiop is still there"
2751 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2755 run_test 51a "layout lock: refresh layout should work"
2758 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
2759 skip "Need MDS version at least 2.3.59"
2761 local tmpfile=`mktemp`
2763 # create an empty file
2764 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2766 # delay glimpse so that layout has changed when glimpse finish
2767 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2768 $LCTL set_param fail_loc=0x1404
2769 stat -c %s $DIR2/$tfile |tee $tmpfile &
2773 # create layout of testing file
2774 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2775 error "dd $DIR1/$tfile failed"
2778 local fsize=$(cat $tmpfile)
2780 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2782 rm -f $DIR1/$tfile $tmpfile
2784 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2787 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2789 # set default layout to have 1 stripe
2791 $LFS setstripe -c 1 $DIR1/$tdir
2793 # create a file with empty layout
2794 $MCREATE $DIR1/$tdir/$tfile ||
2795 error "$MCREATE $DIR1/$tdir/$tfile failed"
2797 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2798 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2800 # change the layout of testing file
2801 echo "Setting layout to have $OSTCOUNT stripes ..."
2802 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2806 # write something to the file, it should be blocked on fetching layout
2807 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2808 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2811 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2812 # count to succeed with only 3/4 of the number of stripes (rounded up),
2813 # so creating striped files does not fail if an OST is offline or full
2814 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2815 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2819 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2822 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2823 cancel_lru_locks mdc
2825 # open should grant LAYOUT lock, mmap and read will install pages
2826 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2830 # rss before revoking
2831 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2832 echo "Before revoking layout lock: $br KB mapped"
2834 # cancel layout lock manually
2835 cancel_lru_locks mdc
2837 # rss after revoking
2838 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2841 wait $PID || error "wait PID $PID failed"
2843 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2845 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2849 echo "==> rename vs getattr vs setxattr should not deadlock"
2850 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2852 do_facet mds1 $LCTL set_param fail_loc=$1
2854 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2862 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2863 wait $PID1 || error "(3) mv failed"
2864 wait $PID2 || error "(4) stat failed"
2871 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2872 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2874 do_facet mds1 $LCTL set_param fail_loc=$1
2876 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2884 $MULTIOP $DIR2/d1/d2 Oc &
2888 stat $DIR/d1 || error "(2) stat failed"
2890 wait $PID1 || error "(3) mv failed"
2891 wait $PID2 || error "(4) stat failed"
2892 wait $PID3 && error "(5) multiop failed"
2898 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2899 save_lustre_params client "llite.*.xattr_cache" > $p
2900 lctl set_param llite.*.xattr_cache 1 ||
2901 { skip "xattr cache is not supported"; return 0; }
2903 #define OBD_FAIL_MDS_RENAME 0x153
2904 #define OBD_FAIL_MDS_RENAME2 0x154
2905 test_54_part1 0x80000153 || error 10
2906 test_54_part1 0x80000154 || error 11
2907 test_54_part2 0x80000153 || error 12
2908 test_54_part2 0x80000154 || error 13
2910 restore_lustre_params < $p
2913 run_test 54 "rename locking"
2916 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2918 #define OBD_FAIL_MDS_RENAME4 0x156
2919 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2921 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2926 wait $PID1 && error "(2) mv succeeded"
2930 run_test 55a "rename vs unlink target dir"
2934 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2936 #define OBD_FAIL_MDS_RENAME4 0x156
2937 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2939 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2944 wait $PID1 && error "(2) mv succeeded"
2948 run_test 55b "rename vs unlink source dir"
2952 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2954 #define OBD_FAIL_MDS_RENAME4 0x156
2955 do_facet mds1 $LCTL set_param fail_loc=0x156
2957 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2961 # while rename is sleeping, open and remove d3
2962 $MULTIOP $DIR2/d3 D_c &
2968 # while rename is sleeping 2nd time, close d3
2970 wait $PID2 || error "(3) multiop failed"
2972 wait $PID1 && error "(2) mv succeeded"
2976 run_test 55c "rename vs unlink orphan target dir"
2982 #define OBD_FAIL_MDS_RENAME3 0x155
2983 do_facet mds1 $LCTL set_param fail_loc=0x155
2984 mv $DIR/f1 $DIR/$tdir &
2988 # while rename is sleeping, create $tdir, but as a directory
2989 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2991 # link in reverse locking order
2992 ln $DIR2/f1 $DIR2/$tdir/
2994 wait $PID1 && error "(2) mv succeeded"
2997 run_test 55d "rename file vs link"
3000 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3001 skip "MDS version must be >= 2.3.0"
3004 test_mkdir $DIR1/$tdir
3005 file1=$DIR1/$tdir/file
3006 file2=$DIR2/$tdir/file
3008 echo orig > $file2 || error "Could not create $file2"
3009 version=$($LFS data_version $file1)
3012 echo append >> $file2 || error "Could not append to $file2"
3013 version2=$($LFS data_version $file1)
3014 [ "$version" != "$version2" ] ||
3015 error "append did not change data version: $version"
3018 echo overwrite > $file2 || error "Could not overwrite $file2"
3019 version3=$($LFS data_version $file1)
3020 [ "$version2" != "$version3" ] ||
3021 error "overwrite did not change data version: $version2"
3023 # Truncate before EOF
3024 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3025 version4=$($LFS data_version $file1)
3026 [ "$version3" != "$version4" ] ||
3027 error "truncate did not change data version: $version3"
3029 # Truncate after EOF
3030 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3031 version5=$($LFS data_version $file1)
3032 [ "$version4" != "$version5" ] ||
3033 error "truncate did not change data version: $version4"
3035 # Chmod do not change version
3036 chmod 400 $file2 || error "Could not chmod 400 $file2"
3037 version6=$($LFS data_version $file1)
3038 [ "$version5" == "$version6" ] ||
3039 error "chmod should not change data version: $version5 != $version6"
3041 # Chown do not change version
3042 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3043 version7=$($LFS data_version $file1)
3044 [ "$version5" == "$version7" ] ||
3045 error "chown should not change data version: $version5 != $version7"
3047 run_test 60 "Verify data_version behaviour"
3050 local test_dir=$tdir/test_dir
3052 mkdir -p $DIR1/$tdir
3053 if [ $MDSCOUNT -ge 2 ]; then
3055 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3056 error "Create remote directory failed"
3058 mkdir -p $DIR1/$test_dir
3060 cd $DIR2/$test_dir || error "cd directory failed"
3061 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3063 cd $DIR2/$tdir || error "exit directory"
3065 run_test 70a "cd directory && rm directory"
3067 test_70b() { # LU-2781
3069 mkdir -p $DIR1/$tdir
3071 touch $DIR1/$tdir/file
3072 for ((i = 0; i < 32; i++)); do
3073 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3075 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3077 touch $DIR1/$tdir/file
3078 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3079 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3080 rm -rf $DIR1/$tdir/test_dir ||
3081 error "cannot remove directory after rm_entry"
3082 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3084 run_test 70b "remove files after calling rm_entry"
3087 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3088 skip "Need MDS version at least 2.1.6"
3090 # Patch not applied to 2.2 and 2.3 branches
3091 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3092 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3093 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3095 checkfiemap --test ||
3096 skip "checkfiemap not runnable: $?"
3097 # write data this way: hole - data - hole - data
3098 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3099 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3101 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3102 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3103 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3105 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3107 checkfiemap $DIR2/$tfile 81920 ||
3108 error "data is not flushed from client"
3109 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3112 # common case of "create file, copy file" on a single node
3113 # should not flush data from ost
3114 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3115 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3117 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3119 checkfiemap $DIR1/$tfile 81920 ||
3121 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3123 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3125 run_test 71a "correct file map just after write operation is finished"
3128 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3129 skip "Need MDS version at least 2.1.6"
3131 # Patch not applied to 2.2 and 2.3 branches
3132 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3133 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3134 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3135 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3137 checkfiemap --test ||
3138 skip "error $?: checkfiemap failed"
3140 mkdir -p $DIR1/$tdir
3142 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3143 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3144 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3146 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3147 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3149 run_test 71b "check fiemap support for stripecount > 1"
3152 local p="$TMP/sanityN-$TESTNAME.parameters"
3155 save_lustre_params client "llite.*.xattr_cache" > $p
3156 lctl set_param llite.*.xattr_cache 1 ||
3157 { skip "xattr cache is not supported"; return 0; }
3160 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3161 error "setfattr1 failed"
3162 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3163 error "getfattr1 failed"
3164 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3165 error "setfattr2 failed"
3166 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3167 error "getfattr2 failed"
3169 # check that trusted.link is consistent
3170 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3171 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3172 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3173 echo "$tlink1 $tlink2"
3174 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3178 restore_lustre_params < $p
3181 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3184 local p="$TMP/sanityN-$TESTNAME.parameters"
3185 save_lustre_params client "llite.*.xattr_cache" > $p
3186 lctl set_param llite.*.xattr_cache 1 ||
3187 { skip "xattr cache is not supported"; return 0; }
3190 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3191 error "setfattr1 failed"
3192 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3193 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3194 clear_stats llite.*.stats
3195 # PR lock should be cached by now on both clients
3196 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3197 # 2 hits for getfattr(0)+getfattr(size)
3198 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3199 error "not cached in $DIR1"
3200 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3201 # 4 hits for more getfattr(0)+getfattr(size)
3202 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3203 error "not cached in $DIR2"
3206 restore_lustre_params < $p
3209 run_test 73 "getxattr should not cause xattr lock cancellation"
3212 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3213 skip "Need MDS version at least 2.4.93"
3215 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3216 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3217 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3219 run_test 74 "flock deadlock: different mounts =============="
3223 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3224 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3225 cancel_lru_locks osc
3227 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3230 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3231 $LCTL set_param fail_loc=0x31d
3232 stat -c %s $DIR1/$tfile &
3237 # For bad lock error handler we should ASSERT and got kernel panic here
3239 $LCTL set_param fail_loc=0
3241 run_test 75 "osc: upcall after unuse lock==================="
3244 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3245 skip "Need MDS version at least 2.5.53"
3247 remote_mds_nodsh && skip "remote MDS with nodsh"
3248 local fcount=$((MDSCOUNT * 256))
3253 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3259 test_mkdir $DIR/$tdir
3261 # drop all open locks and close any cached "open" files on the client
3262 cancel_lru_locks mdc
3264 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3265 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3266 local already=${#fid_list[@]}
3267 for (( i = 0; i < $already; i++ )) ; do
3268 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3271 echo -n "opening files: "
3272 ulimit -n $((fcount + 50))
3273 for ((i = 0; i < $fcount; i++)); do
3274 touch $DIR/$tdir/f_$i
3275 local fd=$(free_fd ${fd_list[i]})
3276 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3281 (( $i % 32 == 0 )) && echo -n "."
3285 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3287 # Possible errors in openfiles FID list.
3288 # 1. Missing FIDs. Check 1
3289 # 2. Extra FIDs. Check 1
3290 # 3. Duplicated FID. Check 2
3291 # 4. Invalid FIDs. Check 2
3292 # 5. Valid FID, points to some other file. Check 3
3295 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3296 error "${#fid_list[@]} != $fcount (+$already old) open files"
3298 echo -n "closing files: "
3299 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3300 local close_cmd="exec ${fd_list[fd]}<&-"
3302 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3304 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3305 echo "skip old open file $filename"
3307 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3311 rm --interactive=no $filename
3313 error "Nonexisting fid ${fid_list[fid]} listed."
3314 (( $fd % 32 == 0 )) && echo -n "."
3319 ls_op=$(ls $DIR2/$tdir | wc -l)
3321 error "Some openfiles are missing in lproc output"
3325 run_test 76 "Verify MDT open_files listing"
3329 local dir=$DIR/$tdir
3332 mkdir $dir || error "mkdir $dir failed"
3333 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3336 do_nodes $CLIENTS $myRUNAS \
3337 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3338 error "dd at 0 on client failed (1)"
3340 do_nodes $CLIENTS $myRUNAS \
3342 for ((i = 0; i < $n; i++)); do
3343 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3344 seek=\\\$i count=1 conv=notrunc &
3345 pids_w[\\\$i]=\\\$!;
3348 for ((i = 0; i < $n; i++)); do
3349 wait \\\${pids_w[\\\$i]};
3351 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3355 do_nodes $CLIENTS sync;
3356 cancel_lru_locks osc
3358 do_nodes $CLIENTS $myRUNAS \
3360 for ((i = 0; i < $n; i++)); do
3361 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3362 seek=\\\$i count=1 &
3363 pids_r[\\\$i]=\\\$!;
3366 for ((i = 0; i < $n; i++)); do
3367 wait \\\${pids_r[\\\$i]};
3369 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3373 cancel_lru_locks osc
3375 wait $pid_w || error "dd (write) failed (2)"
3376 wait $pid_r || error "dd (read) failed (3)"
3377 rm -rvf $dir || error "rm -rf $dir failed"
3380 test_77a() { #LU-3266
3383 oss=$(comma_list $(osts_nodes))
3384 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3386 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3387 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3392 run_test 77a "check FIFO NRS policy"
3394 test_77b() { #LU-3266
3397 oss=$(comma_list $(osts_nodes))
3399 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3400 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3401 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3402 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3404 echo "policy: crr-n, crrn_quantum 1"
3407 do_nodes $oss lctl set_param \
3408 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3409 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3411 echo "policy: crr-n, crrn_quantum 64"
3415 do_nodes $oss lctl set_param \
3416 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3417 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3420 run_test 77b "check CRR-N NRS policy"
3425 oss=$(comma_list $(osts_nodes))
3427 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3428 ost.OSS.*.nrs_"$policy"_quantum=1 \
3429 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3430 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3432 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3433 "physical, ${policy}_supported reads"
3436 do_nodes $oss lctl set_param \
3437 ost.OSS.*.nrs_${policy}_supported="writes" \
3438 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3440 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3441 "physical, ${policy}_supported writes"
3444 do_nodes $oss lctl set_param \
3445 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3446 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3447 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3448 "logical, ${policy}_supported reads_and_writes"
3452 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3457 test_77c() { #LU-3266
3459 orr_trr "orr" || rc=$?
3460 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3461 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3464 run_test 77c "check ORR NRS policy"
3466 test_77d() { #LU-3266
3468 orr_trr "trr" || rc=$?
3469 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3470 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3473 run_test 77d "check TRR nrs policy"
3480 do_facet $facet lctl set_param \
3481 ost.OSS.ost_io.nrs_tbf_rule="$*"
3483 error "failed to run operate '$*' on TBF rules"
3486 cleanup_tbf_verify()
3490 echo "cleanup_tbf $DIR/$tdir"
3493 wait_delete_completed
3498 local dir=$DIR/$tdir
3499 local client1=${CLIENT1:-$(hostname)}
3502 local np=$(check_cpt_number ost1)
3503 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3504 echo "cpu_npartitions on ost1 is $np"
3506 mkdir $dir || error "mkdir $dir failed"
3507 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3510 trap cleanup_tbf_verify EXIT
3511 echo "Limited write rate: $1, read rate: $2"
3512 echo "Verify the write rate is under TBF control"
3513 local start=$SECONDS
3514 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3515 bs=1M count=100 oflag=direct 2>&1
3516 local runtime=$((SECONDS - start + 1))
3517 local rate=$(bc <<< "scale=6; 100 / $runtime")
3518 echo "Write runtime is $runtime s, speed is $rate IOPS"
3520 # verify the write rate does not exceed TBF rate limit
3521 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3522 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3524 cancel_lru_locks osc
3526 echo "Verify the read rate is under TBF control"
3528 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3529 bs=1M count=100 iflag=direct 2>&1
3530 runtime=$((SECONDS - start + 1))
3531 rate=$(bc <<< "scale=6; 100 / $runtime")
3532 echo "Read runtime is $runtime s, speed is $rate IOPS"
3534 # verify the read rate does not exceed TBF rate limit
3535 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3536 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3538 cancel_lru_locks osc
3539 cleanup_tbf_verify || error "rm -rf $dir failed"
3545 oss=$(comma_list $(osts_nodes))
3547 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3549 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3550 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3554 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3559 # Only operate rules on ost1 since OSTs might run on the same OSS
3561 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3562 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3563 local client_nids=$(nids_list $address "\\")
3564 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3565 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3569 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3570 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3571 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3575 tbf_rule_operate ost1 "stop\ localhost"
3576 tbf_rule_operate ost1 "stop\ clients"
3577 tbf_rule_operate ost1 "stop\ others"
3580 # Cleanup the TBF policy
3581 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3582 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3586 run_test 77e "check TBF NID nrs policy"
3591 oss=$(comma_list $(osts_nodes))
3593 do_nodes $oss $LCTL set_param \
3594 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3595 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3596 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3598 # Configure jobid_var
3599 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3601 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3602 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3603 if [ $saved_jobid_var != procname_uid ]; then
3604 set_persistent_param_and_check client \
3605 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3610 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3615 # Only operate rules on ost1 since OSTs might run on the same OSS
3617 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3618 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3619 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3620 nrs_write_read "$RUNAS"
3623 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3624 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3625 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3626 nrs_write_read "$RUNAS"
3629 tbf_rule_operate ost1 "stop\ runas"
3630 tbf_rule_operate ost1 "stop\ iozone_runas"
3631 tbf_rule_operate ost1 "stop\ dd_runas"
3632 nrs_write_read "$RUNAS"
3634 # Cleanup the TBF policy
3635 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3636 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3637 nrs_write_read "$RUNAS"
3639 local current_jobid_var=$($LCTL get_param -n jobid_var)
3640 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3641 if [ $saved_jobid_var != $current_jobid_var ]; then
3642 set_persistent_param_and_check client \
3643 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3647 run_test 77f "check TBF JobID nrs policy"
3652 oss=$(comma_list $(osts_nodes))
3654 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3656 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3657 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3659 do_nodes $oss lctl set_param \
3660 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3661 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3665 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3670 # Add a rule that only valid for Jobid TBF. If direct change between
3671 # TBF types is not supported, this operation will fail.
3672 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3674 # Cleanup the TBF policy
3675 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3676 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3679 run_test 77g "Change TBF type directly"
3682 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3683 skip "Need OST version at least 2.8.55"
3685 local old_policy=$(do_facet ost1 \
3686 lctl get_param ost.OSS.ost_io.nrs_policies)
3689 do_facet ost1 lctl set_param \
3690 ost.OSS.ost_io.nrs_policies="abc"
3691 [ $? -eq 0 ] && error "should return error"
3693 do_facet ost1 lctl set_param \
3694 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3695 [ $? -eq 0 ] && error "should return error"
3697 do_facet ost1 lctl set_param \
3698 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3699 [ $? -eq 0 ] && error "should return error"
3701 do_facet ost1 lctl set_param \
3702 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3703 [ $? -eq 0 ] && error "should return error"
3705 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3706 [ $? -eq 0 ] || error "shouldn't LBUG"
3708 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3712 run_test 77h "Wrong policy name should report error, not LBUG"
3718 local error_message=$3
3720 for rule in $expected; do
3721 rule_number=$((rule_number + 1))
3723 local stop_line=$(($rule_number + 3))
3724 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3726 local output=$(do_facet $facet lctl get_param \
3727 ost.OSS.ost_io.nrs_tbf_rule |
3731 if [ "$output" != "$expected" ]; then
3732 error "$error_message, expected '$expected', got '$output'"
3737 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3738 skip "Need OST version at least 2.8.55"
3740 for i in $(seq 1 $OSTCOUNT)
3742 do_facet ost"$i" lctl set_param \
3743 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3745 error "failed to set TBF policy"
3748 tbf_rule_check ost1 "default" "error before inserting any rule"
3750 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3751 tbf_rule_check ost1 "before default" \
3752 "error when inserting rule 'before'"
3754 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3755 tbf_rule_check ost1 "before after default" \
3756 "error when inserting rule 'after'"
3758 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3759 tbf_rule_check ost1 "before target after default" \
3760 "error when inserting rule 'target'"
3762 echo "Move before itself"
3763 tbf_rule_operate ost1 "change\ target\ rank=target"
3764 tbf_rule_check ost1 "before target after default" \
3765 "error when moving before itself"
3767 echo "Move to higher rank"
3768 tbf_rule_operate ost1 "change\ target\ rank=before"
3769 tbf_rule_check ost1 "target before after default" \
3770 "error when moving to higher rank"
3772 echo "Move to lower rank"
3773 tbf_rule_operate ost1 "change\ target\ rank=after"
3774 tbf_rule_check ost1 "before target after default" \
3775 "error when moving to lower rank"
3777 echo "Move before default"
3778 tbf_rule_operate ost1 "change\ target\ rank=default"
3779 tbf_rule_check ost1 "before after target default" \
3780 error "error when moving before default"
3782 # Cleanup the TBF policy
3783 do_nodes $(comma_list $(osts_nodes)) \
3784 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3787 run_test 77i "Change rank of TBF rule"
3793 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
3794 skip "Need OST version at least 2.9.53"
3795 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
3800 do_nodes $(comma_list $(osts_nodes)) \
3801 lctl set_param jobid_var=procname_uid \
3802 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3803 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3804 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3805 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3810 do_nodes $(comma_list $(osts_nodes)) \
3811 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3812 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3813 ost.OSS.ost_io.nrs_policies="fifo"
3815 # sleep 3 seconds to wait the tbf policy stop completely,
3816 # or the next test case is possible get -EAGAIN when
3817 # setting the tbf policy
3820 run_test 77j "check TBF-OPCode NRS policy"
3823 local idstr="${1}id"
3824 local policy="${idstr}={$2}"
3825 local rate="rate=$3"
3827 do_nodes $(comma_list $(osts_nodes)) \
3828 lctl set_param jobid_var=procname_uid \
3829 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3830 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3831 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3833 nrs_write_read "runas $4"
3834 tbf_verify $3 $3 "runas $4"
3836 do_nodes $(comma_list $(osts_nodes)) \
3837 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3838 ost.OSS.ost_io.nrs_policies="fifo"
3840 # sleep 3 seconds to wait the tbf policy stop completely,
3841 # or the next test case is possible get -eagain when
3842 # setting the tbf policy
3847 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
3848 skip "Need OST version at least 2.11.50"
3851 test_id "u" "500" "5" "-u 500"
3852 test_id "g" "500" "5" "-u 500 -g 500"
3854 run_test 77ja "check TBF-UID/GID NRS policy"
3862 for rule in $rule_lists; do
3863 do_nodes $(comma_list $(osts_nodes)) \
3864 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3867 do_nodes $(comma_list $(osts_nodes)) \
3868 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3874 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
3875 skip "Need OST version at least 2.9.53"
3877 do_nodes $(comma_list $(osts_nodes)) \
3878 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3879 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3880 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3882 nrs_write_read "$RUNAS"
3883 tbf_verify 20 10 "$RUNAS"
3885 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3886 local client_nids=$(nids_list $address "\\")
3887 do_nodes $(comma_list $(osts_nodes)) \
3888 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3889 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3890 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3891 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3896 do_nodes $(comma_list $(osts_nodes)) \
3897 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3898 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3899 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3901 nrs_write_read "$RUNAS"
3902 tbf_verify 20 20 "$RUNAS"
3904 do_nodes $(comma_list $(osts_nodes)) \
3905 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3906 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3907 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3909 nrs_write_read "$RUNAS"
3910 # with parameter "RUNAS", it will match the latest rule
3911 # "ext_b" first, so the limited write rate is 10.
3912 tbf_verify 10 10 "$RUNAS"
3915 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3917 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
3918 skip "Need OST version at least 2.10.58"
3920 do_nodes $(comma_list $(osts_nodes)) \
3921 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3922 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3923 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3924 nrs_write_read "runas -u 500 -g 1000"
3925 tbf_verify 5 5 "runas -u 500 -g 1000"
3927 do_nodes $(comma_list $(osts_nodes)) \
3928 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3929 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3930 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3932 nrs_write_read "runas -u 500"
3933 tbf_verify 20 10 "runas -u 500"
3935 do_nodes $(comma_list $(osts_nodes)) \
3936 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3937 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3938 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3939 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3940 nrs_write_read "runas -u 500"
3941 tbf_verify 10 10 "runas -u 500"
3942 tbf_verify 20 10 "runas -u 500"
3943 cleanup_77k "ext_a ext_b" "fifo"
3945 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3948 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
3949 skip "Need OST version at least 2.10.56"
3951 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3952 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3954 local output=$(do_facet ost1 lctl get_param \
3955 ost.OSS.ost_io.nrs_policies | \
3956 awk '/name: tbf/ {print;exit}' | \
3957 awk -F ': ' '{print $2}')
3959 if [ "$output" != "tbf" ]; then
3960 error "The generic TBF output is '$output', not 'tbf'"
3963 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3965 run_test 77l "check the output of NRS policies for generic TBF"
3968 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
3969 skip "Need OST version at least 2.9.54"
3972 local dir=$DIR/$tdir
3974 mkdir $dir || error "mkdir $dir failed"
3975 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3978 local nodes=$(comma_list $(osts_nodes))
3979 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3980 ost.OSS.ost_io.nrs_delay_min=4 \
3981 ost.OSS.ost_io.nrs_delay_max=4 \
3982 ost.OSS.ost_io.nrs_delay_pct=100
3983 [ $? -ne 0 ] && error "Failed to set delay policy"
3985 local start=$SECONDS
3986 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3987 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3988 oflag=direct conv=fdatasync ||
3989 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3990 error "dd on client failed (1)"; }
3991 local elapsed=$((SECONDS - start))
3993 # NRS delay doesn't do sub-second timing, so a request enqueued at
3994 # 0.9 seconds can be dequeued at 4.0
3995 [ $elapsed -lt 3 ] &&
3996 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3997 error "Single 1M write should take at least 3 seconds"; }
4000 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4001 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4002 oflag=direct conv=fdatasync ||
4003 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4004 error "dd on client failed (2)"; }
4005 elapsed=$((SECONDS - start))
4007 [ $elapsed -lt 30 ] &&
4008 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4009 error "Ten 1M writes should take at least 30 seconds"; }
4011 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4012 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4016 run_test 77m "check NRS Delay slows write RPC processing"
4018 test_77n() { #LU-10802
4019 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4020 skip "Need OST version at least 2.10.58"
4023 # Configure jobid_var
4024 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4025 if [ $saved_jobid_var != procname_uid ]; then
4026 set_persistent_param_and_check client \
4027 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4030 do_nodes $(comma_list $(osts_nodes)) \
4031 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4032 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4033 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4036 tbf_verify 20 20 "$RUNAS"
4038 do_nodes $(comma_list $(osts_nodes)) \
4039 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4040 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4045 do_nodes $(comma_list $(osts_nodes)) \
4046 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4047 ost.OSS.ost_io.nrs_policies="fifo"
4051 local current_jobid_var=$($LCTL get_param -n jobid_var)
4052 if [ $saved_jobid_var != $current_jobid_var ]; then
4053 set_persistent_param_and_check client \
4054 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4057 run_test 77n "check wildcard support for TBF JobID NRS policy"
4059 test_78() { #LU-6673
4062 oss=$(comma_list $(osts_nodes))
4063 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4064 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4066 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4067 # Valid return codes are:
4068 # 0: Tuning succeeded
4069 # ENODEV: Policy is still stopped
4070 # EAGAIN: Policy is being initialized
4071 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4072 error "Expected set_param to return 0|ENODEV|EAGAIN"
4074 # Cleanup the ORR policy
4075 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4076 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4079 run_test 78 "Enable policy and specify tunings right away"
4082 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4083 test_mkdir $DIR/$tdir
4085 # Prevent interference from layout intent RPCs due to
4086 # asynchronous writeback. These will be tested in 130c below.
4087 do_nodes ${CLIENTS:-$HOSTNAME} sync
4089 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4090 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4092 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4093 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4094 local facet=mds$((mdtidx + 1))
4096 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4097 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4101 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4102 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4107 run_test 79 "xattr: intent error"
4110 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4117 mkdir -p $DIR1/$tdir/dir
4118 createmany -o $DIR1/$tdir/dir/f 10 ||
4119 error "create files under remote dir failed $i"
4121 cp /etc/passwd $DIR1/$tdir/$tfile
4123 #migrate open file should fails
4124 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4126 # give multiop a chance to open
4129 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4130 error "migrate open files should failed with open files"
4134 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4135 error "migrate remote dir error"
4137 echo "Finish migration, then checking.."
4138 for file in $(find $DIR1/$tdir); do
4139 mdt_index=$($LFS getstripe -m $file)
4140 [ $mdt_index == $MDTIDX ] ||
4141 error "$file is not on MDT${MDTIDX}"
4144 diff /etc/passwd $DIR1/$tdir/$tfile ||
4145 error "file different after migration"
4147 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4149 run_test 80a "migrate directory when some children is being opened"
4153 kill -9 $migrate_pid
4157 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4158 local migrate_dir1=$DIR1/$tdir/migrate_dir
4159 local migrate_dir2=$DIR2/$tdir/migrate_dir
4160 local migrate_run=$LUSTRE/tests/migrate.sh
4168 trap cleanup_80b EXIT
4169 #prepare migrate directory
4170 mkdir -p $migrate_dir1
4171 for F in {1,2,3,4,5}; do
4172 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4173 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4176 #migrate the directories among MDTs
4179 mdt_idx=$((RANDOM % MDSCOUNT))
4180 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4182 [ $rc -ne 0 -o $rc -ne 16 ] || break
4187 echo "start migration thread $migrate_pid"
4188 #Access the files at the same time
4189 start_time=$(date +%s)
4190 echo "accessing the migrating directory for 5 minutes..."
4192 ls $migrate_dir2 > /dev/null || {
4193 echo "read dir fails"
4196 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4197 echo "access file1 fails"
4201 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4202 echo "access file2/3 fails"
4206 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4207 echo "access file4 fails"
4211 stat $migrate_dir2/file5 > /dev/null || {
4212 echo "stat file5 fails"
4216 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4217 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4218 echo "touch file failed with $rc1"
4222 if [ -e $migrate_dir2/source_file ]; then
4223 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4224 &>/dev/null || rc1=$?
4225 if [ -e $migrate_dir2/link_file ]; then
4226 rm -rf $migrate_dir2/link_file
4229 mrename $migrate_dir2/source_file \
4230 $migrate_dir2/target_file &>/dev/null || rc1=$?
4231 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4232 echo "rename failed with $rc1"
4236 if [ -e $migrate_dir2/target_file ]; then
4237 rm -rf $migrate_dir2/target_file &>/dev/null ||
4240 rm -rf $migrate_dir2/source_file &>/dev/null ||
4243 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4244 echo "unlink failed with $rc1"
4249 end_time=$(date +%s)
4250 duration=$((end_time - start_time))
4251 if [ $((duration % 10)) -eq 0 ]; then
4252 if [ $show_time -eq 1 ]; then
4253 echo "...$duration seconds"
4260 kill -0 $migrate_pid || {
4261 echo "migration stopped 1"
4265 [ $duration -ge 300 ] && break
4268 #check migration are still there
4269 kill -0 $migrate_pid || error "migration stopped 2"
4272 run_test 80b "Accessing directory during migration"
4275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4279 mkdir -p $DIR1/$tdir
4281 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4282 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4285 touch d0/0 || error "create 0 failed"
4286 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4287 stat d0/0 && error "stat mv filed succeed"
4288 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4289 stat d0/0 || error "stat failed"
4291 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4293 if [ $t -ne 3 ]; then
4294 ls -ai $DIR1/$tdir/d0
4295 error "expect 3 get $t"
4300 run_test 81a "rename and stat under striped directory"
4303 [ $MDSCOUNT -lt 2 ] &&
4304 skip "We need at least 2 MDTs for this test"
4311 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4312 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4321 for i in $(seq $total); do
4322 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4326 kill -9 $setattr_pid
4328 run_test 81b "rename under striped directory doesn't deadlock"
4331 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4332 skip "Need MDS version at least 2.6.92"
4334 # Client 1 creates a file.
4335 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4337 # Client 2 opens the file.
4338 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4340 # Client 1 makes the file an orphan.
4341 rm $DIR1/$tfile || error "rm"
4342 # Client 2 sets EA "user.multiop".
4344 wait $pid2 || error "multiop 2"
4345 # Client 1 gets EA "user.multiop". This used to fail because the EA
4346 # cache refill would get "trusted.link" from mdd_xattr_list() but
4347 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4350 wait $pid1 || error "multiop 1"
4352 run_test 82 "fsetxattr and fgetxattr on orphan files"
4355 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4362 $LFS mkdir -i1 -c2 $tdir
4367 echo "start pid $pid1 to create/unlink striped directory"
4369 # Access the directory at the same time
4373 stat $tdir > /dev/null 2>&1
4377 echo "start pid $pid2 to stat striped directory"
4385 run_test 83 "access striped directory while it is being created/unlinked"
4388 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4389 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4393 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4394 error "create $tfile failed"
4395 mtime=$(stat -c%Y $DIR/$tfile)
4396 mtime=$((mtime + 200))
4398 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4399 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4401 touch -c -m $mtime $DIR/$tfile &
4403 # sleep a while to let 'touch' run first
4405 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4408 wait $setattr_pid || true
4410 run_test 84 "0-nlink race in lu_object_find()"
4413 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4418 [ "$SLOW" = "yes" ] && duration=600
4419 # Open/Create under striped directory
4423 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4424 touch $tdir/f{0..3} > /dev/null 2>&1
4428 echo "start pid $pid1 to open/create under striped directory"
4430 # unlink the striped directory at the same time
4434 rm -rf $tdir > /dev/null 2>&1
4438 echo "start pid $pid2 to unlink striped directory"
4447 run_test 90 "open/create and unlink striped directory"
4450 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4455 [ "$SLOW" = "yes" ] && duration=600
4456 # chmod striped directory
4460 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4461 chmod go+w $tdir > /dev/null 2>&1
4465 echo "start pid $pid1 to chmod striped directory"
4467 # unlink the striped directory at the same time
4471 rm -rf $tdir > /dev/null 2>&1
4475 echo "start pid $pid2 to unlink striped directory"
4484 run_test 91 "chmod and unlink striped directory"
4487 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4490 local cmd="exec $fd<$DIR1/$tdir"
4491 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4494 trap "eval $cmd" EXIT
4495 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4496 rmdir ../$tdir || error "rmdir ../$tdir fails"
4498 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4499 $LCTL set_param fail_loc=0x1408
4500 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4501 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4502 error "create remote dir succeeds"
4503 $LCTL set_param fail_loc=0
4507 run_test 92 "create remote directory under orphan directory"
4514 mkdir -p $DIR1/$tfile-1/
4515 mkdir -p $DIR2/$tfile-2/
4516 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4517 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4518 do_facet $SINGLEMDS "$LCTL set_param -n \
4519 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4520 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4521 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4523 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4526 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4530 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4531 do_facet $SINGLEMDS "$LCTL set_param -n \
4532 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4534 $LFS getstripe $DIR1/$tfile-1/file1
4535 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4536 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4537 $LFS getstripe $DIR2/$tfile-2/file2
4538 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4539 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4540 echo "rc1=$rc1 and rc2=$rc2 "
4541 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4542 error "object allocate on same ost detected"
4544 run_test 93 "alloc_rr should not allocate on same ost"
4547 $LCTL set_param osc.*.idle_timeout=0
4548 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4550 local before=$(date +%s)
4554 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4555 $LCTL set_param fail_val=5 fail_loc=0x80000312
4556 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4560 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4561 $LCTL set_param fail_val=6 fail_loc=0x80000329
4562 $LCTL mark kill $pid
4565 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4568 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4570 evict=$(do_facet client $LCTL get_param \
4571 osc.$FSNAME-OST*-osc-*/state |
4572 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4574 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4575 (do_facet client $LCTL get_param \
4576 osc.$FSNAME-OST*-osc-*/state;
4577 error "eviction happened: $evict before:$before")
4578 $LCTL set_param osc.*.idle_timeout=debug
4580 run_test 94 "signal vs CP callback race"
4584 skip "Reserved for glimpse-ahead" && return
4585 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4586 skip "Need MDS version at least 2.10.55"
4590 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4592 lctl set_param -n mdc.*.stats=clear
4593 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4595 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4596 # first stat from server should return size data and save glimpse
4597 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4598 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4599 # second stat to check size is NOT cached on client without IO lock
4600 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4602 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4603 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4606 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4609 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4610 skip "Need MDS version at least 2.10.55"
4614 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4616 lctl set_param -n mdc.*.stats=clear
4617 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4618 cancel_lru_locks mdc
4619 # first stat data from server should have size
4620 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4621 # second stat to check size is cached on client
4622 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4624 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4625 # both stats should cause no glimpse requests
4626 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4629 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4632 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4633 skip "Need MDS version at least 2.10.55"
4637 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4639 lctl set_param -n mdc.*.stats=clear
4640 lctl set_param -n osc.*.stats=clear
4641 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4643 # check that size is merged from MDT and OST correctly
4644 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4645 error "Wrong size from stat #1"
4647 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4648 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4652 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4655 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4656 skip "Need MDS version at least 2.10.55"
4660 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4663 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4664 lctl set_param -n mdc.*.stats=clear
4665 $TRUNCATE $DIR2/$tdir/dom 4096
4667 # check that reported size is valid after file grows to OST and
4668 # is truncated back to MDT stripe size
4669 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4670 error "Wrong size from stat #1"
4672 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4673 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4677 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4680 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
4681 skip "Need MDS version at least 2.11.50"
4683 local dom=$DIR/$tdir/dom
4684 local dom2=$DIR2/$tdir/dom
4687 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4689 cancel_lru_locks mdc
4690 dd if=/dev/urandom of=$dom bs=12000 count=1
4691 $TRUNCATE $dom2 6000
4692 cancel_lru_locks mdc
4693 lctl set_param -n mdc.*.stats=clear
4694 # expect read-on-open to return all data before write
4695 cat /etc/hosts >> $dom
4696 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4697 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4699 run_test 100e "DoM: read on open and file size"
4702 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4703 skip "Need MDS version at least 2.10.55"
4705 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4707 $CHECKSTAT -t file $DIR1/$tfile
4709 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4710 sysctl -wq vm.dirty_writeback_centisecs=0
4712 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4715 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4716 error_noexit "Write fails"
4717 # must discard pages
4718 lctl set_param -n mdc.*.stats=clear
4719 rm $DIR2/$tfile || error "Unlink fails"
4721 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4722 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4724 run_test 101a "Discard DoM data on unlink"
4727 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4728 skip "Need MDS version at least 2.10.55"
4730 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4731 touch $DIR1/${tfile}_2
4733 $CHECKSTAT -t file $DIR1/$tfile
4735 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4736 sysctl -wq vm.dirty_writeback_centisecs=0
4738 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4741 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4742 # must discard pages
4743 lctl set_param -n mdc.*.stats=clear
4744 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4746 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4747 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4749 run_test 101b "Discard DoM data on rename"
4752 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4753 skip "Need MDS version at least 2.10.55"
4755 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4757 $CHECKSTAT -t file $DIR1/$tfile
4759 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4760 sysctl -wq vm.dirty_writeback_centisecs=0
4762 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4765 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4766 $MULTIOP $DIR1/$tfile O_c &
4769 lctl set_param -n mdc.*.stats=clear
4770 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4771 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4773 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4774 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4776 run_test 101c "Discard DoM data on close-unlink"
4778 # test to verify file handle related system calls
4779 # (name_to_handle_at/open_by_handle_at)
4780 # The new system calls are supported in glibc >= 2.14.
4782 # test to verify we can open by handle an unlinked file from > 1 client
4783 # This test opens the file normally on $DIR1, which is on one mount, and then
4784 # opens it by handle on $DIR2, which is on a different mount.
4786 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
4787 skip "Needs MDS version 2.11.57 or later"
4789 echo "Test file_handle syscalls" > $DIR/$tfile ||
4790 error "write failed"
4791 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4792 error "check_fhandle_syscalls failed"
4795 run_test 102 "Test open by handle of unlinked file"
4797 # Compare file size between first & second mount, ensuring the client correctly
4798 # glimpses even with unused speculative locks - LU-11670
4800 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
4801 skip "Lockahead needs OST version at least 2.10.50"
4805 test_mkdir -p $DIR/$tdir
4807 # Force file on to OST0
4808 $LFS setstripe -i 0 $DIR/$tdir
4810 # Do not check multiple locks on glimpse
4811 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
4812 $LCTL set_param fail_loc=0x415
4814 # Delay write commit by 2 seconds to guarantee glimpse wins race
4815 # The same fail_loc is used on client & server so it can work in the
4816 # single node sanity setup
4817 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
4819 echo "Incorrect size expected (no glimpse fix):"
4820 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
4822 if [ $rc -eq 0 ]; then
4823 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
4826 # guarantee write commit timeout has expired
4829 # Clear fail_loc on client
4830 $LCTL set_param fail_loc=0
4832 # Delay write commit by 2 seconds to guarantee glimpse wins race
4833 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4834 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
4836 # Write commit is still delayed by 2 seconds
4837 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
4839 [ $rc -eq 0 ] || error "Lockahead test${testnum} failed, ${rc}"
4841 # guarantee write commit timeout has expired
4844 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
4846 run_test 103 "Test size correctness with lockahead"
4852 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
4863 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
4864 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
4865 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
4866 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
4874 local xtimes=($(get_stat_xtimes))
4875 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4877 echo "STAT a|m|ctime ${xtimes[*]}"
4878 echo "MDT a|m|ctime ${xtimes[*]}"
4879 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
4880 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
4881 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4882 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4883 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4884 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4888 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
4889 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
4890 skip "Need MDS version at least 2.12.4"
4893 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
4894 local atime_diff=$(do_facet $SINGLEMDS \
4895 lctl get_param -n mdd.*MDT0000*.atime_diff)
4897 do_facet $SINGLEMDS \
4898 lctl set_param -n mdd.*MDT0000*.atime_diff=0
4900 stack_trap "do_facet $SINGLEMDS \
4901 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
4903 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4904 check_mdt_xtimes $mdtdev
4907 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4908 check_mdt_xtimes $mdtdev
4910 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
4913 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4915 kill -USR1 $pid && wait $pid || error "multiop failure"
4916 check_mdt_xtimes $mdtdev
4921 # Verify mtime/ctime is NOT upated on MDS when there is no modification
4922 # on the client side
4923 xtimes=($(get_stat_xtimes))
4924 $MULTIOP $DIR/$tfile O_c &
4927 kill -USR1 $pid && wait $pid || error "multiop failure"
4928 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4929 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4930 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4931 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4932 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4933 check_mdt_xtimes $mdtdev
4936 # Change ctime via chmod
4937 $MULTIOP $DIR/$tfile o_tc &
4940 kill -USR1 $pid && wait $pid || error "multiop failure"
4941 check_mdt_xtimes $mdtdev
4943 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
4946 test_mkdir -p $DIR/$tdir
4947 echo test > $DIR/$tdir/$tfile
4948 $LCTL set_param fail_loc=0x416
4949 cancel_lru_locks osc & sleep 1
4950 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
4952 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
4954 run_test 105 "Glimpse and lock cancel race"
4956 log "cleanup: ======================================================"
4958 # kill and wait in each test only guarentee script finish, but command in script
4959 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4960 # otherwise umount below will fail
4961 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4966 check_and_cleanup_lustre