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 ||
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 \
427 $file1 $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 ||
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"
506 test_16e() { # LU-13227
507 local file1=$DIR1/$tfile
508 local file2=$DIR2/$tfile
510 # client1 write 10M data
511 dd if=/dev/zero of=$file1 bs=1M count=10
513 cancel_lru_locks osc > /dev/null
514 # use lockahead to generate one PW lock to keep LVB loaded.
515 $LFS ladvise -a lockahead --start 0 --length 1M \
517 # direct write to extend file size on client2
518 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
519 oflag=direct conv=notrunc
520 local filesize=$(stat -c %s $file2)
521 [ "$filesize" -eq 22020096 ] ||
522 error "expected filesize 22020096 got $filesize"
525 run_test 16e "Verify size consistency for O_DIRECT write"
527 test_17() { # bug 3513, 3667
528 remote_ost_nodsh && skip "remote OST with nodsh" && return
530 lfs setstripe $DIR1/$tfile -i 0 -c 1
531 cp $SAMPLE_FILE $DIR1/$tfile
532 cancel_lru_locks osc > /dev/null
533 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
534 do_facet ost1 lctl set_param fail_loc=0x8000030a
535 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
536 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
538 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
540 run_test 17 "resource creation/LVB creation race ==============="
543 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
546 for idx in {a..z}; do
547 local ptr=EXCEPT_ALWAYS_18$idx
548 [ x${!ptr} = xtrue ] || continue
550 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
553 excepts="$excepts -e 7 -e 8 -e 9"
554 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
555 error "mmap_sanity test failed"
558 run_test 18 "mmap sanity check ================================="
560 test_19() { # bug3811
561 local node=$(facet_active_host ost1)
563 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
565 # check whether obdfilter is cache capable at all
566 get_osd_param $node '' read_cache_enable >/dev/null ||
567 skip "not cache-capable obdfilter"
569 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
570 set_osd_param $node '' readcache_max_filesize 4096
571 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
572 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
573 cp $TMP/$tfile $DIR1/$tfile
574 for i in `seq 1 20`; do
575 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
576 cancel_lru_locks $OSC > /dev/null
577 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
578 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
580 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
581 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
582 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
583 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
585 set_osd_param $node '' readcache_max_filesize $MAX
588 run_test 19 "test concurrent uncached read races ==============="
591 test_mkdir $DIR1/$tdir
593 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
594 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
595 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
596 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
598 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
599 [[ $CNT2 == $CNT ]] ||
600 error $((CNT2 - CNT))" page left in cache after lock cancel"
602 run_test 20 "test extra readahead page left in cache ===="
609 test_21() { # Bug 5907
610 test_mkdir $DIR1/$tdir
611 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
613 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
614 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
615 test -d $DIR1/$tdir || error "Mounted directory disappeared"
617 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
620 run_test 21 " Try to remove mountpoint on another dir ===="
622 test_23() { # Bug 5972
623 local at_diff=$(do_facet $SINGLEMDS \
624 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
625 echo "atime should be updated while another read" > $DIR1/$tfile
627 # clear the lock(mode: LCK_PW) gotten from creating operation
628 cancel_lru_locks $OSC
631 sleep $((at_diff + 1))
633 echo "starting reads"
634 multiop_bg_pause $DIR1/$tfile or20_c || return 1
635 # with SOM and opencache enabled, we need to close a file and cancel
636 # open lock to get atime propogated to MDS
637 kill -USR1 $! || return 2
640 time2=$(stat -c "%X" $DIR/$tfile)
641 echo "new atime is $time2"
643 [ $time2 -gt $time1 ] || error "atime was not updated"
644 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
647 run_test 23 " others should see updated atime while another read===="
651 lfs df || error "lfs df failed"
652 lfs df -ih || error "lfs df -ih failed"
653 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
654 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
655 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
656 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
658 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
659 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
660 lctl --device %osc deactivate
661 lfs df -i || error "lfs df -i with deactivated OSC failed"
662 lctl --device %osc activate
663 lfs df || error "lfs df with reactivated OSC failed"
665 run_test 24a "lfs df [-ih] [path] test ========================="
669 fsnum=$(lfs_df | grep -c "summary")
670 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
672 run_test 24b "lfs df should show both filesystems ==============="
675 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
677 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
680 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
681 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
683 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
684 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
685 error "setfacl $DIR2/$tdir #1"
686 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
687 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
688 error "setfacl $DIR2/$tdir #2"
689 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
690 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
691 error "setfacl $DIR2/$tdir #3"
692 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
693 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
694 error "setfacl $DIR2/$tdir #4"
695 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
699 run_test 25a "change ACL on one mountpoint be seen on another ==="
702 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
704 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
706 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
709 $LFS mkdir -i 1 $DIR1/$tdir
710 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
711 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
713 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
714 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
715 error "setfacl $DIR2/$tdir #1"
716 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
717 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
718 error "setfacl $DIR2/$tdir #2"
719 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
720 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
721 error "setfacl $DIR2/$tdir #3"
722 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
723 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
724 error "setfacl $DIR2/$tdir #4"
725 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
729 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
732 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
734 run_test 26a "allow mtime to get older"
739 echo "aaa" >> $DIR1/$tfile
741 chmod a+x $DIR2/$tfile
742 mt1=`stat -c %Y $DIR1/$tfile`
743 mt2=`stat -c %Y $DIR2/$tfile`
745 if [ x"$mt1" != x"$mt2" ]; then
746 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
749 run_test 26b "sync mtime between ost and mds"
752 cancel_lru_locks $OSC
754 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
759 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
764 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
766 lctl set_param -n ldlm.dump_namespaces ""
767 wait $DD1_PID $DD2_PID
768 [ $? -ne 0 ] && lctl dk $TMP/debug || true
770 run_test 27 "align non-overlapping extent locks from request ==="
772 test_28() { # bug 9977
773 ECHO_UUID="ECHO_osc1_UUID"
774 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
776 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
777 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
778 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
782 attach echo_client ECHO_osc1 $ECHO_UUID
786 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
787 $LCTL --device $tECHOID destroy "${tOBJID}:0"
795 # reading of 1st stripe should pass
796 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
797 # reading of 2nd stripe should fail (this stripe was destroyed)
798 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
800 # now, recreating test file
801 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
802 # reading of 1st stripe should pass
803 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
804 # reading of 2nd stripe should pass
805 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
808 run_test 28 "read/write/truncate file with lost stripes"
810 test_30() { #b=11110, LU-2523
811 test_mkdir $DIR1/$tdir
812 cp -f /bin/bash $DIR1/$tdir/bash
813 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
814 $DIR1/$tdir/bash -c 'sleep 2;
815 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
819 run_test 30 "recreate file race"
822 test_mkdir $DIR1/$tdir
823 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
824 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
825 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
826 lctl set_param fail_loc=0x314
827 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
828 awk 'BEGIN { FS="+" } /in/ {print $1}')
829 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
831 run_test 31a "voluntary cancel / blocking ast race=============="
834 remote_ost || { skip "local OST" && return 0; }
835 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
837 # make sure there is no local locks due to destroy
838 wait_mds_ost_sync || error "wait_mds_ost_sync()"
839 wait_delete_completed || error "wait_delete_completed()"
841 test_mkdir $DIR1/$tdir
842 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
843 cp /etc/hosts $DIR/$tdir/$tfile
844 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
845 lctl set_param fail_loc=0x314
846 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
847 do_facet ost1 lctl set_param fail_loc=0x316
849 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
850 lctl set_param fail_loc=0
851 do_facet ost1 lctl set_param fail_loc=0
852 # cleanup: reconnect the client back
855 run_test 31b "voluntary OST cancel / blocking ast race=============="
857 # enable/disable lockless truncate feature, depending on the arg 0/1
858 enable_lockless_truncate() {
859 lctl set_param -n $OSC.*.lockless_truncate $1
862 test_32a() { # bug 11270
863 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
864 local stripe_size=$(do_facet $SINGLEMDS \
865 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
867 save_lustre_params client "$OSC.*.lockless_truncate" > $save
868 # restore lockless_truncate default values on exit
869 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
870 cancel_lru_locks $OSC
871 enable_lockless_truncate 1
873 lfs setstripe -c -1 $DIR1/$tfile
874 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
876 clear_stats $OSC.*.${OSC}_stats
878 log "checking cached lockless truncate"
879 $TRUNCATE $DIR1/$tfile 8000000
880 $CHECKSTAT -s 8000000 $DIR2/$tfile ||
881 error "cached truncate - wrong file size"
882 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
883 error "cached truncate isn't lockless"
885 log "checking not cached lockless truncate"
886 $TRUNCATE $DIR2/$tfile 5000000
887 $CHECKSTAT -s 5000000 $DIR1/$tfile ||
888 error "not cached truncate - wrong file size"
889 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
890 error "not cached truncate isn't lockless"
892 log "disabled lockless truncate"
893 enable_lockless_truncate 0
894 clear_stats $OSC.*.${OSC}_stats
895 $TRUNCATE $DIR2/$tfile 3000000
896 $CHECKSTAT -s 3000000 $DIR1/$tfile ||
897 error "lockless truncate disabled - wrong file size"
898 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
899 error "lockless truncate disabling failed"
902 run_test 32a "lockless truncate"
904 test_32b() { # bug 11270
905 remote_ost_nodsh && skip "remote OST with nodsh" && return
908 local facets=$(get_facets OST)
909 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
911 save_lustre_params client "osc.*.contention_seconds" > $p
912 save_lustre_params $facets \
913 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
914 save_lustre_params $facets \
915 "ldlm.namespaces.filter-*.contended_locks" >> $p
916 save_lustre_params $facets \
917 "ldlm.namespaces.filter-*.contention_seconds" >> $p
918 clear_stats $OSC.*.${OSC}_stats
920 # agressive lockless i/o settings
921 do_nodes $(comma_list $(osts_nodes)) \
922 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
923 ldlm.namespaces.filter-*.contended_locks=0 \
924 ldlm.namespaces.filter-*.contention_seconds=60"
925 lctl set_param -n $OSC.*.contention_seconds=60
927 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
929 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
932 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
933 error "lockless i/o was not triggered"
934 # disable lockless i/o (it is disabled by default)
935 do_nodes $(comma_list $(osts_nodes)) \
936 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
937 ldlm.namespaces.filter-*.contended_locks=32 \
938 ldlm.namespaces.filter-*.contention_seconds=0"
939 # set contention_seconds to 0 at client too, otherwise Lustre still
940 # remembers lock contention
941 lctl set_param -n $OSC.*.contention_seconds=0
942 clear_stats $OSC.*.${OSC}_stats
944 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
946 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
949 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
950 error "lockless i/o works when disabled"
952 restore_lustre_params <$p
955 run_test 32b "lockless i/o"
959 local mdts=$(get_facets MDS)
964 for mds in ${mdts//,/ }; do
966 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
967 xargs readlink -f" ))
968 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
971 stat=$(( stat + val))
976 # commit on sharing tests
978 remote_mds_nodsh && skip "remote MDS with nodsh" && return
980 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
981 [ $CLIENTCOUNT -lt 2 ] &&
982 skip "Need two or more clients, have $CLIENTCOUNT"
984 local nfiles=${TEST33_NFILES:-10000}
985 local param_file=$TMP/$tfile-params
991 save_lustre_params $(get_facets MDS) \
992 "mdt.*.commit_on_sharing" > $param_file
995 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
999 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1001 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1002 echo "=== START createmany old: $jbdold transaction"
1003 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")
1004 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1005 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1006 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1007 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1008 avgtime=$(( avgtime + elapsed ))
1010 eval cos${COS}_jbd=$((avgjbd / 3))
1011 eval cos${COS}_time=$((avgtime / 3))
1014 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1015 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1016 [ "$cos0_jbd" != 0 ] &&
1017 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1018 [ "$cos0_time" != 0 ] &&
1019 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1021 restore_lustre_params < $param_file
1025 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1027 # commit on sharing tests
1029 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1031 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1032 [ $CLIENTCOUNT -ge 2 ] ||
1033 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1037 local nfiles=${TEST33_NFILES:-10000}
1038 local param_file=$TMP/$tfile-params
1040 save_lustre_params $(get_facets MDS) \
1041 "mdt.*.commit_on_sharing" > $param_file
1050 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1054 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1055 $DIR1/$tdir-\\\$(hostname)-$i"
1057 jbdold=$(print_jbd_stat)
1058 echo "=== START createmany old: $jbdold transaction"
1059 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1060 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1061 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1063 jbdnew=$(print_jbd_stat)
1064 jbd=$(( jbdnew - jbdold ))
1065 echo "=== END createmany new: $jbdnew transaction : \
1066 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1067 avgjbd=$(( avgjbd + jbd ))
1068 avgtime=$(( avgtime + elapsed ))
1070 eval cos${COS}_jbd=$((avgjbd / 3))
1071 eval cos${COS}_time=$((avgtime / 3))
1074 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1075 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1076 [ "$cos0_jbd" != 0 ] &&
1077 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1078 [ "$cos0_time" != 0 ] &&
1079 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1081 restore_lustre_params < $param_file
1085 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1088 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1089 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1090 skip "DNE CoS not supported"
1094 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1100 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1101 # do twice in case transaction is committed before unlock, see LU-8200
1103 # remote dir is created on MDT1, which enqueued lock of $tdir on
1105 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1106 mkdir $DIR/$tdir/local.$i
1108 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1109 echo "sync_count $sync_count"
1110 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1113 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1114 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1115 # during sleep remote mkdir should have been committed and canceled
1116 # remote lock spontaneously, which shouldn't trigger sync
1118 mkdir $DIR/$tdir/local.3
1119 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1120 echo "sync_count $sync_count"
1121 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1123 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1125 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1129 local nodes=$(comma_list $(mdts_nodes))
1133 # trigger CoS twice in case transaction commit before unlock
1136 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1138 commit_nr=$(do_nodes $nodes \
1139 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1140 total=$((total + commit_nr));
1145 echo "CoS count $total"
1146 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1150 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1151 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1152 skip "DNE CoS not supported"
1154 # remote directory create
1155 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1156 # remote directory unlink
1157 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1158 # striped directory create
1159 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1160 # striped directory setattr
1161 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1162 "chmod 713 $DIR/$tdir"
1163 # striped directory unlink
1164 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1167 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1168 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1169 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1170 touch $DIR/$tdir/d1/tgt" \
1171 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1173 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1174 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1175 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1176 touch $DIR/$tdir/d1/src" \
1177 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1179 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1180 "$LFS migrate -m 1 $DIR/$tdir"
1184 run_test 33d "DNE distributed operation should trigger COS"
1187 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1188 [ $CLIENTCOUNT -ge 2 ] ||
1189 skip "Need two or more clients, have $CLIENTCOUNT"
1190 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1191 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1192 skip "DNE CoS not supported"
1194 local client2=${CLIENT2:-$(hostname)}
1198 local nodes=$(comma_list $(mdts_nodes))
1199 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1201 $LFS mkdir -c 2 $DIR/$tdir
1202 mkdir $DIR/$tdir/subdir
1203 echo abc > $DIR/$tdir/$tfile
1204 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1205 do_node $client2 touch $DIR/$tdir/subdir
1207 local async_commit_count=$(do_nodes $nodes \
1208 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1209 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1213 run_test 33e "DNE local operation shouldn't trigger COS"
1215 # End commit on sharing tests
1217 get_ost_lock_timeouts() {
1218 local nodes=${1:-$(comma_list $(osts_nodes))}
1220 local locks=$(do_nodes $nodes \
1221 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1229 do_nodes $(comma_list $(osts_nodes)) \
1230 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1231 for i in $(seq $OSTCOUNT); do
1232 wait_osc_import_ready client ost$i
1237 remote_ost_nodsh && skip "remote OST with nodsh" && return
1241 trap cleanup_34 EXIT RETURN
1242 for OPER in notimeout timeout ; do
1243 rm $DIR1/$tfile 2>/dev/null
1244 lock_in=$(get_ost_lock_timeouts)
1245 if [ $OPER == "timeout" ] ; then
1246 for j in `seq $OSTCOUNT`; do
1247 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1248 do_facet ost$j lctl set_param fail_loc=0x511
1250 echo lock should expire
1252 for j in `seq $OSTCOUNT`; do
1253 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1254 do_facet ost$j lctl set_param fail_loc=0x512
1256 echo lock should not expire
1258 echo writing on client1
1259 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1261 echo reading on client2
1262 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1263 # wait for a lock timeout
1265 lock_out=$(get_ost_lock_timeouts)
1266 if [ $OPER == "timeout" ] ; then
1267 if [ $lock_in == $lock_out ]; then
1268 error "no lock timeout happened"
1273 if [ $lock_in != $lock_out ]; then
1274 error "lock timeout happened"
1282 run_test 34 "no lock timeout under IO"
1284 test_35() { # bug 17645
1287 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1288 awk '/generation/{print $2}')
1290 generation[count]=$g
1294 test_mkdir $MOUNT1/$tdir
1295 cancel_lru_locks mdc
1297 # Let's initiate -EINTR situation by setting fail_loc and take
1298 # write lock on same file from same client. This will not cause
1299 # bl_ast yet as lock is already in local cache.
1300 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1301 do_facet client "lctl set_param fail_loc=0x80000317"
1302 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1303 let timeout=timeout*3
1305 while test $nr -lt 10; do
1306 log "Race attempt $nr"
1307 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1308 awk '/ldlm_bl_callback/ { print $2 }')
1309 test "x$blk1" = "x" && blk1=0
1310 createmany -o $MOUNT2/$tdir/a 4000 &
1314 # Let's make conflict and bl_ast
1315 ls -la $MOUNT1/$tdir > /dev/null &
1318 log "Wait for $pid1 $pid2 for $timeout sec..."
1320 kill -9 $pid1 $pid2 > /dev/null 2>&1
1322 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1323 awk '/ldlm_bl_callback/ { print $2 }')
1324 test "x$blk2" = "x" && blk2=0
1325 test $blk2 -gt $blk1 && break
1326 rm -fr $MOUNT1/$tdir
1327 cancel_lru_locks mdc
1330 do_facet client "lctl set_param fail_loc=0x0"
1331 df -h $MOUNT1 $MOUNT2
1333 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1334 awk '/generation/{print $2}')
1336 if ! test "$g" -eq "${generation[count]}"; then
1337 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1339 for imp in $list; do
1340 if [ $c = $count ]; then
1345 imp=$(echo "$imp" | awk -F"." '{print $2}')
1346 error "Eviction happened on import $imp"
1351 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1353 test_36() { #bug 16417
1358 test_mkdir $DIR1/$tdir
1359 $LFS setstripe -c -1 $DIR1/$tdir
1362 let SIZE_B=SIZE*1024*1024
1363 sync; sleep 2; sync # wait for delete thread
1364 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1365 wait_destroy_complete || error "wait_destroy_complete failed"
1367 while [ $i -le 10 ]; do
1368 lctl mark "start test - cycle ($i)"
1369 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1370 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1371 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1372 sync # sync data from client cache
1373 sync_all_data # sync data from server cache (delayed allocation)
1375 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1376 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1378 rm -f $DIR1/$tdir/$tfile
1379 kill -USR1 $read_pid
1381 sync; sleep 2; sync # Ensure new statfs
1382 wait_delete_completed
1383 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1384 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1386 # this free space! not used
1387 (( $after_dd <= $after)) ||
1388 error "space leaked after_dd:$after_dd > after:$after"
1392 run_test 36 "handle ESTALE/open-unlink correctly"
1394 test_37() { # bug 18695
1395 test_mkdir $DIR1/$tdir
1396 multiop_bg_pause $DIR1/$tdir D_c || return 1
1398 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1399 createmany -m $DIR2/$tdir/f 10000
1400 # set mtime/atime backward
1401 touch -t 198001010000 $DIR2/$tdir
1402 kill -USR1 $MULTIPID
1403 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1404 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1407 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1409 # this should be set to past
1410 TEST_39_MTIME=`date -d "1 year ago" +%s`
1414 local client1=${CLIENT1:-`hostname`}
1415 local client2=${CLIENT2:-`hostname`}
1417 do_node $client1 "touch $DIR1/$tfile"
1419 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1420 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1421 [ "$mtime1" = $TEST_39_MTIME ] || \
1422 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1424 local d1=`do_node $client1 date +%s`
1425 do_node $client1 'echo hello >> '$DIR1/$tfile
1426 local d2=`do_node $client1 date +%s`
1428 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1429 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1430 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1432 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1434 for (( i=0; i < 2; i++ )) ; do
1435 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1436 [ "$mtime2" = "$mtime3" ] || \
1437 error "mtime ($mtime2) changed (to $mtime3) on rename"
1439 cancel_lru_locks osc
1440 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1443 run_test 39a "test from 11063 =================================="
1446 local client1=${CLIENT1:-`hostname`}
1447 local client2=${CLIENT2:-`hostname`}
1451 local mtime1=`stat -c %Y $DIR1/$tfile`
1452 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1455 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
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" = $TEST_39_MTIME ] || \
1464 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1466 cancel_lru_locks osc
1467 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1470 run_test 39b "11063 problem 1 =================================="
1473 local client1=${CLIENT1:-`hostname`}
1474 local client2=${CLIENT2:-`hostname`}
1476 echo hello > $DIR1/$tfile
1478 local mtime1=`stat -c %Y $DIR1/$tfile`
1479 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1480 [ "$mtime1" = "$mtime2" ] || \
1481 error "create: different mtime on clients: $mtime1, $mtime2"
1484 $TRUNCATE $DIR1/$tfile 1
1486 for (( i=0; i < 2; i++ )) ; do
1487 local mtime3=`stat -c %Y $DIR1/$tfile`
1488 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1490 [ "$mtime3" = "$mtime4" ] || \
1491 error "different mtime on clients: $mtime3, $mtime4"
1492 [ "$mtime3" -gt $mtime2 ] || \
1493 error "truncate did not update mtime: $mtime2, $mtime3"
1495 cancel_lru_locks osc
1496 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1499 run_test 39c "check truncate mtime update ======================"
1501 test_39d() { # LU-7310
1503 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1505 local mtime1=$(stat -c %Y $DIR2/$tfile)
1506 [ "$mtime1" = $TEST_39_MTIME ] ||
1507 error "mtime: $mtime1, should be $TEST_39_MTIME"
1510 # define OBD_FAIL_OSC_NO_GRANT 0x411
1511 $LCTL set_param fail_loc=0x411
1513 local d1=$(date +%s)
1514 echo hello >> $DIR1/$tfile
1515 local d2=$(date +%s)
1517 $LCTL set_param fail_loc=0
1519 cancel_lru_locks $OSC
1521 local mtime2=$(stat -c %Y $DIR2/$tfile)
1522 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1523 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1525 run_test 39d "sync write should update mtime"
1528 # how long 40-47 take with specific delay
1535 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1536 # avoid unexpected delays due to previous tests
1538 cancel_lru_locks mdc
1539 do_nodes $(comma_list $(mdts_nodes)) \
1540 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1541 do_nodes $(comma_list $(mdts_nodes)) \
1542 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1543 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1546 # check that pid exists hence second operation wasn't blocked by first one
1547 # if it is so then there is no conflict, return 0
1548 # else second operation is conflicting with first one, return 1
1549 check_pdo_conflict() {
1552 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1553 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1563 # test 40: check non-blocking operations
1565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1567 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1568 do_nodes $(comma_list $(mdts_nodes)) \
1569 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1571 mkdir $DIR1/$tfile &
1573 touch $DIR2/$tfile-2
1574 check_pdo_conflict $PID1 || error "create is blocked"
1575 mkdir $DIR2/$tfile-3
1576 check_pdo_conflict $PID1 || error "mkdir is blocked"
1577 link $DIR2/$tfile-2 $DIR2/$tfile-4
1578 check_pdo_conflict $PID1 || error "link is blocked"
1579 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1580 check_pdo_conflict $PID1 || error "rename is blocked"
1581 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1582 check_pdo_conflict $PID1 || error "getattr is blocked"
1583 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1584 rmdir $DIR2/$tfile-3
1585 check_pdo_conflict $PID1 || error "unlink is blocked"
1587 # all operations above shouldn't wait the first one
1588 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1589 do_nodes $(comma_list $(mdts_nodes)) \
1590 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1595 run_test 40a "pdirops: create vs others =============="
1598 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1600 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1601 do_nodes $(comma_list $(mdts_nodes)) \
1602 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1603 touch $DIR1/$tfile &
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"
1619 # all operations above shouldn't wait the first one
1621 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1622 do_nodes $(comma_list $(mdts_nodes)) \
1623 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1628 run_test 40b "pdirops: open|create and others =============="
1631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1634 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1635 do_nodes $(comma_list $(mdts_nodes)) \
1636 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1637 link $DIR1/$tfile $DIR1/$tfile-0 &
1640 touch $DIR2/$tfile-2
1641 check_pdo_conflict $PID1 || error "create is blocked"
1642 mkdir $DIR2/$tfile-3
1643 check_pdo_conflict $PID1 || error "mkdir is blocked"
1644 link $DIR2/$tfile-2 $DIR2/$tfile-4
1645 check_pdo_conflict $PID1 || error "link is blocked"
1646 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1647 check_pdo_conflict $PID1 || error "rename is blocked"
1648 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1649 check_pdo_conflict $PID1 || error "getattr is blocked"
1650 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1651 rmdir $DIR2/$tfile-3
1652 check_pdo_conflict $PID1 || error "unlink is blocked"
1654 # all operations above shouldn't wait the first one
1655 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1656 do_nodes $(comma_list $(mdts_nodes)) \
1657 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1662 run_test 40c "pdirops: link and others =============="
1665 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1668 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1669 do_nodes $(comma_list $(mdts_nodes)) \
1670 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1674 touch $DIR2/$tfile-2
1675 check_pdo_conflict $PID1 || error "create is blocked"
1676 mkdir $DIR2/$tfile-3
1677 check_pdo_conflict $PID1 || error "mkdir is blocked"
1678 link $DIR2/$tfile-2 $DIR2/$tfile-4
1679 check_pdo_conflict $PID1 || error "link is blocked"
1680 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1681 check_pdo_conflict $PID1 || error "rename is blocked"
1682 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1683 check_pdo_conflict $PID1 || error "getattr is blocked"
1684 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1685 rmdir $DIR2/$tfile-3
1686 check_pdo_conflict $PID1 || error "unlink is blocked"
1688 # all operations above shouldn't wait the first one
1689 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1690 do_nodes $(comma_list $(mdts_nodes)) \
1691 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1695 run_test 40d "pdirops: unlink and others =============="
1698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1701 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1702 do_nodes $(comma_list $(mdts_nodes)) \
1703 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1704 mv $DIR1/$tfile $DIR1/$tfile-0 &
1707 touch $DIR2/$tfile-2
1708 check_pdo_conflict $PID1 || error "create is blocked"
1709 mkdir $DIR2/$tfile-3
1710 check_pdo_conflict $PID1 || error "mkdir is blocked"
1711 link $DIR2/$tfile-2 $DIR2/$tfile-4
1712 check_pdo_conflict $PID1 || error "link is blocked"
1713 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1714 check_pdo_conflict $PID1 || error "getattr is blocked"
1715 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1716 rmdir $DIR2/$tfile-3
1717 check_pdo_conflict $PID1 || error "unlink is blocked"
1719 # all operations above shouldn't wait the first one
1720 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1721 do_nodes $(comma_list $(mdts_nodes)) \
1722 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1727 run_test 40e "pdirops: rename and others =============="
1729 # test 41: create blocking operations
1732 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1733 do_nodes $(comma_list $(mdts_nodes)) \
1734 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1735 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1737 mkdir $DIR2/$tfile &
1739 do_nodes $(comma_list $(mdts_nodes)) \
1740 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1741 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1742 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1746 run_test 41a "pdirops: create vs mkdir =============="
1750 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1751 do_nodes $(comma_list $(mdts_nodes)) \
1752 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1753 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1755 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1757 do_nodes $(comma_list $(mdts_nodes)) \
1758 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1760 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1764 run_test 41b "pdirops: create vs create =============="
1768 touch $DIR1/$tfile-2
1769 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1770 do_nodes $(comma_list $(mdts_nodes)) \
1771 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1772 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1774 link $DIR2/$tfile-2 $DIR2/$tfile &
1776 do_nodes $(comma_list $(mdts_nodes)) \
1777 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1778 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1779 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1783 run_test 41c "pdirops: create vs link =============="
1787 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1788 do_nodes $(comma_list $(mdts_nodes)) \
1789 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1790 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1794 do_nodes $(comma_list $(mdts_nodes)) \
1795 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1796 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1797 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1801 run_test 41d "pdirops: create vs unlink =============="
1805 touch $DIR1/$tfile-2
1806 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1807 do_nodes $(comma_list $(mdts_nodes)) \
1808 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1809 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1811 mv $DIR2/$tfile-2 $DIR2/$tfile &
1813 do_nodes $(comma_list $(mdts_nodes)) \
1814 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1815 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1816 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1820 run_test 41e "pdirops: create and rename (tgt) =============="
1824 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1825 do_nodes $(comma_list $(mdts_nodes)) \
1826 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1827 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1829 mv $DIR2/$tfile $DIR2/$tfile-2 &
1831 do_nodes $(comma_list $(mdts_nodes)) \
1832 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1833 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1834 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1838 run_test 41f "pdirops: create and rename (src) =============="
1842 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1843 do_nodes $(comma_list $(mdts_nodes)) \
1844 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1845 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1847 stat $DIR2/$tfile > /dev/null &
1849 do_nodes $(comma_list $(mdts_nodes)) \
1850 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1851 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1852 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1856 run_test 41g "pdirops: create vs getattr =============="
1860 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1861 do_nodes $(comma_list $(mdts_nodes)) \
1862 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1863 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1865 ls -lia $DIR2/ > /dev/null &
1867 do_nodes $(comma_list $(mdts_nodes)) \
1868 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1869 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1874 run_test 41h "pdirops: create vs readdir =============="
1876 # test 42: unlink and blocking operations
1879 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1880 do_nodes $(comma_list $(mdts_nodes)) \
1881 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1882 mkdir $DIR1/$tfile &
1884 mkdir $DIR2/$tfile &
1886 do_nodes $(comma_list $(mdts_nodes)) \
1887 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1888 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1889 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1893 run_test 42a "pdirops: mkdir vs mkdir =============="
1897 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1898 do_nodes $(comma_list $(mdts_nodes)) \
1899 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1900 mkdir $DIR1/$tfile &
1902 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1904 do_nodes $(comma_list $(mdts_nodes)) \
1905 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1906 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1907 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1911 run_test 42b "pdirops: mkdir vs create =============="
1915 touch $DIR1/$tfile-2
1916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1917 do_nodes $(comma_list $(mdts_nodes)) \
1918 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1919 mkdir $DIR1/$tfile &
1921 link $DIR2/$tfile-2 $DIR2/$tfile &
1923 do_nodes $(comma_list $(mdts_nodes)) \
1924 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1925 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1926 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1930 run_test 42c "pdirops: mkdir vs link =============="
1934 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1935 do_nodes $(comma_list $(mdts_nodes)) \
1936 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1937 mkdir $DIR1/$tfile &
1939 rmdir $DIR2/$tfile &
1941 do_nodes $(comma_list $(mdts_nodes)) \
1942 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1943 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1944 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1948 run_test 42d "pdirops: mkdir vs unlink =============="
1952 touch $DIR1/$tfile-2
1953 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1954 do_nodes $(comma_list $(mdts_nodes)) \
1955 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1956 mkdir $DIR1/$tfile &
1958 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1960 do_nodes $(comma_list $(mdts_nodes)) \
1961 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1962 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1963 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1967 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1971 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1972 do_nodes $(comma_list $(mdts_nodes)) \
1973 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1974 mkdir $DIR1/$tfile &
1976 mv $DIR2/$tfile $DIR2/$tfile-2 &
1978 do_nodes $(comma_list $(mdts_nodes)) \
1979 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1980 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1981 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1985 run_test 42f "pdirops: mkdir and rename (src) =============="
1989 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1990 do_nodes $(comma_list $(mdts_nodes)) \
1991 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1992 mkdir $DIR1/$tfile &
1994 stat $DIR2/$tfile > /dev/null &
1996 do_nodes $(comma_list $(mdts_nodes)) \
1997 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1998 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1999 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2003 run_test 42g "pdirops: mkdir vs getattr =============="
2007 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2008 do_nodes $(comma_list $(mdts_nodes)) \
2009 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2010 mkdir $DIR1/$tfile &
2012 ls -lia $DIR2/ > /dev/null &
2014 do_nodes $(comma_list $(mdts_nodes)) \
2015 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2016 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2021 run_test 42h "pdirops: mkdir vs readdir =============="
2023 # test 43: rmdir,mkdir won't return -EEXIST
2025 for i in {1..1000}; do
2026 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2027 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2031 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2036 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2037 do_nodes $(comma_list $(mdts_nodes)) \
2038 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2041 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2043 do_nodes $(comma_list $(mdts_nodes)) \
2044 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2045 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2046 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2050 run_test 43b "pdirops: unlink vs create =============="
2055 touch $DIR1/$tfile-2
2056 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2057 do_nodes $(comma_list $(mdts_nodes)) \
2058 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2061 link $DIR2/$tfile-2 $DIR2/$tfile &
2063 do_nodes $(comma_list $(mdts_nodes)) \
2064 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2065 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2066 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2070 run_test 43c "pdirops: unlink vs link =============="
2075 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2076 do_nodes $(comma_list $(mdts_nodes)) \
2077 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2082 do_nodes $(comma_list $(mdts_nodes)) \
2083 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2084 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2085 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2089 run_test 43d "pdirops: unlink vs unlink =============="
2094 touch $DIR1/$tfile-2
2095 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2096 do_nodes $(comma_list $(mdts_nodes)) \
2097 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2100 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2102 do_nodes $(comma_list $(mdts_nodes)) \
2103 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2104 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2105 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2109 run_test 43e "pdirops: unlink and rename (tgt) =============="
2114 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2115 do_nodes $(comma_list $(mdts_nodes)) \
2116 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2119 mv $DIR2/$tfile $DIR2/$tfile-2 &
2121 do_nodes $(comma_list $(mdts_nodes)) \
2122 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2123 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2124 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2128 run_test 43f "pdirops: unlink and rename (src) =============="
2133 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2134 do_nodes $(comma_list $(mdts_nodes)) \
2135 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2138 stat $DIR2/$tfile > /dev/null &
2140 do_nodes $(comma_list $(mdts_nodes)) \
2141 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2142 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2143 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2147 run_test 43g "pdirops: unlink vs getattr =============="
2152 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2153 do_nodes $(comma_list $(mdts_nodes)) \
2154 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2157 ls -lia $DIR2/ > /dev/null &
2159 do_nodes $(comma_list $(mdts_nodes)) \
2160 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2161 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2166 run_test 43h "pdirops: unlink vs readdir =============="
2169 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2172 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2173 do_nodes $(comma_list $(mdts_nodes)) \
2174 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2177 $LFS mkdir -i 1 $DIR2/$tfile &
2179 do_nodes $(comma_list $(mdts_nodes)) \
2180 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2181 check_pdo_conflict $PID1 &&
2182 { wait $PID1; error "remote mkdir isn't blocked"; }
2183 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2187 run_test 43i "pdirops: unlink vs remote mkdir"
2190 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2191 skip "Need MDS version newer than 2.13.52"
2193 for i in {1..100}; do
2194 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2195 do_nodes $(comma_list $(mdts_nodes)) \
2196 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2201 mkdir $DIR2/$tdir && ((OK++))
2202 wait $PID1 && ((OK++))
2203 (( OK == 1 )) || error "exactly one mkdir should succeed"
2205 rmdir $DIR1/$tdir || error "rmdir failed"
2209 run_test 43j "racy mkdir return EEXIST =============="
2211 # test 44: rename tgt and blocking operations
2214 touch $DIR1/$tfile-2
2215 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2216 do_nodes $(comma_list $(mdts_nodes)) \
2217 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2218 mv $DIR1/$tfile-2 $DIR1/$tfile &
2220 mkdir $DIR2/$tfile &
2222 do_nodes $(comma_list $(mdts_nodes)) \
2223 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2224 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2225 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2230 run_test 44a "pdirops: rename tgt vs mkdir =============="
2234 touch $DIR1/$tfile-2
2235 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2236 do_nodes $(comma_list $(mdts_nodes)) \
2237 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2238 mv $DIR1/$tfile-2 $DIR1/$tfile &
2240 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2242 do_nodes $(comma_list $(mdts_nodes)) \
2243 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2244 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2245 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2249 run_test 44b "pdirops: rename tgt vs create =============="
2253 touch $DIR1/$tfile-2
2254 touch $DIR1/$tfile-3
2255 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2256 do_nodes $(comma_list $(mdts_nodes)) \
2257 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2258 mv $DIR1/$tfile-2 $DIR1/$tfile &
2260 link $DIR2/$tfile-3 $DIR2/$tfile &
2262 do_nodes $(comma_list $(mdts_nodes)) \
2263 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2264 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2265 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2269 run_test 44c "pdirops: rename tgt vs link =============="
2273 touch $DIR1/$tfile-2
2274 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2275 do_nodes $(comma_list $(mdts_nodes)) \
2276 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2277 mv $DIR1/$tfile-2 $DIR1/$tfile &
2281 do_nodes $(comma_list $(mdts_nodes)) \
2282 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2283 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2284 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2288 run_test 44d "pdirops: rename tgt vs unlink =============="
2293 touch $DIR1/$tfile-2
2294 touch $DIR1/$tfile-3
2295 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2296 do_nodes $(comma_list $(mdts_nodes)) \
2297 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2298 mv $DIR1/$tfile-2 $DIR1/$tfile &
2300 mv $DIR2/$tfile-3 $DIR2/$tfile &
2302 do_nodes $(comma_list $(mdts_nodes)) \
2303 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2304 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2305 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2309 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2313 touch $DIR1/$tfile-2
2314 touch $DIR1/$tfile-3
2315 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2316 do_nodes $(comma_list $(mdts_nodes)) \
2317 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2318 mv $DIR1/$tfile-2 $DIR1/$tfile &
2320 mv $DIR2/$tfile $DIR2/$tfile-3 &
2322 do_nodes $(comma_list $(mdts_nodes)) \
2323 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2324 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2325 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2329 run_test 44f "pdirops: rename tgt and rename (src) =============="
2333 touch $DIR1/$tfile-2
2334 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2335 do_nodes $(comma_list $(mdts_nodes)) \
2336 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2337 mv $DIR1/$tfile-2 $DIR1/$tfile &
2339 stat $DIR2/$tfile > /dev/null &
2341 do_nodes $(comma_list $(mdts_nodes)) \
2342 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2343 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2344 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2348 run_test 44g "pdirops: rename tgt vs getattr =============="
2352 touch $DIR1/$tfile-2
2353 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2354 do_nodes $(comma_list $(mdts_nodes)) \
2355 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2356 mv $DIR1/$tfile-2 $DIR1/$tfile &
2358 ls -lia $DIR2/ > /dev/null &
2360 do_nodes $(comma_list $(mdts_nodes)) \
2361 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2362 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2367 run_test 44h "pdirops: rename tgt vs readdir =============="
2369 # test 44: rename tgt and blocking operations
2371 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2373 touch $DIR1/$tfile-2
2374 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2375 do_nodes $(comma_list $(mdts_nodes)) \
2376 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2377 mv $DIR1/$tfile-2 $DIR1/$tfile &
2379 $LFS mkdir -i 1 $DIR2/$tfile &
2381 do_nodes $(comma_list $(mdts_nodes)) \
2382 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2383 check_pdo_conflict $PID1 && { wait $PID1;
2384 error "remote mkdir isn't blocked"; }
2385 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2389 run_test 44i "pdirops: rename tgt vs remote mkdir"
2391 # test 45: rename,mkdir doesn't fail with -EEXIST
2393 for i in {1..1000}; do
2394 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2395 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2396 error "mrename to $tdir.$i failed"
2401 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2406 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2407 do_nodes $(comma_list $(mdts_nodes)) \
2408 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2409 mv $DIR1/$tfile $DIR1/$tfile-2 &
2411 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2413 do_nodes $(comma_list $(mdts_nodes)) \
2414 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2415 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2416 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2420 run_test 45b "pdirops: rename src vs create =============="
2425 touch $DIR1/$tfile-3
2426 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2427 do_nodes $(comma_list $(mdts_nodes)) \
2428 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2429 mv $DIR1/$tfile $DIR1/$tfile-2 &
2431 link $DIR2/$tfile-3 $DIR2/$tfile &
2433 do_nodes $(comma_list $(mdts_nodes)) \
2434 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2435 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2436 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2440 run_test 45c "pdirops: rename src vs link =============="
2445 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2446 do_nodes $(comma_list $(mdts_nodes)) \
2447 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2448 mv $DIR1/$tfile $DIR1/$tfile-2 &
2452 do_nodes $(comma_list $(mdts_nodes)) \
2453 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2454 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2455 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2459 run_test 45d "pdirops: rename src vs unlink =============="
2464 touch $DIR1/$tfile-3
2465 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2466 do_nodes $(comma_list $(mdts_nodes)) \
2467 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2468 mv $DIR1/$tfile $DIR1/$tfile-2 &
2470 mv $DIR2/$tfile-3 $DIR2/$tfile &
2472 do_nodes $(comma_list $(mdts_nodes)) \
2473 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2474 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2475 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2479 run_test 45e "pdirops: rename src and rename (tgt) =============="
2484 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2485 do_nodes $(comma_list $(mdts_nodes)) \
2486 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2487 mv $DIR1/$tfile $DIR1/$tfile-2 &
2489 mv $DIR2/$tfile $DIR2/$tfile-3 &
2491 do_nodes $(comma_list $(mdts_nodes)) \
2492 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2493 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2494 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2498 run_test 45f "pdirops: rename src and rename (src) =============="
2503 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2504 do_nodes $(comma_list $(mdts_nodes)) \
2505 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2506 mv $DIR1/$tfile $DIR1/$tfile-2 &
2508 stat $DIR2/$tfile > /dev/null &
2510 do_nodes $(comma_list $(mdts_nodes)) \
2511 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2512 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2513 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2517 run_test 45g "pdirops: rename src vs getattr =============="
2522 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2523 do_nodes $(comma_list $(mdts_nodes)) \
2524 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2525 mv $DIR1/$tfile $DIR1/$tfile-2 &
2527 ls -lia $DIR2/ > /dev/null &
2528 do_nodes $(comma_list $(mdts_nodes)) \
2529 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2530 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2535 run_test 45h "pdirops: unlink vs readdir =============="
2538 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2541 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2542 do_nodes $(comma_list $(mdts_nodes)) \
2543 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2544 mv $DIR1/$tfile $DIR1/$tfile-2 &
2546 $LFS mkdir -i 1 $DIR2/$tfile &
2548 do_nodes $(comma_list $(mdts_nodes)) \
2549 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2550 check_pdo_conflict $PID1 && { wait $PID1;
2551 error "create remote dir isn't blocked"; }
2552 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2556 run_test 45i "pdirops: rename src vs remote mkdir"
2558 # test 46: link and blocking operations
2561 touch $DIR1/$tfile-2
2562 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2563 do_nodes $(comma_list $(mdts_nodes)) \
2564 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2565 link $DIR1/$tfile-2 $DIR1/$tfile &
2567 mkdir $DIR2/$tfile &
2569 do_nodes $(comma_list $(mdts_nodes)) \
2570 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2571 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2572 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2576 run_test 46a "pdirops: link vs mkdir =============="
2580 touch $DIR1/$tfile-2
2581 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2582 do_nodes $(comma_list $(mdts_nodes)) \
2583 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2584 link $DIR1/$tfile-2 $DIR1/$tfile &
2586 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2588 do_nodes $(comma_list $(mdts_nodes)) \
2589 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2590 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2591 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2595 run_test 46b "pdirops: link vs create =============="
2599 touch $DIR1/$tfile-2
2600 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2601 do_nodes $(comma_list $(mdts_nodes)) \
2602 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2603 link $DIR1/$tfile-2 $DIR1/$tfile &
2605 link $DIR2/$tfile $DIR2/$tfile &
2607 do_nodes $(comma_list $(mdts_nodes)) \
2608 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2609 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2610 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2614 run_test 46c "pdirops: link vs link =============="
2618 touch $DIR1/$tfile-2
2619 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2620 do_nodes $(comma_list $(mdts_nodes)) \
2621 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2622 link $DIR1/$tfile-2 $DIR1/$tfile &
2626 do_nodes $(comma_list $(mdts_nodes)) \
2627 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2628 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2629 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2633 run_test 46d "pdirops: link vs unlink =============="
2637 touch $DIR1/$tfile-2
2638 touch $DIR1/$tfile-3
2639 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2640 do_nodes $(comma_list $(mdts_nodes)) \
2641 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2642 link $DIR1/$tfile-2 $DIR1/$tfile &
2644 mv $DIR2/$tfile-3 $DIR2/$tfile &
2646 do_nodes $(comma_list $(mdts_nodes)) \
2647 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2648 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2649 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2653 run_test 46e "pdirops: link and rename (tgt) =============="
2657 touch $DIR1/$tfile-2
2658 touch $DIR1/$tfile-3
2659 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2660 do_nodes $(comma_list $(mdts_nodes)) \
2661 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2662 link $DIR1/$tfile-2 $DIR1/$tfile &
2664 mv $DIR2/$tfile $DIR2/$tfile-3 &
2666 do_nodes $(comma_list $(mdts_nodes)) \
2667 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2668 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2669 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2673 run_test 46f "pdirops: link and rename (src) =============="
2677 touch $DIR1/$tfile-2
2678 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2679 do_nodes $(comma_list $(mdts_nodes)) \
2680 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2681 link $DIR1/$tfile-2 $DIR1/$tfile &
2683 stat $DIR2/$tfile > /dev/null &
2685 do_nodes $(comma_list $(mdts_nodes)) \
2686 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2687 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2688 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2692 run_test 46g "pdirops: link vs getattr =============="
2696 touch $DIR1/$tfile-2
2697 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2698 do_nodes $(comma_list $(mdts_nodes)) \
2699 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2700 link $DIR1/$tfile-2 $DIR1/$tfile &
2702 ls -lia $DIR2/ > /dev/null &
2704 do_nodes $(comma_list $(mdts_nodes)) \
2705 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2706 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2711 run_test 46h "pdirops: link vs readdir =============="
2714 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2716 touch $DIR1/$tfile-2
2717 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2718 do_nodes $(comma_list $(mdts_nodes)) \
2719 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2720 link $DIR1/$tfile-2 $DIR1/$tfile &
2722 $LFS mkdir -i 1 $DIR2/$tfile &
2724 do_nodes $(comma_list $(mdts_nodes)) \
2725 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2726 check_pdo_conflict $PID1 && { wait $PID1;
2727 error "remote mkdir isn't blocked"; }
2728 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2732 run_test 46i "pdirops: link vs remote mkdir"
2734 # test 47: remote mkdir and blocking operations
2736 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2737 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2739 do_nodes $(comma_list $(mdts_nodes)) \
2740 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2741 $LFS mkdir -i 1 $DIR1/$tfile &
2743 mkdir $DIR2/$tfile &
2745 do_nodes $(comma_list $(mdts_nodes)) \
2746 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2747 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2748 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2752 run_test 47a "pdirops: remote mkdir vs mkdir"
2755 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2756 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2758 do_nodes $(comma_list $(mdts_nodes)) \
2759 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2760 $LFS mkdir -i 1 $DIR1/$tfile &
2762 sleep 1 # please do not remove this sleep, see LU-10754
2763 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2765 do_nodes $(comma_list $(mdts_nodes)) \
2766 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2767 check_pdo_conflict $PID1 && { wait $PID1;
2768 error "create isn't blocked"; }
2769 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2773 run_test 47b "pdirops: remote mkdir vs create"
2776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2778 touch $DIR1/$tfile-2
2779 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2780 do_nodes $(comma_list $(mdts_nodes)) \
2781 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2782 $LFS mkdir -i 1 $DIR1/$tfile &
2784 link $DIR2/$tfile-2 $DIR2/$tfile &
2786 do_nodes $(comma_list $(mdts_nodes)) \
2787 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2788 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2789 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2793 run_test 47c "pdirops: remote mkdir vs link"
2796 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2798 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2799 do_nodes $(comma_list $(mdts_nodes)) \
2800 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2801 $LFS mkdir -i 1 $DIR1/$tfile &
2803 rmdir $DIR2/$tfile &
2805 do_nodes $(comma_list $(mdts_nodes)) \
2806 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2807 check_pdo_conflict $PID1 && { wait $PID1;
2808 error "unlink isn't blocked"; }
2809 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2813 run_test 47d "pdirops: remote mkdir vs unlink"
2816 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2818 touch $DIR1/$tfile-2
2819 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2820 do_nodes $(comma_list $(mdts_nodes)) \
2821 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2822 $LFS mkdir -i 1 $DIR1/$tfile &
2824 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2826 do_nodes $(comma_list $(mdts_nodes)) \
2827 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2828 check_pdo_conflict $PID1 && { wait $PID1;
2829 error "rename isn't blocked"; }
2830 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2834 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2837 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2839 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2840 do_nodes $(comma_list $(mdts_nodes)) \
2841 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2842 $LFS mkdir -i 1 $DIR1/$tfile &
2844 mv $DIR2/$tfile $DIR2/$tfile-2 &
2846 do_nodes $(comma_list $(mdts_nodes)) \
2847 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2848 check_pdo_conflict $PID1 && { wait $PID1;
2849 error "rename isn't blocked"; }
2850 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2854 run_test 47f "pdirops: remote mkdir and rename (src)"
2857 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2861 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2862 do_nodes $(comma_list $(mdts_nodes)) \
2863 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2864 $LFS mkdir -i 1 $DIR1/$tfile &
2866 stat $DIR2/$tfile > /dev/null &
2868 do_nodes $(comma_list $(mdts_nodes)) \
2869 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2870 check_pdo_conflict $PID1 && { wait $PID1;
2871 error "getattr isn't blocked"; }
2872 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2876 run_test 47g "pdirops: remote mkdir vs getattr"
2880 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2881 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2882 do_facet client "lctl set_param fail_loc=0x410"
2883 $TRUNCATE $DIR2/$tfile $trunc_size
2884 do_facet client "lctl set_param fail_loc=0x0"
2886 size=`stat -c %s $DIR2/$tfile`
2887 [ $size -eq $trunc_size ] || error "wrong size"
2889 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2893 local origfile=/etc/hosts
2895 filesize=$(stat -c %s $origfile)
2897 # create an empty file
2898 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2899 # cache layout lock on both mount point
2900 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2901 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2903 # open and sleep 2 seconds then read
2904 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2908 # create the layout of testing file
2909 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2910 error "dd $DIR1/$tfile failed"
2912 # MULTIOP proc should be able to read enough bytes and exit
2913 for ((i = 0; i < 6; i++)); do
2915 kill -0 $pid || break
2917 kill -0 $pid 2> /dev/null && error "multiop is still there"
2918 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2922 run_test 51a "layout lock: refresh layout should work"
2925 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
2926 skip "Need MDS version at least 2.3.59"
2928 local tmpfile=`mktemp`
2930 $LFS setstripe -E 1M -c 1 -E -1 --extension-size 64M $DIR1/$tfile ||
2931 error "Create $DIR1/$tfile failed"
2933 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
2934 error "dd $DIR1/$tfile failed"
2936 # delay glimpse so that layout has changed when glimpse finish
2937 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2938 $LCTL set_param fail_loc=0x1404 fail_val=4
2939 stat -c %s $DIR2/$tfile |tee $tmpfile &
2943 # extend layout of testing file
2944 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
2945 error "dd $DIR1/$tfile failed"
2948 local fsize=$(cat $tmpfile)
2950 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
2952 rm -f $DIR1/$tfile $tmpfile
2954 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2957 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2959 # set default layout to have 1 stripe
2961 $LFS setstripe -c 1 $DIR1/$tdir
2963 # create a file with empty layout
2964 $MCREATE $DIR1/$tdir/$tfile ||
2965 error "$MCREATE $DIR1/$tdir/$tfile failed"
2967 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2968 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2970 # change the layout of testing file
2971 echo "Setting layout to have $OSTCOUNT stripes ..."
2972 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2976 # write something to the file, it should be blocked on fetching layout
2977 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2978 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2981 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2982 # count to succeed with only 3/4 of the number of stripes (rounded up),
2983 # so creating striped files does not fail if an OST is offline or full
2984 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2985 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2989 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2992 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2993 cancel_lru_locks mdc
2995 # open should grant LAYOUT lock, mmap and read will install pages
2996 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3000 # rss before revoking
3001 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3002 echo "Before revoking layout lock: $br KB mapped"
3004 # cancel layout lock manually
3005 cancel_lru_locks mdc
3007 # rss after revoking
3008 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3011 wait $PID || error "wait PID $PID failed"
3013 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3015 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3020 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3024 $LFS getstripe $DIR2/$tfile
3026 wait $pid || error "multiop failed"
3028 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3032 $LFS getstripe $DIR2/$tfile
3034 wait $pid || error "multiop failed"
3036 run_test 51e "lfs getstripe does not break leases, part 2"
3040 echo "==> rename vs getattr vs setxattr should not deadlock"
3041 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3043 do_facet mds1 $LCTL set_param fail_loc=$1
3045 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3053 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3054 wait $PID1 || error "(3) mv failed"
3055 wait $PID2 || error "(4) stat failed"
3062 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3063 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3065 do_facet mds1 $LCTL set_param fail_loc=$1
3067 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3075 $MULTIOP $DIR2/d1/d2 Oc &
3079 stat $DIR/d1 || error "(2) stat failed"
3081 wait $PID1 || error "(3) mv failed"
3082 wait $PID2 || error "(4) stat failed"
3083 wait $PID3 && error "(5) multiop failed"
3089 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3090 save_lustre_params client "llite.*.xattr_cache" > $p
3091 lctl set_param llite.*.xattr_cache 1 ||
3092 { skip "xattr cache is not supported"; return 0; }
3094 #define OBD_FAIL_MDS_RENAME 0x153
3095 #define OBD_FAIL_MDS_RENAME2 0x154
3096 test_54_part1 0x80000153 || error 10
3097 test_54_part1 0x80000154 || error 11
3098 test_54_part2 0x80000153 || error 12
3099 test_54_part2 0x80000154 || error 13
3101 restore_lustre_params < $p
3104 run_test 54 "rename locking"
3107 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3109 #define OBD_FAIL_MDS_RENAME4 0x156
3110 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3112 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3117 wait $PID1 && error "(2) mv succeeded"
3121 run_test 55a "rename vs unlink target dir"
3125 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3127 #define OBD_FAIL_MDS_RENAME4 0x156
3128 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3130 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3135 wait $PID1 && error "(2) mv succeeded"
3139 run_test 55b "rename vs unlink source dir"
3143 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3145 #define OBD_FAIL_MDS_RENAME4 0x156
3146 do_facet mds1 $LCTL set_param fail_loc=0x156
3148 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3152 # while rename is sleeping, open and remove d3
3153 $MULTIOP $DIR2/d3 D_c &
3159 # while rename is sleeping 2nd time, close d3
3161 wait $PID2 || error "(3) multiop failed"
3163 wait $PID1 && error "(2) mv succeeded"
3167 run_test 55c "rename vs unlink orphan target dir"
3173 #define OBD_FAIL_MDS_RENAME3 0x155
3174 do_facet mds1 $LCTL set_param fail_loc=0x155
3175 mv $DIR/f1 $DIR/$tdir &
3179 # while rename is sleeping, create $tdir, but as a directory
3180 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
3182 # link in reverse locking order
3183 ln $DIR2/f1 $DIR2/$tdir/
3185 wait $PID1 && error "(2) mv succeeded"
3188 run_test 55d "rename file vs link"
3191 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3192 skip "MDS version must be >= 2.3.0"
3195 test_mkdir $DIR1/$tdir
3196 file1=$DIR1/$tdir/file
3197 file2=$DIR2/$tdir/file
3199 echo orig > $file2 || error "Could not create $file2"
3200 version=$($LFS data_version $file1)
3203 echo append >> $file2 || error "Could not append to $file2"
3204 version2=$($LFS data_version $file1)
3205 [ "$version" != "$version2" ] ||
3206 error "append did not change data version: $version"
3209 echo overwrite > $file2 || error "Could not overwrite $file2"
3210 version3=$($LFS data_version $file1)
3211 [ "$version2" != "$version3" ] ||
3212 error "overwrite did not change data version: $version2"
3214 # Truncate before EOF
3215 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3216 version4=$($LFS data_version $file1)
3217 [ "$version3" != "$version4" ] ||
3218 error "truncate did not change data version: $version3"
3220 # Truncate after EOF
3221 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3222 version5=$($LFS data_version $file1)
3223 [ "$version4" != "$version5" ] ||
3224 error "truncate did not change data version: $version4"
3226 # Chmod do not change version
3227 chmod 400 $file2 || error "Could not chmod 400 $file2"
3228 version6=$($LFS data_version $file1)
3229 [ "$version5" == "$version6" ] ||
3230 error "chmod should not change data version: $version5 != $version6"
3232 # Chown do not change version
3233 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3234 version7=$($LFS data_version $file1)
3235 [ "$version5" == "$version7" ] ||
3236 error "chown should not change data version: $version5 != $version7"
3238 run_test 60 "Verify data_version behaviour"
3241 local test_dir=$tdir/test_dir
3243 mkdir -p $DIR1/$tdir
3244 if [ $MDSCOUNT -ge 2 ]; then
3246 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3247 error "Create remote directory failed"
3249 mkdir -p $DIR1/$test_dir
3251 cd $DIR2/$test_dir || error "cd directory failed"
3252 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3254 cd $DIR2/$tdir || error "exit directory"
3256 run_test 70a "cd directory && rm directory"
3258 test_70b() { # LU-2781
3260 mkdir -p $DIR1/$tdir
3262 touch $DIR1/$tdir/file
3263 for ((i = 0; i < 32; i++)); do
3264 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3266 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3268 touch $DIR1/$tdir/file
3269 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3270 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3271 rm -rf $DIR1/$tdir/test_dir ||
3272 error "cannot remove directory after rm_entry"
3273 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3275 run_test 70b "remove files after calling rm_entry"
3278 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3279 skip "Need MDS version at least 2.1.6"
3281 # Patch not applied to 2.2 and 2.3 branches
3282 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3283 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3284 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3286 checkfiemap --test ||
3287 skip "checkfiemap not runnable: $?"
3288 # write data this way: hole - data - hole - data
3289 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3290 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3292 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3293 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3294 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3296 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3298 checkfiemap $DIR2/$tfile 81920 ||
3299 error "data is not flushed from client"
3300 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3303 # common case of "create file, copy file" on a single node
3304 # should not flush data from ost
3305 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3306 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3308 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3310 checkfiemap $DIR1/$tfile 81920 ||
3312 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3314 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3316 run_test 71a "correct file map just after write operation is finished"
3319 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3320 skip "Need MDS version at least 2.1.6"
3322 # Patch not applied to 2.2 and 2.3 branches
3323 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3324 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3325 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3326 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3328 checkfiemap --test ||
3329 skip "error $?: checkfiemap failed"
3331 mkdir -p $DIR1/$tdir
3333 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3334 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3335 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3337 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3338 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3340 run_test 71b "check fiemap support for stripecount > 1"
3343 local p="$TMP/sanityN-$TESTNAME.parameters"
3346 save_lustre_params client "llite.*.xattr_cache" > $p
3347 lctl set_param llite.*.xattr_cache 1 ||
3348 { skip "xattr cache is not supported"; return 0; }
3351 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3352 error "setfattr1 failed"
3353 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3354 error "getfattr1 failed"
3355 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3356 error "setfattr2 failed"
3357 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3358 error "getfattr2 failed"
3360 # check that trusted.link is consistent
3361 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3362 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3363 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3364 echo "$tlink1 $tlink2"
3365 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3369 restore_lustre_params < $p
3372 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3375 local p="$TMP/sanityN-$TESTNAME.parameters"
3376 save_lustre_params client "llite.*.xattr_cache" > $p
3377 lctl set_param llite.*.xattr_cache 1 ||
3378 { skip "xattr cache is not supported"; return 0; }
3381 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3382 error "setfattr1 failed"
3383 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3384 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3385 clear_stats llite.*.stats
3386 # PR lock should be cached by now on both clients
3387 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3388 # 2 hits for getfattr(0)+getfattr(size)
3389 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3390 error "not cached in $DIR1"
3391 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3392 # 4 hits for more getfattr(0)+getfattr(size)
3393 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3394 error "not cached in $DIR2"
3397 restore_lustre_params < $p
3400 run_test 73 "getxattr should not cause xattr lock cancellation"
3403 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3404 skip "Need MDS version at least 2.4.93"
3406 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3407 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3408 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3410 run_test 74 "flock deadlock: different mounts =============="
3414 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3415 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3416 cancel_lru_locks osc
3418 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3421 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3422 $LCTL set_param fail_loc=0x31d
3423 stat -c %s $DIR1/$tfile &
3428 # For bad lock error handler we should ASSERT and got kernel panic here
3430 $LCTL set_param fail_loc=0
3432 run_test 75 "osc: upcall after unuse lock==================="
3435 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3436 skip "Need MDS version at least 2.5.53"
3438 remote_mds_nodsh && skip "remote MDS with nodsh"
3439 local fcount=$((MDSCOUNT * 256))
3444 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3450 test_mkdir $DIR/$tdir
3452 # drop all open locks and close any cached "open" files on the client
3453 cancel_lru_locks mdc
3455 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3456 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3457 local already=${#fid_list[@]}
3458 for (( i = 0; i < $already; i++ )) ; do
3459 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3462 echo -n "opening files: "
3463 ulimit -n $((fcount + 50))
3464 for ((i = 0; i < $fcount; i++)); do
3465 touch $DIR/$tdir/f_$i
3466 local fd=$(free_fd ${fd_list[i]})
3467 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3472 (( $i % 32 == 0 )) && echo -n "."
3476 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3478 # Possible errors in openfiles FID list.
3479 # 1. Missing FIDs. Check 1
3480 # 2. Extra FIDs. Check 1
3481 # 3. Duplicated FID. Check 2
3482 # 4. Invalid FIDs. Check 2
3483 # 5. Valid FID, points to some other file. Check 3
3486 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3487 error "${#fid_list[@]} != $fcount (+$already old) open files"
3489 echo -n "closing files: "
3490 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3491 local close_cmd="exec ${fd_list[fd]}<&-"
3493 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3495 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3496 echo "skip old open file $filename"
3498 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3502 rm --interactive=no $filename
3504 error "Nonexisting fid ${fid_list[fid]} listed."
3505 (( $fd % 32 == 0 )) && echo -n "."
3510 ls_op=$(ls $DIR2/$tdir | wc -l)
3512 error "Some openfiles are missing in lproc output"
3516 run_test 76 "Verify MDT open_files listing"
3520 local dir=$DIR/$tdir
3523 mkdir $dir || error "mkdir $dir failed"
3524 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3527 do_nodes $CLIENTS $myRUNAS \
3528 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3529 error "dd at 0 on client failed (1)"
3531 do_nodes $CLIENTS $myRUNAS \
3533 for ((i = 0; i < $n; i++)); do
3534 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3535 seek=\\\$i count=1 conv=notrunc &
3536 pids_w[\\\$i]=\\\$!;
3539 for ((i = 0; i < $n; i++)); do
3540 wait \\\${pids_w[\\\$i]};
3542 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3546 do_nodes $CLIENTS sync;
3547 cancel_lru_locks osc
3549 do_nodes $CLIENTS $myRUNAS \
3551 for ((i = 0; i < $n; i++)); do
3552 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3553 seek=\\\$i count=1 &
3554 pids_r[\\\$i]=\\\$!;
3557 for ((i = 0; i < $n; i++)); do
3558 wait \\\${pids_r[\\\$i]};
3560 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3564 cancel_lru_locks osc
3566 wait $pid_w || error "dd (write) failed (2)"
3567 wait $pid_r || error "dd (read) failed (3)"
3568 rm -rvf $dir || error "rm -rf $dir failed"
3571 test_77a() { #LU-3266
3574 oss=$(comma_list $(osts_nodes))
3575 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3577 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3578 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3583 run_test 77a "check FIFO NRS policy"
3585 test_77b() { #LU-3266
3588 oss=$(comma_list $(osts_nodes))
3590 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3591 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3592 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3593 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3595 echo "policy: crr-n, crrn_quantum 1"
3598 do_nodes $oss lctl set_param \
3599 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3600 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3602 echo "policy: crr-n, crrn_quantum 64"
3606 do_nodes $oss lctl set_param \
3607 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3608 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3611 run_test 77b "check CRR-N NRS policy"
3616 oss=$(comma_list $(osts_nodes))
3618 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3619 ost.OSS.*.nrs_"$policy"_quantum=1 \
3620 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3621 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3623 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3624 "physical, ${policy}_supported reads"
3627 do_nodes $oss lctl set_param \
3628 ost.OSS.*.nrs_${policy}_supported="writes" \
3629 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3631 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3632 "physical, ${policy}_supported writes"
3635 do_nodes $oss lctl set_param \
3636 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3637 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3638 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3639 "logical, ${policy}_supported reads_and_writes"
3643 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3648 test_77c() { #LU-3266
3650 orr_trr "orr" || rc=$?
3651 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3652 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3655 run_test 77c "check ORR NRS policy"
3657 test_77d() { #LU-3266
3659 orr_trr "trr" || rc=$?
3660 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3661 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3664 run_test 77d "check TRR nrs policy"
3671 do_facet $facet lctl set_param \
3672 ost.OSS.ost_io.nrs_tbf_rule="$*"
3674 error "failed to run operate '$*' on TBF rules"
3677 cleanup_tbf_verify()
3681 echo "cleanup_tbf $DIR/$tdir"
3684 wait_delete_completed
3689 local dir=$DIR/$tdir
3690 local client1=${CLIENT1:-$(hostname)}
3693 local np=$(check_cpt_number ost1)
3694 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3695 echo "cpu_npartitions on ost1 is $np"
3697 mkdir $dir || error "mkdir $dir failed"
3698 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3701 trap cleanup_tbf_verify EXIT
3702 echo "Limited write rate: $1, read rate: $2"
3703 echo "Verify the write rate is under TBF control"
3704 local start=$SECONDS
3705 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3706 bs=1M count=100 oflag=direct 2>&1
3707 local runtime=$((SECONDS - start + 1))
3708 local rate=$(bc <<< "scale=6; 100 / $runtime")
3709 echo "Write runtime is $runtime s, speed is $rate IOPS"
3711 # verify the write rate does not exceed TBF rate limit
3712 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3713 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3715 cancel_lru_locks osc
3717 echo "Verify the read rate is under TBF control"
3719 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3720 bs=1M count=100 iflag=direct 2>&1
3721 runtime=$((SECONDS - start + 1))
3722 rate=$(bc <<< "scale=6; 100 / $runtime")
3723 echo "Read runtime is $runtime s, speed is $rate IOPS"
3725 # verify the read rate does not exceed TBF rate limit
3726 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3727 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3729 cancel_lru_locks osc
3730 cleanup_tbf_verify || error "rm -rf $dir failed"
3736 oss=$(comma_list $(osts_nodes))
3738 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3740 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3741 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3745 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3750 # Only operate rules on ost1 since OSTs might run on the same OSS
3752 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3753 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3754 local client_nids=$(nids_list $address "\\")
3755 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3756 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3760 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3761 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3762 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3766 tbf_rule_operate ost1 "stop\ localhost"
3767 tbf_rule_operate ost1 "stop\ clients"
3768 tbf_rule_operate ost1 "stop\ others"
3771 # Cleanup the TBF policy
3772 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3773 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3777 run_test 77e "check TBF NID nrs policy"
3782 oss=$(comma_list $(osts_nodes))
3784 do_nodes $oss $LCTL set_param \
3785 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3786 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3787 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3789 # Configure jobid_var
3790 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3792 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3793 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3794 if [ $saved_jobid_var != procname_uid ]; then
3795 set_persistent_param_and_check client \
3796 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3801 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3806 # Only operate rules on ost1 since OSTs might run on the same OSS
3808 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3809 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3810 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3811 nrs_write_read "$RUNAS"
3814 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3815 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3816 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3817 nrs_write_read "$RUNAS"
3820 tbf_rule_operate ost1 "stop\ runas"
3821 tbf_rule_operate ost1 "stop\ iozone_runas"
3822 tbf_rule_operate ost1 "stop\ dd_runas"
3823 nrs_write_read "$RUNAS"
3825 # Cleanup the TBF policy
3826 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3827 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3828 nrs_write_read "$RUNAS"
3830 local current_jobid_var=$($LCTL get_param -n jobid_var)
3831 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3832 if [ $saved_jobid_var != $current_jobid_var ]; then
3833 set_persistent_param_and_check client \
3834 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3838 run_test 77f "check TBF JobID nrs policy"
3843 oss=$(comma_list $(osts_nodes))
3845 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3847 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3848 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3850 do_nodes $oss lctl set_param \
3851 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3852 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3856 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3861 # Add a rule that only valid for Jobid TBF. If direct change between
3862 # TBF types is not supported, this operation will fail.
3863 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3865 # Cleanup the TBF policy
3866 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3867 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3870 run_test 77g "Change TBF type directly"
3873 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3874 skip "Need OST version at least 2.8.55"
3876 local old_policy=$(do_facet ost1 \
3877 lctl get_param ost.OSS.ost_io.nrs_policies)
3880 do_facet ost1 lctl set_param \
3881 ost.OSS.ost_io.nrs_policies="abc"
3882 [ $? -eq 0 ] && error "should return error"
3884 do_facet ost1 lctl set_param \
3885 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3886 [ $? -eq 0 ] && error "should return error"
3888 do_facet ost1 lctl set_param \
3889 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3890 [ $? -eq 0 ] && error "should return error"
3892 do_facet ost1 lctl set_param \
3893 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3894 [ $? -eq 0 ] && error "should return error"
3896 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3897 [ $? -eq 0 ] || error "shouldn't LBUG"
3899 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3903 run_test 77h "Wrong policy name should report error, not LBUG"
3909 local error_message=$3
3911 for rule in $expected; do
3912 rule_number=$((rule_number + 1))
3914 local stop_line=$(($rule_number + 3))
3915 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3917 local output=$(do_facet $facet lctl get_param \
3918 ost.OSS.ost_io.nrs_tbf_rule |
3922 if [ "$output" != "$expected" ]; then
3923 error "$error_message, expected '$expected', got '$output'"
3928 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3929 skip "Need OST version at least 2.8.55"
3931 for i in $(seq 1 $OSTCOUNT)
3933 do_facet ost"$i" lctl set_param \
3934 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3936 error "failed to set TBF policy"
3939 tbf_rule_check ost1 "default" "error before inserting any rule"
3941 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3942 tbf_rule_check ost1 "before default" \
3943 "error when inserting rule 'before'"
3945 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3946 tbf_rule_check ost1 "before after default" \
3947 "error when inserting rule 'after'"
3949 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3950 tbf_rule_check ost1 "before target after default" \
3951 "error when inserting rule 'target'"
3953 echo "Move before itself"
3954 tbf_rule_operate ost1 "change\ target\ rank=target"
3955 tbf_rule_check ost1 "before target after default" \
3956 "error when moving before itself"
3958 echo "Move to higher rank"
3959 tbf_rule_operate ost1 "change\ target\ rank=before"
3960 tbf_rule_check ost1 "target before after default" \
3961 "error when moving to higher rank"
3963 echo "Move to lower rank"
3964 tbf_rule_operate ost1 "change\ target\ rank=after"
3965 tbf_rule_check ost1 "before target after default" \
3966 "error when moving to lower rank"
3968 echo "Move before default"
3969 tbf_rule_operate ost1 "change\ target\ rank=default"
3970 tbf_rule_check ost1 "before after target default" \
3971 error "error when moving before default"
3973 # Cleanup the TBF policy
3974 do_nodes $(comma_list $(osts_nodes)) \
3975 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3978 run_test 77i "Change rank of TBF rule"
3984 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
3985 skip "Need OST version at least 2.9.53"
3986 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
3991 do_nodes $(comma_list $(osts_nodes)) \
3992 lctl set_param jobid_var=procname_uid \
3993 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3994 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3995 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3996 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4001 do_nodes $(comma_list $(osts_nodes)) \
4002 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4003 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4004 ost.OSS.ost_io.nrs_policies="fifo"
4006 # sleep 3 seconds to wait the tbf policy stop completely,
4007 # or the next test case is possible get -EAGAIN when
4008 # setting the tbf policy
4011 run_test 77j "check TBF-OPCode NRS policy"
4014 local idstr="${1}id"
4015 local policy="${idstr}={$2}"
4016 local rate="rate=$3"
4018 do_nodes $(comma_list $(osts_nodes)) \
4019 lctl set_param jobid_var=procname_uid \
4020 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4021 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4022 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4024 nrs_write_read "runas $4"
4025 tbf_verify $3 $3 "runas $4"
4027 do_nodes $(comma_list $(osts_nodes)) \
4028 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4029 ost.OSS.ost_io.nrs_policies="fifo"
4031 # sleep 3 seconds to wait the tbf policy stop completely,
4032 # or the next test case is possible get -eagain when
4033 # setting the tbf policy
4038 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4039 skip "Need OST version at least 2.11.50"
4042 test_id "u" "500" "5" "-u 500"
4043 test_id "g" "500" "5" "-u 500 -g 500"
4045 run_test 77ja "check TBF-UID/GID NRS policy"
4053 for rule in $rule_lists; do
4054 do_nodes $(comma_list $(osts_nodes)) \
4055 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4058 do_nodes $(comma_list $(osts_nodes)) \
4059 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4065 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4066 skip "Need OST version at least 2.9.53"
4068 do_nodes $(comma_list $(osts_nodes)) \
4069 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4070 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4071 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4073 nrs_write_read "$RUNAS"
4074 tbf_verify 20 10 "$RUNAS"
4076 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4077 local client_nids=$(nids_list $address "\\")
4078 do_nodes $(comma_list $(osts_nodes)) \
4079 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4080 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4081 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4082 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4087 do_nodes $(comma_list $(osts_nodes)) \
4088 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4089 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4090 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4092 nrs_write_read "$RUNAS"
4093 tbf_verify 20 20 "$RUNAS"
4095 do_nodes $(comma_list $(osts_nodes)) \
4096 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4097 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4098 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4100 nrs_write_read "$RUNAS"
4101 # with parameter "RUNAS", it will match the latest rule
4102 # "ext_b" first, so the limited write rate is 10.
4103 tbf_verify 10 10 "$RUNAS"
4106 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4108 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4109 skip "Need OST version at least 2.10.58"
4111 do_nodes $(comma_list $(osts_nodes)) \
4112 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4113 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4114 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4115 nrs_write_read "runas -u 500 -g 1000"
4116 tbf_verify 5 5 "runas -u 500 -g 1000"
4118 do_nodes $(comma_list $(osts_nodes)) \
4119 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4120 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4121 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4123 nrs_write_read "runas -u 500"
4124 tbf_verify 20 10 "runas -u 500"
4126 do_nodes $(comma_list $(osts_nodes)) \
4127 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4128 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4129 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4130 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4131 nrs_write_read "runas -u 500"
4132 tbf_verify 10 10 "runas -u 500"
4133 tbf_verify 20 10 "runas -u 500"
4134 cleanup_77k "ext_a ext_b" "fifo"
4136 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4139 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4140 skip "Need OST version at least 2.10.56"
4142 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4143 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4145 local output=$(do_facet ost1 lctl get_param \
4146 ost.OSS.ost_io.nrs_policies | \
4147 awk '/name: tbf/ {print;exit}' | \
4148 awk -F ': ' '{print $2}')
4150 if [ "$output" != "tbf" ]; then
4151 error "The generic TBF output is '$output', not 'tbf'"
4154 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4156 run_test 77l "check the output of NRS policies for generic TBF"
4159 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4160 skip "Need OST version at least 2.9.54"
4163 local dir=$DIR/$tdir
4165 mkdir $dir || error "mkdir $dir failed"
4166 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4169 local nodes=$(comma_list $(osts_nodes))
4170 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4171 ost.OSS.ost_io.nrs_delay_min=4 \
4172 ost.OSS.ost_io.nrs_delay_max=4 \
4173 ost.OSS.ost_io.nrs_delay_pct=100
4174 [ $? -ne 0 ] && error "Failed to set delay policy"
4176 local start=$SECONDS
4177 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4178 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4179 oflag=direct conv=fdatasync ||
4180 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4181 error "dd on client failed (1)"; }
4182 local elapsed=$((SECONDS - start))
4184 # NRS delay doesn't do sub-second timing, so a request enqueued at
4185 # 0.9 seconds can be dequeued at 4.0
4186 [ $elapsed -lt 3 ] &&
4187 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4188 error "Single 1M write should take at least 3 seconds"; }
4191 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4192 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4193 oflag=direct conv=fdatasync ||
4194 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4195 error "dd on client failed (2)"; }
4196 elapsed=$((SECONDS - start))
4198 [ $elapsed -lt 30 ] &&
4199 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4200 error "Ten 1M writes should take at least 30 seconds"; }
4202 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4203 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4207 run_test 77m "check NRS Delay slows write RPC processing"
4209 test_77n() { #LU-10802
4210 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4211 skip "Need OST version at least 2.10.58"
4214 # Configure jobid_var
4215 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4216 if [ $saved_jobid_var != procname_uid ]; then
4217 set_persistent_param_and_check client \
4218 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4221 do_nodes $(comma_list $(osts_nodes)) \
4222 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4223 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4224 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4227 tbf_verify 20 20 "$RUNAS"
4229 do_nodes $(comma_list $(osts_nodes)) \
4230 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4231 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4236 do_nodes $(comma_list $(osts_nodes)) \
4237 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4238 ost.OSS.ost_io.nrs_policies="fifo"
4242 local current_jobid_var=$($LCTL get_param -n jobid_var)
4243 if [ $saved_jobid_var != $current_jobid_var ]; then
4244 set_persistent_param_and_check client \
4245 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4248 run_test 77n "check wildcard support for TBF JobID NRS policy"
4250 test_78() { #LU-6673
4253 oss=$(comma_list $(osts_nodes))
4254 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4255 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4257 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4258 # Valid return codes are:
4259 # 0: Tuning succeeded
4260 # ENODEV: Policy is still stopped
4261 # EAGAIN: Policy is being initialized
4262 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4263 error "Expected set_param to return 0|ENODEV|EAGAIN"
4265 # Cleanup the ORR policy
4266 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4267 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4270 run_test 78 "Enable policy and specify tunings right away"
4273 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4274 test_mkdir $DIR/$tdir
4276 # Prevent interference from layout intent RPCs due to
4277 # asynchronous writeback. These will be tested in 130c below.
4278 do_nodes ${CLIENTS:-$HOSTNAME} sync
4280 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4281 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4283 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4284 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4285 local facet=mds$((mdtidx + 1))
4287 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4288 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4292 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4293 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4298 run_test 79 "xattr: intent error"
4301 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4308 mkdir -p $DIR1/$tdir/dir
4309 createmany -o $DIR1/$tdir/dir/f 10 ||
4310 error "create files under remote dir failed $i"
4312 cp /etc/passwd $DIR1/$tdir/$tfile
4314 #migrate open file should fails
4315 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4317 # give multiop a chance to open
4320 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4321 error "migrate open files should failed with open files"
4325 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4326 error "migrate remote dir error"
4328 echo "Finish migration, then checking.."
4329 for file in $(find $DIR1/$tdir); do
4330 mdt_index=$($LFS getstripe -m $file)
4331 [ $mdt_index == $MDTIDX ] ||
4332 error "$file is not on MDT${MDTIDX}"
4335 diff /etc/passwd $DIR1/$tdir/$tfile ||
4336 error "file different after migration"
4338 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4340 run_test 80a "migrate directory when some children is being opened"
4344 kill -9 $migrate_pid
4348 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4349 local migrate_dir1=$DIR1/$tdir/migrate_dir
4350 local migrate_dir2=$DIR2/$tdir/migrate_dir
4351 local migrate_run=$LUSTRE/tests/migrate.sh
4359 trap cleanup_80b EXIT
4360 #prepare migrate directory
4361 mkdir -p $migrate_dir1
4362 for F in {1,2,3,4,5}; do
4363 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4364 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4367 #migrate the directories among MDTs
4370 mdt_idx=$((RANDOM % MDSCOUNT))
4371 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4373 [ $rc -ne 0 -o $rc -ne 16 ] || break
4378 echo "start migration thread $migrate_pid"
4379 #Access the files at the same time
4380 start_time=$(date +%s)
4381 echo "accessing the migrating directory for 5 minutes..."
4383 ls $migrate_dir2 > /dev/null || {
4384 echo "read dir fails"
4387 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4388 echo "access file1 fails"
4392 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4393 echo "access file2/3 fails"
4397 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4398 echo "access file4 fails"
4402 stat $migrate_dir2/file5 > /dev/null || {
4403 echo "stat file5 fails"
4407 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4408 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4409 echo "touch file failed with $rc1"
4413 if [ -e $migrate_dir2/source_file ]; then
4414 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4415 &>/dev/null || rc1=$?
4416 if [ -e $migrate_dir2/link_file ]; then
4417 rm -rf $migrate_dir2/link_file
4420 mrename $migrate_dir2/source_file \
4421 $migrate_dir2/target_file &>/dev/null || rc1=$?
4422 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4423 echo "rename failed with $rc1"
4427 if [ -e $migrate_dir2/target_file ]; then
4428 rm -rf $migrate_dir2/target_file &>/dev/null ||
4431 rm -rf $migrate_dir2/source_file &>/dev/null ||
4434 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4435 echo "unlink failed with $rc1"
4440 end_time=$(date +%s)
4441 duration=$((end_time - start_time))
4442 if [ $((duration % 10)) -eq 0 ]; then
4443 if [ $show_time -eq 1 ]; then
4444 echo "...$duration seconds"
4451 kill -0 $migrate_pid || {
4452 echo "migration stopped 1"
4456 [ $duration -ge 300 ] && break
4459 #check migration are still there
4460 kill -0 $migrate_pid || error "migration stopped 2"
4463 run_test 80b "Accessing directory during migration"
4466 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4470 mkdir -p $DIR1/$tdir
4472 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4473 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4476 touch d0/0 || error "create 0 failed"
4477 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4478 stat d0/0 && error "stat mv filed succeed"
4479 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4480 stat d0/0 || error "stat failed"
4482 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4484 if [ $t -ne 3 ]; then
4485 ls -ai $DIR1/$tdir/d0
4486 error "expect 3 get $t"
4491 run_test 81a "rename and stat under striped directory"
4494 [ $MDSCOUNT -lt 2 ] &&
4495 skip "We need at least 2 MDTs for this test"
4502 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4503 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4512 for i in $(seq $total); do
4513 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4517 kill -9 $setattr_pid
4519 run_test 81b "rename under striped directory doesn't deadlock"
4522 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4523 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4524 skip "Need MDS version at least 2.13.52"
4526 # source is local, source parent is remote
4527 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4528 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4529 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4530 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4531 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4532 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4533 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4534 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4536 # source is remote, source parent is local
4537 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4538 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4539 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4540 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4541 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4542 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4543 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4544 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4546 # source and source parent are remote
4547 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4548 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4549 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4550 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4551 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4552 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4553 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4554 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4556 # source and source parent are remote, and source is remote object
4557 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4558 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4559 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4560 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4561 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4562 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4563 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4565 run_test 81c "rename revoke LOOKUP lock for remote object"
4568 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4569 skip "Need MDS version at least 2.6.92"
4571 # Client 1 creates a file.
4572 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4574 # Client 2 opens the file.
4575 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4577 # Client 1 makes the file an orphan.
4578 rm $DIR1/$tfile || error "rm"
4579 # Client 2 sets EA "user.multiop".
4581 wait $pid2 || error "multiop 2"
4582 # Client 1 gets EA "user.multiop". This used to fail because the EA
4583 # cache refill would get "trusted.link" from mdd_xattr_list() but
4584 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4587 wait $pid1 || error "multiop 1"
4589 run_test 82 "fsetxattr and fgetxattr on orphan files"
4592 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4599 $LFS mkdir -i1 -c2 $tdir
4604 echo "start pid $pid1 to create/unlink striped directory"
4606 # Access the directory at the same time
4610 stat $tdir > /dev/null 2>&1
4614 echo "start pid $pid2 to stat striped directory"
4622 run_test 83 "access striped directory while it is being created/unlinked"
4625 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4626 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4630 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4631 error "create $tfile failed"
4632 mtime=$(stat -c%Y $DIR/$tfile)
4633 mtime=$((mtime + 200))
4635 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4636 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4638 touch -c -m $mtime $DIR/$tfile &
4640 # sleep a while to let 'touch' run first
4642 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4645 wait $setattr_pid || true
4647 run_test 84 "0-nlink race in lu_object_find()"
4650 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4655 [ "$SLOW" = "yes" ] && duration=600
4656 # Open/Create under striped directory
4660 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4661 touch $tdir/f{0..3} > /dev/null 2>&1
4665 echo "start pid $pid1 to open/create under striped directory"
4667 # unlink the striped directory at the same time
4671 rm -rf $tdir > /dev/null 2>&1
4675 echo "start pid $pid2 to unlink striped directory"
4684 run_test 90 "open/create and unlink striped directory"
4687 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4692 [ "$SLOW" = "yes" ] && duration=600
4693 # chmod striped directory
4697 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4698 chmod go+w $tdir > /dev/null 2>&1
4702 echo "start pid $pid1 to chmod striped directory"
4704 # unlink the striped directory at the same time
4708 rm -rf $tdir > /dev/null 2>&1
4712 echo "start pid $pid2 to unlink striped directory"
4721 run_test 91 "chmod and unlink striped directory"
4724 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4727 local cmd="exec $fd<$DIR1/$tdir"
4728 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4731 trap "eval $cmd" EXIT
4732 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4733 rmdir ../$tdir || error "rmdir ../$tdir fails"
4735 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4736 $LCTL set_param fail_loc=0x1408
4737 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4738 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4739 error "create remote dir succeeds"
4740 $LCTL set_param fail_loc=0
4744 run_test 92 "create remote directory under orphan directory"
4751 mkdir -p $DIR1/$tfile-1/
4752 mkdir -p $DIR2/$tfile-2/
4753 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4754 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4755 do_facet $SINGLEMDS "$LCTL set_param -n \
4756 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4757 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4758 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4760 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4763 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4767 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4768 do_facet $SINGLEMDS "$LCTL set_param -n \
4769 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4771 $LFS getstripe $DIR1/$tfile-1/file1
4772 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4773 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4774 $LFS getstripe $DIR2/$tfile-2/file2
4775 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4776 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4777 echo "rc1=$rc1 and rc2=$rc2 "
4778 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4779 error "object allocate on same ost detected"
4781 run_test 93 "alloc_rr should not allocate on same ost"
4784 $LCTL set_param osc.*.idle_timeout=0
4785 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4787 local before=$(date +%s)
4791 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4792 $LCTL set_param fail_val=5 fail_loc=0x80000312
4793 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4797 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4798 $LCTL set_param fail_val=6 fail_loc=0x80000329
4799 $LCTL mark kill $pid
4802 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4805 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4807 evict=$(do_facet client $LCTL get_param \
4808 osc.$FSNAME-OST*-osc-*/state |
4809 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4811 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4812 (do_facet client $LCTL get_param \
4813 osc.$FSNAME-OST*-osc-*/state;
4814 error "eviction happened: $evict before:$before")
4815 $LCTL set_param osc.*.idle_timeout=debug
4817 run_test 94 "signal vs CP callback race"
4821 skip "Reserved for glimpse-ahead" && return
4822 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4823 skip "Need MDS version at least 2.10.55"
4827 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4829 lctl set_param -n mdc.*.stats=clear
4830 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4832 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4833 # first stat from server should return size data and save glimpse
4834 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4835 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4836 # second stat to check size is NOT cached on client without IO lock
4837 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4839 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4840 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4843 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4846 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4847 skip "Need MDS version at least 2.10.55"
4851 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4853 lctl set_param -n mdc.*.stats=clear
4854 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4855 cancel_lru_locks mdc
4856 # first stat data from server should have size
4857 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4858 # second stat to check size is cached on client
4859 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4861 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4862 # both stats should cause no glimpse requests
4863 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4866 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4869 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4870 skip "Need MDS version at least 2.10.55"
4874 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4876 lctl set_param -n mdc.*.stats=clear
4877 lctl set_param -n osc.*.stats=clear
4878 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4880 # check that size is merged from MDT and OST correctly
4881 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4882 error "Wrong size from stat #1"
4884 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4885 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4889 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4892 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4893 skip "Need MDS version at least 2.10.55"
4897 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4900 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4901 lctl set_param -n mdc.*.stats=clear
4902 $TRUNCATE $DIR2/$tdir/dom 4096
4904 # check that reported size is valid after file grows to OST and
4905 # is truncated back to MDT stripe size
4906 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4907 error "Wrong size from stat #1"
4909 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4910 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4914 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4917 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
4918 skip "Need MDS version at least 2.11.50"
4920 local dom=$DIR/$tdir/dom
4921 local dom2=$DIR2/$tdir/dom
4924 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4926 cancel_lru_locks mdc
4927 dd if=/dev/urandom of=$dom bs=12000 count=1
4928 $TRUNCATE $dom2 6000
4929 cancel_lru_locks mdc
4930 lctl set_param -n mdc.*.stats=clear
4931 # expect read-on-open to return all data before write
4932 cat /etc/hosts >> $dom
4933 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4934 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4936 run_test 100e "DoM: read on open and file size"
4939 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4940 skip "Need MDS version at least 2.10.55"
4942 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4944 $CHECKSTAT -t file $DIR1/$tfile
4946 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4947 sysctl -wq vm.dirty_writeback_centisecs=0
4949 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4952 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4953 error_noexit "Write fails"
4954 # must discard pages
4955 lctl set_param -n mdc.*.stats=clear
4956 rm $DIR2/$tfile || error "Unlink fails"
4958 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4959 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4961 run_test 101a "Discard DoM data on unlink"
4964 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4965 skip "Need MDS version at least 2.10.55"
4967 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4968 touch $DIR1/${tfile}_2
4970 $CHECKSTAT -t file $DIR1/$tfile
4972 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4973 sysctl -wq vm.dirty_writeback_centisecs=0
4975 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4978 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4979 # must discard pages
4980 lctl set_param -n mdc.*.stats=clear
4981 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4983 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4984 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4986 run_test 101b "Discard DoM data on rename"
4989 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4990 skip "Need MDS version at least 2.10.55"
4992 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4994 $CHECKSTAT -t file $DIR1/$tfile
4996 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4997 sysctl -wq vm.dirty_writeback_centisecs=0
4999 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5002 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5003 $MULTIOP $DIR1/$tfile O_c &
5006 lctl set_param -n mdc.*.stats=clear
5007 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5008 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5010 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5011 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5013 run_test 101c "Discard DoM data on close-unlink"
5015 # test to verify file handle related system calls
5016 # (name_to_handle_at/open_by_handle_at)
5017 # The new system calls are supported in glibc >= 2.14.
5019 # test to verify we can open by handle an unlinked file from > 1 client
5020 # This test opens the file normally on $DIR1, which is on one mount, and then
5021 # opens it by handle on $DIR2, which is on a different mount.
5023 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
5024 skip "Needs MDS version 2.11.57 or later"
5026 echo "Test file_handle syscalls" > $DIR/$tfile ||
5027 error "write failed"
5028 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5029 error "check_fhandle_syscalls failed"
5032 run_test 102 "Test open by handle of unlinked file"
5034 # Compare file size between first & second mount, ensuring the client correctly
5035 # glimpses even with unused speculative locks - LU-11670
5037 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5038 skip "Lockahead needs OST version at least 2.10.50"
5042 test_mkdir -p $DIR/$tdir
5044 # Force file on to OST0
5045 $LFS setstripe -i 0 $DIR/$tdir
5047 # Do not check multiple locks on glimpse
5048 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5049 $LCTL set_param fail_loc=0x415
5051 # Delay write commit by 2 seconds to guarantee glimpse wins race
5052 # The same fail_loc is used on client & server so it can work in the
5053 # single node sanity setup
5054 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5056 echo "Incorrect size expected (no glimpse fix):"
5057 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5059 if [ $rc -eq 0 ]; then
5060 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5063 # guarantee write commit timeout has expired
5066 # Clear fail_loc on client
5067 $LCTL set_param fail_loc=0
5069 # Delay write commit by 2 seconds to guarantee glimpse wins race
5070 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5071 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5073 # Write commit is still delayed by 2 seconds
5074 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5076 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5078 # guarantee write commit timeout has expired
5081 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5083 run_test 103 "Test size correctness with lockahead"
5089 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5100 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5101 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5102 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5103 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5111 local xtimes=($(get_stat_xtimes))
5112 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5114 echo "STAT a|m|ctime ${xtimes[*]}"
5115 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5116 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5117 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5118 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5119 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5120 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5121 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5125 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5126 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5127 skip "Need MDS version at least 2.12.4"
5130 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5131 local atime_diff=$(do_facet $SINGLEMDS \
5132 lctl get_param -n mdd.*MDT0000*.atime_diff)
5134 do_facet $SINGLEMDS \
5135 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5137 stack_trap "do_facet $SINGLEMDS \
5138 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5140 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5141 check_mdt_xtimes $mdtdev
5144 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5145 check_mdt_xtimes $mdtdev
5147 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5150 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5152 kill -USR1 $pid && wait $pid || error "multiop failure"
5153 check_mdt_xtimes $mdtdev
5158 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5159 # on the client side
5160 xtimes=($(get_stat_xtimes))
5161 $MULTIOP $DIR/$tfile O_c &
5164 kill -USR1 $pid && wait $pid || error "multiop failure"
5165 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5166 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5167 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5168 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5169 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5170 check_mdt_xtimes $mdtdev
5173 # Change ctime via chmod
5174 $MULTIOP $DIR/$tfile o_tc &
5177 kill -USR1 $pid && wait $pid || error "multiop failure"
5178 check_mdt_xtimes $mdtdev
5180 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5183 test_mkdir -p $DIR/$tdir
5184 echo test > $DIR/$tdir/$tfile
5185 $LCTL set_param fail_loc=0x416
5186 cancel_lru_locks osc & sleep 1
5187 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5189 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5191 run_test 105 "Glimpse and lock cancel race"
5194 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5195 skip_env "Test only for ldiskfs and statx() supported"
5200 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5202 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5203 btime=$($STATX -c %W $DIR/$tfile)
5204 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5206 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5207 [[ $btime == $mdt_btime ]] ||
5208 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5211 run_test 106a "Verify the btime via statx()"
5214 statx_supported || skip_env "statx() only test"
5219 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5220 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5221 cancel_lru_locks $OSC
5222 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5224 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5225 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5226 error "$STATX should send 1 glimpse RPC to $OSC"
5228 cancel_lru_locks $OSC
5229 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5230 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5231 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5233 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5234 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5235 [ $rpcs_after -eq $rpcs_before ] ||
5236 error "$STATX should not send glimpse RPCs to $OSC"
5238 cancel_lru_locks $OSC
5239 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5240 $STATX --cached=always $DIR/$tfile
5241 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5242 [ $rpcs_after -eq $rpcs_before ] ||
5243 error "$STATX should not send glimpse RPCs to $OSC"
5245 cancel_lru_locks $OSC
5246 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5247 $STATX -c %Y $DIR/$tfile
5248 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5249 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5250 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5252 cancel_lru_locks $OSC
5253 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5254 $STATX -c %s $DIR/$tfile
5255 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5256 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5257 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5259 cancel_lru_locks $OSC
5260 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5261 $STATX -c %b $DIR/$tfile
5262 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5263 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5264 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5266 run_test 106b "Glimpse RPCs test for statx"
5269 statx_supported || skip_env "statx() only test"
5274 # Mask supported in stx_attributes by Lustre is
5275 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5276 mask=$($STATX -c %p $DIR/$tfile)
5277 [[ $mask == "30" ]] ||
5278 error "supported stx_attributes: got '$mask', expected '30'"
5279 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5280 mask=$($STATX -c %r $DIR/$tfile)
5281 [[ $mask == "10" ]] ||
5282 error "got immutable flags '$mask', expected '10'"
5283 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5284 mask=$($STATX -c %r $DIR/$tfile)
5285 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5286 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5287 mask=$($STATX -c %r $DIR/$tfile)
5288 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5289 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5290 mask=$($STATX -c %r $DIR/$tfile)
5291 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5292 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5293 mask=$($STATX -c %r $DIR/$tfile)
5294 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5295 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5296 mask=$($STATX -c %r $DIR/$tfile)
5297 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5299 run_test 106c "Verify statx attributes mask"
5301 test_107a() { # LU-1031
5302 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5306 $LFS getstripe $DIR1/$tfile
5308 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5310 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5312 kill -USR1 $MULTIPID2
5314 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5315 error "First grouplock does not block second one"
5317 echo "First grouplock blocks second one"
5319 kill -USR1 $MULTIPID1
5323 run_test 107a "Basic grouplock conflict"
5326 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5330 $LFS getstripe $DIR1/$tfile
5332 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5334 multiop $DIR2/$tfile Or10c &
5338 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5339 error "Grouplock does not block IO"
5341 echo "Grouplock blocks IO"
5344 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5347 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5348 error "First grouplock does not block second one"
5350 echo "First grouplock blocks second one"
5353 kill -USR1 $MULTIPID1
5356 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5357 error "Second grouplock thread disappeared"
5360 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5361 error "Second grouplock does not block IO"
5363 echo "Second grouplock blocks IO"
5366 kill -USR1 $MULTIPID3
5371 run_test 107b "Grouplock is added to the head of waiting list"
5376 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5377 error "Create $DIR1/$tfile failed"
5379 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5380 error "dd $DIR1/$tfile failed"
5381 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5382 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5384 $TRUNCATE $DIR1/$tfile 2000
5385 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5386 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5388 #define OBD_FAIL_OSC_DELAY_IO 0x414
5389 $LCTL set_param fail_val=4 fail_loc=0x80000414
5390 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5394 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5396 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5398 run_test 108a "lseek: parallel updates"
5400 log "cleanup: ======================================================"
5402 # kill and wait in each test only guarentee script finish, but command in script
5403 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5404 # otherwise umount below will fail
5405 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5410 check_and_cleanup_lustre