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: unlink and blocking operations
1956 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1957 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1960 mkdir $DIR2/$tfile &
1962 do_facet $SINGLEMDS lctl set_param fail_loc=0
1963 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1964 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
1968 run_test 43a "pdirops: unlink vs mkdir =============="
1973 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1974 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1977 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1979 do_facet $SINGLEMDS lctl set_param fail_loc=0
1980 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1981 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
1985 run_test 43b "pdirops: unlink vs create =============="
1990 touch $DIR1/$tfile-2
1991 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1992 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1995 link $DIR2/$tfile-2 $DIR2/$tfile &
1997 do_facet $SINGLEMDS lctl set_param fail_loc=0
1998 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1999 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2003 run_test 43c "pdirops: unlink vs link =============="
2008 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2009 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2014 do_facet $SINGLEMDS lctl set_param fail_loc=0
2015 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2016 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2020 run_test 43d "pdirops: unlink vs unlink =============="
2025 touch $DIR1/$tfile-2
2026 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2027 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2030 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2032 do_facet $SINGLEMDS lctl set_param fail_loc=0
2033 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2034 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2038 run_test 43e "pdirops: unlink and rename (tgt) =============="
2043 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2044 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2047 mv $DIR2/$tfile $DIR2/$tfile-2 &
2049 do_facet $SINGLEMDS lctl set_param fail_loc=0
2050 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2051 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2055 run_test 43f "pdirops: unlink and rename (src) =============="
2060 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2061 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2064 stat $DIR2/$tfile > /dev/null &
2066 do_facet $SINGLEMDS lctl set_param fail_loc=0
2067 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2068 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2072 run_test 43g "pdirops: unlink vs getattr =============="
2077 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2078 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2081 ls -lia $DIR2/ > /dev/null &
2083 do_facet $SINGLEMDS lctl set_param fail_loc=0
2084 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2089 run_test 43h "pdirops: unlink vs readdir =============="
2092 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2095 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2096 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2099 $LFS mkdir -i 1 $DIR2/$tfile &
2101 do_facet $SINGLEMDS lctl set_param fail_loc=0
2102 check_pdo_conflict $PID1 &&
2103 { wait $PID1; error "remote mkdir isn't blocked"; }
2104 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2108 run_test 43i "pdirops: unlink vs remote mkdir"
2110 # test 44: rename tgt and blocking operations
2113 touch $DIR1/$tfile-2
2114 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2115 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2116 mv $DIR1/$tfile-2 $DIR1/$tfile &
2118 mkdir $DIR2/$tfile &
2120 do_facet $SINGLEMDS lctl set_param fail_loc=0
2121 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2122 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2127 run_test 44a "pdirops: rename tgt vs mkdir =============="
2131 touch $DIR1/$tfile-2
2132 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2133 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2134 mv $DIR1/$tfile-2 $DIR1/$tfile &
2136 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2138 do_facet $SINGLEMDS lctl set_param fail_loc=0
2139 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2140 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2144 run_test 44b "pdirops: rename tgt vs create =============="
2148 touch $DIR1/$tfile-2
2149 touch $DIR1/$tfile-3
2150 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2151 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2152 mv $DIR1/$tfile-2 $DIR1/$tfile &
2154 link $DIR2/$tfile-3 $DIR2/$tfile &
2156 do_facet $SINGLEMDS lctl set_param fail_loc=0
2157 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2158 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2162 run_test 44c "pdirops: rename tgt vs link =============="
2166 touch $DIR1/$tfile-2
2167 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2168 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2169 mv $DIR1/$tfile-2 $DIR1/$tfile &
2173 do_facet $SINGLEMDS lctl set_param fail_loc=0
2174 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2175 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2179 run_test 44d "pdirops: rename tgt vs unlink =============="
2184 touch $DIR1/$tfile-2
2185 touch $DIR1/$tfile-3
2186 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2187 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2188 mv $DIR1/$tfile-2 $DIR1/$tfile &
2190 mv $DIR2/$tfile-3 $DIR2/$tfile &
2192 do_facet $SINGLEMDS lctl set_param fail_loc=0
2193 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2194 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2198 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2202 touch $DIR1/$tfile-2
2203 touch $DIR1/$tfile-3
2204 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2205 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2206 mv $DIR1/$tfile-2 $DIR1/$tfile &
2208 mv $DIR2/$tfile $DIR2/$tfile-3 &
2210 do_facet $SINGLEMDS lctl set_param fail_loc=0
2211 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2212 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2216 run_test 44f "pdirops: rename tgt and rename (src) =============="
2220 touch $DIR1/$tfile-2
2221 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2222 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2223 mv $DIR1/$tfile-2 $DIR1/$tfile &
2225 stat $DIR2/$tfile > /dev/null &
2227 do_facet $SINGLEMDS lctl set_param fail_loc=0
2228 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2229 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2233 run_test 44g "pdirops: rename tgt vs getattr =============="
2237 touch $DIR1/$tfile-2
2238 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2239 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2240 mv $DIR1/$tfile-2 $DIR1/$tfile &
2242 ls -lia $DIR2/ > /dev/null &
2244 do_facet $SINGLEMDS lctl set_param fail_loc=0
2245 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2250 run_test 44h "pdirops: rename tgt vs readdir =============="
2252 # test 44: rename tgt and blocking operations
2254 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2256 touch $DIR1/$tfile-2
2257 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2258 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2259 mv $DIR1/$tfile-2 $DIR1/$tfile &
2261 $LFS mkdir -i 1 $DIR2/$tfile &
2263 do_facet $SINGLEMDS lctl set_param fail_loc=0
2264 check_pdo_conflict $PID1 && { wait $PID1;
2265 error "remote mkdir isn't blocked"; }
2266 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2270 run_test 44i "pdirops: rename tgt vs remote mkdir"
2272 # test 45: rename src and blocking operations
2276 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2277 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2278 mv $DIR1/$tfile $DIR1/$tfile-2 &
2280 mkdir $DIR2/$tfile &
2282 do_facet $SINGLEMDS lctl set_param fail_loc=0
2283 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2284 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
2288 run_test 45a "pdirops: rename src vs mkdir =============="
2293 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2294 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2295 mv $DIR1/$tfile $DIR1/$tfile-2 &
2297 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2299 do_facet $SINGLEMDS lctl set_param fail_loc=0
2300 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2301 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2305 run_test 45b "pdirops: rename src vs create =============="
2310 touch $DIR1/$tfile-3
2311 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2312 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2313 mv $DIR1/$tfile $DIR1/$tfile-2 &
2315 link $DIR2/$tfile-3 $DIR2/$tfile &
2317 do_facet $SINGLEMDS lctl set_param fail_loc=0
2318 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2319 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2323 run_test 45c "pdirops: rename src vs link =============="
2328 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2329 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2330 mv $DIR1/$tfile $DIR1/$tfile-2 &
2334 do_facet $SINGLEMDS lctl set_param fail_loc=0
2335 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2336 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2340 run_test 45d "pdirops: rename src vs unlink =============="
2345 touch $DIR1/$tfile-3
2346 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2347 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2348 mv $DIR1/$tfile $DIR1/$tfile-2 &
2350 mv $DIR2/$tfile-3 $DIR2/$tfile &
2352 do_facet $SINGLEMDS lctl set_param fail_loc=0
2353 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2354 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2358 run_test 45e "pdirops: rename src and rename (tgt) =============="
2363 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2364 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2365 mv $DIR1/$tfile $DIR1/$tfile-2 &
2367 mv $DIR2/$tfile $DIR2/$tfile-3 &
2369 do_facet $SINGLEMDS lctl set_param fail_loc=0
2370 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2371 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2375 run_test 45f "pdirops: rename src and rename (src) =============="
2380 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2381 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2382 mv $DIR1/$tfile $DIR1/$tfile-2 &
2384 stat $DIR2/$tfile > /dev/null &
2386 do_facet $SINGLEMDS lctl set_param fail_loc=0
2387 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2388 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2392 run_test 45g "pdirops: rename src vs getattr =============="
2397 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2398 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2399 mv $DIR1/$tfile $DIR1/$tfile-2 &
2401 ls -lia $DIR2/ > /dev/null &
2402 do_facet $SINGLEMDS lctl set_param fail_loc=0
2403 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2408 run_test 45h "pdirops: unlink vs readdir =============="
2411 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2414 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2415 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2416 mv $DIR1/$tfile $DIR1/$tfile-2 &
2418 $LFS mkdir -i 1 $DIR2/$tfile &
2420 do_facet $SINGLEMDS lctl set_param fail_loc=0
2421 check_pdo_conflict $PID1 && { wait $PID1;
2422 error "create remote dir isn't blocked"; }
2423 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2427 run_test 45i "pdirops: rename src vs remote mkdir"
2429 # test 46: link and blocking operations
2432 touch $DIR1/$tfile-2
2433 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2434 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2435 link $DIR1/$tfile-2 $DIR1/$tfile &
2437 mkdir $DIR2/$tfile &
2439 do_facet $SINGLEMDS lctl set_param fail_loc=0
2440 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2441 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2445 run_test 46a "pdirops: link vs mkdir =============="
2449 touch $DIR1/$tfile-2
2450 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2451 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2452 link $DIR1/$tfile-2 $DIR1/$tfile &
2454 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2456 do_facet $SINGLEMDS lctl set_param fail_loc=0
2457 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2458 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2462 run_test 46b "pdirops: link vs create =============="
2466 touch $DIR1/$tfile-2
2467 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2468 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2469 link $DIR1/$tfile-2 $DIR1/$tfile &
2471 link $DIR2/$tfile $DIR2/$tfile &
2473 do_facet $SINGLEMDS lctl set_param fail_loc=0
2474 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2475 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2479 run_test 46c "pdirops: link vs link =============="
2483 touch $DIR1/$tfile-2
2484 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2485 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2486 link $DIR1/$tfile-2 $DIR1/$tfile &
2490 do_facet $SINGLEMDS lctl set_param fail_loc=0
2491 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2492 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2496 run_test 46d "pdirops: link vs unlink =============="
2500 touch $DIR1/$tfile-2
2501 touch $DIR1/$tfile-3
2502 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2503 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2504 link $DIR1/$tfile-2 $DIR1/$tfile &
2506 mv $DIR2/$tfile-3 $DIR2/$tfile &
2508 do_facet $SINGLEMDS lctl set_param fail_loc=0
2509 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2510 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2514 run_test 46e "pdirops: link and rename (tgt) =============="
2518 touch $DIR1/$tfile-2
2519 touch $DIR1/$tfile-3
2520 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2521 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2522 link $DIR1/$tfile-2 $DIR1/$tfile &
2524 mv $DIR2/$tfile $DIR2/$tfile-3 &
2526 do_facet $SINGLEMDS lctl set_param fail_loc=0
2527 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2528 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2532 run_test 46f "pdirops: link and rename (src) =============="
2536 touch $DIR1/$tfile-2
2537 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2538 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2539 link $DIR1/$tfile-2 $DIR1/$tfile &
2541 stat $DIR2/$tfile > /dev/null &
2543 do_facet $SINGLEMDS lctl set_param fail_loc=0
2544 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2545 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2549 run_test 46g "pdirops: link vs getattr =============="
2553 touch $DIR1/$tfile-2
2554 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2555 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2556 link $DIR1/$tfile-2 $DIR1/$tfile &
2558 ls -lia $DIR2/ > /dev/null &
2560 do_facet $SINGLEMDS lctl set_param fail_loc=0
2561 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2566 run_test 46h "pdirops: link vs readdir =============="
2569 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2571 touch $DIR1/$tfile-2
2572 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2573 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2574 link $DIR1/$tfile-2 $DIR1/$tfile &
2576 $LFS mkdir -i 1 $DIR2/$tfile &
2578 do_facet $SINGLEMDS lctl set_param fail_loc=0
2579 check_pdo_conflict $PID1 && { wait $PID1;
2580 error "remote mkdir isn't blocked"; }
2581 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2585 run_test 46i "pdirops: link vs remote mkdir"
2587 # test 47: remote mkdir and blocking operations
2589 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2590 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2592 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2593 $LFS mkdir -i 1 $DIR1/$tfile &
2595 mkdir $DIR2/$tfile &
2597 do_facet $SINGLEMDS lctl set_param fail_loc=0
2598 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2599 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2603 run_test 47a "pdirops: remote mkdir vs mkdir"
2606 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2607 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2609 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2610 $LFS mkdir -i 1 $DIR1/$tfile &
2612 sleep 1 # please do not remove this sleep, see LU-10754
2613 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2615 do_facet $SINGLEMDS lctl set_param fail_loc=0
2616 check_pdo_conflict $PID1 && { wait $PID1;
2617 error "create isn't blocked"; }
2618 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2622 run_test 47b "pdirops: remote mkdir vs create"
2625 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2627 touch $DIR1/$tfile-2
2628 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2629 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2630 $LFS mkdir -i 1 $DIR1/$tfile &
2632 link $DIR2/$tfile-2 $DIR2/$tfile &
2634 do_facet $SINGLEMDS lctl set_param fail_loc=0
2635 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2636 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2640 run_test 47c "pdirops: remote mkdir vs link"
2643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2645 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2646 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2647 $LFS mkdir -i 1 $DIR1/$tfile &
2649 rmdir $DIR2/$tfile &
2651 do_facet $SINGLEMDS lctl set_param fail_loc=0
2652 check_pdo_conflict $PID1 && { wait $PID1;
2653 error "unlink isn't blocked"; }
2654 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2658 run_test 47d "pdirops: remote mkdir vs unlink"
2661 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2663 touch $DIR1/$tfile-2
2664 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2665 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2666 $LFS mkdir -i 1 $DIR1/$tfile &
2668 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2670 do_facet $SINGLEMDS lctl set_param fail_loc=0
2671 check_pdo_conflict $PID1 && { wait $PID1;
2672 error "rename isn't blocked"; }
2673 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2677 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2680 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2682 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2683 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2684 $LFS mkdir -i 1 $DIR1/$tfile &
2686 mv $DIR2/$tfile $DIR2/$tfile-2 &
2688 do_facet $SINGLEMDS lctl set_param fail_loc=0
2689 check_pdo_conflict $PID1 && { wait $PID1;
2690 error "rename isn't blocked"; }
2691 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2695 run_test 47f "pdirops: remote mkdir and rename (src)"
2698 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2702 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2703 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2704 $LFS mkdir -i 1 $DIR1/$tfile &
2706 stat $DIR2/$tfile > /dev/null &
2708 do_facet $SINGLEMDS lctl set_param fail_loc=0
2709 check_pdo_conflict $PID1 && { wait $PID1;
2710 error "getattr isn't blocked"; }
2711 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2715 run_test 47g "pdirops: remote mkdir vs getattr"
2719 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2720 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2721 do_facet client "lctl set_param fail_loc=0x410"
2722 $TRUNCATE $DIR2/$tfile $trunc_size
2723 do_facet client "lctl set_param fail_loc=0x0"
2725 size=`stat -c %s $DIR2/$tfile`
2726 [ $size -eq $trunc_size ] || error "wrong size"
2728 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2732 local origfile=/etc/hosts
2734 filesize=$(stat -c %s $origfile)
2736 # create an empty file
2737 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2738 # cache layout lock on both mount point
2739 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2740 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2742 # open and sleep 2 seconds then read
2743 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2747 # create the layout of testing file
2748 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2749 error "dd $DIR1/$tfile failed"
2751 # MULTIOP proc should be able to read enough bytes and exit
2752 for ((i = 0; i < 6; i++)); do
2754 kill -0 $pid || break
2756 kill -0 $pid 2> /dev/null && error "multiop is still there"
2757 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2761 run_test 51a "layout lock: refresh layout should work"
2764 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
2765 skip "Need MDS version at least 2.3.59"
2767 local tmpfile=`mktemp`
2769 # create an empty file
2770 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2772 # delay glimpse so that layout has changed when glimpse finish
2773 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2774 $LCTL set_param fail_loc=0x1404
2775 stat -c %s $DIR2/$tfile |tee $tmpfile &
2779 # create layout of testing file
2780 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2781 error "dd $DIR1/$tfile failed"
2784 local fsize=$(cat $tmpfile)
2786 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2788 rm -f $DIR1/$tfile $tmpfile
2790 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2793 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2795 # set default layout to have 1 stripe
2797 $LFS setstripe -c 1 $DIR1/$tdir
2799 # create a file with empty layout
2800 $MCREATE $DIR1/$tdir/$tfile ||
2801 error "$MCREATE $DIR1/$tdir/$tfile failed"
2803 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2804 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2806 # change the layout of testing file
2807 echo "Setting layout to have $OSTCOUNT stripes ..."
2808 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2812 # write something to the file, it should be blocked on fetching layout
2813 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2814 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2817 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2818 # count to succeed with only 3/4 of the number of stripes (rounded up),
2819 # so creating striped files does not fail if an OST is offline or full
2820 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2821 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2825 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2828 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2829 cancel_lru_locks mdc
2831 # open should grant LAYOUT lock, mmap and read will install pages
2832 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2836 # rss before revoking
2837 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2838 echo "Before revoking layout lock: $br KB mapped"
2840 # cancel layout lock manually
2841 cancel_lru_locks mdc
2843 # rss after revoking
2844 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2847 wait $PID || error "wait PID $PID failed"
2849 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2851 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2855 echo "==> rename vs getattr vs setxattr should not deadlock"
2856 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2858 do_facet mds1 $LCTL set_param fail_loc=$1
2860 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2868 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2869 wait $PID1 || error "(3) mv failed"
2870 wait $PID2 || error "(4) stat failed"
2877 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2878 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2880 do_facet mds1 $LCTL set_param fail_loc=$1
2882 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2890 $MULTIOP $DIR2/d1/d2 Oc &
2894 stat $DIR/d1 || error "(2) stat failed"
2896 wait $PID1 || error "(3) mv failed"
2897 wait $PID2 || error "(4) stat failed"
2898 wait $PID3 && error "(5) multiop failed"
2904 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2905 save_lustre_params client "llite.*.xattr_cache" > $p
2906 lctl set_param llite.*.xattr_cache 1 ||
2907 { skip "xattr cache is not supported"; return 0; }
2909 #define OBD_FAIL_MDS_RENAME 0x153
2910 #define OBD_FAIL_MDS_RENAME2 0x154
2911 test_54_part1 0x80000153 || error 10
2912 test_54_part1 0x80000154 || error 11
2913 test_54_part2 0x80000153 || error 12
2914 test_54_part2 0x80000154 || error 13
2916 restore_lustre_params < $p
2919 run_test 54 "rename locking"
2922 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2924 #define OBD_FAIL_MDS_RENAME4 0x156
2925 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2927 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2932 wait $PID1 && error "(2) mv succeeded"
2936 run_test 55a "rename vs unlink target dir"
2940 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2942 #define OBD_FAIL_MDS_RENAME4 0x156
2943 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2945 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2950 wait $PID1 && error "(2) mv succeeded"
2954 run_test 55b "rename vs unlink source dir"
2958 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2960 #define OBD_FAIL_MDS_RENAME4 0x156
2961 do_facet mds1 $LCTL set_param fail_loc=0x156
2963 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2967 # while rename is sleeping, open and remove d3
2968 $MULTIOP $DIR2/d3 D_c &
2974 # while rename is sleeping 2nd time, close d3
2976 wait $PID2 || error "(3) multiop failed"
2978 wait $PID1 && error "(2) mv succeeded"
2982 run_test 55c "rename vs unlink orphan target dir"
2988 #define OBD_FAIL_MDS_RENAME3 0x155
2989 do_facet mds1 $LCTL set_param fail_loc=0x155
2990 mv $DIR/f1 $DIR/$tdir &
2994 # while rename is sleeping, create $tdir, but as a directory
2995 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2997 # link in reverse locking order
2998 ln $DIR2/f1 $DIR2/$tdir/
3000 wait $PID1 && error "(2) mv succeeded"
3003 run_test 55d "rename file vs link"
3006 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3007 skip "MDS version must be >= 2.3.0"
3010 test_mkdir $DIR1/$tdir
3011 file1=$DIR1/$tdir/file
3012 file2=$DIR2/$tdir/file
3014 echo orig > $file2 || error "Could not create $file2"
3015 version=$($LFS data_version $file1)
3018 echo append >> $file2 || error "Could not append to $file2"
3019 version2=$($LFS data_version $file1)
3020 [ "$version" != "$version2" ] ||
3021 error "append did not change data version: $version"
3024 echo overwrite > $file2 || error "Could not overwrite $file2"
3025 version3=$($LFS data_version $file1)
3026 [ "$version2" != "$version3" ] ||
3027 error "overwrite did not change data version: $version2"
3029 # Truncate before EOF
3030 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3031 version4=$($LFS data_version $file1)
3032 [ "$version3" != "$version4" ] ||
3033 error "truncate did not change data version: $version3"
3035 # Truncate after EOF
3036 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3037 version5=$($LFS data_version $file1)
3038 [ "$version4" != "$version5" ] ||
3039 error "truncate did not change data version: $version4"
3041 # Chmod do not change version
3042 chmod 400 $file2 || error "Could not chmod 400 $file2"
3043 version6=$($LFS data_version $file1)
3044 [ "$version5" == "$version6" ] ||
3045 error "chmod should not change data version: $version5 != $version6"
3047 # Chown do not change version
3048 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3049 version7=$($LFS data_version $file1)
3050 [ "$version5" == "$version7" ] ||
3051 error "chown should not change data version: $version5 != $version7"
3053 run_test 60 "Verify data_version behaviour"
3056 local test_dir=$tdir/test_dir
3058 mkdir -p $DIR1/$tdir
3059 if [ $MDSCOUNT -ge 2 ]; then
3061 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3062 error "Create remote directory failed"
3064 mkdir -p $DIR1/$test_dir
3066 cd $DIR2/$test_dir || error "cd directory failed"
3067 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3069 cd $DIR2/$tdir || error "exit directory"
3071 run_test 70a "cd directory && rm directory"
3073 test_70b() { # LU-2781
3075 mkdir -p $DIR1/$tdir
3077 touch $DIR1/$tdir/file
3078 for ((i = 0; i < 32; i++)); do
3079 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3081 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3083 touch $DIR1/$tdir/file
3084 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3085 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3086 rm -rf $DIR1/$tdir/test_dir ||
3087 error "cannot remove directory after rm_entry"
3088 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3090 run_test 70b "remove files after calling rm_entry"
3093 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3094 skip "Need MDS version at least 2.1.6"
3096 # Patch not applied to 2.2 and 2.3 branches
3097 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3098 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3099 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3101 checkfiemap --test ||
3102 skip "checkfiemap not runnable: $?"
3103 # write data this way: hole - data - hole - data
3104 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3105 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3107 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3108 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3109 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3111 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3113 checkfiemap $DIR2/$tfile 81920 ||
3114 error "data is not flushed from client"
3115 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3118 # common case of "create file, copy file" on a single node
3119 # should not flush data from ost
3120 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3121 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3123 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3125 checkfiemap $DIR1/$tfile 81920 ||
3127 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3129 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3131 run_test 71a "correct file map just after write operation is finished"
3134 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3135 skip "Need MDS version at least 2.1.6"
3137 # Patch not applied to 2.2 and 2.3 branches
3138 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3139 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3140 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3141 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3143 checkfiemap --test ||
3144 skip "error $?: checkfiemap failed"
3146 mkdir -p $DIR1/$tdir
3148 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3149 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3150 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3152 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3153 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3155 run_test 71b "check fiemap support for stripecount > 1"
3158 local p="$TMP/sanityN-$TESTNAME.parameters"
3161 save_lustre_params client "llite.*.xattr_cache" > $p
3162 lctl set_param llite.*.xattr_cache 1 ||
3163 { skip "xattr cache is not supported"; return 0; }
3166 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3167 error "setfattr1 failed"
3168 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3169 error "getfattr1 failed"
3170 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3171 error "setfattr2 failed"
3172 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3173 error "getfattr2 failed"
3175 # check that trusted.link is consistent
3176 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3177 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3178 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3179 echo "$tlink1 $tlink2"
3180 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3184 restore_lustre_params < $p
3187 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3190 local p="$TMP/sanityN-$TESTNAME.parameters"
3191 save_lustre_params client "llite.*.xattr_cache" > $p
3192 lctl set_param llite.*.xattr_cache 1 ||
3193 { skip "xattr cache is not supported"; return 0; }
3196 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3197 error "setfattr1 failed"
3198 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3199 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3200 clear_stats llite.*.stats
3201 # PR lock should be cached by now on both clients
3202 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3203 # 2 hits for getfattr(0)+getfattr(size)
3204 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3205 error "not cached in $DIR1"
3206 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3207 # 4 hits for more getfattr(0)+getfattr(size)
3208 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3209 error "not cached in $DIR2"
3212 restore_lustre_params < $p
3215 run_test 73 "getxattr should not cause xattr lock cancellation"
3218 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3219 skip "Need MDS version at least 2.4.93"
3221 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3222 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3223 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3225 run_test 74 "flock deadlock: different mounts =============="
3229 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3230 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3231 cancel_lru_locks osc
3233 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3236 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3237 $LCTL set_param fail_loc=0x31d
3238 stat -c %s $DIR1/$tfile &
3243 # For bad lock error handler we should ASSERT and got kernel panic here
3245 $LCTL set_param fail_loc=0
3247 run_test 75 "osc: upcall after unuse lock==================="
3250 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3251 skip "Need MDS version at least 2.5.53"
3253 remote_mds_nodsh && skip "remote MDS with nodsh"
3254 local fcount=$((MDSCOUNT * 256))
3259 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3265 test_mkdir $DIR/$tdir
3267 # drop all open locks and close any cached "open" files on the client
3268 cancel_lru_locks mdc
3270 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3271 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3272 local already=${#fid_list[@]}
3273 for (( i = 0; i < $already; i++ )) ; do
3274 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3277 echo -n "opening files: "
3278 ulimit -n $((fcount + 50))
3279 for ((i = 0; i < $fcount; i++)); do
3280 touch $DIR/$tdir/f_$i
3281 local fd=$(free_fd ${fd_list[i]})
3282 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3287 (( $i % 32 == 0 )) && echo -n "."
3291 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3293 # Possible errors in openfiles FID list.
3294 # 1. Missing FIDs. Check 1
3295 # 2. Extra FIDs. Check 1
3296 # 3. Duplicated FID. Check 2
3297 # 4. Invalid FIDs. Check 2
3298 # 5. Valid FID, points to some other file. Check 3
3301 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3302 error "${#fid_list[@]} != $fcount (+$already old) open files"
3304 echo -n "closing files: "
3305 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3306 local close_cmd="exec ${fd_list[fd]}<&-"
3308 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3310 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3311 echo "skip old open file $filename"
3313 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3317 rm --interactive=no $filename
3319 error "Nonexisting fid ${fid_list[fid]} listed."
3320 (( $fd % 32 == 0 )) && echo -n "."
3325 ls_op=$(ls $DIR2/$tdir | wc -l)
3327 error "Some openfiles are missing in lproc output"
3331 run_test 76 "Verify MDT open_files listing"
3335 local dir=$DIR/$tdir
3338 mkdir $dir || error "mkdir $dir failed"
3339 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3342 do_nodes $CLIENTS $myRUNAS \
3343 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3344 error "dd at 0 on client failed (1)"
3346 do_nodes $CLIENTS $myRUNAS \
3348 for ((i = 0; i < $n; i++)); do
3349 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3350 seek=\\\$i count=1 conv=notrunc &
3351 pids_w[\\\$i]=\\\$!;
3354 for ((i = 0; i < $n; i++)); do
3355 wait \\\${pids_w[\\\$i]};
3357 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3361 do_nodes $CLIENTS sync;
3362 cancel_lru_locks osc
3364 do_nodes $CLIENTS $myRUNAS \
3366 for ((i = 0; i < $n; i++)); do
3367 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3368 seek=\\\$i count=1 &
3369 pids_r[\\\$i]=\\\$!;
3372 for ((i = 0; i < $n; i++)); do
3373 wait \\\${pids_r[\\\$i]};
3375 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3379 cancel_lru_locks osc
3381 wait $pid_w || error "dd (write) failed (2)"
3382 wait $pid_r || error "dd (read) failed (3)"
3383 rm -rvf $dir || error "rm -rf $dir failed"
3386 test_77a() { #LU-3266
3389 oss=$(comma_list $(osts_nodes))
3390 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3392 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3393 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3398 run_test 77a "check FIFO NRS policy"
3400 test_77b() { #LU-3266
3403 oss=$(comma_list $(osts_nodes))
3405 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3406 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3407 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3408 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3410 echo "policy: crr-n, crrn_quantum 1"
3413 do_nodes $oss lctl set_param \
3414 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3415 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3417 echo "policy: crr-n, crrn_quantum 64"
3421 do_nodes $oss lctl set_param \
3422 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3423 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3426 run_test 77b "check CRR-N NRS policy"
3431 oss=$(comma_list $(osts_nodes))
3433 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3434 ost.OSS.*.nrs_"$policy"_quantum=1 \
3435 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3436 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3438 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3439 "physical, ${policy}_supported reads"
3442 do_nodes $oss lctl set_param \
3443 ost.OSS.*.nrs_${policy}_supported="writes" \
3444 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3446 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3447 "physical, ${policy}_supported writes"
3450 do_nodes $oss lctl set_param \
3451 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3452 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3453 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3454 "logical, ${policy}_supported reads_and_writes"
3458 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3463 test_77c() { #LU-3266
3465 orr_trr "orr" || rc=$?
3466 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3467 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3470 run_test 77c "check ORR NRS policy"
3472 test_77d() { #LU-3266
3474 orr_trr "trr" || rc=$?
3475 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3476 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3479 run_test 77d "check TRR nrs policy"
3486 do_facet $facet lctl set_param \
3487 ost.OSS.ost_io.nrs_tbf_rule="$*"
3489 error "failed to run operate '$*' on TBF rules"
3492 cleanup_tbf_verify()
3496 echo "cleanup_tbf $DIR/$tdir"
3499 wait_delete_completed
3504 local dir=$DIR/$tdir
3505 local client1=${CLIENT1:-$(hostname)}
3508 local np=$(check_cpt_number ost1)
3509 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3510 echo "cpu_npartitions on ost1 is $np"
3512 mkdir $dir || error "mkdir $dir failed"
3513 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3516 trap cleanup_tbf_verify EXIT
3517 echo "Limited write rate: $1, read rate: $2"
3518 echo "Verify the write rate is under TBF control"
3519 local start=$SECONDS
3520 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3521 bs=1M count=100 oflag=direct 2>&1
3522 local runtime=$((SECONDS - start + 1))
3523 local rate=$(bc <<< "scale=6; 100 / $runtime")
3524 echo "Write runtime is $runtime s, speed is $rate IOPS"
3526 # verify the write rate does not exceed TBF rate limit
3527 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3528 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3530 cancel_lru_locks osc
3532 echo "Verify the read rate is under TBF control"
3534 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3535 bs=1M count=100 iflag=direct 2>&1
3536 runtime=$((SECONDS - start + 1))
3537 rate=$(bc <<< "scale=6; 100 / $runtime")
3538 echo "Read runtime is $runtime s, speed is $rate IOPS"
3540 # verify the read rate does not exceed TBF rate limit
3541 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3542 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3544 cancel_lru_locks osc
3545 cleanup_tbf_verify || error "rm -rf $dir failed"
3551 oss=$(comma_list $(osts_nodes))
3553 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3555 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3556 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3560 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3565 # Only operate rules on ost1 since OSTs might run on the same OSS
3567 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3568 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3569 local client_nids=$(nids_list $address "\\")
3570 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3571 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3575 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3576 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3577 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3581 tbf_rule_operate ost1 "stop\ localhost"
3582 tbf_rule_operate ost1 "stop\ clients"
3583 tbf_rule_operate ost1 "stop\ others"
3586 # Cleanup the TBF policy
3587 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3588 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3592 run_test 77e "check TBF NID nrs policy"
3597 oss=$(comma_list $(osts_nodes))
3599 do_nodes $oss $LCTL set_param \
3600 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3601 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3602 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3604 # Configure jobid_var
3605 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3607 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3608 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3609 if [ $saved_jobid_var != procname_uid ]; then
3610 set_persistent_param_and_check client \
3611 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3616 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3621 # Only operate rules on ost1 since OSTs might run on the same OSS
3623 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3624 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3625 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3626 nrs_write_read "$RUNAS"
3629 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3630 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3631 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3632 nrs_write_read "$RUNAS"
3635 tbf_rule_operate ost1 "stop\ runas"
3636 tbf_rule_operate ost1 "stop\ iozone_runas"
3637 tbf_rule_operate ost1 "stop\ dd_runas"
3638 nrs_write_read "$RUNAS"
3640 # Cleanup the TBF policy
3641 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3642 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3643 nrs_write_read "$RUNAS"
3645 local current_jobid_var=$($LCTL get_param -n jobid_var)
3646 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3647 if [ $saved_jobid_var != $current_jobid_var ]; then
3648 set_persistent_param_and_check client \
3649 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3653 run_test 77f "check TBF JobID nrs policy"
3658 oss=$(comma_list $(osts_nodes))
3660 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3662 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3663 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3665 do_nodes $oss lctl set_param \
3666 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3667 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3671 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3676 # Add a rule that only valid for Jobid TBF. If direct change between
3677 # TBF types is not supported, this operation will fail.
3678 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3680 # Cleanup the TBF policy
3681 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3682 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3685 run_test 77g "Change TBF type directly"
3688 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3689 skip "Need OST version at least 2.8.55"
3691 local old_policy=$(do_facet ost1 \
3692 lctl get_param ost.OSS.ost_io.nrs_policies)
3695 do_facet ost1 lctl set_param \
3696 ost.OSS.ost_io.nrs_policies="abc"
3697 [ $? -eq 0 ] && error "should return error"
3699 do_facet ost1 lctl set_param \
3700 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3701 [ $? -eq 0 ] && error "should return error"
3703 do_facet ost1 lctl set_param \
3704 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3705 [ $? -eq 0 ] && error "should return error"
3707 do_facet ost1 lctl set_param \
3708 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3709 [ $? -eq 0 ] && error "should return error"
3711 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3712 [ $? -eq 0 ] || error "shouldn't LBUG"
3714 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3718 run_test 77h "Wrong policy name should report error, not LBUG"
3724 local error_message=$3
3726 for rule in $expected; do
3727 rule_number=$((rule_number + 1))
3729 local stop_line=$(($rule_number + 3))
3730 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3732 local output=$(do_facet $facet lctl get_param \
3733 ost.OSS.ost_io.nrs_tbf_rule |
3737 if [ "$output" != "$expected" ]; then
3738 error "$error_message, expected '$expected', got '$output'"
3743 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3744 skip "Need OST version at least 2.8.55"
3746 for i in $(seq 1 $OSTCOUNT)
3748 do_facet ost"$i" lctl set_param \
3749 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3751 error "failed to set TBF policy"
3754 tbf_rule_check ost1 "default" "error before inserting any rule"
3756 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3757 tbf_rule_check ost1 "before default" \
3758 "error when inserting rule 'before'"
3760 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3761 tbf_rule_check ost1 "before after default" \
3762 "error when inserting rule 'after'"
3764 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3765 tbf_rule_check ost1 "before target after default" \
3766 "error when inserting rule 'target'"
3768 echo "Move before itself"
3769 tbf_rule_operate ost1 "change\ target\ rank=target"
3770 tbf_rule_check ost1 "before target after default" \
3771 "error when moving before itself"
3773 echo "Move to higher rank"
3774 tbf_rule_operate ost1 "change\ target\ rank=before"
3775 tbf_rule_check ost1 "target before after default" \
3776 "error when moving to higher rank"
3778 echo "Move to lower rank"
3779 tbf_rule_operate ost1 "change\ target\ rank=after"
3780 tbf_rule_check ost1 "before target after default" \
3781 "error when moving to lower rank"
3783 echo "Move before default"
3784 tbf_rule_operate ost1 "change\ target\ rank=default"
3785 tbf_rule_check ost1 "before after target default" \
3786 error "error when moving before default"
3788 # Cleanup the TBF policy
3789 do_nodes $(comma_list $(osts_nodes)) \
3790 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3793 run_test 77i "Change rank of TBF rule"
3799 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
3800 skip "Need OST version at least 2.9.53"
3801 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
3806 do_nodes $(comma_list $(osts_nodes)) \
3807 lctl set_param jobid_var=procname_uid \
3808 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3809 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3810 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3811 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3816 do_nodes $(comma_list $(osts_nodes)) \
3817 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3818 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3819 ost.OSS.ost_io.nrs_policies="fifo"
3821 # sleep 3 seconds to wait the tbf policy stop completely,
3822 # or the next test case is possible get -EAGAIN when
3823 # setting the tbf policy
3826 run_test 77j "check TBF-OPCode NRS policy"
3829 local idstr="${1}id"
3830 local policy="${idstr}={$2}"
3831 local rate="rate=$3"
3833 do_nodes $(comma_list $(osts_nodes)) \
3834 lctl set_param jobid_var=procname_uid \
3835 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3836 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3837 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3839 nrs_write_read "runas $4"
3840 tbf_verify $3 $3 "runas $4"
3842 do_nodes $(comma_list $(osts_nodes)) \
3843 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3844 ost.OSS.ost_io.nrs_policies="fifo"
3846 # sleep 3 seconds to wait the tbf policy stop completely,
3847 # or the next test case is possible get -eagain when
3848 # setting the tbf policy
3853 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
3854 skip "Need OST version at least 2.11.50"
3857 test_id "u" "500" "5" "-u 500"
3858 test_id "g" "500" "5" "-u 500 -g 500"
3860 run_test 77ja "check TBF-UID/GID NRS policy"
3868 for rule in $rule_lists; do
3869 do_nodes $(comma_list $(osts_nodes)) \
3870 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3873 do_nodes $(comma_list $(osts_nodes)) \
3874 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3880 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
3881 skip "Need OST version at least 2.9.53"
3883 do_nodes $(comma_list $(osts_nodes)) \
3884 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3885 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3886 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3888 nrs_write_read "$RUNAS"
3889 tbf_verify 20 10 "$RUNAS"
3891 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3892 local client_nids=$(nids_list $address "\\")
3893 do_nodes $(comma_list $(osts_nodes)) \
3894 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3895 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3896 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3897 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3902 do_nodes $(comma_list $(osts_nodes)) \
3903 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3904 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3905 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3907 nrs_write_read "$RUNAS"
3908 tbf_verify 20 20 "$RUNAS"
3910 do_nodes $(comma_list $(osts_nodes)) \
3911 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3912 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3913 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3915 nrs_write_read "$RUNAS"
3916 # with parameter "RUNAS", it will match the latest rule
3917 # "ext_b" first, so the limited write rate is 10.
3918 tbf_verify 10 10 "$RUNAS"
3921 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3923 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
3924 skip "Need OST version at least 2.10.58"
3926 do_nodes $(comma_list $(osts_nodes)) \
3927 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3928 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3929 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3930 nrs_write_read "runas -u 500 -g 1000"
3931 tbf_verify 5 5 "runas -u 500 -g 1000"
3933 do_nodes $(comma_list $(osts_nodes)) \
3934 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3935 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3936 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3938 nrs_write_read "runas -u 500"
3939 tbf_verify 20 10 "runas -u 500"
3941 do_nodes $(comma_list $(osts_nodes)) \
3942 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3943 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3944 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3945 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3946 nrs_write_read "runas -u 500"
3947 tbf_verify 10 10 "runas -u 500"
3948 tbf_verify 20 10 "runas -u 500"
3949 cleanup_77k "ext_a ext_b" "fifo"
3951 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3954 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
3955 skip "Need OST version at least 2.10.56"
3957 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3958 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3960 local output=$(do_facet ost1 lctl get_param \
3961 ost.OSS.ost_io.nrs_policies | \
3962 awk '/name: tbf/ {print;exit}' | \
3963 awk -F ': ' '{print $2}')
3965 if [ "$output" != "tbf" ]; then
3966 error "The generic TBF output is '$output', not 'tbf'"
3969 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3971 run_test 77l "check the output of NRS policies for generic TBF"
3974 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
3975 skip "Need OST version at least 2.9.54"
3978 local dir=$DIR/$tdir
3980 mkdir $dir || error "mkdir $dir failed"
3981 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3984 local nodes=$(comma_list $(osts_nodes))
3985 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3986 ost.OSS.ost_io.nrs_delay_min=4 \
3987 ost.OSS.ost_io.nrs_delay_max=4 \
3988 ost.OSS.ost_io.nrs_delay_pct=100
3989 [ $? -ne 0 ] && error "Failed to set delay policy"
3991 local start=$SECONDS
3992 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3993 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3994 oflag=direct conv=fdatasync ||
3995 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3996 error "dd on client failed (1)"; }
3997 local elapsed=$((SECONDS - start))
3999 # NRS delay doesn't do sub-second timing, so a request enqueued at
4000 # 0.9 seconds can be dequeued at 4.0
4001 [ $elapsed -lt 3 ] &&
4002 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4003 error "Single 1M write should take at least 3 seconds"; }
4006 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4007 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4008 oflag=direct conv=fdatasync ||
4009 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4010 error "dd on client failed (2)"; }
4011 elapsed=$((SECONDS - start))
4013 [ $elapsed -lt 30 ] &&
4014 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4015 error "Ten 1M writes should take at least 30 seconds"; }
4017 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4018 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4022 run_test 77m "check NRS Delay slows write RPC processing"
4024 test_77n() { #LU-10802
4025 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4026 skip "Need OST version at least 2.10.58"
4029 # Configure jobid_var
4030 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4031 if [ $saved_jobid_var != procname_uid ]; then
4032 set_persistent_param_and_check client \
4033 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4036 do_nodes $(comma_list $(osts_nodes)) \
4037 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4038 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4039 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4042 tbf_verify 20 20 "$RUNAS"
4044 do_nodes $(comma_list $(osts_nodes)) \
4045 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4046 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4051 do_nodes $(comma_list $(osts_nodes)) \
4052 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4053 ost.OSS.ost_io.nrs_policies="fifo"
4057 local current_jobid_var=$($LCTL get_param -n jobid_var)
4058 if [ $saved_jobid_var != $current_jobid_var ]; then
4059 set_persistent_param_and_check client \
4060 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4063 run_test 77n "check wildcard support for TBF JobID NRS policy"
4065 test_78() { #LU-6673
4068 oss=$(comma_list $(osts_nodes))
4069 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4070 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4072 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4073 # Valid return codes are:
4074 # 0: Tuning succeeded
4075 # ENODEV: Policy is still stopped
4076 # EAGAIN: Policy is being initialized
4077 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4078 error "Expected set_param to return 0|ENODEV|EAGAIN"
4080 # Cleanup the ORR policy
4081 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4082 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4085 run_test 78 "Enable policy and specify tunings right away"
4088 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4089 test_mkdir $DIR/$tdir
4091 # Prevent interference from layout intent RPCs due to
4092 # asynchronous writeback. These will be tested in 130c below.
4093 do_nodes ${CLIENTS:-$HOSTNAME} sync
4095 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4096 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4098 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4099 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4100 local facet=mds$((mdtidx + 1))
4102 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4103 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4107 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4108 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4113 run_test 79 "xattr: intent error"
4116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4123 mkdir -p $DIR1/$tdir/dir
4124 createmany -o $DIR1/$tdir/dir/f 10 ||
4125 error "create files under remote dir failed $i"
4127 cp /etc/passwd $DIR1/$tdir/$tfile
4129 #migrate open file should fails
4130 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4132 # give multiop a chance to open
4135 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4136 error "migrate open files should failed with open files"
4140 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4141 error "migrate remote dir error"
4143 echo "Finish migration, then checking.."
4144 for file in $(find $DIR1/$tdir); do
4145 mdt_index=$($LFS getstripe -m $file)
4146 [ $mdt_index == $MDTIDX ] ||
4147 error "$file is not on MDT${MDTIDX}"
4150 diff /etc/passwd $DIR1/$tdir/$tfile ||
4151 error "file different after migration"
4153 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4155 run_test 80a "migrate directory when some children is being opened"
4159 kill -9 $migrate_pid
4163 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4164 local migrate_dir1=$DIR1/$tdir/migrate_dir
4165 local migrate_dir2=$DIR2/$tdir/migrate_dir
4166 local migrate_run=$LUSTRE/tests/migrate.sh
4174 trap cleanup_80b EXIT
4175 #prepare migrate directory
4176 mkdir -p $migrate_dir1
4177 for F in {1,2,3,4,5}; do
4178 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4179 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4182 #migrate the directories among MDTs
4185 mdt_idx=$((RANDOM % MDSCOUNT))
4186 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4188 [ $rc -ne 0 -o $rc -ne 16 ] || break
4193 echo "start migration thread $migrate_pid"
4194 #Access the files at the same time
4195 start_time=$(date +%s)
4196 echo "accessing the migrating directory for 5 minutes..."
4198 ls $migrate_dir2 > /dev/null || {
4199 echo "read dir fails"
4202 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4203 echo "access file1 fails"
4207 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4208 echo "access file2/3 fails"
4212 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4213 echo "access file4 fails"
4217 stat $migrate_dir2/file5 > /dev/null || {
4218 echo "stat file5 fails"
4222 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4223 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4224 echo "touch file failed with $rc1"
4228 if [ -e $migrate_dir2/source_file ]; then
4229 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4230 &>/dev/null || rc1=$?
4231 if [ -e $migrate_dir2/link_file ]; then
4232 rm -rf $migrate_dir2/link_file
4235 mrename $migrate_dir2/source_file \
4236 $migrate_dir2/target_file &>/dev/null || rc1=$?
4237 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4238 echo "rename failed with $rc1"
4242 if [ -e $migrate_dir2/target_file ]; then
4243 rm -rf $migrate_dir2/target_file &>/dev/null ||
4246 rm -rf $migrate_dir2/source_file &>/dev/null ||
4249 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4250 echo "unlink failed with $rc1"
4255 end_time=$(date +%s)
4256 duration=$((end_time - start_time))
4257 if [ $((duration % 10)) -eq 0 ]; then
4258 if [ $show_time -eq 1 ]; then
4259 echo "...$duration seconds"
4266 kill -0 $migrate_pid || {
4267 echo "migration stopped 1"
4271 [ $duration -ge 300 ] && break
4274 #check migration are still there
4275 kill -0 $migrate_pid || error "migration stopped 2"
4278 run_test 80b "Accessing directory during migration"
4281 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4285 mkdir -p $DIR1/$tdir
4287 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4288 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4291 touch d0/0 || error "create 0 failed"
4292 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4293 stat d0/0 && error "stat mv filed succeed"
4294 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4295 stat d0/0 || error "stat failed"
4297 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4299 if [ $t -ne 3 ]; then
4300 ls -ai $DIR1/$tdir/d0
4301 error "expect 3 get $t"
4306 run_test 81a "rename and stat under striped directory"
4309 [ $MDSCOUNT -lt 2 ] &&
4310 skip "We need at least 2 MDTs for this test"
4317 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4318 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4327 for i in $(seq $total); do
4328 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4332 kill -9 $setattr_pid
4334 run_test 81b "rename under striped directory doesn't deadlock"
4337 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4338 skip "Need MDS version at least 2.6.92"
4340 # Client 1 creates a file.
4341 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4343 # Client 2 opens the file.
4344 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4346 # Client 1 makes the file an orphan.
4347 rm $DIR1/$tfile || error "rm"
4348 # Client 2 sets EA "user.multiop".
4350 wait $pid2 || error "multiop 2"
4351 # Client 1 gets EA "user.multiop". This used to fail because the EA
4352 # cache refill would get "trusted.link" from mdd_xattr_list() but
4353 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4356 wait $pid1 || error "multiop 1"
4358 run_test 82 "fsetxattr and fgetxattr on orphan files"
4361 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4368 $LFS mkdir -i1 -c2 $tdir
4373 echo "start pid $pid1 to create/unlink striped directory"
4375 # Access the directory at the same time
4379 stat $tdir > /dev/null 2>&1
4383 echo "start pid $pid2 to stat striped directory"
4391 run_test 83 "access striped directory while it is being created/unlinked"
4394 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4395 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4399 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4400 error "create $tfile failed"
4401 mtime=$(stat -c%Y $DIR/$tfile)
4402 mtime=$((mtime + 200))
4404 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4405 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4407 touch -c -m $mtime $DIR/$tfile &
4409 # sleep a while to let 'touch' run first
4411 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4414 wait $setattr_pid || true
4416 run_test 84 "0-nlink race in lu_object_find()"
4419 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4424 [ "$SLOW" = "yes" ] && duration=600
4425 # Open/Create under striped directory
4429 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4430 touch $tdir/f{0..3} > /dev/null 2>&1
4434 echo "start pid $pid1 to open/create under striped directory"
4436 # unlink the striped directory at the same time
4440 rm -rf $tdir > /dev/null 2>&1
4444 echo "start pid $pid2 to unlink striped directory"
4453 run_test 90 "open/create and unlink striped directory"
4456 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4461 [ "$SLOW" = "yes" ] && duration=600
4462 # chmod striped directory
4466 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4467 chmod go+w $tdir > /dev/null 2>&1
4471 echo "start pid $pid1 to chmod striped directory"
4473 # unlink the striped directory at the same time
4477 rm -rf $tdir > /dev/null 2>&1
4481 echo "start pid $pid2 to unlink striped directory"
4490 run_test 91 "chmod and unlink striped directory"
4493 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4496 local cmd="exec $fd<$DIR1/$tdir"
4497 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4500 trap "eval $cmd" EXIT
4501 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4502 rmdir ../$tdir || error "rmdir ../$tdir fails"
4504 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4505 $LCTL set_param fail_loc=0x1408
4506 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4507 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4508 error "create remote dir succeeds"
4509 $LCTL set_param fail_loc=0
4513 run_test 92 "create remote directory under orphan directory"
4520 mkdir -p $DIR1/$tfile-1/
4521 mkdir -p $DIR2/$tfile-2/
4522 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4523 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4524 do_facet $SINGLEMDS "$LCTL set_param -n \
4525 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4526 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4527 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4529 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4532 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4536 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4537 do_facet $SINGLEMDS "$LCTL set_param -n \
4538 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4540 $LFS getstripe $DIR1/$tfile-1/file1
4541 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4542 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4543 $LFS getstripe $DIR2/$tfile-2/file2
4544 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4545 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4546 echo "rc1=$rc1 and rc2=$rc2 "
4547 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4548 error "object allocate on same ost detected"
4550 run_test 93 "alloc_rr should not allocate on same ost"
4553 $LCTL set_param osc.*.idle_timeout=0
4554 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4556 local before=$(date +%s)
4560 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4561 $LCTL set_param fail_val=5 fail_loc=0x80000312
4562 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4566 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4567 $LCTL set_param fail_val=6 fail_loc=0x80000329
4568 $LCTL mark kill $pid
4571 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4574 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4576 evict=$(do_facet client $LCTL get_param \
4577 osc.$FSNAME-OST*-osc-*/state |
4578 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4580 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4581 (do_facet client $LCTL get_param \
4582 osc.$FSNAME-OST*-osc-*/state;
4583 error "eviction happened: $evict before:$before")
4584 $LCTL set_param osc.*.idle_timeout=debug
4586 run_test 94 "signal vs CP callback race"
4590 skip "Reserved for glimpse-ahead" && return
4591 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4592 skip "Need MDS version at least 2.10.55"
4596 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4598 lctl set_param -n mdc.*.stats=clear
4599 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4601 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4602 # first stat from server should return size data and save glimpse
4603 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4604 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4605 # second stat to check size is NOT cached on client without IO lock
4606 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4608 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4609 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4612 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4615 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4616 skip "Need MDS version at least 2.10.55"
4620 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4622 lctl set_param -n mdc.*.stats=clear
4623 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4624 cancel_lru_locks mdc
4625 # first stat data from server should have size
4626 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4627 # second stat to check size is cached on client
4628 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4630 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4631 # both stats should cause no glimpse requests
4632 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4635 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4638 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4639 skip "Need MDS version at least 2.10.55"
4643 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4645 lctl set_param -n mdc.*.stats=clear
4646 lctl set_param -n osc.*.stats=clear
4647 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4649 # check that size is merged from MDT and OST correctly
4650 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4651 error "Wrong size from stat #1"
4653 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4654 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4658 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4661 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4662 skip "Need MDS version at least 2.10.55"
4666 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4669 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4670 lctl set_param -n mdc.*.stats=clear
4671 $TRUNCATE $DIR2/$tdir/dom 4096
4673 # check that reported size is valid after file grows to OST and
4674 # is truncated back to MDT stripe size
4675 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4676 error "Wrong size from stat #1"
4678 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4679 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4683 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4686 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
4687 skip "Need MDS version at least 2.11.50"
4689 local dom=$DIR/$tdir/dom
4690 local dom2=$DIR2/$tdir/dom
4693 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4695 cancel_lru_locks mdc
4696 dd if=/dev/urandom of=$dom bs=12000 count=1
4697 $TRUNCATE $dom2 6000
4698 cancel_lru_locks mdc
4699 lctl set_param -n mdc.*.stats=clear
4700 # expect read-on-open to return all data before write
4701 cat /etc/hosts >> $dom
4702 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4703 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4705 run_test 100e "DoM: read on open and file size"
4708 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4709 skip "Need MDS version at least 2.10.55"
4711 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4713 $CHECKSTAT -t file $DIR1/$tfile
4715 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4716 sysctl -wq vm.dirty_writeback_centisecs=0
4718 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4721 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4722 error_noexit "Write fails"
4723 # must discard pages
4724 lctl set_param -n mdc.*.stats=clear
4725 rm $DIR2/$tfile || error "Unlink fails"
4727 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4728 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4730 run_test 101a "Discard DoM data on unlink"
4733 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4734 skip "Need MDS version at least 2.10.55"
4736 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4737 touch $DIR1/${tfile}_2
4739 $CHECKSTAT -t file $DIR1/$tfile
4741 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4742 sysctl -wq vm.dirty_writeback_centisecs=0
4744 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4747 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4748 # must discard pages
4749 lctl set_param -n mdc.*.stats=clear
4750 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4752 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4753 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4755 run_test 101b "Discard DoM data on rename"
4758 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4759 skip "Need MDS version at least 2.10.55"
4761 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4763 $CHECKSTAT -t file $DIR1/$tfile
4765 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4766 sysctl -wq vm.dirty_writeback_centisecs=0
4768 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4771 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4772 $MULTIOP $DIR1/$tfile O_c &
4775 lctl set_param -n mdc.*.stats=clear
4776 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4777 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4779 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4780 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4782 run_test 101c "Discard DoM data on close-unlink"
4784 # test to verify file handle related system calls
4785 # (name_to_handle_at/open_by_handle_at)
4786 # The new system calls are supported in glibc >= 2.14.
4788 # test to verify we can open by handle an unlinked file from > 1 client
4789 # This test opens the file normally on $DIR1, which is on one mount, and then
4790 # opens it by handle on $DIR2, which is on a different mount.
4792 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
4793 skip "Needs MDS version 2.11.57 or later"
4795 echo "Test file_handle syscalls" > $DIR/$tfile ||
4796 error "write failed"
4797 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4798 error "check_fhandle_syscalls failed"
4801 run_test 102 "Test open by handle of unlinked file"
4803 # Compare file size between first & second mount, ensuring the client correctly
4804 # glimpses even with unused speculative locks - LU-11670
4806 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
4807 skip "Lockahead needs OST version at least 2.10.50"
4811 test_mkdir -p $DIR/$tdir
4813 # Force file on to OST0
4814 $LFS setstripe -i 0 $DIR/$tdir
4816 # Do not check multiple locks on glimpse
4817 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
4818 $LCTL set_param fail_loc=0x415
4820 # Delay write commit by 2 seconds to guarantee glimpse wins race
4821 # The same fail_loc is used on client & server so it can work in the
4822 # single node sanity setup
4823 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
4825 echo "Incorrect size expected (no glimpse fix):"
4826 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4828 if [ $rc -eq 0 ]; then
4829 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
4832 # guarantee write commit timeout has expired
4835 # Clear fail_loc on client
4836 $LCTL set_param fail_loc=0
4838 # Delay write commit by 2 seconds to guarantee glimpse wins race
4839 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4840 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
4842 # Write commit is still delayed by 2 seconds
4843 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4845 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
4847 # guarantee write commit timeout has expired
4850 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
4852 run_test 103 "Test size correctness with lockahead"
4858 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
4869 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
4870 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
4871 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
4872 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
4880 local xtimes=($(get_stat_xtimes))
4881 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4883 echo "STAT a|m|ctime ${xtimes[*]}"
4884 echo "MDT a|m|ctime ${xtimes[*]}"
4885 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
4886 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
4887 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4888 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4889 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4890 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4894 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
4895 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
4896 skip "Need MDS version at least 2.12.4"
4899 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
4900 local atime_diff=$(do_facet $SINGLEMDS \
4901 lctl get_param -n mdd.*MDT0000*.atime_diff)
4903 do_facet $SINGLEMDS \
4904 lctl set_param -n mdd.*MDT0000*.atime_diff=0
4906 stack_trap "do_facet $SINGLEMDS \
4907 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
4909 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4910 check_mdt_xtimes $mdtdev
4913 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4914 check_mdt_xtimes $mdtdev
4916 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
4919 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4921 kill -USR1 $pid && wait $pid || error "multiop failure"
4922 check_mdt_xtimes $mdtdev
4927 # Verify mtime/ctime is NOT upated on MDS when there is no modification
4928 # on the client side
4929 xtimes=($(get_stat_xtimes))
4930 $MULTIOP $DIR/$tfile O_c &
4933 kill -USR1 $pid && wait $pid || error "multiop failure"
4934 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4935 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4936 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4937 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4938 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4939 check_mdt_xtimes $mdtdev
4942 # Change ctime via chmod
4943 $MULTIOP $DIR/$tfile o_tc &
4946 kill -USR1 $pid && wait $pid || error "multiop failure"
4947 check_mdt_xtimes $mdtdev
4949 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
4952 test_mkdir -p $DIR/$tdir
4953 echo test > $DIR/$tdir/$tfile
4954 $LCTL set_param fail_loc=0x416
4955 cancel_lru_locks osc & sleep 1
4956 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
4958 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
4960 run_test 105 "Glimpse and lock cancel race"
4962 log "cleanup: ======================================================"
4964 # kill and wait in each test only guarentee script finish, but command in script
4965 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4966 # otherwise umount below will fail
4967 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4972 check_and_cleanup_lustre