8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 # skip tests for PPC until they are fixed
26 if [[ $(uname -m) = ppc64 ]]; then
27 # bug number: LU-11597 LU-11787
28 ALWAYS_EXCEPT+=" 16a 71a"
31 if [ $mds1_FSTYPE = "zfs" ]; then
32 # LU-2829 / LU-2887 - make allowances for ZFS slowness
33 TEST33_NFILES=${TEST33_NFILES:-1000}
37 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
46 check_and_setup_lustre
51 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
53 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
54 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
56 # $RUNAS_ID may get set incorrectly somewhere else
57 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
59 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
63 [ -f $DIR2/$tfile ] || error "Check create"
64 chmod 777 $DIR2/$tfile
65 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
66 error "Check attribute update for 0777"
68 chmod a-x $DIR2/$tfile
69 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
70 error "Check attribute update for 0666"
73 $CHECKSTAT -a $DIR1/$tfile ||
74 error "Check unlink - removes file on other mountpoint"
76 run_test 1 "Check attribute updates on 2 mount points"
82 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
83 error "Either not file type or perms not 0777"
85 run_test 2a "check cached attribute updates on 2 mtpt's ========"
91 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
92 error "Either not file type or perms not 0777"
94 run_test 2b "check cached attribute updates on 2 mtpt's ========"
96 # NEED TO SAVE ROOT DIR MODE
99 $CHECKSTAT -t dir -p 0777 $DIR2 ||
100 error "Either not dir type or perms not 0777"
102 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
106 $CHECKSTAT -t dir -p 0755 $DIR2 ||
107 error "Either not file type or perms not 0775"
109 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
116 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
119 run_test 2e "check chmod on root is propagated to others"
122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
124 local remote_dir=$tdir/remote_dir
127 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
128 error "Create remote directory failed"
130 touch $DIR1/$remote_dir/$tfile ||
131 error "Create file under remote directory failed"
132 chmod 777 $DIR1/$remote_dir/$tfile ||
133 error "Chmod file under remote directory failed"
135 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
136 error "Check attr of file under remote directory failed"
138 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
139 error "Chown file under remote directory failed"
141 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
142 error "Check owner of file under remote directory failed"
144 cd $DIR2/$remote_dir || error "enter remote dir"
145 rm -rf $DIR1/$remote_dir/$tfile ||
146 error "Unlink remote directory failed"
148 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
149 error "unlink file still exists!"
151 cd $DIR2/$tdir || error "exit remote dir"
152 rm -rf $DIR1/$tdir || error "unlink directory failed"
154 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
157 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
159 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
161 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
162 echo "$DIR1/$tfile has $block1 blocks"
163 echo "$DIR2/$tfile has $block2 blocks"
164 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
166 run_test 2g "check blocks update on sync write"
169 local target="this/is/good"
170 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
171 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
172 error "link $DIR2/$tfile not as expected"
174 run_test 3 "symlink on one mtpt, readlink on another ==========="
177 multifstat $DIR1/f4 $DIR2/f4
179 run_test 4 "fstat validation on multiple mount points =========="
183 $TRUNCATE $DIR2/f5 100
184 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
185 error "Either not file type or size not equal to 100 bytes"
188 run_test 5 "create a file on one mount, truncate it on the other"
191 openunlink $DIR1/$tfile $DIR2/$tfile || \
192 error "openunlink $DIR1/$tfile $DIR2/$tfile"
194 run_test 6 "remove of open file on other node =================="
198 opendirunlink $DIR1/$dir $DIR2/$dir || \
199 error "opendirunlink $DIR1/$dir $DIR2/$dir"
201 run_test 7 "remove of open directory on other node ============="
204 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
205 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
207 run_test 8 "remove of open special file on other node =========="
213 for C in a b c d e f g h i j k l; do
214 dir=`eval echo \\$DIR$MTPT`
215 echo -n $C >> $dir/f9
216 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
218 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
219 error "`od -a $DIR1/f9` != abcdefghijkl"
221 run_test 9a "append of file with sub-page size on multiple mounts"
223 #LU-10681 - tiny writes & appending to sparse striped file
225 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
227 $LFS setstripe -c 2 -S 1M $DIR/$tfile
228 echo "foo" >> $DIR/$tfile
229 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
230 error "sparse dd $DIR2/$tfile failed"
231 echo "foo" >> $DIR/$tfile
233 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
234 echo "Data read (expecting 'foo')": $data
235 [ "$data" = "foo" ] || error "append to sparse striped file failed"
237 run_test 9b "append to striped sparse file"
244 for C in a b c d e f g h i j k l; do
245 dir=`eval echo \\$DIR$MTPT`
246 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
247 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
248 OFFSET=`expr $OFFSET + 1`
250 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
251 error "`od -a $DIR1/f10` != abcdefghijkl"
253 run_test 10a "write of file with sub-page size on multiple mounts "
257 yes "R" | head -c 4000 >$TMP/f10b-seed
258 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
260 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
262 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
264 # create a test file locally to compare
265 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
266 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
267 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
268 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
270 run_test 10b "write of file with sub-page size on multiple mounts "
274 multiop_bg_pause $DIR1/d11/f O_c || return 1
276 cp -p /bin/ls $DIR1/d11/f
280 wait $MULTIPID || error "wait for PID $MULTIPID failed"
281 [ $RC -eq 0 ] && error || true
283 run_test 11 "execution of file opened for write should return error ===="
286 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
288 run_test 12 "test lock ordering (link, stat, unlink)"
290 test_13() { # bug 2451 - directory coherency
292 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
294 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
296 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
297 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
298 # need to run it twice
299 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
301 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
302 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
304 run_test 13 "test directory page revocation"
307 test_mkdir $DIR1/$tdir
308 cp -p /bin/ls $DIR1/$tdir/$tfile
309 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
312 $DIR2/$tdir/$tfile && error || true
315 run_test 14aa "execution of file open for write returns -ETXTBSY"
318 test_mkdir $DIR1/$tdir
319 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
320 $DIR1/$tdir/sleep 60 &
322 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
325 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
327 test_14b() { # bug 3192, 7040
328 test_mkdir $DIR1/$tdir
329 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
330 $DIR1/$tdir/sleep 60 &
332 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
333 error "expected truncate error, got success"
335 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
337 run_test 14b "truncate of executing file returns -ETXTBSY ======"
339 test_14c() { # bug 3430, 7040
340 test_mkdir $DIR1/$tdir
341 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
342 $DIR1/$tdir/sleep 60 &
344 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
346 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
348 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
350 test_14d() { # bug 10921
351 test_mkdir $DIR1/$tdir
352 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
353 $DIR1/$tdir/sleep 60 &
356 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
358 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
360 run_test 14d "chmod of executing file is still possible ========"
362 test_15() { # bug 974 - ENOSPC
364 sh oos2.sh $MOUNT1 $MOUNT2
365 wait_delete_completed
366 grant_error=$(dmesg | grep "< tot_grant")
367 [ -z "$grant_error" ] || error "$grant_error"
369 run_test 15 "test out-of-space with multiple writers ==========="
372 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
373 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
374 # pass a 2500 operation dual-mount run within the time limit.
375 if [ "$ost1_FSTYPE" = "zfs" ]; then
376 FSXNUM=$((COUNT / 5))
378 elif [ "$SLOW" = "yes" ]; then
379 FSXNUM=$((COUNT * 5))
387 local file1=$DIR1/$tfile
388 local file2=$DIR2/$tfile
389 local stripe_size=$(do_facet $SINGLEMDS \
390 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
392 # to allocate grant because it may run out due to test_15.
393 $LFS setstripe -c -1 $file1
394 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
395 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
398 $LFS setstripe -c -1 $file1 # b=10919
399 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
400 || error "fsx failed"
403 # O_DIRECT reads and writes must be aligned to the device block size.
404 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
405 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
407 run_test 16a "$FSXNUM iterations of dual-mount fsx"
409 # Consistency check for tiny writes, LU-9409
411 local file1=$DIR1/$tfile
412 local file2=$DIR2/$tfile
413 local stripe_size=($($LFS getstripe -S $DIR))
415 # to allocate grant because it may run out due to test_15.
416 lfs setstripe -c -1 $file1
417 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
418 error "dd failed writing to file=$file1"
419 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
420 error "dd failed writing to file=$file2"
423 lfs setstripe -c -1 $file1 # b=10919
424 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
425 # create a mix of tiny writes & normal writes
426 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
427 $file2 || error "fsx with tiny write failed."
429 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
432 local file1=$DIR1/$tfile
433 local file2=$DIR2/$tfile
434 local stripe_size=$(do_facet $SINGLEMDS \
435 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
437 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
439 # to allocate grant because it may run out due to test_15.
440 $LFS setstripe -c -1 $file1
441 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
442 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
444 wait_delete_completed
446 local list=$(comma_list $(osts_nodes))
447 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
448 skip "not cache-capable obdfilter"
451 set_osd_param $list '' read_cache_enable 0
452 set_osd_param $list '' writethrough_cache_enable 0
454 $LFS setstripe -c -1 $file1 # b=10919
455 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
456 || error "fsx failed"
459 set_osd_param $list '' read_cache_enable 1
460 set_osd_param $list '' writethrough_cache_enable 1
464 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
467 local file1=$DIR1/$tfile
468 local file2=$DIR2/$tfile
469 local file3=$DIR1/file
470 local stripe_size=$(do_facet $SINGLEMDS \
471 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
473 # to allocate grant because it may run out due to test_15.
474 $LFS setstripe -c -1 $file1
475 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
476 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
479 local tmpfile=`mktemp`
480 $LFS setstripe -c -1 $file1 # b=10919
481 $LCTL set_param ldlm.namespaces.*.lru_size=clear
483 # direct write on one client and direct read from another
484 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
485 dd if=$file2 of=$tmpfile iflag=direct bs=1M
486 diff $file1 $tmpfile || error "file different(1)"
489 # buffer write on one client, but direct read from another
490 dd if=$tmpfile of=$file1 bs=1M count=100
491 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
492 diff $file3 $tmpfile || error "file different(2)"
494 rm -f $file3 $file2 $file1
495 # direct write on one client
496 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
497 # buffer read from another client
498 dd if=$file2 of=$file3 bs=1M count=100
499 diff $file3 $tmpfile || error "file different(3)"
501 rm -f $file1 $file2 $file3 $tmpfile
504 run_test 16d "Verify DIO and buffer IO with two clients"
507 test_17() { # bug 3513, 3667
508 remote_ost_nodsh && skip "remote OST with nodsh" && return
510 lfs setstripe $DIR1/$tfile -i 0 -c 1
511 cp $SAMPLE_FILE $DIR1/$tfile
512 cancel_lru_locks osc > /dev/null
513 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
514 do_facet ost1 lctl set_param fail_loc=0x8000030a
515 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
516 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
518 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
520 run_test 17 "resource creation/LVB creation race ==============="
523 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
526 for idx in {a..z}; do
527 local ptr=EXCEPT_ALWAYS_18$idx
528 [ x${!ptr} = xtrue ] || continue
530 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
533 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
536 run_test 18 "mmap sanity check ================================="
538 test_19() { # bug3811
539 local node=$(facet_active_host ost1)
541 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
543 # check whether obdfilter is cache capable at all
544 get_osd_param $node '' read_cache_enable >/dev/null ||
545 skip "not cache-capable obdfilter"
547 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
548 set_osd_param $node '' readcache_max_filesize 4096
549 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
550 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
551 cp $TMP/$tfile $DIR1/$tfile
552 for i in `seq 1 20`; do
553 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
554 cancel_lru_locks $OSC > /dev/null
555 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
556 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
558 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
559 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
560 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
561 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
563 set_osd_param $node '' readcache_max_filesize $MAX
566 run_test 19 "test concurrent uncached read races ==============="
570 cancel_lru_locks $OSC
571 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
572 $MULTIOP $DIR1/f20 Ow8190c
573 $MULTIOP $DIR2/f20 Oz8194w8190c
574 $MULTIOP $DIR1/f20 Oz0r8190c
575 cancel_lru_locks $OSC
576 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
578 error $CNTD" page left in cache after lock cancel" || true
580 run_test 20 "test extra readahead page left in cache ===="
587 test_21() { # Bug 5907
588 test_mkdir $DIR1/$tdir
589 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
591 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
592 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
593 test -d $DIR1/$tdir || error "Mounted directory disappeared"
595 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
598 run_test 21 " Try to remove mountpoint on another dir ===="
600 test_23() { # Bug 5972
601 local at_diff=$(do_facet $SINGLEMDS \
602 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
603 echo "atime should be updated while another read" > $DIR1/$tfile
605 # clear the lock(mode: LCK_PW) gotten from creating operation
606 cancel_lru_locks $OSC
609 sleep $((at_diff + 1))
611 echo "starting reads"
612 multiop_bg_pause $DIR1/$tfile or20_c || return 1
613 # with SOM and opencache enabled, we need to close a file and cancel
614 # open lock to get atime propogated to MDS
615 kill -USR1 $! || return 2
618 time2=$(stat -c "%X" $DIR/$tfile)
619 echo "new atime is $time2"
621 [ $time2 -gt $time1 ] || error "atime was not updated"
622 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
625 run_test 23 " others should see updated atime while another read===="
629 lfs df || error "lfs df failed"
630 lfs df -ih || error "lfs df -ih failed"
631 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
632 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
633 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
634 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
636 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
637 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
638 lctl --device %osc deactivate
639 lfs df -i || error "lfs df -i with deactivated OSC failed"
640 lctl --device %osc activate
641 lfs df || error "lfs df with reactivated OSC failed"
643 run_test 24a "lfs df [-ih] [path] test ========================="
647 fsnum=$(lfs_df | grep -c "summary")
648 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
650 run_test 24b "lfs df should show both filesystems ==============="
653 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
655 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
658 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
659 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
661 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
662 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
663 error "setfacl $DIR2/$tdir #1"
664 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
665 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
666 error "setfacl $DIR2/$tdir #2"
667 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
668 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
669 error "setfacl $DIR2/$tdir #3"
670 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
671 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
672 error "setfacl $DIR2/$tdir #4"
673 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
677 run_test 25a "change ACL on one mountpoint be seen on another ==="
680 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
682 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
684 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
687 $LFS mkdir -i 1 $DIR1/$tdir
688 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
689 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
691 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
692 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
693 error "setfacl $DIR2/$tdir #1"
694 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
695 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
696 error "setfacl $DIR2/$tdir #2"
697 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
698 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
699 error "setfacl $DIR2/$tdir #3"
700 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
701 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
702 error "setfacl $DIR2/$tdir #4"
703 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
707 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
710 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
712 run_test 26a "allow mtime to get older"
717 echo "aaa" >> $DIR1/$tfile
719 chmod a+x $DIR2/$tfile
720 mt1=`stat -c %Y $DIR1/$tfile`
721 mt2=`stat -c %Y $DIR2/$tfile`
723 if [ x"$mt1" != x"$mt2" ]; then
724 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
727 run_test 26b "sync mtime between ost and mds"
730 cancel_lru_locks $OSC
732 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
737 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
742 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
744 lctl set_param -n ldlm.dump_namespaces ""
745 wait $DD1_PID $DD2_PID
746 [ $? -ne 0 ] && lctl dk $TMP/debug || true
748 run_test 27 "align non-overlapping extent locks from request ==="
750 test_28() { # bug 9977
751 ECHO_UUID="ECHO_osc1_UUID"
752 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
754 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
755 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
756 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
760 attach echo_client ECHO_osc1 $ECHO_UUID
764 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
765 $LCTL --device $tECHOID destroy "${tOBJID}:0"
773 # reading of 1st stripe should pass
774 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
775 # reading of 2nd stripe should fail (this stripe was destroyed)
776 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
778 # now, recreating test file
779 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
780 # reading of 1st stripe should pass
781 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
782 # reading of 2nd stripe should pass
783 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
786 run_test 28 "read/write/truncate file with lost stripes"
788 test_30() { #b=11110, LU-2523
789 test_mkdir $DIR1/$tdir
790 cp -f /bin/bash $DIR1/$tdir/bash
791 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
792 $DIR1/$tdir/bash -c 'sleep 2;
793 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
797 run_test 30 "recreate file race"
800 test_mkdir $DIR1/$tdir
801 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
802 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
803 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
804 lctl set_param fail_loc=0x314
805 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
806 awk 'BEGIN { FS="+" } /in/ {print $1}')
807 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
809 run_test 31a "voluntary cancel / blocking ast race=============="
812 remote_ost || { skip "local OST" && return 0; }
813 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
815 # make sure there is no local locks due to destroy
816 wait_mds_ost_sync || error "wait_mds_ost_sync()"
817 wait_delete_completed || error "wait_delete_completed()"
819 test_mkdir $DIR1/$tdir
820 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
821 cp /etc/hosts $DIR/$tdir/$tfile
822 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
823 lctl set_param fail_loc=0x314
824 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
825 do_facet ost1 lctl set_param fail_loc=0x316
827 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
828 lctl set_param fail_loc=0
829 do_facet ost1 lctl set_param fail_loc=0
830 # cleanup: reconnect the client back
833 run_test 31b "voluntary OST cancel / blocking ast race=============="
835 # enable/disable lockless truncate feature, depending on the arg 0/1
836 enable_lockless_truncate() {
837 lctl set_param -n $OSC.*.lockless_truncate $1
840 test_32a() { # bug 11270
841 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
842 local stripe_size=$(do_facet $SINGLEMDS \
843 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
845 save_lustre_params client "$OSC.*.lockless_truncate" > $save
846 # restore lockless_truncate default values on exit
847 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
848 cancel_lru_locks $OSC
849 enable_lockless_truncate 1
851 lfs setstripe -c -1 $DIR1/$tfile
852 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
854 clear_stats $OSC.*.${OSC}_stats
856 log "checking cached lockless truncate"
857 $TRUNCATE $DIR1/$tfile 8000000
858 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
859 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
860 error "cached truncate isn't lockless"
862 log "checking not cached lockless truncate"
863 $TRUNCATE $DIR2/$tfile 5000000
864 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
865 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
866 error "not cached truncate isn't lockless"
868 log "disabled lockless truncate"
869 enable_lockless_truncate 0
870 clear_stats $OSC.*.${OSC}_stats
871 $TRUNCATE $DIR2/$tfile 3000000
872 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
873 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
874 error "lockless truncate disabling failed"
877 run_test 32a "lockless truncate"
879 test_32b() { # bug 11270
880 remote_ost_nodsh && skip "remote OST with nodsh" && return
883 local facets=$(get_facets OST)
884 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
886 save_lustre_params client "osc.*.contention_seconds" > $p
887 save_lustre_params $facets \
888 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
889 save_lustre_params $facets \
890 "ldlm.namespaces.filter-*.contended_locks" >> $p
891 save_lustre_params $facets \
892 "ldlm.namespaces.filter-*.contention_seconds" >> $p
893 clear_stats $OSC.*.${OSC}_stats
895 # agressive lockless i/o settings
896 do_nodes $(comma_list $(osts_nodes)) \
897 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
898 ldlm.namespaces.filter-*.contended_locks=0 \
899 ldlm.namespaces.filter-*.contention_seconds=60"
900 lctl set_param -n $OSC.*.contention_seconds=60
902 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
904 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
907 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
908 error "lockless i/o was not triggered"
909 # disable lockless i/o (it is disabled by default)
910 do_nodes $(comma_list $(osts_nodes)) \
911 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
912 ldlm.namespaces.filter-*.contended_locks=32 \
913 ldlm.namespaces.filter-*.contention_seconds=0"
914 # set contention_seconds to 0 at client too, otherwise Lustre still
915 # remembers lock contention
916 lctl set_param -n $OSC.*.contention_seconds=0
917 clear_stats $OSC.*.${OSC}_stats
919 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
921 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
924 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
925 error "lockless i/o works when disabled"
927 restore_lustre_params <$p
930 run_test 32b "lockless i/o"
934 local mdts=$(get_facets MDS)
939 for mds in ${mdts//,/ }; do
941 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
942 xargs readlink -f" ))
943 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
946 stat=$(( stat + val))
951 # commit on sharing tests
953 remote_mds_nodsh && skip "remote MDS with nodsh" && return
955 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
956 [ $CLIENTCOUNT -lt 2 ] &&
957 skip "Need two or more clients, have $CLIENTCOUNT"
959 local nfiles=${TEST33_NFILES:-10000}
960 local param_file=$TMP/$tfile-params
966 save_lustre_params $(get_facets MDS) \
967 "mdt.*.commit_on_sharing" > $param_file
970 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
974 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
976 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
977 echo "=== START createmany old: $jbdold transaction"
978 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")
979 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
980 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
981 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
982 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
983 avgtime=$(( avgtime + elapsed ))
985 eval cos${COS}_jbd=$((avgjbd / 3))
986 eval cos${COS}_time=$((avgtime / 3))
989 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
990 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
991 [ "$cos0_jbd" != 0 ] &&
992 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
993 [ "$cos0_time" != 0 ] &&
994 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
996 restore_lustre_params < $param_file
1000 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1002 # commit on sharing tests
1004 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1006 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1007 [ $CLIENTCOUNT -ge 2 ] ||
1008 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1010 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1012 local nfiles=${TEST33_NFILES:-10000}
1013 local param_file=$TMP/$tfile-params
1015 save_lustre_params $(get_facets MDS) \
1016 "mdt.*.commit_on_sharing" > $param_file
1025 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1029 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1030 $DIR1/$tdir-\\\$(hostname)-$i"
1032 jbdold=$(print_jbd_stat)
1033 echo "=== START createmany old: $jbdold transaction"
1034 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1035 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1036 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1038 jbdnew=$(print_jbd_stat)
1039 jbd=$(( jbdnew - jbdold ))
1040 echo "=== END createmany new: $jbdnew transaction : \
1041 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1042 avgjbd=$(( avgjbd + jbd ))
1043 avgtime=$(( avgtime + elapsed ))
1045 eval cos${COS}_jbd=$((avgjbd / 3))
1046 eval cos${COS}_time=$((avgtime / 3))
1049 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1050 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1051 [ "$cos0_jbd" != 0 ] &&
1052 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1053 [ "$cos0_time" != 0 ] &&
1054 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1056 restore_lustre_params < $param_file
1060 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1063 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1064 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1065 skip "DNE CoS not supported"
1071 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1072 # do twice in case transaction is committed before unlock, see LU-8200
1074 # remote dir is created on MDT1, which enqueued lock of $tdir on
1076 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1077 mkdir $DIR/$tdir/local.$i
1079 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1080 echo "sync_count $sync_count"
1081 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1084 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1085 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1086 # during sleep remote mkdir should have been committed and canceled
1087 # remote lock spontaneously, which shouldn't trigger sync
1089 mkdir $DIR/$tdir/local.3
1090 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1091 echo "sync_count $sync_count"
1092 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1094 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1096 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1100 local nodes=$(comma_list $(mdts_nodes))
1104 # trigger CoS twice in case transaction commit before unlock
1107 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1109 commit_nr=$(do_nodes $nodes \
1110 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1111 total=$((total + commit_nr));
1116 echo "CoS count $total"
1117 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1121 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1122 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1123 skip "DNE CoS not supported"
1125 # remote directory create
1126 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1127 # remote directory unlink
1128 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1129 # striped directory create
1130 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1131 # striped directory setattr
1132 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1133 "chmod 713 $DIR/$tdir"
1134 # striped directory unlink
1135 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
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/tgt" \
1142 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1144 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1145 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1146 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1147 touch $DIR/$tdir/d1/src" \
1148 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1150 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1151 "$LFS migrate -m 1 $DIR/$tdir"
1155 run_test 33d "DNE distributed operation should trigger COS"
1158 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1159 [ $CLIENTCOUNT -ge 2 ] ||
1160 skip "Need two or more clients, have $CLIENTCOUNT"
1161 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1162 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1163 skip "DNE CoS not supported"
1165 local client2=${CLIENT2:-$(hostname)}
1169 local nodes=$(comma_list $(mdts_nodes))
1170 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1172 $LFS mkdir -c 2 $DIR/$tdir
1173 mkdir $DIR/$tdir/subdir
1174 echo abc > $DIR/$tdir/$tfile
1175 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1176 do_node $client2 touch $DIR/$tdir/subdir
1178 local async_commit_count=$(do_nodes $nodes \
1179 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1180 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1184 run_test 33e "DNE local operation shouldn't trigger COS"
1186 # End commit on sharing tests
1188 get_ost_lock_timeouts() {
1189 local nodes=${1:-$(comma_list $(osts_nodes))}
1191 local locks=$(do_nodes $nodes \
1192 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1200 do_nodes $(comma_list $(osts_nodes)) \
1201 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1202 for i in $(seq $OSTCOUNT); do
1203 wait_osc_import_ready client ost$i
1208 remote_ost_nodsh && skip "remote OST with nodsh" && return
1212 trap cleanup_34 EXIT RETURN
1213 for OPER in notimeout timeout ; do
1214 rm $DIR1/$tfile 2>/dev/null
1215 lock_in=$(get_ost_lock_timeouts)
1216 if [ $OPER == "timeout" ] ; then
1217 for j in `seq $OSTCOUNT`; do
1218 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1219 do_facet ost$j lctl set_param fail_loc=0x511
1221 echo lock should expire
1223 for j in `seq $OSTCOUNT`; do
1224 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1225 do_facet ost$j lctl set_param fail_loc=0x512
1227 echo lock should not expire
1229 echo writing on client1
1230 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1232 echo reading on client2
1233 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1234 # wait for a lock timeout
1236 lock_out=$(get_ost_lock_timeouts)
1237 if [ $OPER == "timeout" ] ; then
1238 if [ $lock_in == $lock_out ]; then
1239 error "no lock timeout happened"
1244 if [ $lock_in != $lock_out ]; then
1245 error "lock timeout happened"
1253 run_test 34 "no lock timeout under IO"
1255 test_35() { # bug 17645
1258 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1259 awk '/generation/{print $2}')
1261 generation[count]=$g
1265 test_mkdir $MOUNT1/$tdir
1266 cancel_lru_locks mdc
1268 # Let's initiate -EINTR situation by setting fail_loc and take
1269 # write lock on same file from same client. This will not cause
1270 # bl_ast yet as lock is already in local cache.
1271 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1272 do_facet client "lctl set_param fail_loc=0x80000317"
1273 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1274 let timeout=timeout*3
1276 while test $nr -lt 10; do
1277 log "Race attempt $nr"
1278 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1279 awk '/ldlm_bl_callback/ { print $2 }')
1280 test "x$blk1" = "x" && blk1=0
1281 createmany -o $MOUNT2/$tdir/a 4000 &
1285 # Let's make conflict and bl_ast
1286 ls -la $MOUNT1/$tdir > /dev/null &
1289 log "Wait for $pid1 $pid2 for $timeout sec..."
1291 kill -9 $pid1 $pid2 > /dev/null 2>&1
1293 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1294 awk '/ldlm_bl_callback/ { print $2 }')
1295 test "x$blk2" = "x" && blk2=0
1296 test $blk2 -gt $blk1 && break
1297 rm -fr $MOUNT1/$tdir
1298 cancel_lru_locks mdc
1301 do_facet client "lctl set_param fail_loc=0x0"
1302 df -h $MOUNT1 $MOUNT2
1304 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1305 awk '/generation/{print $2}')
1307 if ! test "$g" -eq "${generation[count]}"; then
1308 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1310 for imp in $list; do
1311 if [ $c = $count ]; then
1316 imp=$(echo "$imp" | awk -F"." '{print $2}')
1317 error "Eviction happened on import $imp"
1322 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1324 test_36() { #bug 16417
1329 test_mkdir $DIR1/$tdir
1330 $LFS setstripe -c -1 $DIR1/$tdir
1333 let SIZE_B=SIZE*1024*1024
1334 sync; sleep 2; sync # wait for delete thread
1335 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1336 wait_destroy_complete || error "wait_destroy_complete failed"
1338 while [ $i -le 10 ]; do
1339 lctl mark "start test - cycle ($i)"
1340 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1341 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1342 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1343 sync # sync data from client cache
1344 sync_all_data # sync data from server cache (delayed allocation)
1346 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1347 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1349 rm -f $DIR1/$tdir/$tfile
1350 kill -USR1 $read_pid
1352 sync; sleep 2; sync # Ensure new statfs
1353 wait_delete_completed
1354 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1355 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1357 # this free space! not used
1358 (( $after_dd <= $after)) ||
1359 error "space leaked after_dd:$after_dd > after:$after"
1363 run_test 36 "handle ESTALE/open-unlink correctly"
1365 test_37() { # bug 18695
1366 test_mkdir $DIR1/$tdir
1367 multiop_bg_pause $DIR1/$tdir D_c || return 1
1369 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1370 createmany -m $DIR2/$tdir/f 10000
1371 # set mtime/atime backward
1372 touch -t 198001010000 $DIR2/$tdir
1373 kill -USR1 $MULTIPID
1374 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1375 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1378 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1380 # this should be set to past
1381 TEST_39_MTIME=`date -d "1 year ago" +%s`
1385 local client1=${CLIENT1:-`hostname`}
1386 local client2=${CLIENT2:-`hostname`}
1388 do_node $client1 "touch $DIR1/$tfile"
1390 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1391 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1392 [ "$mtime1" = $TEST_39_MTIME ] || \
1393 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1395 local d1=`do_node $client1 date +%s`
1396 do_node $client1 'echo hello >> '$DIR1/$tfile
1397 local d2=`do_node $client1 date +%s`
1399 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1400 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1401 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1403 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1405 for (( i=0; i < 2; i++ )) ; do
1406 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1407 [ "$mtime2" = "$mtime3" ] || \
1408 error "mtime ($mtime2) changed (to $mtime3) on rename"
1410 cancel_lru_locks osc
1411 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1414 run_test 39a "test from 11063 =================================="
1417 local client1=${CLIENT1:-`hostname`}
1418 local client2=${CLIENT2:-`hostname`}
1422 local mtime1=`stat -c %Y $DIR1/$tfile`
1423 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1426 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1428 for (( i=0; i < 2; i++ )) ; do
1429 local mtime3=`stat -c %Y $DIR1/$tfile`
1430 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1432 [ "$mtime3" = "$mtime4" ] || \
1433 error "different mtime on clients: $mtime3, $mtime4"
1434 [ "$mtime3" = $TEST_39_MTIME ] || \
1435 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1437 cancel_lru_locks osc
1438 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1441 run_test 39b "11063 problem 1 =================================="
1444 local client1=${CLIENT1:-`hostname`}
1445 local client2=${CLIENT2:-`hostname`}
1447 echo hello > $DIR1/$tfile
1449 local mtime1=`stat -c %Y $DIR1/$tfile`
1450 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1451 [ "$mtime1" = "$mtime2" ] || \
1452 error "create: different mtime on clients: $mtime1, $mtime2"
1455 $TRUNCATE $DIR1/$tfile 1
1457 for (( i=0; i < 2; i++ )) ; do
1458 local mtime3=`stat -c %Y $DIR1/$tfile`
1459 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1461 [ "$mtime3" = "$mtime4" ] || \
1462 error "different mtime on clients: $mtime3, $mtime4"
1463 [ "$mtime3" -gt $mtime2 ] || \
1464 error "truncate did not update mtime: $mtime2, $mtime3"
1466 cancel_lru_locks osc
1467 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1470 run_test 39c "check truncate mtime update ======================"
1472 test_39d() { # LU-7310
1474 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1476 local mtime1=$(stat -c %Y $DIR2/$tfile)
1477 [ "$mtime1" = $TEST_39_MTIME ] ||
1478 error "mtime: $mtime1, should be $TEST_39_MTIME"
1481 # define OBD_FAIL_OSC_NO_GRANT 0x411
1482 $LCTL set_param fail_loc=0x411
1484 local d1=$(date +%s)
1485 echo hello >> $DIR1/$tfile
1486 local d2=$(date +%s)
1488 $LCTL set_param fail_loc=0
1490 cancel_lru_locks $OSC
1492 local mtime2=$(stat -c %Y $DIR2/$tfile)
1493 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1494 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1496 run_test 39d "sync write should update mtime"
1499 # how long 40-47 take with specific delay
1506 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1507 # avoid unexpected delays due to previous tests
1509 cancel_lru_locks mdc
1510 do_nodes $(comma_list $(mdts_nodes)) \
1511 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1512 do_nodes $(comma_list $(mdts_nodes)) \
1513 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1514 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1517 # check that pid exists hence second operation wasn't blocked by first one
1518 # if it is so then there is no conflict, return 0
1519 # else second operation is conflicting with first one, return 1
1520 check_pdo_conflict() {
1523 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1524 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1534 # test 40: check non-blocking operations
1536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1538 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1539 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1541 mkdir $DIR1/$tfile &
1543 touch $DIR2/$tfile-2
1544 check_pdo_conflict $PID1 || error "create is blocked"
1545 mkdir $DIR2/$tfile-3
1546 check_pdo_conflict $PID1 || error "mkdir is blocked"
1547 link $DIR2/$tfile-2 $DIR2/$tfile-4
1548 check_pdo_conflict $PID1 || error "link is blocked"
1549 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1550 check_pdo_conflict $PID1 || error "rename is blocked"
1551 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1552 check_pdo_conflict $PID1 || error "getattr is blocked"
1553 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1554 rmdir $DIR2/$tfile-3
1555 check_pdo_conflict $PID1 || error "unlink is blocked"
1557 # all operations above shouldn't wait the first one
1558 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1559 do_facet $SINGLEMDS lctl set_param fail_loc=0
1564 run_test 40a "pdirops: create vs others =============="
1567 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1569 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1570 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1571 touch $DIR1/$tfile &
1574 touch $DIR2/$tfile-2
1575 check_pdo_conflict $PID1 || error "create is blocked"
1576 mkdir $DIR2/$tfile-3
1577 check_pdo_conflict $PID1 || error "mkdir is blocked"
1578 link $DIR2/$tfile-2 $DIR2/$tfile-4
1579 check_pdo_conflict $PID1 || error "link is blocked"
1580 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1581 check_pdo_conflict $PID1 || error "rename is blocked"
1582 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1583 check_pdo_conflict $PID1 || error "getattr is blocked"
1584 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1585 rmdir $DIR2/$tfile-3
1586 check_pdo_conflict $PID1 || error "unlink is blocked"
1587 # all operations above shouldn't wait the first one
1589 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1590 do_facet $SINGLEMDS lctl set_param fail_loc=0
1595 run_test 40b "pdirops: open|create and others =============="
1598 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1601 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1602 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1603 link $DIR1/$tfile $DIR1/$tfile-0 &
1606 touch $DIR2/$tfile-2
1607 check_pdo_conflict $PID1 || error "create is blocked"
1608 mkdir $DIR2/$tfile-3
1609 check_pdo_conflict $PID1 || error "mkdir is blocked"
1610 link $DIR2/$tfile-2 $DIR2/$tfile-4
1611 check_pdo_conflict $PID1 || error "link is blocked"
1612 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1613 check_pdo_conflict $PID1 || error "rename is blocked"
1614 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1615 check_pdo_conflict $PID1 || error "getattr is blocked"
1616 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1617 rmdir $DIR2/$tfile-3
1618 check_pdo_conflict $PID1 || error "unlink is blocked"
1620 # all operations above shouldn't wait the first one
1621 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1622 do_facet $SINGLEMDS lctl set_param fail_loc=0
1627 run_test 40c "pdirops: link and others =============="
1630 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1633 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1634 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1638 touch $DIR2/$tfile-2
1639 check_pdo_conflict $PID1 || error "create is blocked"
1640 mkdir $DIR2/$tfile-3
1641 check_pdo_conflict $PID1 || error "mkdir is blocked"
1642 link $DIR2/$tfile-2 $DIR2/$tfile-4
1643 check_pdo_conflict $PID1 || error "link is blocked"
1644 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1645 check_pdo_conflict $PID1 || error "rename is blocked"
1646 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1647 check_pdo_conflict $PID1 || error "getattr is blocked"
1648 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1649 rmdir $DIR2/$tfile-3
1650 check_pdo_conflict $PID1 || error "unlink is blocked"
1652 # all operations above shouldn't wait the first one
1653 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1654 do_facet $SINGLEMDS lctl set_param fail_loc=0
1658 run_test 40d "pdirops: unlink and others =============="
1661 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1664 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1665 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1666 mv $DIR1/$tfile $DIR1/$tfile-0 &
1669 touch $DIR2/$tfile-2
1670 check_pdo_conflict $PID1 || error "create is blocked"
1671 mkdir $DIR2/$tfile-3
1672 check_pdo_conflict $PID1 || error "mkdir is blocked"
1673 link $DIR2/$tfile-2 $DIR2/$tfile-4
1674 check_pdo_conflict $PID1 || error "link is blocked"
1675 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1676 check_pdo_conflict $PID1 || error "getattr is blocked"
1677 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1678 rmdir $DIR2/$tfile-3
1679 check_pdo_conflict $PID1 || error "unlink is blocked"
1681 # all operations above shouldn't wait the first one
1682 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1683 do_facet $SINGLEMDS lctl set_param fail_loc=0
1688 run_test 40e "pdirops: rename and others =============="
1690 # test 41: create blocking operations
1693 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1694 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1695 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1697 mkdir $DIR2/$tfile &
1699 do_facet $SINGLEMDS lctl set_param fail_loc=0
1700 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1701 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1705 run_test 41a "pdirops: create vs mkdir =============="
1709 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1710 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1711 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1713 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1715 do_facet $SINGLEMDS lctl set_param fail_loc=0
1716 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1717 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1721 run_test 41b "pdirops: create vs create =============="
1725 touch $DIR1/$tfile-2
1726 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1727 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1728 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1730 link $DIR2/$tfile-2 $DIR2/$tfile &
1732 do_facet $SINGLEMDS lctl set_param fail_loc=0
1733 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1734 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1738 run_test 41c "pdirops: create vs link =============="
1742 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1743 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1744 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1748 do_facet $SINGLEMDS lctl set_param fail_loc=0
1749 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1750 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1754 run_test 41d "pdirops: create vs unlink =============="
1758 touch $DIR1/$tfile-2
1759 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1760 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1761 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1763 mv $DIR2/$tfile-2 $DIR2/$tfile &
1765 do_facet $SINGLEMDS lctl set_param fail_loc=0
1766 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1767 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1771 run_test 41e "pdirops: create and rename (tgt) =============="
1775 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1776 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1777 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1779 mv $DIR2/$tfile $DIR2/$tfile-2 &
1781 do_facet $SINGLEMDS lctl set_param fail_loc=0
1782 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1783 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1787 run_test 41f "pdirops: create and rename (src) =============="
1791 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1792 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1793 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1795 stat $DIR2/$tfile > /dev/null &
1797 do_facet $SINGLEMDS lctl set_param fail_loc=0
1798 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1799 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1803 run_test 41g "pdirops: create vs getattr =============="
1807 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1808 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1809 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1811 ls -lia $DIR2/ > /dev/null &
1813 do_facet $SINGLEMDS lctl set_param fail_loc=0
1814 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1819 run_test 41h "pdirops: create vs readdir =============="
1821 # test 42: unlink and blocking operations
1824 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1825 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1826 mkdir $DIR1/$tfile &
1828 mkdir $DIR2/$tfile &
1830 do_facet $SINGLEMDS lctl set_param fail_loc=0
1831 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1832 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1836 run_test 42a "pdirops: mkdir vs mkdir =============="
1840 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1841 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1842 mkdir $DIR1/$tfile &
1844 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1846 do_facet $SINGLEMDS lctl set_param fail_loc=0
1847 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1848 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1852 run_test 42b "pdirops: mkdir vs create =============="
1856 touch $DIR1/$tfile-2
1857 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1858 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1859 mkdir $DIR1/$tfile &
1861 link $DIR2/$tfile-2 $DIR2/$tfile &
1863 do_facet $SINGLEMDS lctl set_param fail_loc=0
1864 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1865 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1869 run_test 42c "pdirops: mkdir vs link =============="
1873 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1874 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1875 mkdir $DIR1/$tfile &
1877 rmdir $DIR2/$tfile &
1879 do_facet $SINGLEMDS lctl set_param fail_loc=0
1880 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1881 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1885 run_test 42d "pdirops: mkdir vs unlink =============="
1889 touch $DIR1/$tfile-2
1890 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1891 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1892 mkdir $DIR1/$tfile &
1894 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1896 do_facet $SINGLEMDS lctl set_param fail_loc=0
1897 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1898 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1902 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1906 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1907 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1908 mkdir $DIR1/$tfile &
1910 mv $DIR2/$tfile $DIR2/$tfile-2 &
1912 do_facet $SINGLEMDS lctl set_param fail_loc=0
1913 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1914 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1918 run_test 42f "pdirops: mkdir and rename (src) =============="
1922 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1923 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1924 mkdir $DIR1/$tfile &
1926 stat $DIR2/$tfile > /dev/null &
1928 do_facet $SINGLEMDS lctl set_param fail_loc=0
1929 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1930 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1934 run_test 42g "pdirops: mkdir vs getattr =============="
1938 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1939 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1940 mkdir $DIR1/$tfile &
1942 ls -lia $DIR2/ > /dev/null &
1944 do_facet $SINGLEMDS lctl set_param fail_loc=0
1945 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1950 run_test 42h "pdirops: mkdir vs readdir =============="
1952 # test 43: rmdir,mkdir won't return -EEXIST
1954 for i in {1..1000}; do
1955 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
1956 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
1960 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
1965 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1966 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1969 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1971 do_facet $SINGLEMDS lctl set_param fail_loc=0
1972 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1973 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
1977 run_test 43b "pdirops: unlink vs create =============="
1982 touch $DIR1/$tfile-2
1983 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1984 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1987 link $DIR2/$tfile-2 $DIR2/$tfile &
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0
1990 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1991 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
1995 run_test 43c "pdirops: unlink vs link =============="
2000 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2001 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2006 do_facet $SINGLEMDS lctl set_param fail_loc=0
2007 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2008 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2012 run_test 43d "pdirops: unlink vs unlink =============="
2017 touch $DIR1/$tfile-2
2018 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2019 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2022 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2024 do_facet $SINGLEMDS lctl set_param fail_loc=0
2025 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2026 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2030 run_test 43e "pdirops: unlink and rename (tgt) =============="
2035 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2036 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2039 mv $DIR2/$tfile $DIR2/$tfile-2 &
2041 do_facet $SINGLEMDS lctl set_param fail_loc=0
2042 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2043 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2047 run_test 43f "pdirops: unlink and rename (src) =============="
2052 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2053 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2056 stat $DIR2/$tfile > /dev/null &
2058 do_facet $SINGLEMDS lctl set_param fail_loc=0
2059 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2060 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2064 run_test 43g "pdirops: unlink vs getattr =============="
2069 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2070 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2073 ls -lia $DIR2/ > /dev/null &
2075 do_facet $SINGLEMDS lctl set_param fail_loc=0
2076 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2081 run_test 43h "pdirops: unlink vs readdir =============="
2084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2087 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2088 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2091 $LFS mkdir -i 1 $DIR2/$tfile &
2093 do_facet $SINGLEMDS lctl set_param fail_loc=0
2094 check_pdo_conflict $PID1 &&
2095 { wait $PID1; error "remote mkdir isn't blocked"; }
2096 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2100 run_test 43i "pdirops: unlink vs remote mkdir"
2103 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2104 skip "Need MDS version newer than 2.13.52"
2106 for i in {1..100}; do
2107 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2108 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000167
2112 mkdir $DIR2/$tdir && ((OK++))
2113 wait $PID1 && ((OK++))
2114 (( OK == 1 )) || error "exactly one mkdir should succeed"
2116 rmdir $DIR1/$tdir || error "rmdir failed"
2120 run_test 43j "racy mkdir return EEXIST =============="
2122 # test 44: rename tgt and blocking operations
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 mkdir $DIR2/$tfile &
2132 do_facet $SINGLEMDS lctl set_param fail_loc=0
2133 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2134 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2139 run_test 44a "pdirops: rename tgt vs mkdir =============="
2143 touch $DIR1/$tfile-2
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 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2150 do_facet $SINGLEMDS lctl set_param fail_loc=0
2151 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2152 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2156 run_test 44b "pdirops: rename tgt vs create =============="
2160 touch $DIR1/$tfile-2
2161 touch $DIR1/$tfile-3
2162 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2163 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2164 mv $DIR1/$tfile-2 $DIR1/$tfile &
2166 link $DIR2/$tfile-3 $DIR2/$tfile &
2168 do_facet $SINGLEMDS lctl set_param fail_loc=0
2169 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2170 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2174 run_test 44c "pdirops: rename tgt vs link =============="
2178 touch $DIR1/$tfile-2
2179 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2180 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2181 mv $DIR1/$tfile-2 $DIR1/$tfile &
2185 do_facet $SINGLEMDS lctl set_param fail_loc=0
2186 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2187 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2191 run_test 44d "pdirops: rename tgt vs unlink =============="
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-3 $DIR2/$tfile &
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 44e "pdirops: rename tgt and rename (tgt) =============="
2214 touch $DIR1/$tfile-2
2215 touch $DIR1/$tfile-3
2216 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2217 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2218 mv $DIR1/$tfile-2 $DIR1/$tfile &
2220 mv $DIR2/$tfile $DIR2/$tfile-3 &
2222 do_facet $SINGLEMDS lctl set_param fail_loc=0
2223 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2224 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2228 run_test 44f "pdirops: rename tgt and rename (src) =============="
2232 touch $DIR1/$tfile-2
2233 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2234 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2235 mv $DIR1/$tfile-2 $DIR1/$tfile &
2237 stat $DIR2/$tfile > /dev/null &
2239 do_facet $SINGLEMDS lctl set_param fail_loc=0
2240 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2241 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2245 run_test 44g "pdirops: rename tgt vs getattr =============="
2249 touch $DIR1/$tfile-2
2250 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2251 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2252 mv $DIR1/$tfile-2 $DIR1/$tfile &
2254 ls -lia $DIR2/ > /dev/null &
2256 do_facet $SINGLEMDS lctl set_param fail_loc=0
2257 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2262 run_test 44h "pdirops: rename tgt vs readdir =============="
2264 # test 44: rename tgt and blocking operations
2266 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2268 touch $DIR1/$tfile-2
2269 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2270 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2271 mv $DIR1/$tfile-2 $DIR1/$tfile &
2273 $LFS mkdir -i 1 $DIR2/$tfile &
2275 do_facet $SINGLEMDS lctl set_param fail_loc=0
2276 check_pdo_conflict $PID1 && { wait $PID1;
2277 error "remote mkdir isn't blocked"; }
2278 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2282 run_test 44i "pdirops: rename tgt vs remote mkdir"
2284 # test 45: rename,mkdir doesn't fail with -EEXIST
2286 for i in {1..1000}; do
2287 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2288 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2289 error "mrename to $tdir.$i failed"
2294 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2299 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2300 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2301 mv $DIR1/$tfile $DIR1/$tfile-2 &
2303 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2305 do_facet $SINGLEMDS lctl set_param fail_loc=0
2306 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2307 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2311 run_test 45b "pdirops: rename src vs create =============="
2316 touch $DIR1/$tfile-3
2317 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2318 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2319 mv $DIR1/$tfile $DIR1/$tfile-2 &
2321 link $DIR2/$tfile-3 $DIR2/$tfile &
2323 do_facet $SINGLEMDS lctl set_param fail_loc=0
2324 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2325 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2329 run_test 45c "pdirops: rename src vs link =============="
2334 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2335 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2336 mv $DIR1/$tfile $DIR1/$tfile-2 &
2340 do_facet $SINGLEMDS lctl set_param fail_loc=0
2341 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2342 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2346 run_test 45d "pdirops: rename src vs unlink =============="
2351 touch $DIR1/$tfile-3
2352 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2353 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2354 mv $DIR1/$tfile $DIR1/$tfile-2 &
2356 mv $DIR2/$tfile-3 $DIR2/$tfile &
2358 do_facet $SINGLEMDS lctl set_param fail_loc=0
2359 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2360 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2364 run_test 45e "pdirops: rename src and rename (tgt) =============="
2369 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2370 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2371 mv $DIR1/$tfile $DIR1/$tfile-2 &
2373 mv $DIR2/$tfile $DIR2/$tfile-3 &
2375 do_facet $SINGLEMDS lctl set_param fail_loc=0
2376 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2377 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2381 run_test 45f "pdirops: rename src and rename (src) =============="
2386 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2387 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2388 mv $DIR1/$tfile $DIR1/$tfile-2 &
2390 stat $DIR2/$tfile > /dev/null &
2392 do_facet $SINGLEMDS lctl set_param fail_loc=0
2393 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2394 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2398 run_test 45g "pdirops: rename src vs getattr =============="
2403 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2404 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2405 mv $DIR1/$tfile $DIR1/$tfile-2 &
2407 ls -lia $DIR2/ > /dev/null &
2408 do_facet $SINGLEMDS lctl set_param fail_loc=0
2409 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2414 run_test 45h "pdirops: unlink vs readdir =============="
2417 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2420 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2421 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2422 mv $DIR1/$tfile $DIR1/$tfile-2 &
2424 $LFS mkdir -i 1 $DIR2/$tfile &
2426 do_facet $SINGLEMDS lctl set_param fail_loc=0
2427 check_pdo_conflict $PID1 && { wait $PID1;
2428 error "create remote dir isn't blocked"; }
2429 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2433 run_test 45i "pdirops: rename src vs remote mkdir"
2435 # test 46: link and blocking operations
2438 touch $DIR1/$tfile-2
2439 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2440 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2441 link $DIR1/$tfile-2 $DIR1/$tfile &
2443 mkdir $DIR2/$tfile &
2445 do_facet $SINGLEMDS lctl set_param fail_loc=0
2446 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2447 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2451 run_test 46a "pdirops: link vs mkdir =============="
2455 touch $DIR1/$tfile-2
2456 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2457 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2458 link $DIR1/$tfile-2 $DIR1/$tfile &
2460 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2462 do_facet $SINGLEMDS lctl set_param fail_loc=0
2463 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2464 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2468 run_test 46b "pdirops: link vs create =============="
2472 touch $DIR1/$tfile-2
2473 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2474 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2475 link $DIR1/$tfile-2 $DIR1/$tfile &
2477 link $DIR2/$tfile $DIR2/$tfile &
2479 do_facet $SINGLEMDS lctl set_param fail_loc=0
2480 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2481 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2485 run_test 46c "pdirops: link vs link =============="
2489 touch $DIR1/$tfile-2
2490 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2491 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2492 link $DIR1/$tfile-2 $DIR1/$tfile &
2496 do_facet $SINGLEMDS lctl set_param fail_loc=0
2497 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2498 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2502 run_test 46d "pdirops: link vs unlink =============="
2506 touch $DIR1/$tfile-2
2507 touch $DIR1/$tfile-3
2508 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2509 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2510 link $DIR1/$tfile-2 $DIR1/$tfile &
2512 mv $DIR2/$tfile-3 $DIR2/$tfile &
2514 do_facet $SINGLEMDS lctl set_param fail_loc=0
2515 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2516 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2520 run_test 46e "pdirops: link and rename (tgt) =============="
2524 touch $DIR1/$tfile-2
2525 touch $DIR1/$tfile-3
2526 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2527 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2528 link $DIR1/$tfile-2 $DIR1/$tfile &
2530 mv $DIR2/$tfile $DIR2/$tfile-3 &
2532 do_facet $SINGLEMDS lctl set_param fail_loc=0
2533 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2534 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2538 run_test 46f "pdirops: link and rename (src) =============="
2542 touch $DIR1/$tfile-2
2543 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2544 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2545 link $DIR1/$tfile-2 $DIR1/$tfile &
2547 stat $DIR2/$tfile > /dev/null &
2549 do_facet $SINGLEMDS lctl set_param fail_loc=0
2550 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2551 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2555 run_test 46g "pdirops: link vs getattr =============="
2559 touch $DIR1/$tfile-2
2560 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2561 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2562 link $DIR1/$tfile-2 $DIR1/$tfile &
2564 ls -lia $DIR2/ > /dev/null &
2566 do_facet $SINGLEMDS lctl set_param fail_loc=0
2567 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2572 run_test 46h "pdirops: link vs readdir =============="
2575 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2577 touch $DIR1/$tfile-2
2578 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2579 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2580 link $DIR1/$tfile-2 $DIR1/$tfile &
2582 $LFS mkdir -i 1 $DIR2/$tfile &
2584 do_facet $SINGLEMDS lctl set_param fail_loc=0
2585 check_pdo_conflict $PID1 && { wait $PID1;
2586 error "remote mkdir isn't blocked"; }
2587 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2591 run_test 46i "pdirops: link vs remote mkdir"
2593 # test 47: remote mkdir and blocking operations
2595 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2596 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2598 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2599 $LFS mkdir -i 1 $DIR1/$tfile &
2601 mkdir $DIR2/$tfile &
2603 do_facet $SINGLEMDS lctl set_param fail_loc=0
2604 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2605 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2609 run_test 47a "pdirops: remote mkdir vs mkdir"
2612 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2613 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2615 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2616 $LFS mkdir -i 1 $DIR1/$tfile &
2618 sleep 1 # please do not remove this sleep, see LU-10754
2619 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2621 do_facet $SINGLEMDS lctl set_param fail_loc=0
2622 check_pdo_conflict $PID1 && { wait $PID1;
2623 error "create isn't blocked"; }
2624 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2628 run_test 47b "pdirops: remote mkdir vs create"
2631 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2633 touch $DIR1/$tfile-2
2634 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2635 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2636 $LFS mkdir -i 1 $DIR1/$tfile &
2638 link $DIR2/$tfile-2 $DIR2/$tfile &
2640 do_facet $SINGLEMDS lctl set_param fail_loc=0
2641 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2642 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2646 run_test 47c "pdirops: remote mkdir vs link"
2649 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2651 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2652 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2653 $LFS mkdir -i 1 $DIR1/$tfile &
2655 rmdir $DIR2/$tfile &
2657 do_facet $SINGLEMDS lctl set_param fail_loc=0
2658 check_pdo_conflict $PID1 && { wait $PID1;
2659 error "unlink isn't blocked"; }
2660 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2664 run_test 47d "pdirops: remote mkdir vs unlink"
2667 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2669 touch $DIR1/$tfile-2
2670 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2671 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2672 $LFS mkdir -i 1 $DIR1/$tfile &
2674 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2676 do_facet $SINGLEMDS lctl set_param fail_loc=0
2677 check_pdo_conflict $PID1 && { wait $PID1;
2678 error "rename isn't blocked"; }
2679 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2683 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2686 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2688 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2689 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2690 $LFS mkdir -i 1 $DIR1/$tfile &
2692 mv $DIR2/$tfile $DIR2/$tfile-2 &
2694 do_facet $SINGLEMDS lctl set_param fail_loc=0
2695 check_pdo_conflict $PID1 && { wait $PID1;
2696 error "rename isn't blocked"; }
2697 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2701 run_test 47f "pdirops: remote mkdir and rename (src)"
2704 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2708 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2709 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2710 $LFS mkdir -i 1 $DIR1/$tfile &
2712 stat $DIR2/$tfile > /dev/null &
2714 do_facet $SINGLEMDS lctl set_param fail_loc=0
2715 check_pdo_conflict $PID1 && { wait $PID1;
2716 error "getattr isn't blocked"; }
2717 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2721 run_test 47g "pdirops: remote mkdir vs getattr"
2725 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2726 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2727 do_facet client "lctl set_param fail_loc=0x410"
2728 $TRUNCATE $DIR2/$tfile $trunc_size
2729 do_facet client "lctl set_param fail_loc=0x0"
2731 size=`stat -c %s $DIR2/$tfile`
2732 [ $size -eq $trunc_size ] || error "wrong size"
2734 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2738 local origfile=/etc/hosts
2740 filesize=$(stat -c %s $origfile)
2742 # create an empty file
2743 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2744 # cache layout lock on both mount point
2745 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2746 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2748 # open and sleep 2 seconds then read
2749 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2753 # create the layout of testing file
2754 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2755 error "dd $DIR1/$tfile failed"
2757 # MULTIOP proc should be able to read enough bytes and exit
2758 for ((i = 0; i < 6; i++)); do
2760 kill -0 $pid || break
2762 kill -0 $pid 2> /dev/null && error "multiop is still there"
2763 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2767 run_test 51a "layout lock: refresh layout should work"
2770 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
2771 skip "Need MDS version at least 2.3.59"
2773 local tmpfile=`mktemp`
2775 # create an empty file
2776 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2778 # delay glimpse so that layout has changed when glimpse finish
2779 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2780 $LCTL set_param fail_loc=0x1404
2781 stat -c %s $DIR2/$tfile |tee $tmpfile &
2785 # create layout of testing file
2786 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2787 error "dd $DIR1/$tfile failed"
2790 local fsize=$(cat $tmpfile)
2792 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2794 rm -f $DIR1/$tfile $tmpfile
2796 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2799 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2801 # set default layout to have 1 stripe
2803 $LFS setstripe -c 1 $DIR1/$tdir
2805 # create a file with empty layout
2806 $MCREATE $DIR1/$tdir/$tfile ||
2807 error "$MCREATE $DIR1/$tdir/$tfile failed"
2809 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2810 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2812 # change the layout of testing file
2813 echo "Setting layout to have $OSTCOUNT stripes ..."
2814 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2818 # write something to the file, it should be blocked on fetching layout
2819 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2820 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2823 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2824 # count to succeed with only 3/4 of the number of stripes (rounded up),
2825 # so creating striped files does not fail if an OST is offline or full
2826 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2827 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2831 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2834 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2835 cancel_lru_locks mdc
2837 # open should grant LAYOUT lock, mmap and read will install pages
2838 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2842 # rss before revoking
2843 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2844 echo "Before revoking layout lock: $br KB mapped"
2846 # cancel layout lock manually
2847 cancel_lru_locks mdc
2849 # rss after revoking
2850 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2853 wait $PID || error "wait PID $PID failed"
2855 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2857 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2861 echo "==> rename vs getattr vs setxattr should not deadlock"
2862 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2864 do_facet mds1 $LCTL set_param fail_loc=$1
2866 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2874 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2875 wait $PID1 || error "(3) mv failed"
2876 wait $PID2 || error "(4) stat failed"
2883 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2884 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2886 do_facet mds1 $LCTL set_param fail_loc=$1
2888 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2896 $MULTIOP $DIR2/d1/d2 Oc &
2900 stat $DIR/d1 || error "(2) stat failed"
2902 wait $PID1 || error "(3) mv failed"
2903 wait $PID2 || error "(4) stat failed"
2904 wait $PID3 && error "(5) multiop failed"
2910 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2911 save_lustre_params client "llite.*.xattr_cache" > $p
2912 lctl set_param llite.*.xattr_cache 1 ||
2913 { skip "xattr cache is not supported"; return 0; }
2915 #define OBD_FAIL_MDS_RENAME 0x153
2916 #define OBD_FAIL_MDS_RENAME2 0x154
2917 test_54_part1 0x80000153 || error 10
2918 test_54_part1 0x80000154 || error 11
2919 test_54_part2 0x80000153 || error 12
2920 test_54_part2 0x80000154 || error 13
2922 restore_lustre_params < $p
2925 run_test 54 "rename locking"
2928 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2930 #define OBD_FAIL_MDS_RENAME4 0x156
2931 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2933 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2938 wait $PID1 && error "(2) mv succeeded"
2942 run_test 55a "rename vs unlink target dir"
2946 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2948 #define OBD_FAIL_MDS_RENAME4 0x156
2949 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2951 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2956 wait $PID1 && error "(2) mv succeeded"
2960 run_test 55b "rename vs unlink source dir"
2964 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2966 #define OBD_FAIL_MDS_RENAME4 0x156
2967 do_facet mds1 $LCTL set_param fail_loc=0x156
2969 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2973 # while rename is sleeping, open and remove d3
2974 $MULTIOP $DIR2/d3 D_c &
2980 # while rename is sleeping 2nd time, close d3
2982 wait $PID2 || error "(3) multiop failed"
2984 wait $PID1 && error "(2) mv succeeded"
2988 run_test 55c "rename vs unlink orphan target dir"
2994 #define OBD_FAIL_MDS_RENAME3 0x155
2995 do_facet mds1 $LCTL set_param fail_loc=0x155
2996 mv $DIR/f1 $DIR/$tdir &
3000 # while rename is sleeping, create $tdir, but as a directory
3001 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
3003 # link in reverse locking order
3004 ln $DIR2/f1 $DIR2/$tdir/
3006 wait $PID1 && error "(2) mv succeeded"
3009 run_test 55d "rename file vs link"
3012 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3013 skip "MDS version must be >= 2.3.0"
3016 test_mkdir $DIR1/$tdir
3017 file1=$DIR1/$tdir/file
3018 file2=$DIR2/$tdir/file
3020 echo orig > $file2 || error "Could not create $file2"
3021 version=$($LFS data_version $file1)
3024 echo append >> $file2 || error "Could not append to $file2"
3025 version2=$($LFS data_version $file1)
3026 [ "$version" != "$version2" ] ||
3027 error "append did not change data version: $version"
3030 echo overwrite > $file2 || error "Could not overwrite $file2"
3031 version3=$($LFS data_version $file1)
3032 [ "$version2" != "$version3" ] ||
3033 error "overwrite did not change data version: $version2"
3035 # Truncate before EOF
3036 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3037 version4=$($LFS data_version $file1)
3038 [ "$version3" != "$version4" ] ||
3039 error "truncate did not change data version: $version3"
3041 # Truncate after EOF
3042 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3043 version5=$($LFS data_version $file1)
3044 [ "$version4" != "$version5" ] ||
3045 error "truncate did not change data version: $version4"
3047 # Chmod do not change version
3048 chmod 400 $file2 || error "Could not chmod 400 $file2"
3049 version6=$($LFS data_version $file1)
3050 [ "$version5" == "$version6" ] ||
3051 error "chmod should not change data version: $version5 != $version6"
3053 # Chown do not change version
3054 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3055 version7=$($LFS data_version $file1)
3056 [ "$version5" == "$version7" ] ||
3057 error "chown should not change data version: $version5 != $version7"
3059 run_test 60 "Verify data_version behaviour"
3062 local test_dir=$tdir/test_dir
3064 mkdir -p $DIR1/$tdir
3065 if [ $MDSCOUNT -ge 2 ]; then
3067 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3068 error "Create remote directory failed"
3070 mkdir -p $DIR1/$test_dir
3072 cd $DIR2/$test_dir || error "cd directory failed"
3073 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3075 cd $DIR2/$tdir || error "exit directory"
3077 run_test 70a "cd directory && rm directory"
3079 test_70b() { # LU-2781
3081 mkdir -p $DIR1/$tdir
3083 touch $DIR1/$tdir/file
3084 for ((i = 0; i < 32; i++)); do
3085 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3087 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3089 touch $DIR1/$tdir/file
3090 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3091 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3092 rm -rf $DIR1/$tdir/test_dir ||
3093 error "cannot remove directory after rm_entry"
3094 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3096 run_test 70b "remove files after calling rm_entry"
3099 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3100 skip "Need MDS version at least 2.1.6"
3102 # Patch not applied to 2.2 and 2.3 branches
3103 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3104 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3105 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3107 checkfiemap --test ||
3108 skip "checkfiemap not runnable: $?"
3109 # write data this way: hole - data - hole - data
3110 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3111 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3113 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3114 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3115 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3117 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3119 checkfiemap $DIR2/$tfile 81920 ||
3120 error "data is not flushed from client"
3121 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3124 # common case of "create file, copy file" on a single node
3125 # should not flush data from ost
3126 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3127 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3129 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3131 checkfiemap $DIR1/$tfile 81920 ||
3133 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3135 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3137 run_test 71a "correct file map just after write operation is finished"
3140 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3141 skip "Need MDS version at least 2.1.6"
3143 # Patch not applied to 2.2 and 2.3 branches
3144 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3145 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3146 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3147 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3149 checkfiemap --test ||
3150 skip "error $?: checkfiemap failed"
3152 mkdir -p $DIR1/$tdir
3154 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3155 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3156 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3158 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3159 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3161 run_test 71b "check fiemap support for stripecount > 1"
3164 local p="$TMP/sanityN-$TESTNAME.parameters"
3167 save_lustre_params client "llite.*.xattr_cache" > $p
3168 lctl set_param llite.*.xattr_cache 1 ||
3169 { skip "xattr cache is not supported"; return 0; }
3172 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3173 error "setfattr1 failed"
3174 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3175 error "getfattr1 failed"
3176 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3177 error "setfattr2 failed"
3178 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3179 error "getfattr2 failed"
3181 # check that trusted.link is consistent
3182 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3183 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3184 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3185 echo "$tlink1 $tlink2"
3186 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3190 restore_lustre_params < $p
3193 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3196 local p="$TMP/sanityN-$TESTNAME.parameters"
3197 save_lustre_params client "llite.*.xattr_cache" > $p
3198 lctl set_param llite.*.xattr_cache 1 ||
3199 { skip "xattr cache is not supported"; return 0; }
3202 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3203 error "setfattr1 failed"
3204 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3205 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3206 clear_stats llite.*.stats
3207 # PR lock should be cached by now on both clients
3208 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3209 # 2 hits for getfattr(0)+getfattr(size)
3210 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3211 error "not cached in $DIR1"
3212 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3213 # 4 hits for more getfattr(0)+getfattr(size)
3214 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3215 error "not cached in $DIR2"
3218 restore_lustre_params < $p
3221 run_test 73 "getxattr should not cause xattr lock cancellation"
3224 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3225 skip "Need MDS version at least 2.4.93"
3227 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3228 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3229 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3231 run_test 74 "flock deadlock: different mounts =============="
3235 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3236 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3237 cancel_lru_locks osc
3239 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3242 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3243 $LCTL set_param fail_loc=0x31d
3244 stat -c %s $DIR1/$tfile &
3249 # For bad lock error handler we should ASSERT and got kernel panic here
3251 $LCTL set_param fail_loc=0
3253 run_test 75 "osc: upcall after unuse lock==================="
3256 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3257 skip "Need MDS version at least 2.5.53"
3259 remote_mds_nodsh && skip "remote MDS with nodsh"
3260 local fcount=$((MDSCOUNT * 256))
3265 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3271 test_mkdir $DIR/$tdir
3273 # drop all open locks and close any cached "open" files on the client
3274 cancel_lru_locks mdc
3276 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3277 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3278 local already=${#fid_list[@]}
3279 for (( i = 0; i < $already; i++ )) ; do
3280 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3283 echo -n "opening files: "
3284 ulimit -n $((fcount + 50))
3285 for ((i = 0; i < $fcount; i++)); do
3286 touch $DIR/$tdir/f_$i
3287 local fd=$(free_fd ${fd_list[i]})
3288 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3293 (( $i % 32 == 0 )) && echo -n "."
3297 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3299 # Possible errors in openfiles FID list.
3300 # 1. Missing FIDs. Check 1
3301 # 2. Extra FIDs. Check 1
3302 # 3. Duplicated FID. Check 2
3303 # 4. Invalid FIDs. Check 2
3304 # 5. Valid FID, points to some other file. Check 3
3307 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3308 error "${#fid_list[@]} != $fcount (+$already old) open files"
3310 echo -n "closing files: "
3311 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3312 local close_cmd="exec ${fd_list[fd]}<&-"
3314 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3316 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3317 echo "skip old open file $filename"
3319 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3323 rm --interactive=no $filename
3325 error "Nonexisting fid ${fid_list[fid]} listed."
3326 (( $fd % 32 == 0 )) && echo -n "."
3331 ls_op=$(ls $DIR2/$tdir | wc -l)
3333 error "Some openfiles are missing in lproc output"
3337 run_test 76 "Verify MDT open_files listing"
3341 local dir=$DIR/$tdir
3344 mkdir $dir || error "mkdir $dir failed"
3345 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3348 do_nodes $CLIENTS $myRUNAS \
3349 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3350 error "dd at 0 on client failed (1)"
3352 do_nodes $CLIENTS $myRUNAS \
3354 for ((i = 0; i < $n; i++)); do
3355 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3356 seek=\\\$i count=1 conv=notrunc &
3357 pids_w[\\\$i]=\\\$!;
3360 for ((i = 0; i < $n; i++)); do
3361 wait \\\${pids_w[\\\$i]};
3363 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3367 do_nodes $CLIENTS sync;
3368 cancel_lru_locks osc
3370 do_nodes $CLIENTS $myRUNAS \
3372 for ((i = 0; i < $n; i++)); do
3373 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3374 seek=\\\$i count=1 &
3375 pids_r[\\\$i]=\\\$!;
3378 for ((i = 0; i < $n; i++)); do
3379 wait \\\${pids_r[\\\$i]};
3381 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3385 cancel_lru_locks osc
3387 wait $pid_w || error "dd (write) failed (2)"
3388 wait $pid_r || error "dd (read) failed (3)"
3389 rm -rvf $dir || error "rm -rf $dir failed"
3392 test_77a() { #LU-3266
3395 oss=$(comma_list $(osts_nodes))
3396 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3398 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3399 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3404 run_test 77a "check FIFO NRS policy"
3406 test_77b() { #LU-3266
3409 oss=$(comma_list $(osts_nodes))
3411 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3412 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3413 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3414 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3416 echo "policy: crr-n, crrn_quantum 1"
3419 do_nodes $oss lctl set_param \
3420 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3421 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3423 echo "policy: crr-n, crrn_quantum 64"
3427 do_nodes $oss lctl set_param \
3428 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3429 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3432 run_test 77b "check CRR-N NRS policy"
3437 oss=$(comma_list $(osts_nodes))
3439 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3440 ost.OSS.*.nrs_"$policy"_quantum=1 \
3441 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3442 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3444 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3445 "physical, ${policy}_supported reads"
3448 do_nodes $oss lctl set_param \
3449 ost.OSS.*.nrs_${policy}_supported="writes" \
3450 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3452 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3453 "physical, ${policy}_supported writes"
3456 do_nodes $oss lctl set_param \
3457 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3458 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3459 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3460 "logical, ${policy}_supported reads_and_writes"
3464 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3469 test_77c() { #LU-3266
3471 orr_trr "orr" || rc=$?
3472 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3473 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3476 run_test 77c "check ORR NRS policy"
3478 test_77d() { #LU-3266
3480 orr_trr "trr" || rc=$?
3481 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3482 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3485 run_test 77d "check TRR nrs policy"
3492 do_facet $facet lctl set_param \
3493 ost.OSS.ost_io.nrs_tbf_rule="$*"
3495 error "failed to run operate '$*' on TBF rules"
3498 cleanup_tbf_verify()
3502 echo "cleanup_tbf $DIR/$tdir"
3505 wait_delete_completed
3510 local dir=$DIR/$tdir
3511 local client1=${CLIENT1:-$(hostname)}
3514 local np=$(check_cpt_number ost1)
3515 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3516 echo "cpu_npartitions on ost1 is $np"
3518 mkdir $dir || error "mkdir $dir failed"
3519 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3522 trap cleanup_tbf_verify EXIT
3523 echo "Limited write rate: $1, read rate: $2"
3524 echo "Verify the write rate is under TBF control"
3525 local start=$SECONDS
3526 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3527 bs=1M count=100 oflag=direct 2>&1
3528 local runtime=$((SECONDS - start + 1))
3529 local rate=$(bc <<< "scale=6; 100 / $runtime")
3530 echo "Write runtime is $runtime s, speed is $rate IOPS"
3532 # verify the write rate does not exceed TBF rate limit
3533 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3534 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3536 cancel_lru_locks osc
3538 echo "Verify the read rate is under TBF control"
3540 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3541 bs=1M count=100 iflag=direct 2>&1
3542 runtime=$((SECONDS - start + 1))
3543 rate=$(bc <<< "scale=6; 100 / $runtime")
3544 echo "Read runtime is $runtime s, speed is $rate IOPS"
3546 # verify the read rate does not exceed TBF rate limit
3547 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3548 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3550 cancel_lru_locks osc
3551 cleanup_tbf_verify || error "rm -rf $dir failed"
3557 oss=$(comma_list $(osts_nodes))
3559 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3561 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3562 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3566 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3571 # Only operate rules on ost1 since OSTs might run on the same OSS
3573 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3574 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3575 local client_nids=$(nids_list $address "\\")
3576 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3577 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3581 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3582 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3583 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3587 tbf_rule_operate ost1 "stop\ localhost"
3588 tbf_rule_operate ost1 "stop\ clients"
3589 tbf_rule_operate ost1 "stop\ others"
3592 # Cleanup the TBF policy
3593 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3594 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3598 run_test 77e "check TBF NID nrs policy"
3603 oss=$(comma_list $(osts_nodes))
3605 do_nodes $oss $LCTL set_param \
3606 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3607 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3608 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3610 # Configure jobid_var
3611 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3613 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3614 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3615 if [ $saved_jobid_var != procname_uid ]; then
3616 set_persistent_param_and_check client \
3617 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3622 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3627 # Only operate rules on ost1 since OSTs might run on the same OSS
3629 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3630 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3631 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3632 nrs_write_read "$RUNAS"
3635 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3636 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3637 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3638 nrs_write_read "$RUNAS"
3641 tbf_rule_operate ost1 "stop\ runas"
3642 tbf_rule_operate ost1 "stop\ iozone_runas"
3643 tbf_rule_operate ost1 "stop\ dd_runas"
3644 nrs_write_read "$RUNAS"
3646 # Cleanup the TBF policy
3647 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3648 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3649 nrs_write_read "$RUNAS"
3651 local current_jobid_var=$($LCTL get_param -n jobid_var)
3652 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3653 if [ $saved_jobid_var != $current_jobid_var ]; then
3654 set_persistent_param_and_check client \
3655 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3659 run_test 77f "check TBF JobID nrs policy"
3664 oss=$(comma_list $(osts_nodes))
3666 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3668 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3669 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3671 do_nodes $oss lctl set_param \
3672 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3673 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3677 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3682 # Add a rule that only valid for Jobid TBF. If direct change between
3683 # TBF types is not supported, this operation will fail.
3684 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3686 # Cleanup the TBF policy
3687 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3688 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3691 run_test 77g "Change TBF type directly"
3694 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3695 skip "Need OST version at least 2.8.55"
3697 local old_policy=$(do_facet ost1 \
3698 lctl get_param ost.OSS.ost_io.nrs_policies)
3701 do_facet ost1 lctl set_param \
3702 ost.OSS.ost_io.nrs_policies="abc"
3703 [ $? -eq 0 ] && error "should return error"
3705 do_facet ost1 lctl set_param \
3706 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3707 [ $? -eq 0 ] && error "should return error"
3709 do_facet ost1 lctl set_param \
3710 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3711 [ $? -eq 0 ] && error "should return error"
3713 do_facet ost1 lctl set_param \
3714 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3715 [ $? -eq 0 ] && error "should return error"
3717 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3718 [ $? -eq 0 ] || error "shouldn't LBUG"
3720 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3724 run_test 77h "Wrong policy name should report error, not LBUG"
3730 local error_message=$3
3732 for rule in $expected; do
3733 rule_number=$((rule_number + 1))
3735 local stop_line=$(($rule_number + 3))
3736 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3738 local output=$(do_facet $facet lctl get_param \
3739 ost.OSS.ost_io.nrs_tbf_rule |
3743 if [ "$output" != "$expected" ]; then
3744 error "$error_message, expected '$expected', got '$output'"
3749 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3750 skip "Need OST version at least 2.8.55"
3752 for i in $(seq 1 $OSTCOUNT)
3754 do_facet ost"$i" lctl set_param \
3755 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3757 error "failed to set TBF policy"
3760 tbf_rule_check ost1 "default" "error before inserting any rule"
3762 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3763 tbf_rule_check ost1 "before default" \
3764 "error when inserting rule 'before'"
3766 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3767 tbf_rule_check ost1 "before after default" \
3768 "error when inserting rule 'after'"
3770 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3771 tbf_rule_check ost1 "before target after default" \
3772 "error when inserting rule 'target'"
3774 echo "Move before itself"
3775 tbf_rule_operate ost1 "change\ target\ rank=target"
3776 tbf_rule_check ost1 "before target after default" \
3777 "error when moving before itself"
3779 echo "Move to higher rank"
3780 tbf_rule_operate ost1 "change\ target\ rank=before"
3781 tbf_rule_check ost1 "target before after default" \
3782 "error when moving to higher rank"
3784 echo "Move to lower rank"
3785 tbf_rule_operate ost1 "change\ target\ rank=after"
3786 tbf_rule_check ost1 "before target after default" \
3787 "error when moving to lower rank"
3789 echo "Move before default"
3790 tbf_rule_operate ost1 "change\ target\ rank=default"
3791 tbf_rule_check ost1 "before after target default" \
3792 error "error when moving before default"
3794 # Cleanup the TBF policy
3795 do_nodes $(comma_list $(osts_nodes)) \
3796 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3799 run_test 77i "Change rank of TBF rule"
3805 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
3806 skip "Need OST version at least 2.9.53"
3807 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
3812 do_nodes $(comma_list $(osts_nodes)) \
3813 lctl set_param jobid_var=procname_uid \
3814 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3815 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3816 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3817 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3822 do_nodes $(comma_list $(osts_nodes)) \
3823 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3824 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3825 ost.OSS.ost_io.nrs_policies="fifo"
3827 # sleep 3 seconds to wait the tbf policy stop completely,
3828 # or the next test case is possible get -EAGAIN when
3829 # setting the tbf policy
3832 run_test 77j "check TBF-OPCode NRS policy"
3835 local idstr="${1}id"
3836 local policy="${idstr}={$2}"
3837 local rate="rate=$3"
3839 do_nodes $(comma_list $(osts_nodes)) \
3840 lctl set_param jobid_var=procname_uid \
3841 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3842 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3843 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3845 nrs_write_read "runas $4"
3846 tbf_verify $3 $3 "runas $4"
3848 do_nodes $(comma_list $(osts_nodes)) \
3849 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3850 ost.OSS.ost_io.nrs_policies="fifo"
3852 # sleep 3 seconds to wait the tbf policy stop completely,
3853 # or the next test case is possible get -eagain when
3854 # setting the tbf policy
3859 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
3860 skip "Need OST version at least 2.11.50"
3863 test_id "u" "500" "5" "-u 500"
3864 test_id "g" "500" "5" "-u 500 -g 500"
3866 run_test 77ja "check TBF-UID/GID NRS policy"
3874 for rule in $rule_lists; do
3875 do_nodes $(comma_list $(osts_nodes)) \
3876 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3879 do_nodes $(comma_list $(osts_nodes)) \
3880 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3886 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
3887 skip "Need OST version at least 2.9.53"
3889 do_nodes $(comma_list $(osts_nodes)) \
3890 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3891 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3892 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3894 nrs_write_read "$RUNAS"
3895 tbf_verify 20 10 "$RUNAS"
3897 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3898 local client_nids=$(nids_list $address "\\")
3899 do_nodes $(comma_list $(osts_nodes)) \
3900 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3901 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3902 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3903 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3908 do_nodes $(comma_list $(osts_nodes)) \
3909 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3910 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3911 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3913 nrs_write_read "$RUNAS"
3914 tbf_verify 20 20 "$RUNAS"
3916 do_nodes $(comma_list $(osts_nodes)) \
3917 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3918 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3919 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3921 nrs_write_read "$RUNAS"
3922 # with parameter "RUNAS", it will match the latest rule
3923 # "ext_b" first, so the limited write rate is 10.
3924 tbf_verify 10 10 "$RUNAS"
3927 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3929 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
3930 skip "Need OST version at least 2.10.58"
3932 do_nodes $(comma_list $(osts_nodes)) \
3933 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3934 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3935 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3936 nrs_write_read "runas -u 500 -g 1000"
3937 tbf_verify 5 5 "runas -u 500 -g 1000"
3939 do_nodes $(comma_list $(osts_nodes)) \
3940 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3941 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3942 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3944 nrs_write_read "runas -u 500"
3945 tbf_verify 20 10 "runas -u 500"
3947 do_nodes $(comma_list $(osts_nodes)) \
3948 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3949 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3950 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3951 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3952 nrs_write_read "runas -u 500"
3953 tbf_verify 10 10 "runas -u 500"
3954 tbf_verify 20 10 "runas -u 500"
3955 cleanup_77k "ext_a ext_b" "fifo"
3957 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3960 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
3961 skip "Need OST version at least 2.10.56"
3963 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3964 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3966 local output=$(do_facet ost1 lctl get_param \
3967 ost.OSS.ost_io.nrs_policies | \
3968 awk '/name: tbf/ {print;exit}' | \
3969 awk -F ': ' '{print $2}')
3971 if [ "$output" != "tbf" ]; then
3972 error "The generic TBF output is '$output', not 'tbf'"
3975 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3977 run_test 77l "check the output of NRS policies for generic TBF"
3980 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
3981 skip "Need OST version at least 2.9.54"
3984 local dir=$DIR/$tdir
3986 mkdir $dir || error "mkdir $dir failed"
3987 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3990 local nodes=$(comma_list $(osts_nodes))
3991 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3992 ost.OSS.ost_io.nrs_delay_min=4 \
3993 ost.OSS.ost_io.nrs_delay_max=4 \
3994 ost.OSS.ost_io.nrs_delay_pct=100
3995 [ $? -ne 0 ] && error "Failed to set delay policy"
3997 local start=$SECONDS
3998 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3999 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4000 oflag=direct conv=fdatasync ||
4001 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4002 error "dd on client failed (1)"; }
4003 local elapsed=$((SECONDS - start))
4005 # NRS delay doesn't do sub-second timing, so a request enqueued at
4006 # 0.9 seconds can be dequeued at 4.0
4007 [ $elapsed -lt 3 ] &&
4008 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4009 error "Single 1M write should take at least 3 seconds"; }
4012 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4013 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4014 oflag=direct conv=fdatasync ||
4015 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4016 error "dd on client failed (2)"; }
4017 elapsed=$((SECONDS - start))
4019 [ $elapsed -lt 30 ] &&
4020 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4021 error "Ten 1M writes should take at least 30 seconds"; }
4023 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4024 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4028 run_test 77m "check NRS Delay slows write RPC processing"
4030 test_77n() { #LU-10802
4031 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4032 skip "Need OST version at least 2.10.58"
4035 # Configure jobid_var
4036 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4037 if [ $saved_jobid_var != procname_uid ]; then
4038 set_persistent_param_and_check client \
4039 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4042 do_nodes $(comma_list $(osts_nodes)) \
4043 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4044 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4045 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4048 tbf_verify 20 20 "$RUNAS"
4050 do_nodes $(comma_list $(osts_nodes)) \
4051 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4052 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4057 do_nodes $(comma_list $(osts_nodes)) \
4058 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4059 ost.OSS.ost_io.nrs_policies="fifo"
4063 local current_jobid_var=$($LCTL get_param -n jobid_var)
4064 if [ $saved_jobid_var != $current_jobid_var ]; then
4065 set_persistent_param_and_check client \
4066 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4069 run_test 77n "check wildcard support for TBF JobID NRS policy"
4071 test_78() { #LU-6673
4074 oss=$(comma_list $(osts_nodes))
4075 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4076 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4078 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4079 # Valid return codes are:
4080 # 0: Tuning succeeded
4081 # ENODEV: Policy is still stopped
4082 # EAGAIN: Policy is being initialized
4083 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4084 error "Expected set_param to return 0|ENODEV|EAGAIN"
4086 # Cleanup the ORR policy
4087 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4088 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4091 run_test 78 "Enable policy and specify tunings right away"
4094 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4095 test_mkdir $DIR/$tdir
4097 # Prevent interference from layout intent RPCs due to
4098 # asynchronous writeback. These will be tested in 130c below.
4099 do_nodes ${CLIENTS:-$HOSTNAME} sync
4101 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4102 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4104 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4105 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4106 local facet=mds$((mdtidx + 1))
4108 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4109 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4113 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4114 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4119 run_test 79 "xattr: intent error"
4122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4129 mkdir -p $DIR1/$tdir/dir
4130 createmany -o $DIR1/$tdir/dir/f 10 ||
4131 error "create files under remote dir failed $i"
4133 cp /etc/passwd $DIR1/$tdir/$tfile
4135 #migrate open file should fails
4136 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4138 # give multiop a chance to open
4141 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4142 error "migrate open files should failed with open files"
4146 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4147 error "migrate remote dir error"
4149 echo "Finish migration, then checking.."
4150 for file in $(find $DIR1/$tdir); do
4151 mdt_index=$($LFS getstripe -m $file)
4152 [ $mdt_index == $MDTIDX ] ||
4153 error "$file is not on MDT${MDTIDX}"
4156 diff /etc/passwd $DIR1/$tdir/$tfile ||
4157 error "file different after migration"
4159 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4161 run_test 80a "migrate directory when some children is being opened"
4165 kill -9 $migrate_pid
4169 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4170 local migrate_dir1=$DIR1/$tdir/migrate_dir
4171 local migrate_dir2=$DIR2/$tdir/migrate_dir
4172 local migrate_run=$LUSTRE/tests/migrate.sh
4180 trap cleanup_80b EXIT
4181 #prepare migrate directory
4182 mkdir -p $migrate_dir1
4183 for F in {1,2,3,4,5}; do
4184 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4185 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4188 #migrate the directories among MDTs
4191 mdt_idx=$((RANDOM % MDSCOUNT))
4192 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4194 [ $rc -ne 0 -o $rc -ne 16 ] || break
4199 echo "start migration thread $migrate_pid"
4200 #Access the files at the same time
4201 start_time=$(date +%s)
4202 echo "accessing the migrating directory for 5 minutes..."
4204 ls $migrate_dir2 > /dev/null || {
4205 echo "read dir fails"
4208 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4209 echo "access file1 fails"
4213 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4214 echo "access file2/3 fails"
4218 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4219 echo "access file4 fails"
4223 stat $migrate_dir2/file5 > /dev/null || {
4224 echo "stat file5 fails"
4228 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4229 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4230 echo "touch file failed with $rc1"
4234 if [ -e $migrate_dir2/source_file ]; then
4235 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4236 &>/dev/null || rc1=$?
4237 if [ -e $migrate_dir2/link_file ]; then
4238 rm -rf $migrate_dir2/link_file
4241 mrename $migrate_dir2/source_file \
4242 $migrate_dir2/target_file &>/dev/null || rc1=$?
4243 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4244 echo "rename failed with $rc1"
4248 if [ -e $migrate_dir2/target_file ]; then
4249 rm -rf $migrate_dir2/target_file &>/dev/null ||
4252 rm -rf $migrate_dir2/source_file &>/dev/null ||
4255 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4256 echo "unlink failed with $rc1"
4261 end_time=$(date +%s)
4262 duration=$((end_time - start_time))
4263 if [ $((duration % 10)) -eq 0 ]; then
4264 if [ $show_time -eq 1 ]; then
4265 echo "...$duration seconds"
4272 kill -0 $migrate_pid || {
4273 echo "migration stopped 1"
4277 [ $duration -ge 300 ] && break
4280 #check migration are still there
4281 kill -0 $migrate_pid || error "migration stopped 2"
4284 run_test 80b "Accessing directory during migration"
4287 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4291 mkdir -p $DIR1/$tdir
4293 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4294 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4297 touch d0/0 || error "create 0 failed"
4298 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4299 stat d0/0 && error "stat mv filed succeed"
4300 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4301 stat d0/0 || error "stat failed"
4303 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4305 if [ $t -ne 3 ]; then
4306 ls -ai $DIR1/$tdir/d0
4307 error "expect 3 get $t"
4312 run_test 81a "rename and stat under striped directory"
4315 [ $MDSCOUNT -lt 2 ] &&
4316 skip "We need at least 2 MDTs for this test"
4323 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4324 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4333 for i in $(seq $total); do
4334 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4338 kill -9 $setattr_pid
4340 run_test 81b "rename under striped directory doesn't deadlock"
4343 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4344 skip "Need MDS version at least 2.6.92"
4346 # Client 1 creates a file.
4347 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4349 # Client 2 opens the file.
4350 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4352 # Client 1 makes the file an orphan.
4353 rm $DIR1/$tfile || error "rm"
4354 # Client 2 sets EA "user.multiop".
4356 wait $pid2 || error "multiop 2"
4357 # Client 1 gets EA "user.multiop". This used to fail because the EA
4358 # cache refill would get "trusted.link" from mdd_xattr_list() but
4359 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4362 wait $pid1 || error "multiop 1"
4364 run_test 82 "fsetxattr and fgetxattr on orphan files"
4367 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4374 $LFS mkdir -i1 -c2 $tdir
4379 echo "start pid $pid1 to create/unlink striped directory"
4381 # Access the directory at the same time
4385 stat $tdir > /dev/null 2>&1
4389 echo "start pid $pid2 to stat striped directory"
4397 run_test 83 "access striped directory while it is being created/unlinked"
4400 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4401 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4405 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4406 error "create $tfile failed"
4407 mtime=$(stat -c%Y $DIR/$tfile)
4408 mtime=$((mtime + 200))
4410 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4411 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4413 touch -c -m $mtime $DIR/$tfile &
4415 # sleep a while to let 'touch' run first
4417 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4420 wait $setattr_pid || true
4422 run_test 84 "0-nlink race in lu_object_find()"
4425 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4430 [ "$SLOW" = "yes" ] && duration=600
4431 # Open/Create under striped directory
4435 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4436 touch $tdir/f{0..3} > /dev/null 2>&1
4440 echo "start pid $pid1 to open/create under striped directory"
4442 # unlink the striped directory at the same time
4446 rm -rf $tdir > /dev/null 2>&1
4450 echo "start pid $pid2 to unlink striped directory"
4459 run_test 90 "open/create and unlink striped directory"
4462 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4467 [ "$SLOW" = "yes" ] && duration=600
4468 # chmod striped directory
4472 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4473 chmod go+w $tdir > /dev/null 2>&1
4477 echo "start pid $pid1 to chmod striped directory"
4479 # unlink the striped directory at the same time
4483 rm -rf $tdir > /dev/null 2>&1
4487 echo "start pid $pid2 to unlink striped directory"
4496 run_test 91 "chmod and unlink striped directory"
4499 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4502 local cmd="exec $fd<$DIR1/$tdir"
4503 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4506 trap "eval $cmd" EXIT
4507 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4508 rmdir ../$tdir || error "rmdir ../$tdir fails"
4510 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4511 $LCTL set_param fail_loc=0x1408
4512 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4513 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4514 error "create remote dir succeeds"
4515 $LCTL set_param fail_loc=0
4519 run_test 92 "create remote directory under orphan directory"
4526 mkdir -p $DIR1/$tfile-1/
4527 mkdir -p $DIR2/$tfile-2/
4528 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4529 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4530 do_facet $SINGLEMDS "$LCTL set_param -n \
4531 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4532 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4533 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4535 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4538 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4542 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4543 do_facet $SINGLEMDS "$LCTL set_param -n \
4544 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4546 $LFS getstripe $DIR1/$tfile-1/file1
4547 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4548 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4549 $LFS getstripe $DIR2/$tfile-2/file2
4550 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4551 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4552 echo "rc1=$rc1 and rc2=$rc2 "
4553 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4554 error "object allocate on same ost detected"
4556 run_test 93 "alloc_rr should not allocate on same ost"
4559 $LCTL set_param osc.*.idle_timeout=0
4560 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4562 local before=$(date +%s)
4566 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4567 $LCTL set_param fail_val=5 fail_loc=0x80000312
4568 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4572 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4573 $LCTL set_param fail_val=6 fail_loc=0x80000329
4574 $LCTL mark kill $pid
4577 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4580 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4582 evict=$(do_facet client $LCTL get_param \
4583 osc.$FSNAME-OST*-osc-*/state |
4584 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4586 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4587 (do_facet client $LCTL get_param \
4588 osc.$FSNAME-OST*-osc-*/state;
4589 error "eviction happened: $evict before:$before")
4590 $LCTL set_param osc.*.idle_timeout=debug
4592 run_test 94 "signal vs CP callback race"
4596 skip "Reserved for glimpse-ahead" && return
4597 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4598 skip "Need MDS version at least 2.10.55"
4602 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4604 lctl set_param -n mdc.*.stats=clear
4605 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4607 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4608 # first stat from server should return size data and save glimpse
4609 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4610 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4611 # second stat to check size is NOT cached on client without IO lock
4612 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4614 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4615 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4618 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4621 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4622 skip "Need MDS version at least 2.10.55"
4626 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4628 lctl set_param -n mdc.*.stats=clear
4629 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4630 cancel_lru_locks mdc
4631 # first stat data from server should have size
4632 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4633 # second stat to check size is cached on client
4634 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4636 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4637 # both stats should cause no glimpse requests
4638 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4641 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4644 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4645 skip "Need MDS version at least 2.10.55"
4649 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4651 lctl set_param -n mdc.*.stats=clear
4652 lctl set_param -n osc.*.stats=clear
4653 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4655 # check that size is merged from MDT and OST correctly
4656 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4657 error "Wrong size from stat #1"
4659 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4660 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4664 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4667 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4668 skip "Need MDS version at least 2.10.55"
4672 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4675 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4676 lctl set_param -n mdc.*.stats=clear
4677 $TRUNCATE $DIR2/$tdir/dom 4096
4679 # check that reported size is valid after file grows to OST and
4680 # is truncated back to MDT stripe size
4681 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4682 error "Wrong size from stat #1"
4684 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4685 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4689 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4692 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
4693 skip "Need MDS version at least 2.11.50"
4695 local dom=$DIR/$tdir/dom
4696 local dom2=$DIR2/$tdir/dom
4699 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4701 cancel_lru_locks mdc
4702 dd if=/dev/urandom of=$dom bs=12000 count=1
4703 $TRUNCATE $dom2 6000
4704 cancel_lru_locks mdc
4705 lctl set_param -n mdc.*.stats=clear
4706 # expect read-on-open to return all data before write
4707 cat /etc/hosts >> $dom
4708 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4709 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4711 run_test 100e "DoM: read on open and file size"
4714 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4715 skip "Need MDS version at least 2.10.55"
4717 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4719 $CHECKSTAT -t file $DIR1/$tfile
4721 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4722 sysctl -wq vm.dirty_writeback_centisecs=0
4724 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4727 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4728 error_noexit "Write fails"
4729 # must discard pages
4730 lctl set_param -n mdc.*.stats=clear
4731 rm $DIR2/$tfile || error "Unlink fails"
4733 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4734 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4736 run_test 101a "Discard DoM data on unlink"
4739 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4740 skip "Need MDS version at least 2.10.55"
4742 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4743 touch $DIR1/${tfile}_2
4745 $CHECKSTAT -t file $DIR1/$tfile
4747 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4748 sysctl -wq vm.dirty_writeback_centisecs=0
4750 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4753 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4754 # must discard pages
4755 lctl set_param -n mdc.*.stats=clear
4756 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4758 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4759 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4761 run_test 101b "Discard DoM data on rename"
4764 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4765 skip "Need MDS version at least 2.10.55"
4767 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4769 $CHECKSTAT -t file $DIR1/$tfile
4771 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4772 sysctl -wq vm.dirty_writeback_centisecs=0
4774 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4777 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4778 $MULTIOP $DIR1/$tfile O_c &
4781 lctl set_param -n mdc.*.stats=clear
4782 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4783 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4785 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4786 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4788 run_test 101c "Discard DoM data on close-unlink"
4790 # test to verify file handle related system calls
4791 # (name_to_handle_at/open_by_handle_at)
4792 # The new system calls are supported in glibc >= 2.14.
4794 # test to verify we can open by handle an unlinked file from > 1 client
4795 # This test opens the file normally on $DIR1, which is on one mount, and then
4796 # opens it by handle on $DIR2, which is on a different mount.
4798 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
4799 skip "Needs MDS version 2.11.57 or later"
4801 echo "Test file_handle syscalls" > $DIR/$tfile ||
4802 error "write failed"
4803 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4804 error "check_fhandle_syscalls failed"
4807 run_test 102 "Test open by handle of unlinked file"
4809 # Compare file size between first & second mount, ensuring the client correctly
4810 # glimpses even with unused speculative locks - LU-11670
4812 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
4813 skip "Lockahead needs OST version at least 2.10.50"
4817 test_mkdir -p $DIR/$tdir
4819 # Force file on to OST0
4820 $LFS setstripe -i 0 $DIR/$tdir
4822 # Do not check multiple locks on glimpse
4823 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
4824 $LCTL set_param fail_loc=0x415
4826 # Delay write commit by 2 seconds to guarantee glimpse wins race
4827 # The same fail_loc is used on client & server so it can work in the
4828 # single node sanity setup
4829 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
4831 echo "Incorrect size expected (no glimpse fix):"
4832 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4834 if [ $rc -eq 0 ]; then
4835 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
4838 # guarantee write commit timeout has expired
4841 # Clear fail_loc on client
4842 $LCTL set_param fail_loc=0
4844 # Delay write commit by 2 seconds to guarantee glimpse wins race
4845 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4846 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
4848 # Write commit is still delayed by 2 seconds
4849 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4851 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
4853 # guarantee write commit timeout has expired
4856 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
4858 run_test 103 "Test size correctness with lockahead"
4864 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
4875 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
4876 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
4877 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
4878 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
4886 local xtimes=($(get_stat_xtimes))
4887 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4889 echo "STAT a|m|ctime ${xtimes[*]}"
4890 echo "MDT a|m|ctime ${xtimes[*]}"
4891 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
4892 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
4893 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4894 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4895 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4896 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4900 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
4901 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
4902 skip "Need MDS version at least 2.12.4"
4905 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
4906 local atime_diff=$(do_facet $SINGLEMDS \
4907 lctl get_param -n mdd.*MDT0000*.atime_diff)
4909 do_facet $SINGLEMDS \
4910 lctl set_param -n mdd.*MDT0000*.atime_diff=0
4912 stack_trap "do_facet $SINGLEMDS \
4913 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
4915 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4916 check_mdt_xtimes $mdtdev
4919 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4920 check_mdt_xtimes $mdtdev
4922 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
4925 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4927 kill -USR1 $pid && wait $pid || error "multiop failure"
4928 check_mdt_xtimes $mdtdev
4933 # Verify mtime/ctime is NOT upated on MDS when there is no modification
4934 # on the client side
4935 xtimes=($(get_stat_xtimes))
4936 $MULTIOP $DIR/$tfile O_c &
4939 kill -USR1 $pid && wait $pid || error "multiop failure"
4940 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4941 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4942 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4943 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4944 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4945 check_mdt_xtimes $mdtdev
4948 # Change ctime via chmod
4949 $MULTIOP $DIR/$tfile o_tc &
4952 kill -USR1 $pid && wait $pid || error "multiop failure"
4953 check_mdt_xtimes $mdtdev
4955 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
4958 test_mkdir -p $DIR/$tdir
4959 echo test > $DIR/$tdir/$tfile
4960 $LCTL set_param fail_loc=0x416
4961 cancel_lru_locks osc & sleep 1
4962 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
4964 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
4966 run_test 105 "Glimpse and lock cancel race"
4968 log "cleanup: ======================================================"
4970 # kill and wait in each test only guarentee script finish, but command in script
4971 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4972 # otherwise umount below will fail
4973 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4978 check_and_cleanup_lustre