8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 # skip tests for PPC until they are fixed
26 if [[ $(uname -m) = ppc64 ]]; then
27 # bug number: LU-11597 LU-11787
28 ALWAYS_EXCEPT+=" 16a 71a"
31 if [ $mds1_FSTYPE = "zfs" ]; then
32 # LU-2829 / LU-2887 - make allowances for ZFS slowness
33 TEST33_NFILES=${TEST33_NFILES:-1000}
37 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
46 check_and_setup_lustre
51 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
53 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
54 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
56 # $RUNAS_ID may get set incorrectly somewhere else
57 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
59 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
63 [ -f $DIR2/$tfile ] || error "Check create"
64 chmod 777 $DIR2/$tfile
65 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
66 error "Check attribute update for 0777"
68 chmod a-x $DIR2/$tfile
69 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
70 error "Check attribute update for 0666"
73 $CHECKSTAT -a $DIR1/$tfile ||
74 error "Check unlink - removes file on other mountpoint"
76 run_test 1 "Check attribute updates on 2 mount points"
82 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
83 error "Either not file type or perms not 0777"
85 run_test 2a "check cached attribute updates on 2 mtpt's ========"
91 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
92 error "Either not file type or perms not 0777"
94 run_test 2b "check cached attribute updates on 2 mtpt's ========"
96 # NEED TO SAVE ROOT DIR MODE
99 $CHECKSTAT -t dir -p 0777 $DIR2 ||
100 error "Either not dir type or perms not 0777"
102 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
106 $CHECKSTAT -t dir -p 0755 $DIR2 ||
107 error "Either not file type or perms not 0775"
109 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
116 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
119 run_test 2e "check chmod on root is propagated to others"
122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
124 local remote_dir=$tdir/remote_dir
127 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
128 error "Create remote directory failed"
130 touch $DIR1/$remote_dir/$tfile ||
131 error "Create file under remote directory failed"
132 chmod 777 $DIR1/$remote_dir/$tfile ||
133 error "Chmod file under remote directory failed"
135 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
136 error "Check attr of file under remote directory failed"
138 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
139 error "Chown file under remote directory failed"
141 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
142 error "Check owner of file under remote directory failed"
144 cd $DIR2/$remote_dir || error "enter remote dir"
145 rm -rf $DIR1/$remote_dir/$tfile ||
146 error "Unlink remote directory failed"
148 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
149 error "unlink file still exists!"
151 cd $DIR2/$tdir || error "exit remote dir"
152 rm -rf $DIR1/$tdir || error "unlink directory failed"
154 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
157 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
159 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
161 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
162 echo "$DIR1/$tfile has $block1 blocks"
163 echo "$DIR2/$tfile has $block2 blocks"
164 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
166 run_test 2g "check blocks update on sync write"
169 local target="this/is/good"
170 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
171 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
172 error "link $DIR2/$tfile not as expected"
174 run_test 3 "symlink on one mtpt, readlink on another ==========="
177 multifstat $DIR1/f4 $DIR2/f4
179 run_test 4 "fstat validation on multiple mount points =========="
183 $TRUNCATE $DIR2/f5 100
184 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
185 error "Either not file type or size not equal to 100 bytes"
188 run_test 5 "create a file on one mount, truncate it on the other"
191 openunlink $DIR1/$tfile $DIR2/$tfile || \
192 error "openunlink $DIR1/$tfile $DIR2/$tfile"
194 run_test 6 "remove of open file on other node =================="
198 opendirunlink $DIR1/$dir $DIR2/$dir || \
199 error "opendirunlink $DIR1/$dir $DIR2/$dir"
201 run_test 7 "remove of open directory on other node ============="
204 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
205 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
207 run_test 8 "remove of open special file on other node =========="
213 for C in a b c d e f g h i j k l; do
214 dir=`eval echo \\$DIR$MTPT`
215 echo -n $C >> $dir/f9
216 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
218 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
219 error "`od -a $DIR1/f9` != abcdefghijkl"
221 run_test 9a "append of file with sub-page size on multiple mounts"
223 #LU-10681 - tiny writes & appending to sparse striped file
225 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
227 $LFS setstripe -c 2 -S 1M $DIR/$tfile
228 echo "foo" >> $DIR/$tfile
229 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
230 error "sparse dd $DIR2/$tfile failed"
231 echo "foo" >> $DIR/$tfile
233 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
234 echo "Data read (expecting 'foo')": $data
235 [ "$data" = "foo" ] || error "append to sparse striped file failed"
237 run_test 9b "append to striped sparse file"
244 for C in a b c d e f g h i j k l; do
245 dir=`eval echo \\$DIR$MTPT`
246 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
247 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
248 OFFSET=`expr $OFFSET + 1`
250 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
251 error "`od -a $DIR1/f10` != abcdefghijkl"
253 run_test 10a "write of file with sub-page size on multiple mounts "
257 yes "R" | head -c 4000 >$TMP/f10b-seed
258 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
260 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
262 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
264 # create a test file locally to compare
265 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
266 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
267 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
268 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
270 run_test 10b "write of file with sub-page size on multiple mounts "
274 multiop_bg_pause $DIR1/d11/f O_c || return 1
276 cp -p /bin/ls $DIR1/d11/f
280 wait $MULTIPID || error "wait for PID $MULTIPID failed"
281 [ $RC -eq 0 ] && error || true
283 run_test 11 "execution of file opened for write should return error ===="
286 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
288 run_test 12 "test lock ordering (link, stat, unlink)"
290 test_13() { # bug 2451 - directory coherency
292 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
294 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
296 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
297 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
298 # need to run it twice
299 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
301 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
302 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
304 run_test 13 "test directory page revocation"
307 test_mkdir $DIR1/$tdir
308 cp -p /bin/ls $DIR1/$tdir/$tfile
309 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
312 $DIR2/$tdir/$tfile && error || true
315 run_test 14aa "execution of file open for write returns -ETXTBSY"
318 test_mkdir $DIR1/$tdir
319 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
320 $DIR1/$tdir/sleep 60 &
322 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
325 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
327 test_14b() { # bug 3192, 7040
328 test_mkdir $DIR1/$tdir
329 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
330 $DIR1/$tdir/sleep 60 &
332 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
333 error "expected truncate error, got success"
335 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
337 run_test 14b "truncate of executing file returns -ETXTBSY ======"
339 test_14c() { # bug 3430, 7040
340 test_mkdir $DIR1/$tdir
341 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
342 $DIR1/$tdir/sleep 60 &
344 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
346 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
348 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
350 test_14d() { # bug 10921
351 test_mkdir $DIR1/$tdir
352 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
353 $DIR1/$tdir/sleep 60 &
356 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
358 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
360 run_test 14d "chmod of executing file is still possible ========"
362 test_15() { # bug 974 - ENOSPC
364 sh oos2.sh $MOUNT1 $MOUNT2
365 wait_delete_completed
366 grant_error=$(dmesg | grep "< tot_grant")
367 [ -z "$grant_error" ] || error "$grant_error"
369 run_test 15 "test out-of-space with multiple writers ==========="
372 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
373 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
374 # pass a 2500 operation dual-mount run within the time limit.
375 if [ "$ost1_FSTYPE" = "zfs" ]; then
376 FSXNUM=$((COUNT / 5))
378 elif [ "$SLOW" = "yes" ]; then
379 FSXNUM=$((COUNT * 5))
387 local file1=$DIR1/$tfile
388 local file2=$DIR2/$tfile
389 local stripe_size=$(do_facet $SINGLEMDS \
390 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
392 # to allocate grant because it may run out due to test_15.
393 $LFS setstripe -c -1 $file1
394 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
395 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
398 $LFS setstripe -c -1 $file1 # b=10919
399 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
400 || error "fsx failed"
403 # O_DIRECT reads and writes must be aligned to the device block size.
404 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
405 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
407 run_test 16a "$FSXNUM iterations of dual-mount fsx"
409 # Consistency check for tiny writes, LU-9409
411 local file1=$DIR1/$tfile
412 local file2=$DIR2/$tfile
413 local stripe_size=($($LFS getstripe -S $DIR))
415 # to allocate grant because it may run out due to test_15.
416 lfs setstripe -c -1 $file1
417 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
418 error "dd failed writing to file=$file1"
419 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
420 error "dd failed writing to file=$file2"
423 lfs setstripe -c -1 $file1 # b=10919
424 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
425 # create a mix of tiny writes & normal writes
426 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
427 $file2 || error "fsx with tiny write failed."
429 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
432 local file1=$DIR1/$tfile
433 local file2=$DIR2/$tfile
434 local stripe_size=$(do_facet $SINGLEMDS \
435 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
437 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
439 # to allocate grant because it may run out due to test_15.
440 $LFS setstripe -c -1 $file1
441 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
442 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
444 wait_delete_completed
446 local list=$(comma_list $(osts_nodes))
447 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
448 skip "not cache-capable obdfilter"
451 set_osd_param $list '' read_cache_enable 0
452 set_osd_param $list '' writethrough_cache_enable 0
454 $LFS setstripe -c -1 $file1 # b=10919
455 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
456 || error "fsx failed"
459 set_osd_param $list '' read_cache_enable 1
460 set_osd_param $list '' writethrough_cache_enable 1
464 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
467 local file1=$DIR1/$tfile
468 local file2=$DIR2/$tfile
469 local file3=$DIR1/file
470 local stripe_size=$(do_facet $SINGLEMDS \
471 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
473 # to allocate grant because it may run out due to test_15.
474 $LFS setstripe -c -1 $file1
475 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
476 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
479 local tmpfile=`mktemp`
480 $LFS setstripe -c -1 $file1 # b=10919
481 $LCTL set_param ldlm.namespaces.*.lru_size=clear
483 # direct write on one client and direct read from another
484 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
485 dd if=$file2 of=$tmpfile iflag=direct bs=1M
486 diff $file1 $tmpfile || error "file different(1)"
489 # buffer write on one client, but direct read from another
490 dd if=$tmpfile of=$file1 bs=1M count=100
491 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
492 diff $file3 $tmpfile || error "file different(2)"
494 rm -f $file3 $file2 $file1
495 # direct write on one client
496 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
497 # buffer read from another client
498 dd if=$file2 of=$file3 bs=1M count=100
499 diff $file3 $tmpfile || error "file different(3)"
501 rm -f $file1 $file2 $file3 $tmpfile
504 run_test 16d "Verify DIO and buffer IO with two clients"
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 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
556 run_test 18 "mmap sanity check ================================="
558 test_19() { # bug3811
559 local node=$(facet_active_host ost1)
561 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
563 # check whether obdfilter is cache capable at all
564 get_osd_param $node '' read_cache_enable >/dev/null ||
565 skip "not cache-capable obdfilter"
567 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
568 set_osd_param $node '' readcache_max_filesize 4096
569 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
570 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
571 cp $TMP/$tfile $DIR1/$tfile
572 for i in `seq 1 20`; do
573 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
574 cancel_lru_locks $OSC > /dev/null
575 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
576 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
578 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
579 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
580 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
581 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
583 set_osd_param $node '' readcache_max_filesize $MAX
586 run_test 19 "test concurrent uncached read races ==============="
590 cancel_lru_locks $OSC
591 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
592 $MULTIOP $DIR1/f20 Ow8190c
593 $MULTIOP $DIR2/f20 Oz8194w8190c
594 $MULTIOP $DIR1/f20 Oz0r8190c
595 cancel_lru_locks $OSC
596 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
598 error $CNTD" page left in cache after lock cancel" || true
600 run_test 20 "test extra readahead page left in cache ===="
607 test_21() { # Bug 5907
608 test_mkdir $DIR1/$tdir
609 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
611 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
612 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
613 test -d $DIR1/$tdir || error "Mounted directory disappeared"
615 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
618 run_test 21 " Try to remove mountpoint on another dir ===="
620 test_23() { # Bug 5972
621 local at_diff=$(do_facet $SINGLEMDS \
622 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
623 echo "atime should be updated while another read" > $DIR1/$tfile
625 # clear the lock(mode: LCK_PW) gotten from creating operation
626 cancel_lru_locks $OSC
629 sleep $((at_diff + 1))
631 echo "starting reads"
632 multiop_bg_pause $DIR1/$tfile or20_c || return 1
633 # with SOM and opencache enabled, we need to close a file and cancel
634 # open lock to get atime propogated to MDS
635 kill -USR1 $! || return 2
638 time2=$(stat -c "%X" $DIR/$tfile)
639 echo "new atime is $time2"
641 [ $time2 -gt $time1 ] || error "atime was not updated"
642 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
645 run_test 23 " others should see updated atime while another read===="
649 lfs df || error "lfs df failed"
650 lfs df -ih || error "lfs df -ih failed"
651 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
652 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
653 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
654 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
656 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
657 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
658 lctl --device %osc deactivate
659 lfs df -i || error "lfs df -i with deactivated OSC failed"
660 lctl --device %osc activate
661 lfs df || error "lfs df with reactivated OSC failed"
663 run_test 24a "lfs df [-ih] [path] test ========================="
667 fsnum=$(lfs_df | grep -c "summary")
668 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
670 run_test 24b "lfs df should show both filesystems ==============="
673 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
675 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
678 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
679 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
681 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
682 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
683 error "setfacl $DIR2/$tdir #1"
684 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
685 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
686 error "setfacl $DIR2/$tdir #2"
687 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
688 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
689 error "setfacl $DIR2/$tdir #3"
690 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
691 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
692 error "setfacl $DIR2/$tdir #4"
693 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
697 run_test 25a "change ACL on one mountpoint be seen on another ==="
700 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
702 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
704 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
707 $LFS mkdir -i 1 $DIR1/$tdir
708 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
709 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
711 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
712 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
713 error "setfacl $DIR2/$tdir #1"
714 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
715 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
716 error "setfacl $DIR2/$tdir #2"
717 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
718 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
719 error "setfacl $DIR2/$tdir #3"
720 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
721 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
722 error "setfacl $DIR2/$tdir #4"
723 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
727 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
730 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
732 run_test 26a "allow mtime to get older"
737 echo "aaa" >> $DIR1/$tfile
739 chmod a+x $DIR2/$tfile
740 mt1=`stat -c %Y $DIR1/$tfile`
741 mt2=`stat -c %Y $DIR2/$tfile`
743 if [ x"$mt1" != x"$mt2" ]; then
744 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
747 run_test 26b "sync mtime between ost and mds"
750 cancel_lru_locks $OSC
752 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
757 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
762 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
764 lctl set_param -n ldlm.dump_namespaces ""
765 wait $DD1_PID $DD2_PID
766 [ $? -ne 0 ] && lctl dk $TMP/debug || true
768 run_test 27 "align non-overlapping extent locks from request ==="
770 test_28() { # bug 9977
771 ECHO_UUID="ECHO_osc1_UUID"
772 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
774 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
775 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
776 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
780 attach echo_client ECHO_osc1 $ECHO_UUID
784 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
785 $LCTL --device $tECHOID destroy "${tOBJID}:0"
793 # reading of 1st stripe should pass
794 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
795 # reading of 2nd stripe should fail (this stripe was destroyed)
796 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
798 # now, recreating test file
799 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
800 # reading of 1st stripe should pass
801 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
802 # reading of 2nd stripe should pass
803 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
806 run_test 28 "read/write/truncate file with lost stripes"
808 test_30() { #b=11110, LU-2523
809 test_mkdir $DIR1/$tdir
810 cp -f /bin/bash $DIR1/$tdir/bash
811 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
812 $DIR1/$tdir/bash -c 'sleep 2;
813 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
817 run_test 30 "recreate file race"
820 test_mkdir $DIR1/$tdir
821 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
822 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
823 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
824 lctl set_param fail_loc=0x314
825 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
826 awk 'BEGIN { FS="+" } /in/ {print $1}')
827 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
829 run_test 31a "voluntary cancel / blocking ast race=============="
832 remote_ost || { skip "local OST" && return 0; }
833 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
835 # make sure there is no local locks due to destroy
836 wait_mds_ost_sync || error "wait_mds_ost_sync()"
837 wait_delete_completed || error "wait_delete_completed()"
839 test_mkdir $DIR1/$tdir
840 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
841 cp /etc/hosts $DIR/$tdir/$tfile
842 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
843 lctl set_param fail_loc=0x314
844 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
845 do_facet ost1 lctl set_param fail_loc=0x316
847 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
848 lctl set_param fail_loc=0
849 do_facet ost1 lctl set_param fail_loc=0
850 # cleanup: reconnect the client back
853 run_test 31b "voluntary OST cancel / blocking ast race=============="
855 # enable/disable lockless truncate feature, depending on the arg 0/1
856 enable_lockless_truncate() {
857 lctl set_param -n $OSC.*.lockless_truncate $1
860 test_32a() { # bug 11270
861 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
862 local stripe_size=$(do_facet $SINGLEMDS \
863 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
865 save_lustre_params client "$OSC.*.lockless_truncate" > $save
866 # restore lockless_truncate default values on exit
867 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
868 cancel_lru_locks $OSC
869 enable_lockless_truncate 1
871 lfs setstripe -c -1 $DIR1/$tfile
872 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
874 clear_stats $OSC.*.${OSC}_stats
876 log "checking cached lockless truncate"
877 $TRUNCATE $DIR1/$tfile 8000000
878 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
879 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
880 error "cached truncate isn't lockless"
882 log "checking not cached lockless truncate"
883 $TRUNCATE $DIR2/$tfile 5000000
884 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
885 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
886 error "not cached truncate isn't lockless"
888 log "disabled lockless truncate"
889 enable_lockless_truncate 0
890 clear_stats $OSC.*.${OSC}_stats
891 $TRUNCATE $DIR2/$tfile 3000000
892 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
893 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
894 error "lockless truncate disabling failed"
897 run_test 32a "lockless truncate"
899 test_32b() { # bug 11270
900 remote_ost_nodsh && skip "remote OST with nodsh" && return
903 local facets=$(get_facets OST)
904 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
906 save_lustre_params client "osc.*.contention_seconds" > $p
907 save_lustre_params $facets \
908 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
909 save_lustre_params $facets \
910 "ldlm.namespaces.filter-*.contended_locks" >> $p
911 save_lustre_params $facets \
912 "ldlm.namespaces.filter-*.contention_seconds" >> $p
913 clear_stats $OSC.*.${OSC}_stats
915 # agressive lockless i/o settings
916 do_nodes $(comma_list $(osts_nodes)) \
917 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
918 ldlm.namespaces.filter-*.contended_locks=0 \
919 ldlm.namespaces.filter-*.contention_seconds=60"
920 lctl set_param -n $OSC.*.contention_seconds=60
922 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
924 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
927 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
928 error "lockless i/o was not triggered"
929 # disable lockless i/o (it is disabled by default)
930 do_nodes $(comma_list $(osts_nodes)) \
931 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
932 ldlm.namespaces.filter-*.contended_locks=32 \
933 ldlm.namespaces.filter-*.contention_seconds=0"
934 # set contention_seconds to 0 at client too, otherwise Lustre still
935 # remembers lock contention
936 lctl set_param -n $OSC.*.contention_seconds=0
937 clear_stats $OSC.*.${OSC}_stats
939 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
941 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
944 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
945 error "lockless i/o works when disabled"
947 restore_lustre_params <$p
950 run_test 32b "lockless i/o"
954 local mdts=$(get_facets MDS)
959 for mds in ${mdts//,/ }; do
961 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
962 xargs readlink -f" ))
963 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
966 stat=$(( stat + val))
971 # commit on sharing tests
973 remote_mds_nodsh && skip "remote MDS with nodsh" && return
975 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
976 [ $CLIENTCOUNT -lt 2 ] &&
977 skip "Need two or more clients, have $CLIENTCOUNT"
979 local nfiles=${TEST33_NFILES:-10000}
980 local param_file=$TMP/$tfile-params
986 save_lustre_params $(get_facets MDS) \
987 "mdt.*.commit_on_sharing" > $param_file
990 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
994 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
996 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
997 echo "=== START createmany old: $jbdold transaction"
998 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")
999 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1000 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1001 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1002 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1003 avgtime=$(( avgtime + elapsed ))
1005 eval cos${COS}_jbd=$((avgjbd / 3))
1006 eval cos${COS}_time=$((avgtime / 3))
1009 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1010 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1011 [ "$cos0_jbd" != 0 ] &&
1012 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1013 [ "$cos0_time" != 0 ] &&
1014 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1016 restore_lustre_params < $param_file
1020 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1022 # commit on sharing tests
1024 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1026 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1027 [ $CLIENTCOUNT -ge 2 ] ||
1028 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1030 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1032 local nfiles=${TEST33_NFILES:-10000}
1033 local param_file=$TMP/$tfile-params
1035 save_lustre_params $(get_facets MDS) \
1036 "mdt.*.commit_on_sharing" > $param_file
1045 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1049 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1050 $DIR1/$tdir-\\\$(hostname)-$i"
1052 jbdold=$(print_jbd_stat)
1053 echo "=== START createmany old: $jbdold transaction"
1054 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1055 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1056 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1058 jbdnew=$(print_jbd_stat)
1059 jbd=$(( jbdnew - jbdold ))
1060 echo "=== END createmany new: $jbdnew transaction : \
1061 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1062 avgjbd=$(( avgjbd + jbd ))
1063 avgtime=$(( avgtime + elapsed ))
1065 eval cos${COS}_jbd=$((avgjbd / 3))
1066 eval cos${COS}_time=$((avgtime / 3))
1069 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1070 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1071 [ "$cos0_jbd" != 0 ] &&
1072 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1073 [ "$cos0_time" != 0 ] &&
1074 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1076 restore_lustre_params < $param_file
1080 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1083 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1084 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1085 skip "DNE CoS not supported"
1091 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1092 # do twice in case transaction is committed before unlock, see LU-8200
1094 # remote dir is created on MDT1, which enqueued lock of $tdir on
1096 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1097 mkdir $DIR/$tdir/local.$i
1099 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1100 echo "sync_count $sync_count"
1101 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1104 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1105 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1106 # during sleep remote mkdir should have been committed and canceled
1107 # remote lock spontaneously, which shouldn't trigger sync
1109 mkdir $DIR/$tdir/local.3
1110 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1111 echo "sync_count $sync_count"
1112 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1114 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1116 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1120 local nodes=$(comma_list $(mdts_nodes))
1124 # trigger CoS twice in case transaction commit before unlock
1127 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1129 commit_nr=$(do_nodes $nodes \
1130 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1131 total=$((total + commit_nr));
1136 echo "CoS count $total"
1137 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1141 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1142 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1143 skip "DNE CoS not supported"
1145 # remote directory create
1146 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1147 # remote directory unlink
1148 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1149 # striped directory create
1150 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1151 # striped directory setattr
1152 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1153 "chmod 713 $DIR/$tdir"
1154 # striped directory unlink
1155 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1158 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1159 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1160 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1161 touch $DIR/$tdir/d1/tgt" \
1162 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1164 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1165 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1166 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1167 touch $DIR/$tdir/d1/src" \
1168 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1170 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1171 "$LFS migrate -m 1 $DIR/$tdir"
1175 run_test 33d "DNE distributed operation should trigger COS"
1178 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1179 [ $CLIENTCOUNT -ge 2 ] ||
1180 skip "Need two or more clients, have $CLIENTCOUNT"
1181 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1182 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1183 skip "DNE CoS not supported"
1185 local client2=${CLIENT2:-$(hostname)}
1189 local nodes=$(comma_list $(mdts_nodes))
1190 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1192 $LFS mkdir -c 2 $DIR/$tdir
1193 mkdir $DIR/$tdir/subdir
1194 echo abc > $DIR/$tdir/$tfile
1195 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1196 do_node $client2 touch $DIR/$tdir/subdir
1198 local async_commit_count=$(do_nodes $nodes \
1199 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1200 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1204 run_test 33e "DNE local operation shouldn't trigger COS"
1206 # End commit on sharing tests
1208 get_ost_lock_timeouts() {
1209 local nodes=${1:-$(comma_list $(osts_nodes))}
1211 local locks=$(do_nodes $nodes \
1212 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1220 do_nodes $(comma_list $(osts_nodes)) \
1221 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1222 for i in $(seq $OSTCOUNT); do
1223 wait_osc_import_ready client ost$i
1228 remote_ost_nodsh && skip "remote OST with nodsh" && return
1232 trap cleanup_34 EXIT RETURN
1233 for OPER in notimeout timeout ; do
1234 rm $DIR1/$tfile 2>/dev/null
1235 lock_in=$(get_ost_lock_timeouts)
1236 if [ $OPER == "timeout" ] ; then
1237 for j in `seq $OSTCOUNT`; do
1238 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1239 do_facet ost$j lctl set_param fail_loc=0x511
1241 echo lock should expire
1243 for j in `seq $OSTCOUNT`; do
1244 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1245 do_facet ost$j lctl set_param fail_loc=0x512
1247 echo lock should not expire
1249 echo writing on client1
1250 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1252 echo reading on client2
1253 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1254 # wait for a lock timeout
1256 lock_out=$(get_ost_lock_timeouts)
1257 if [ $OPER == "timeout" ] ; then
1258 if [ $lock_in == $lock_out ]; then
1259 error "no lock timeout happened"
1264 if [ $lock_in != $lock_out ]; then
1265 error "lock timeout happened"
1273 run_test 34 "no lock timeout under IO"
1275 test_35() { # bug 17645
1278 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1279 awk '/generation/{print $2}')
1281 generation[count]=$g
1285 test_mkdir $MOUNT1/$tdir
1286 cancel_lru_locks mdc
1288 # Let's initiate -EINTR situation by setting fail_loc and take
1289 # write lock on same file from same client. This will not cause
1290 # bl_ast yet as lock is already in local cache.
1291 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1292 do_facet client "lctl set_param fail_loc=0x80000317"
1293 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1294 let timeout=timeout*3
1296 while test $nr -lt 10; do
1297 log "Race attempt $nr"
1298 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1299 awk '/ldlm_bl_callback/ { print $2 }')
1300 test "x$blk1" = "x" && blk1=0
1301 createmany -o $MOUNT2/$tdir/a 4000 &
1305 # Let's make conflict and bl_ast
1306 ls -la $MOUNT1/$tdir > /dev/null &
1309 log "Wait for $pid1 $pid2 for $timeout sec..."
1311 kill -9 $pid1 $pid2 > /dev/null 2>&1
1313 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1314 awk '/ldlm_bl_callback/ { print $2 }')
1315 test "x$blk2" = "x" && blk2=0
1316 test $blk2 -gt $blk1 && break
1317 rm -fr $MOUNT1/$tdir
1318 cancel_lru_locks mdc
1321 do_facet client "lctl set_param fail_loc=0x0"
1322 df -h $MOUNT1 $MOUNT2
1324 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1325 awk '/generation/{print $2}')
1327 if ! test "$g" -eq "${generation[count]}"; then
1328 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1330 for imp in $list; do
1331 if [ $c = $count ]; then
1336 imp=$(echo "$imp" | awk -F"." '{print $2}')
1337 error "Eviction happened on import $imp"
1342 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1344 test_36() { #bug 16417
1349 test_mkdir $DIR1/$tdir
1350 $LFS setstripe -c -1 $DIR1/$tdir
1353 let SIZE_B=SIZE*1024*1024
1354 sync; sleep 2; sync # wait for delete thread
1355 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1356 wait_destroy_complete || error "wait_destroy_complete failed"
1358 while [ $i -le 10 ]; do
1359 lctl mark "start test - cycle ($i)"
1360 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1361 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1362 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1363 sync # sync data from client cache
1364 sync_all_data # sync data from server cache (delayed allocation)
1366 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1367 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1369 rm -f $DIR1/$tdir/$tfile
1370 kill -USR1 $read_pid
1372 sync; sleep 2; sync # Ensure new statfs
1373 wait_delete_completed
1374 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1375 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1377 # this free space! not used
1378 (( $after_dd <= $after)) ||
1379 error "space leaked after_dd:$after_dd > after:$after"
1383 run_test 36 "handle ESTALE/open-unlink correctly"
1385 test_37() { # bug 18695
1386 test_mkdir $DIR1/$tdir
1387 multiop_bg_pause $DIR1/$tdir D_c || return 1
1389 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1390 createmany -m $DIR2/$tdir/f 10000
1391 # set mtime/atime backward
1392 touch -t 198001010000 $DIR2/$tdir
1393 kill -USR1 $MULTIPID
1394 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1395 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1398 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1400 # this should be set to past
1401 TEST_39_MTIME=`date -d "1 year ago" +%s`
1405 local client1=${CLIENT1:-`hostname`}
1406 local client2=${CLIENT2:-`hostname`}
1408 do_node $client1 "touch $DIR1/$tfile"
1410 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1411 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1412 [ "$mtime1" = $TEST_39_MTIME ] || \
1413 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1415 local d1=`do_node $client1 date +%s`
1416 do_node $client1 'echo hello >> '$DIR1/$tfile
1417 local d2=`do_node $client1 date +%s`
1419 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1420 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1421 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1423 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1425 for (( i=0; i < 2; i++ )) ; do
1426 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1427 [ "$mtime2" = "$mtime3" ] || \
1428 error "mtime ($mtime2) changed (to $mtime3) on rename"
1430 cancel_lru_locks osc
1431 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1434 run_test 39a "test from 11063 =================================="
1437 local client1=${CLIENT1:-`hostname`}
1438 local client2=${CLIENT2:-`hostname`}
1442 local mtime1=`stat -c %Y $DIR1/$tfile`
1443 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1446 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1448 for (( i=0; i < 2; i++ )) ; do
1449 local mtime3=`stat -c %Y $DIR1/$tfile`
1450 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1452 [ "$mtime3" = "$mtime4" ] || \
1453 error "different mtime on clients: $mtime3, $mtime4"
1454 [ "$mtime3" = $TEST_39_MTIME ] || \
1455 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1457 cancel_lru_locks osc
1458 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1461 run_test 39b "11063 problem 1 =================================="
1464 local client1=${CLIENT1:-`hostname`}
1465 local client2=${CLIENT2:-`hostname`}
1467 echo hello > $DIR1/$tfile
1469 local mtime1=`stat -c %Y $DIR1/$tfile`
1470 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1471 [ "$mtime1" = "$mtime2" ] || \
1472 error "create: different mtime on clients: $mtime1, $mtime2"
1475 $TRUNCATE $DIR1/$tfile 1
1477 for (( i=0; i < 2; i++ )) ; do
1478 local mtime3=`stat -c %Y $DIR1/$tfile`
1479 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1481 [ "$mtime3" = "$mtime4" ] || \
1482 error "different mtime on clients: $mtime3, $mtime4"
1483 [ "$mtime3" -gt $mtime2 ] || \
1484 error "truncate did not update mtime: $mtime2, $mtime3"
1486 cancel_lru_locks osc
1487 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1490 run_test 39c "check truncate mtime update ======================"
1492 test_39d() { # LU-7310
1494 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1496 local mtime1=$(stat -c %Y $DIR2/$tfile)
1497 [ "$mtime1" = $TEST_39_MTIME ] ||
1498 error "mtime: $mtime1, should be $TEST_39_MTIME"
1501 # define OBD_FAIL_OSC_NO_GRANT 0x411
1502 $LCTL set_param fail_loc=0x411
1504 local d1=$(date +%s)
1505 echo hello >> $DIR1/$tfile
1506 local d2=$(date +%s)
1508 $LCTL set_param fail_loc=0
1510 cancel_lru_locks $OSC
1512 local mtime2=$(stat -c %Y $DIR2/$tfile)
1513 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1514 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1516 run_test 39d "sync write should update mtime"
1519 # how long 40-47 take with specific delay
1526 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1527 # avoid unexpected delays due to previous tests
1529 cancel_lru_locks mdc
1530 do_nodes $(comma_list $(mdts_nodes)) \
1531 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1532 do_nodes $(comma_list $(mdts_nodes)) \
1533 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1534 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1537 # check that pid exists hence second operation wasn't blocked by first one
1538 # if it is so then there is no conflict, return 0
1539 # else second operation is conflicting with first one, return 1
1540 check_pdo_conflict() {
1543 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1544 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1554 # test 40: check non-blocking operations
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1558 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1559 do_nodes $(comma_list $(mdts_nodes)) \
1560 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1562 mkdir $DIR1/$tfile &
1564 touch $DIR2/$tfile-2
1565 check_pdo_conflict $PID1 || error "create is blocked"
1566 mkdir $DIR2/$tfile-3
1567 check_pdo_conflict $PID1 || error "mkdir is blocked"
1568 link $DIR2/$tfile-2 $DIR2/$tfile-4
1569 check_pdo_conflict $PID1 || error "link is blocked"
1570 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1571 check_pdo_conflict $PID1 || error "rename is blocked"
1572 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1573 check_pdo_conflict $PID1 || error "getattr is blocked"
1574 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1575 rmdir $DIR2/$tfile-3
1576 check_pdo_conflict $PID1 || error "unlink is blocked"
1578 # all operations above shouldn't wait the first one
1579 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1580 do_nodes $(comma_list $(mdts_nodes)) \
1581 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1586 run_test 40a "pdirops: create vs others =============="
1589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1591 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1592 do_nodes $(comma_list $(mdts_nodes)) \
1593 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1594 touch $DIR1/$tfile &
1597 touch $DIR2/$tfile-2
1598 check_pdo_conflict $PID1 || error "create is blocked"
1599 mkdir $DIR2/$tfile-3
1600 check_pdo_conflict $PID1 || error "mkdir is blocked"
1601 link $DIR2/$tfile-2 $DIR2/$tfile-4
1602 check_pdo_conflict $PID1 || error "link is blocked"
1603 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1604 check_pdo_conflict $PID1 || error "rename is blocked"
1605 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1606 check_pdo_conflict $PID1 || error "getattr is blocked"
1607 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1608 rmdir $DIR2/$tfile-3
1609 check_pdo_conflict $PID1 || error "unlink is blocked"
1610 # all operations above shouldn't wait the first one
1612 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1613 do_nodes $(comma_list $(mdts_nodes)) \
1614 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1619 run_test 40b "pdirops: open|create and others =============="
1622 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1625 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1626 do_nodes $(comma_list $(mdts_nodes)) \
1627 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1628 link $DIR1/$tfile $DIR1/$tfile-0 &
1631 touch $DIR2/$tfile-2
1632 check_pdo_conflict $PID1 || error "create is blocked"
1633 mkdir $DIR2/$tfile-3
1634 check_pdo_conflict $PID1 || error "mkdir is blocked"
1635 link $DIR2/$tfile-2 $DIR2/$tfile-4
1636 check_pdo_conflict $PID1 || error "link is blocked"
1637 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1638 check_pdo_conflict $PID1 || error "rename is blocked"
1639 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1640 check_pdo_conflict $PID1 || error "getattr is blocked"
1641 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1642 rmdir $DIR2/$tfile-3
1643 check_pdo_conflict $PID1 || error "unlink is blocked"
1645 # all operations above shouldn't wait the first one
1646 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1647 do_nodes $(comma_list $(mdts_nodes)) \
1648 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1653 run_test 40c "pdirops: link and others =============="
1656 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1659 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1660 do_nodes $(comma_list $(mdts_nodes)) \
1661 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1665 touch $DIR2/$tfile-2
1666 check_pdo_conflict $PID1 || error "create is blocked"
1667 mkdir $DIR2/$tfile-3
1668 check_pdo_conflict $PID1 || error "mkdir is blocked"
1669 link $DIR2/$tfile-2 $DIR2/$tfile-4
1670 check_pdo_conflict $PID1 || error "link is blocked"
1671 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1672 check_pdo_conflict $PID1 || error "rename is blocked"
1673 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1674 check_pdo_conflict $PID1 || error "getattr is blocked"
1675 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1676 rmdir $DIR2/$tfile-3
1677 check_pdo_conflict $PID1 || error "unlink is blocked"
1679 # all operations above shouldn't wait the first one
1680 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1681 do_nodes $(comma_list $(mdts_nodes)) \
1682 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1686 run_test 40d "pdirops: unlink and others =============="
1689 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1692 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1693 do_nodes $(comma_list $(mdts_nodes)) \
1694 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1695 mv $DIR1/$tfile $DIR1/$tfile-0 &
1698 touch $DIR2/$tfile-2
1699 check_pdo_conflict $PID1 || error "create is blocked"
1700 mkdir $DIR2/$tfile-3
1701 check_pdo_conflict $PID1 || error "mkdir is blocked"
1702 link $DIR2/$tfile-2 $DIR2/$tfile-4
1703 check_pdo_conflict $PID1 || error "link is blocked"
1704 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1705 check_pdo_conflict $PID1 || error "getattr is blocked"
1706 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1707 rmdir $DIR2/$tfile-3
1708 check_pdo_conflict $PID1 || error "unlink is blocked"
1710 # all operations above shouldn't wait the first one
1711 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1712 do_nodes $(comma_list $(mdts_nodes)) \
1713 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1718 run_test 40e "pdirops: rename and others =============="
1720 # test 41: create blocking operations
1723 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1724 do_nodes $(comma_list $(mdts_nodes)) \
1725 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1726 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1728 mkdir $DIR2/$tfile &
1730 do_nodes $(comma_list $(mdts_nodes)) \
1731 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1732 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1733 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1737 run_test 41a "pdirops: create vs mkdir =============="
1741 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1742 do_nodes $(comma_list $(mdts_nodes)) \
1743 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1744 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1746 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1748 do_nodes $(comma_list $(mdts_nodes)) \
1749 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1750 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1751 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1755 run_test 41b "pdirops: create vs create =============="
1759 touch $DIR1/$tfile-2
1760 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1761 do_nodes $(comma_list $(mdts_nodes)) \
1762 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1763 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1765 link $DIR2/$tfile-2 $DIR2/$tfile &
1767 do_nodes $(comma_list $(mdts_nodes)) \
1768 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1769 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1770 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1774 run_test 41c "pdirops: create vs link =============="
1778 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1779 do_nodes $(comma_list $(mdts_nodes)) \
1780 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1781 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1785 do_nodes $(comma_list $(mdts_nodes)) \
1786 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1787 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1788 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1792 run_test 41d "pdirops: create vs unlink =============="
1796 touch $DIR1/$tfile-2
1797 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1798 do_nodes $(comma_list $(mdts_nodes)) \
1799 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1800 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1802 mv $DIR2/$tfile-2 $DIR2/$tfile &
1804 do_nodes $(comma_list $(mdts_nodes)) \
1805 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1806 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1807 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1811 run_test 41e "pdirops: create and rename (tgt) =============="
1815 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1816 do_nodes $(comma_list $(mdts_nodes)) \
1817 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1818 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1820 mv $DIR2/$tfile $DIR2/$tfile-2 &
1822 do_nodes $(comma_list $(mdts_nodes)) \
1823 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1824 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1825 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1829 run_test 41f "pdirops: create and rename (src) =============="
1833 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1834 do_nodes $(comma_list $(mdts_nodes)) \
1835 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1836 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1838 stat $DIR2/$tfile > /dev/null &
1840 do_nodes $(comma_list $(mdts_nodes)) \
1841 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1842 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1843 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1847 run_test 41g "pdirops: create vs getattr =============="
1851 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1852 do_nodes $(comma_list $(mdts_nodes)) \
1853 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1854 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1856 ls -lia $DIR2/ > /dev/null &
1858 do_nodes $(comma_list $(mdts_nodes)) \
1859 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1860 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1865 run_test 41h "pdirops: create vs readdir =============="
1867 # test 42: unlink and blocking operations
1870 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1871 do_nodes $(comma_list $(mdts_nodes)) \
1872 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1873 mkdir $DIR1/$tfile &
1875 mkdir $DIR2/$tfile &
1877 do_nodes $(comma_list $(mdts_nodes)) \
1878 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1879 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1880 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1884 run_test 42a "pdirops: mkdir vs mkdir =============="
1888 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1889 do_nodes $(comma_list $(mdts_nodes)) \
1890 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1891 mkdir $DIR1/$tfile &
1893 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1895 do_nodes $(comma_list $(mdts_nodes)) \
1896 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1897 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1898 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1902 run_test 42b "pdirops: mkdir vs create =============="
1906 touch $DIR1/$tfile-2
1907 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1908 do_nodes $(comma_list $(mdts_nodes)) \
1909 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1910 mkdir $DIR1/$tfile &
1912 link $DIR2/$tfile-2 $DIR2/$tfile &
1914 do_nodes $(comma_list $(mdts_nodes)) \
1915 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1916 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1917 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1921 run_test 42c "pdirops: mkdir vs link =============="
1925 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1926 do_nodes $(comma_list $(mdts_nodes)) \
1927 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1928 mkdir $DIR1/$tfile &
1930 rmdir $DIR2/$tfile &
1932 do_nodes $(comma_list $(mdts_nodes)) \
1933 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1934 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1935 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1939 run_test 42d "pdirops: mkdir vs unlink =============="
1943 touch $DIR1/$tfile-2
1944 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1945 do_nodes $(comma_list $(mdts_nodes)) \
1946 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1947 mkdir $DIR1/$tfile &
1949 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1951 do_nodes $(comma_list $(mdts_nodes)) \
1952 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1953 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1954 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1958 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1962 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1963 do_nodes $(comma_list $(mdts_nodes)) \
1964 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1965 mkdir $DIR1/$tfile &
1967 mv $DIR2/$tfile $DIR2/$tfile-2 &
1969 do_nodes $(comma_list $(mdts_nodes)) \
1970 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1971 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1972 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1976 run_test 42f "pdirops: mkdir and rename (src) =============="
1980 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1981 do_nodes $(comma_list $(mdts_nodes)) \
1982 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1983 mkdir $DIR1/$tfile &
1985 stat $DIR2/$tfile > /dev/null &
1987 do_nodes $(comma_list $(mdts_nodes)) \
1988 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1989 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1990 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1994 run_test 42g "pdirops: mkdir vs getattr =============="
1998 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1999 do_nodes $(comma_list $(mdts_nodes)) \
2000 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2001 mkdir $DIR1/$tfile &
2003 ls -lia $DIR2/ > /dev/null &
2005 do_nodes $(comma_list $(mdts_nodes)) \
2006 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2007 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2012 run_test 42h "pdirops: mkdir vs readdir =============="
2014 # test 43: rmdir,mkdir won't return -EEXIST
2016 for i in {1..1000}; do
2017 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2018 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2022 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2027 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2028 do_nodes $(comma_list $(mdts_nodes)) \
2029 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2032 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2034 do_nodes $(comma_list $(mdts_nodes)) \
2035 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2036 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2037 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2041 run_test 43b "pdirops: unlink vs create =============="
2046 touch $DIR1/$tfile-2
2047 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2048 do_nodes $(comma_list $(mdts_nodes)) \
2049 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2052 link $DIR2/$tfile-2 $DIR2/$tfile &
2054 do_nodes $(comma_list $(mdts_nodes)) \
2055 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2056 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2057 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2061 run_test 43c "pdirops: unlink vs link =============="
2066 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2067 do_nodes $(comma_list $(mdts_nodes)) \
2068 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2073 do_nodes $(comma_list $(mdts_nodes)) \
2074 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2075 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2076 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2080 run_test 43d "pdirops: unlink vs unlink =============="
2085 touch $DIR1/$tfile-2
2086 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2087 do_nodes $(comma_list $(mdts_nodes)) \
2088 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2091 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2093 do_nodes $(comma_list $(mdts_nodes)) \
2094 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2095 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2096 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2100 run_test 43e "pdirops: unlink and rename (tgt) =============="
2105 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2106 do_nodes $(comma_list $(mdts_nodes)) \
2107 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2110 mv $DIR2/$tfile $DIR2/$tfile-2 &
2112 do_nodes $(comma_list $(mdts_nodes)) \
2113 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2114 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2115 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2119 run_test 43f "pdirops: unlink and rename (src) =============="
2124 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2125 do_nodes $(comma_list $(mdts_nodes)) \
2126 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2129 stat $DIR2/$tfile > /dev/null &
2131 do_nodes $(comma_list $(mdts_nodes)) \
2132 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2133 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2134 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2138 run_test 43g "pdirops: unlink vs getattr =============="
2143 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2144 do_nodes $(comma_list $(mdts_nodes)) \
2145 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2148 ls -lia $DIR2/ > /dev/null &
2150 do_nodes $(comma_list $(mdts_nodes)) \
2151 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2152 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2157 run_test 43h "pdirops: unlink vs readdir =============="
2160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2163 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2164 do_nodes $(comma_list $(mdts_nodes)) \
2165 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2168 $LFS mkdir -i 1 $DIR2/$tfile &
2170 do_nodes $(comma_list $(mdts_nodes)) \
2171 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2172 check_pdo_conflict $PID1 &&
2173 { wait $PID1; error "remote mkdir isn't blocked"; }
2174 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2178 run_test 43i "pdirops: unlink vs remote mkdir"
2181 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2182 skip "Need MDS version newer than 2.13.52"
2184 for i in {1..100}; do
2185 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2186 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000167
2190 mkdir $DIR2/$tdir && ((OK++))
2191 wait $PID1 && ((OK++))
2192 (( OK == 1 )) || error "exactly one mkdir should succeed"
2194 rmdir $DIR1/$tdir || error "rmdir failed"
2198 run_test 43j "racy mkdir return EEXIST =============="
2200 # test 44: rename tgt and blocking operations
2203 touch $DIR1/$tfile-2
2204 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2205 do_nodes $(comma_list $(mdts_nodes)) \
2206 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2207 mv $DIR1/$tfile-2 $DIR1/$tfile &
2209 mkdir $DIR2/$tfile &
2211 do_nodes $(comma_list $(mdts_nodes)) \
2212 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2213 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2214 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2219 run_test 44a "pdirops: rename tgt vs mkdir =============="
2223 touch $DIR1/$tfile-2
2224 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2225 do_nodes $(comma_list $(mdts_nodes)) \
2226 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2227 mv $DIR1/$tfile-2 $DIR1/$tfile &
2229 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2231 do_nodes $(comma_list $(mdts_nodes)) \
2232 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2233 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2234 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2238 run_test 44b "pdirops: rename tgt vs create =============="
2242 touch $DIR1/$tfile-2
2243 touch $DIR1/$tfile-3
2244 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2245 do_nodes $(comma_list $(mdts_nodes)) \
2246 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2247 mv $DIR1/$tfile-2 $DIR1/$tfile &
2249 link $DIR2/$tfile-3 $DIR2/$tfile &
2251 do_nodes $(comma_list $(mdts_nodes)) \
2252 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2253 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2254 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2258 run_test 44c "pdirops: rename tgt vs link =============="
2262 touch $DIR1/$tfile-2
2263 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2264 do_nodes $(comma_list $(mdts_nodes)) \
2265 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2266 mv $DIR1/$tfile-2 $DIR1/$tfile &
2270 do_nodes $(comma_list $(mdts_nodes)) \
2271 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2272 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2273 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2277 run_test 44d "pdirops: rename tgt vs unlink =============="
2282 touch $DIR1/$tfile-2
2283 touch $DIR1/$tfile-3
2284 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2285 do_nodes $(comma_list $(mdts_nodes)) \
2286 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2287 mv $DIR1/$tfile-2 $DIR1/$tfile &
2289 mv $DIR2/$tfile-3 $DIR2/$tfile &
2291 do_nodes $(comma_list $(mdts_nodes)) \
2292 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2293 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2294 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2298 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2302 touch $DIR1/$tfile-2
2303 touch $DIR1/$tfile-3
2304 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2305 do_nodes $(comma_list $(mdts_nodes)) \
2306 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2307 mv $DIR1/$tfile-2 $DIR1/$tfile &
2309 mv $DIR2/$tfile $DIR2/$tfile-3 &
2311 do_nodes $(comma_list $(mdts_nodes)) \
2312 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2313 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2314 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2318 run_test 44f "pdirops: rename tgt and rename (src) =============="
2322 touch $DIR1/$tfile-2
2323 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2324 do_nodes $(comma_list $(mdts_nodes)) \
2325 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2326 mv $DIR1/$tfile-2 $DIR1/$tfile &
2328 stat $DIR2/$tfile > /dev/null &
2330 do_nodes $(comma_list $(mdts_nodes)) \
2331 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2332 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2333 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2337 run_test 44g "pdirops: rename tgt vs getattr =============="
2341 touch $DIR1/$tfile-2
2342 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2343 do_nodes $(comma_list $(mdts_nodes)) \
2344 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2345 mv $DIR1/$tfile-2 $DIR1/$tfile &
2347 ls -lia $DIR2/ > /dev/null &
2349 do_nodes $(comma_list $(mdts_nodes)) \
2350 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2351 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2356 run_test 44h "pdirops: rename tgt vs readdir =============="
2358 # test 44: rename tgt and blocking operations
2360 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2362 touch $DIR1/$tfile-2
2363 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2364 do_nodes $(comma_list $(mdts_nodes)) \
2365 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2366 mv $DIR1/$tfile-2 $DIR1/$tfile &
2368 $LFS mkdir -i 1 $DIR2/$tfile &
2370 do_nodes $(comma_list $(mdts_nodes)) \
2371 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2372 check_pdo_conflict $PID1 && { wait $PID1;
2373 error "remote mkdir isn't blocked"; }
2374 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2378 run_test 44i "pdirops: rename tgt vs remote mkdir"
2380 # test 45: rename,mkdir doesn't fail with -EEXIST
2382 for i in {1..1000}; do
2383 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2384 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2385 error "mrename to $tdir.$i failed"
2390 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2395 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2396 do_nodes $(comma_list $(mdts_nodes)) \
2397 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2398 mv $DIR1/$tfile $DIR1/$tfile-2 &
2400 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2402 do_nodes $(comma_list $(mdts_nodes)) \
2403 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2404 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2405 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2409 run_test 45b "pdirops: rename src vs create =============="
2414 touch $DIR1/$tfile-3
2415 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2416 do_nodes $(comma_list $(mdts_nodes)) \
2417 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2418 mv $DIR1/$tfile $DIR1/$tfile-2 &
2420 link $DIR2/$tfile-3 $DIR2/$tfile &
2422 do_nodes $(comma_list $(mdts_nodes)) \
2423 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2424 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2425 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2429 run_test 45c "pdirops: rename src vs link =============="
2434 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2435 do_nodes $(comma_list $(mdts_nodes)) \
2436 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2437 mv $DIR1/$tfile $DIR1/$tfile-2 &
2441 do_nodes $(comma_list $(mdts_nodes)) \
2442 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2443 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2444 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2448 run_test 45d "pdirops: rename src vs unlink =============="
2453 touch $DIR1/$tfile-3
2454 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2455 do_nodes $(comma_list $(mdts_nodes)) \
2456 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2457 mv $DIR1/$tfile $DIR1/$tfile-2 &
2459 mv $DIR2/$tfile-3 $DIR2/$tfile &
2461 do_nodes $(comma_list $(mdts_nodes)) \
2462 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2463 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2464 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2468 run_test 45e "pdirops: rename src and rename (tgt) =============="
2473 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2474 do_nodes $(comma_list $(mdts_nodes)) \
2475 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2476 mv $DIR1/$tfile $DIR1/$tfile-2 &
2478 mv $DIR2/$tfile $DIR2/$tfile-3 &
2480 do_nodes $(comma_list $(mdts_nodes)) \
2481 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2482 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2483 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2487 run_test 45f "pdirops: rename src and rename (src) =============="
2492 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2493 do_nodes $(comma_list $(mdts_nodes)) \
2494 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2495 mv $DIR1/$tfile $DIR1/$tfile-2 &
2497 stat $DIR2/$tfile > /dev/null &
2499 do_nodes $(comma_list $(mdts_nodes)) \
2500 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2501 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2502 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2506 run_test 45g "pdirops: rename src vs getattr =============="
2511 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2512 do_nodes $(comma_list $(mdts_nodes)) \
2513 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2514 mv $DIR1/$tfile $DIR1/$tfile-2 &
2516 ls -lia $DIR2/ > /dev/null &
2517 do_nodes $(comma_list $(mdts_nodes)) \
2518 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2519 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2524 run_test 45h "pdirops: unlink vs readdir =============="
2527 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2530 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2531 do_nodes $(comma_list $(mdts_nodes)) \
2532 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2533 mv $DIR1/$tfile $DIR1/$tfile-2 &
2535 $LFS mkdir -i 1 $DIR2/$tfile &
2537 do_nodes $(comma_list $(mdts_nodes)) \
2538 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2539 check_pdo_conflict $PID1 && { wait $PID1;
2540 error "create remote dir isn't blocked"; }
2541 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2545 run_test 45i "pdirops: rename src vs remote mkdir"
2547 # test 46: link and blocking operations
2550 touch $DIR1/$tfile-2
2551 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2552 do_nodes $(comma_list $(mdts_nodes)) \
2553 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2554 link $DIR1/$tfile-2 $DIR1/$tfile &
2556 mkdir $DIR2/$tfile &
2558 do_nodes $(comma_list $(mdts_nodes)) \
2559 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2560 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2561 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2565 run_test 46a "pdirops: link vs mkdir =============="
2569 touch $DIR1/$tfile-2
2570 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2571 do_nodes $(comma_list $(mdts_nodes)) \
2572 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2573 link $DIR1/$tfile-2 $DIR1/$tfile &
2575 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2577 do_nodes $(comma_list $(mdts_nodes)) \
2578 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2579 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2580 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2584 run_test 46b "pdirops: link vs create =============="
2588 touch $DIR1/$tfile-2
2589 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2590 do_nodes $(comma_list $(mdts_nodes)) \
2591 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2592 link $DIR1/$tfile-2 $DIR1/$tfile &
2594 link $DIR2/$tfile $DIR2/$tfile &
2596 do_nodes $(comma_list $(mdts_nodes)) \
2597 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2598 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2599 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2603 run_test 46c "pdirops: link vs link =============="
2607 touch $DIR1/$tfile-2
2608 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2609 do_nodes $(comma_list $(mdts_nodes)) \
2610 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2611 link $DIR1/$tfile-2 $DIR1/$tfile &
2615 do_nodes $(comma_list $(mdts_nodes)) \
2616 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2617 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2618 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2622 run_test 46d "pdirops: link vs unlink =============="
2626 touch $DIR1/$tfile-2
2627 touch $DIR1/$tfile-3
2628 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2629 do_nodes $(comma_list $(mdts_nodes)) \
2630 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2631 link $DIR1/$tfile-2 $DIR1/$tfile &
2633 mv $DIR2/$tfile-3 $DIR2/$tfile &
2635 do_nodes $(comma_list $(mdts_nodes)) \
2636 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2637 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2638 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2642 run_test 46e "pdirops: link and rename (tgt) =============="
2646 touch $DIR1/$tfile-2
2647 touch $DIR1/$tfile-3
2648 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2649 do_nodes $(comma_list $(mdts_nodes)) \
2650 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2651 link $DIR1/$tfile-2 $DIR1/$tfile &
2653 mv $DIR2/$tfile $DIR2/$tfile-3 &
2655 do_nodes $(comma_list $(mdts_nodes)) \
2656 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2657 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2658 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2662 run_test 46f "pdirops: link and rename (src) =============="
2666 touch $DIR1/$tfile-2
2667 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2668 do_nodes $(comma_list $(mdts_nodes)) \
2669 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2670 link $DIR1/$tfile-2 $DIR1/$tfile &
2672 stat $DIR2/$tfile > /dev/null &
2674 do_nodes $(comma_list $(mdts_nodes)) \
2675 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2676 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2677 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2681 run_test 46g "pdirops: link vs getattr =============="
2685 touch $DIR1/$tfile-2
2686 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2687 do_nodes $(comma_list $(mdts_nodes)) \
2688 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2689 link $DIR1/$tfile-2 $DIR1/$tfile &
2691 ls -lia $DIR2/ > /dev/null &
2693 do_nodes $(comma_list $(mdts_nodes)) \
2694 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2695 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2700 run_test 46h "pdirops: link vs readdir =============="
2703 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2705 touch $DIR1/$tfile-2
2706 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2707 do_nodes $(comma_list $(mdts_nodes)) \
2708 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2709 link $DIR1/$tfile-2 $DIR1/$tfile &
2711 $LFS mkdir -i 1 $DIR2/$tfile &
2713 do_nodes $(comma_list $(mdts_nodes)) \
2714 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2715 check_pdo_conflict $PID1 && { wait $PID1;
2716 error "remote mkdir isn't blocked"; }
2717 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2721 run_test 46i "pdirops: link vs remote mkdir"
2723 # test 47: remote mkdir and blocking operations
2725 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2726 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2728 do_nodes $(comma_list $(mdts_nodes)) \
2729 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2730 $LFS mkdir -i 1 $DIR1/$tfile &
2732 mkdir $DIR2/$tfile &
2734 do_nodes $(comma_list $(mdts_nodes)) \
2735 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2736 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2737 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2741 run_test 47a "pdirops: remote mkdir vs mkdir"
2744 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2745 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2747 do_nodes $(comma_list $(mdts_nodes)) \
2748 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2749 $LFS mkdir -i 1 $DIR1/$tfile &
2751 sleep 1 # please do not remove this sleep, see LU-10754
2752 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2754 do_nodes $(comma_list $(mdts_nodes)) \
2755 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2756 check_pdo_conflict $PID1 && { wait $PID1;
2757 error "create isn't blocked"; }
2758 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2762 run_test 47b "pdirops: remote mkdir vs create"
2765 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2767 touch $DIR1/$tfile-2
2768 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2769 do_nodes $(comma_list $(mdts_nodes)) \
2770 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2771 $LFS mkdir -i 1 $DIR1/$tfile &
2773 link $DIR2/$tfile-2 $DIR2/$tfile &
2775 do_nodes $(comma_list $(mdts_nodes)) \
2776 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2777 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2778 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2782 run_test 47c "pdirops: remote mkdir vs link"
2785 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2787 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2788 do_nodes $(comma_list $(mdts_nodes)) \
2789 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2790 $LFS mkdir -i 1 $DIR1/$tfile &
2792 rmdir $DIR2/$tfile &
2794 do_nodes $(comma_list $(mdts_nodes)) \
2795 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2796 check_pdo_conflict $PID1 && { wait $PID1;
2797 error "unlink isn't blocked"; }
2798 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2802 run_test 47d "pdirops: remote mkdir vs unlink"
2805 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2807 touch $DIR1/$tfile-2
2808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2809 do_nodes $(comma_list $(mdts_nodes)) \
2810 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2811 $LFS mkdir -i 1 $DIR1/$tfile &
2813 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2815 do_nodes $(comma_list $(mdts_nodes)) \
2816 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2817 check_pdo_conflict $PID1 && { wait $PID1;
2818 error "rename isn't blocked"; }
2819 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2823 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2826 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2828 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2829 do_nodes $(comma_list $(mdts_nodes)) \
2830 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2831 $LFS mkdir -i 1 $DIR1/$tfile &
2833 mv $DIR2/$tfile $DIR2/$tfile-2 &
2835 do_nodes $(comma_list $(mdts_nodes)) \
2836 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2837 check_pdo_conflict $PID1 && { wait $PID1;
2838 error "rename isn't blocked"; }
2839 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2843 run_test 47f "pdirops: remote mkdir and rename (src)"
2846 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2850 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2851 do_nodes $(comma_list $(mdts_nodes)) \
2852 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2853 $LFS mkdir -i 1 $DIR1/$tfile &
2855 stat $DIR2/$tfile > /dev/null &
2857 do_nodes $(comma_list $(mdts_nodes)) \
2858 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2859 check_pdo_conflict $PID1 && { wait $PID1;
2860 error "getattr isn't blocked"; }
2861 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2865 run_test 47g "pdirops: remote mkdir vs getattr"
2869 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2870 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2871 do_facet client "lctl set_param fail_loc=0x410"
2872 $TRUNCATE $DIR2/$tfile $trunc_size
2873 do_facet client "lctl set_param fail_loc=0x0"
2875 size=`stat -c %s $DIR2/$tfile`
2876 [ $size -eq $trunc_size ] || error "wrong size"
2878 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2882 local origfile=/etc/hosts
2884 filesize=$(stat -c %s $origfile)
2886 # create an empty file
2887 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2888 # cache layout lock on both mount point
2889 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2890 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2892 # open and sleep 2 seconds then read
2893 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2897 # create the layout of testing file
2898 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2899 error "dd $DIR1/$tfile failed"
2901 # MULTIOP proc should be able to read enough bytes and exit
2902 for ((i = 0; i < 6; i++)); do
2904 kill -0 $pid || break
2906 kill -0 $pid 2> /dev/null && error "multiop is still there"
2907 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2911 run_test 51a "layout lock: refresh layout should work"
2914 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
2915 skip "Need MDS version at least 2.3.59"
2917 local tmpfile=`mktemp`
2919 # create an empty file
2920 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2922 # delay glimpse so that layout has changed when glimpse finish
2923 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2924 $LCTL set_param fail_loc=0x1404
2925 stat -c %s $DIR2/$tfile |tee $tmpfile &
2929 # create layout of testing file
2930 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2931 error "dd $DIR1/$tfile failed"
2934 local fsize=$(cat $tmpfile)
2936 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2938 rm -f $DIR1/$tfile $tmpfile
2940 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2943 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2945 # set default layout to have 1 stripe
2947 $LFS setstripe -c 1 $DIR1/$tdir
2949 # create a file with empty layout
2950 $MCREATE $DIR1/$tdir/$tfile ||
2951 error "$MCREATE $DIR1/$tdir/$tfile failed"
2953 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2954 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2956 # change the layout of testing file
2957 echo "Setting layout to have $OSTCOUNT stripes ..."
2958 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2962 # write something to the file, it should be blocked on fetching layout
2963 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2964 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2967 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2968 # count to succeed with only 3/4 of the number of stripes (rounded up),
2969 # so creating striped files does not fail if an OST is offline or full
2970 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2971 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2975 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2978 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2979 cancel_lru_locks mdc
2981 # open should grant LAYOUT lock, mmap and read will install pages
2982 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2986 # rss before revoking
2987 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2988 echo "Before revoking layout lock: $br KB mapped"
2990 # cancel layout lock manually
2991 cancel_lru_locks mdc
2993 # rss after revoking
2994 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2997 wait $PID || error "wait PID $PID failed"
2999 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3001 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3005 echo "==> rename vs getattr vs setxattr should not deadlock"
3006 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3008 do_facet mds1 $LCTL set_param fail_loc=$1
3010 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3018 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3019 wait $PID1 || error "(3) mv failed"
3020 wait $PID2 || error "(4) stat failed"
3027 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3028 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3030 do_facet mds1 $LCTL set_param fail_loc=$1
3032 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3040 $MULTIOP $DIR2/d1/d2 Oc &
3044 stat $DIR/d1 || error "(2) stat failed"
3046 wait $PID1 || error "(3) mv failed"
3047 wait $PID2 || error "(4) stat failed"
3048 wait $PID3 && error "(5) multiop failed"
3054 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3055 save_lustre_params client "llite.*.xattr_cache" > $p
3056 lctl set_param llite.*.xattr_cache 1 ||
3057 { skip "xattr cache is not supported"; return 0; }
3059 #define OBD_FAIL_MDS_RENAME 0x153
3060 #define OBD_FAIL_MDS_RENAME2 0x154
3061 test_54_part1 0x80000153 || error 10
3062 test_54_part1 0x80000154 || error 11
3063 test_54_part2 0x80000153 || error 12
3064 test_54_part2 0x80000154 || error 13
3066 restore_lustre_params < $p
3069 run_test 54 "rename locking"
3072 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3074 #define OBD_FAIL_MDS_RENAME4 0x156
3075 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3077 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3082 wait $PID1 && error "(2) mv succeeded"
3086 run_test 55a "rename vs unlink target dir"
3090 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3092 #define OBD_FAIL_MDS_RENAME4 0x156
3093 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3095 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3100 wait $PID1 && error "(2) mv succeeded"
3104 run_test 55b "rename vs unlink source dir"
3108 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3110 #define OBD_FAIL_MDS_RENAME4 0x156
3111 do_facet mds1 $LCTL set_param fail_loc=0x156
3113 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3117 # while rename is sleeping, open and remove d3
3118 $MULTIOP $DIR2/d3 D_c &
3124 # while rename is sleeping 2nd time, close d3
3126 wait $PID2 || error "(3) multiop failed"
3128 wait $PID1 && error "(2) mv succeeded"
3132 run_test 55c "rename vs unlink orphan target dir"
3138 #define OBD_FAIL_MDS_RENAME3 0x155
3139 do_facet mds1 $LCTL set_param fail_loc=0x155
3140 mv $DIR/f1 $DIR/$tdir &
3144 # while rename is sleeping, create $tdir, but as a directory
3145 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
3147 # link in reverse locking order
3148 ln $DIR2/f1 $DIR2/$tdir/
3150 wait $PID1 && error "(2) mv succeeded"
3153 run_test 55d "rename file vs link"
3156 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3157 skip "MDS version must be >= 2.3.0"
3160 test_mkdir $DIR1/$tdir
3161 file1=$DIR1/$tdir/file
3162 file2=$DIR2/$tdir/file
3164 echo orig > $file2 || error "Could not create $file2"
3165 version=$($LFS data_version $file1)
3168 echo append >> $file2 || error "Could not append to $file2"
3169 version2=$($LFS data_version $file1)
3170 [ "$version" != "$version2" ] ||
3171 error "append did not change data version: $version"
3174 echo overwrite > $file2 || error "Could not overwrite $file2"
3175 version3=$($LFS data_version $file1)
3176 [ "$version2" != "$version3" ] ||
3177 error "overwrite did not change data version: $version2"
3179 # Truncate before EOF
3180 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3181 version4=$($LFS data_version $file1)
3182 [ "$version3" != "$version4" ] ||
3183 error "truncate did not change data version: $version3"
3185 # Truncate after EOF
3186 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3187 version5=$($LFS data_version $file1)
3188 [ "$version4" != "$version5" ] ||
3189 error "truncate did not change data version: $version4"
3191 # Chmod do not change version
3192 chmod 400 $file2 || error "Could not chmod 400 $file2"
3193 version6=$($LFS data_version $file1)
3194 [ "$version5" == "$version6" ] ||
3195 error "chmod should not change data version: $version5 != $version6"
3197 # Chown do not change version
3198 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3199 version7=$($LFS data_version $file1)
3200 [ "$version5" == "$version7" ] ||
3201 error "chown should not change data version: $version5 != $version7"
3203 run_test 60 "Verify data_version behaviour"
3206 local test_dir=$tdir/test_dir
3208 mkdir -p $DIR1/$tdir
3209 if [ $MDSCOUNT -ge 2 ]; then
3211 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3212 error "Create remote directory failed"
3214 mkdir -p $DIR1/$test_dir
3216 cd $DIR2/$test_dir || error "cd directory failed"
3217 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3219 cd $DIR2/$tdir || error "exit directory"
3221 run_test 70a "cd directory && rm directory"
3223 test_70b() { # LU-2781
3225 mkdir -p $DIR1/$tdir
3227 touch $DIR1/$tdir/file
3228 for ((i = 0; i < 32; i++)); do
3229 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3231 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3233 touch $DIR1/$tdir/file
3234 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3235 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3236 rm -rf $DIR1/$tdir/test_dir ||
3237 error "cannot remove directory after rm_entry"
3238 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3240 run_test 70b "remove files after calling rm_entry"
3243 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3244 skip "Need MDS version at least 2.1.6"
3246 # Patch not applied to 2.2 and 2.3 branches
3247 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3248 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3249 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3251 checkfiemap --test ||
3252 skip "checkfiemap not runnable: $?"
3253 # write data this way: hole - data - hole - data
3254 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3255 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3257 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3258 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3259 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3261 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3263 checkfiemap $DIR2/$tfile 81920 ||
3264 error "data is not flushed from client"
3265 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3268 # common case of "create file, copy file" on a single node
3269 # should not flush data from ost
3270 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3271 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3273 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3275 checkfiemap $DIR1/$tfile 81920 ||
3277 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3279 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3281 run_test 71a "correct file map just after write operation is finished"
3284 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3285 skip "Need MDS version at least 2.1.6"
3287 # Patch not applied to 2.2 and 2.3 branches
3288 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3289 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3290 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3291 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3293 checkfiemap --test ||
3294 skip "error $?: checkfiemap failed"
3296 mkdir -p $DIR1/$tdir
3298 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3299 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3300 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3302 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3303 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3305 run_test 71b "check fiemap support for stripecount > 1"
3308 local p="$TMP/sanityN-$TESTNAME.parameters"
3311 save_lustre_params client "llite.*.xattr_cache" > $p
3312 lctl set_param llite.*.xattr_cache 1 ||
3313 { skip "xattr cache is not supported"; return 0; }
3316 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3317 error "setfattr1 failed"
3318 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3319 error "getfattr1 failed"
3320 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3321 error "setfattr2 failed"
3322 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3323 error "getfattr2 failed"
3325 # check that trusted.link is consistent
3326 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3327 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3328 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3329 echo "$tlink1 $tlink2"
3330 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3334 restore_lustre_params < $p
3337 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3340 local p="$TMP/sanityN-$TESTNAME.parameters"
3341 save_lustre_params client "llite.*.xattr_cache" > $p
3342 lctl set_param llite.*.xattr_cache 1 ||
3343 { skip "xattr cache is not supported"; return 0; }
3346 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3347 error "setfattr1 failed"
3348 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3349 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3350 clear_stats llite.*.stats
3351 # PR lock should be cached by now on both clients
3352 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3353 # 2 hits for getfattr(0)+getfattr(size)
3354 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3355 error "not cached in $DIR1"
3356 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3357 # 4 hits for more getfattr(0)+getfattr(size)
3358 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3359 error "not cached in $DIR2"
3362 restore_lustre_params < $p
3365 run_test 73 "getxattr should not cause xattr lock cancellation"
3368 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3369 skip "Need MDS version at least 2.4.93"
3371 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3372 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3373 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3375 run_test 74 "flock deadlock: different mounts =============="
3379 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3380 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3381 cancel_lru_locks osc
3383 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3386 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3387 $LCTL set_param fail_loc=0x31d
3388 stat -c %s $DIR1/$tfile &
3393 # For bad lock error handler we should ASSERT and got kernel panic here
3395 $LCTL set_param fail_loc=0
3397 run_test 75 "osc: upcall after unuse lock==================="
3400 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3401 skip "Need MDS version at least 2.5.53"
3403 remote_mds_nodsh && skip "remote MDS with nodsh"
3404 local fcount=$((MDSCOUNT * 256))
3409 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3415 test_mkdir $DIR/$tdir
3417 # drop all open locks and close any cached "open" files on the client
3418 cancel_lru_locks mdc
3420 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3421 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3422 local already=${#fid_list[@]}
3423 for (( i = 0; i < $already; i++ )) ; do
3424 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3427 echo -n "opening files: "
3428 ulimit -n $((fcount + 50))
3429 for ((i = 0; i < $fcount; i++)); do
3430 touch $DIR/$tdir/f_$i
3431 local fd=$(free_fd ${fd_list[i]})
3432 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3437 (( $i % 32 == 0 )) && echo -n "."
3441 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3443 # Possible errors in openfiles FID list.
3444 # 1. Missing FIDs. Check 1
3445 # 2. Extra FIDs. Check 1
3446 # 3. Duplicated FID. Check 2
3447 # 4. Invalid FIDs. Check 2
3448 # 5. Valid FID, points to some other file. Check 3
3451 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3452 error "${#fid_list[@]} != $fcount (+$already old) open files"
3454 echo -n "closing files: "
3455 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3456 local close_cmd="exec ${fd_list[fd]}<&-"
3458 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3460 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3461 echo "skip old open file $filename"
3463 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3467 rm --interactive=no $filename
3469 error "Nonexisting fid ${fid_list[fid]} listed."
3470 (( $fd % 32 == 0 )) && echo -n "."
3475 ls_op=$(ls $DIR2/$tdir | wc -l)
3477 error "Some openfiles are missing in lproc output"
3481 run_test 76 "Verify MDT open_files listing"
3485 local dir=$DIR/$tdir
3488 mkdir $dir || error "mkdir $dir failed"
3489 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3492 do_nodes $CLIENTS $myRUNAS \
3493 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3494 error "dd at 0 on client failed (1)"
3496 do_nodes $CLIENTS $myRUNAS \
3498 for ((i = 0; i < $n; i++)); do
3499 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3500 seek=\\\$i count=1 conv=notrunc &
3501 pids_w[\\\$i]=\\\$!;
3504 for ((i = 0; i < $n; i++)); do
3505 wait \\\${pids_w[\\\$i]};
3507 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3511 do_nodes $CLIENTS sync;
3512 cancel_lru_locks osc
3514 do_nodes $CLIENTS $myRUNAS \
3516 for ((i = 0; i < $n; i++)); do
3517 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3518 seek=\\\$i count=1 &
3519 pids_r[\\\$i]=\\\$!;
3522 for ((i = 0; i < $n; i++)); do
3523 wait \\\${pids_r[\\\$i]};
3525 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3529 cancel_lru_locks osc
3531 wait $pid_w || error "dd (write) failed (2)"
3532 wait $pid_r || error "dd (read) failed (3)"
3533 rm -rvf $dir || error "rm -rf $dir failed"
3536 test_77a() { #LU-3266
3539 oss=$(comma_list $(osts_nodes))
3540 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3542 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3543 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3548 run_test 77a "check FIFO NRS policy"
3550 test_77b() { #LU-3266
3553 oss=$(comma_list $(osts_nodes))
3555 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3556 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3557 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3558 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3560 echo "policy: crr-n, crrn_quantum 1"
3563 do_nodes $oss lctl set_param \
3564 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3565 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3567 echo "policy: crr-n, crrn_quantum 64"
3571 do_nodes $oss lctl set_param \
3572 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3573 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3576 run_test 77b "check CRR-N NRS policy"
3581 oss=$(comma_list $(osts_nodes))
3583 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3584 ost.OSS.*.nrs_"$policy"_quantum=1 \
3585 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3586 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3588 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3589 "physical, ${policy}_supported reads"
3592 do_nodes $oss lctl set_param \
3593 ost.OSS.*.nrs_${policy}_supported="writes" \
3594 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3596 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3597 "physical, ${policy}_supported writes"
3600 do_nodes $oss lctl set_param \
3601 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3602 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3603 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3604 "logical, ${policy}_supported reads_and_writes"
3608 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3613 test_77c() { #LU-3266
3615 orr_trr "orr" || rc=$?
3616 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3617 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3620 run_test 77c "check ORR NRS policy"
3622 test_77d() { #LU-3266
3624 orr_trr "trr" || rc=$?
3625 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3626 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3629 run_test 77d "check TRR nrs policy"
3636 do_facet $facet lctl set_param \
3637 ost.OSS.ost_io.nrs_tbf_rule="$*"
3639 error "failed to run operate '$*' on TBF rules"
3642 cleanup_tbf_verify()
3646 echo "cleanup_tbf $DIR/$tdir"
3649 wait_delete_completed
3654 local dir=$DIR/$tdir
3655 local client1=${CLIENT1:-$(hostname)}
3658 local np=$(check_cpt_number ost1)
3659 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3660 echo "cpu_npartitions on ost1 is $np"
3662 mkdir $dir || error "mkdir $dir failed"
3663 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3666 trap cleanup_tbf_verify EXIT
3667 echo "Limited write rate: $1, read rate: $2"
3668 echo "Verify the write rate is under TBF control"
3669 local start=$SECONDS
3670 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3671 bs=1M count=100 oflag=direct 2>&1
3672 local runtime=$((SECONDS - start + 1))
3673 local rate=$(bc <<< "scale=6; 100 / $runtime")
3674 echo "Write runtime is $runtime s, speed is $rate IOPS"
3676 # verify the write rate does not exceed TBF rate limit
3677 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3678 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3680 cancel_lru_locks osc
3682 echo "Verify the read rate is under TBF control"
3684 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3685 bs=1M count=100 iflag=direct 2>&1
3686 runtime=$((SECONDS - start + 1))
3687 rate=$(bc <<< "scale=6; 100 / $runtime")
3688 echo "Read runtime is $runtime s, speed is $rate IOPS"
3690 # verify the read rate does not exceed TBF rate limit
3691 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3692 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3694 cancel_lru_locks osc
3695 cleanup_tbf_verify || error "rm -rf $dir failed"
3701 oss=$(comma_list $(osts_nodes))
3703 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3705 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3706 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3710 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3715 # Only operate rules on ost1 since OSTs might run on the same OSS
3717 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3718 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3719 local client_nids=$(nids_list $address "\\")
3720 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3721 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3725 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3726 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3727 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3731 tbf_rule_operate ost1 "stop\ localhost"
3732 tbf_rule_operate ost1 "stop\ clients"
3733 tbf_rule_operate ost1 "stop\ others"
3736 # Cleanup the TBF policy
3737 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3738 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3742 run_test 77e "check TBF NID nrs policy"
3747 oss=$(comma_list $(osts_nodes))
3749 do_nodes $oss $LCTL set_param \
3750 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3751 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3752 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3754 # Configure jobid_var
3755 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3757 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3758 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3759 if [ $saved_jobid_var != procname_uid ]; then
3760 set_persistent_param_and_check client \
3761 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3766 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3771 # Only operate rules on ost1 since OSTs might run on the same OSS
3773 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3774 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3775 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3776 nrs_write_read "$RUNAS"
3779 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3780 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3781 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3782 nrs_write_read "$RUNAS"
3785 tbf_rule_operate ost1 "stop\ runas"
3786 tbf_rule_operate ost1 "stop\ iozone_runas"
3787 tbf_rule_operate ost1 "stop\ dd_runas"
3788 nrs_write_read "$RUNAS"
3790 # Cleanup the TBF policy
3791 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3792 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3793 nrs_write_read "$RUNAS"
3795 local current_jobid_var=$($LCTL get_param -n jobid_var)
3796 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3797 if [ $saved_jobid_var != $current_jobid_var ]; then
3798 set_persistent_param_and_check client \
3799 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3803 run_test 77f "check TBF JobID nrs policy"
3808 oss=$(comma_list $(osts_nodes))
3810 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3812 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3813 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3815 do_nodes $oss lctl set_param \
3816 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3817 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3821 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3826 # Add a rule that only valid for Jobid TBF. If direct change between
3827 # TBF types is not supported, this operation will fail.
3828 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3830 # Cleanup the TBF policy
3831 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3832 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3835 run_test 77g "Change TBF type directly"
3838 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3839 skip "Need OST version at least 2.8.55"
3841 local old_policy=$(do_facet ost1 \
3842 lctl get_param ost.OSS.ost_io.nrs_policies)
3845 do_facet ost1 lctl set_param \
3846 ost.OSS.ost_io.nrs_policies="abc"
3847 [ $? -eq 0 ] && error "should return error"
3849 do_facet ost1 lctl set_param \
3850 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3851 [ $? -eq 0 ] && error "should return error"
3853 do_facet ost1 lctl set_param \
3854 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3855 [ $? -eq 0 ] && error "should return error"
3857 do_facet ost1 lctl set_param \
3858 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3859 [ $? -eq 0 ] && error "should return error"
3861 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3862 [ $? -eq 0 ] || error "shouldn't LBUG"
3864 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3868 run_test 77h "Wrong policy name should report error, not LBUG"
3874 local error_message=$3
3876 for rule in $expected; do
3877 rule_number=$((rule_number + 1))
3879 local stop_line=$(($rule_number + 3))
3880 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3882 local output=$(do_facet $facet lctl get_param \
3883 ost.OSS.ost_io.nrs_tbf_rule |
3887 if [ "$output" != "$expected" ]; then
3888 error "$error_message, expected '$expected', got '$output'"
3893 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
3894 skip "Need OST version at least 2.8.55"
3896 for i in $(seq 1 $OSTCOUNT)
3898 do_facet ost"$i" lctl set_param \
3899 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3901 error "failed to set TBF policy"
3904 tbf_rule_check ost1 "default" "error before inserting any rule"
3906 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3907 tbf_rule_check ost1 "before default" \
3908 "error when inserting rule 'before'"
3910 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3911 tbf_rule_check ost1 "before after default" \
3912 "error when inserting rule 'after'"
3914 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3915 tbf_rule_check ost1 "before target after default" \
3916 "error when inserting rule 'target'"
3918 echo "Move before itself"
3919 tbf_rule_operate ost1 "change\ target\ rank=target"
3920 tbf_rule_check ost1 "before target after default" \
3921 "error when moving before itself"
3923 echo "Move to higher rank"
3924 tbf_rule_operate ost1 "change\ target\ rank=before"
3925 tbf_rule_check ost1 "target before after default" \
3926 "error when moving to higher rank"
3928 echo "Move to lower rank"
3929 tbf_rule_operate ost1 "change\ target\ rank=after"
3930 tbf_rule_check ost1 "before target after default" \
3931 "error when moving to lower rank"
3933 echo "Move before default"
3934 tbf_rule_operate ost1 "change\ target\ rank=default"
3935 tbf_rule_check ost1 "before after target default" \
3936 error "error when moving before default"
3938 # Cleanup the TBF policy
3939 do_nodes $(comma_list $(osts_nodes)) \
3940 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3943 run_test 77i "Change rank of TBF rule"
3949 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
3950 skip "Need OST version at least 2.9.53"
3951 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
3956 do_nodes $(comma_list $(osts_nodes)) \
3957 lctl set_param jobid_var=procname_uid \
3958 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3959 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3960 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3961 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3966 do_nodes $(comma_list $(osts_nodes)) \
3967 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3968 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3969 ost.OSS.ost_io.nrs_policies="fifo"
3971 # sleep 3 seconds to wait the tbf policy stop completely,
3972 # or the next test case is possible get -EAGAIN when
3973 # setting the tbf policy
3976 run_test 77j "check TBF-OPCode NRS policy"
3979 local idstr="${1}id"
3980 local policy="${idstr}={$2}"
3981 local rate="rate=$3"
3983 do_nodes $(comma_list $(osts_nodes)) \
3984 lctl set_param jobid_var=procname_uid \
3985 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3986 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3987 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3989 nrs_write_read "runas $4"
3990 tbf_verify $3 $3 "runas $4"
3992 do_nodes $(comma_list $(osts_nodes)) \
3993 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3994 ost.OSS.ost_io.nrs_policies="fifo"
3996 # sleep 3 seconds to wait the tbf policy stop completely,
3997 # or the next test case is possible get -eagain when
3998 # setting the tbf policy
4003 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4004 skip "Need OST version at least 2.11.50"
4007 test_id "u" "500" "5" "-u 500"
4008 test_id "g" "500" "5" "-u 500 -g 500"
4010 run_test 77ja "check TBF-UID/GID NRS policy"
4018 for rule in $rule_lists; do
4019 do_nodes $(comma_list $(osts_nodes)) \
4020 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4023 do_nodes $(comma_list $(osts_nodes)) \
4024 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4030 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4031 skip "Need OST version at least 2.9.53"
4033 do_nodes $(comma_list $(osts_nodes)) \
4034 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4035 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4036 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4038 nrs_write_read "$RUNAS"
4039 tbf_verify 20 10 "$RUNAS"
4041 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4042 local client_nids=$(nids_list $address "\\")
4043 do_nodes $(comma_list $(osts_nodes)) \
4044 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4045 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4046 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4047 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4052 do_nodes $(comma_list $(osts_nodes)) \
4053 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4054 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4055 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4057 nrs_write_read "$RUNAS"
4058 tbf_verify 20 20 "$RUNAS"
4060 do_nodes $(comma_list $(osts_nodes)) \
4061 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4062 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4063 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4065 nrs_write_read "$RUNAS"
4066 # with parameter "RUNAS", it will match the latest rule
4067 # "ext_b" first, so the limited write rate is 10.
4068 tbf_verify 10 10 "$RUNAS"
4071 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4073 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4074 skip "Need OST version at least 2.10.58"
4076 do_nodes $(comma_list $(osts_nodes)) \
4077 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4078 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4079 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4080 nrs_write_read "runas -u 500 -g 1000"
4081 tbf_verify 5 5 "runas -u 500 -g 1000"
4083 do_nodes $(comma_list $(osts_nodes)) \
4084 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4085 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4086 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4088 nrs_write_read "runas -u 500"
4089 tbf_verify 20 10 "runas -u 500"
4091 do_nodes $(comma_list $(osts_nodes)) \
4092 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4093 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4094 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4095 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4096 nrs_write_read "runas -u 500"
4097 tbf_verify 10 10 "runas -u 500"
4098 tbf_verify 20 10 "runas -u 500"
4099 cleanup_77k "ext_a ext_b" "fifo"
4101 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4104 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4105 skip "Need OST version at least 2.10.56"
4107 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4108 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4110 local output=$(do_facet ost1 lctl get_param \
4111 ost.OSS.ost_io.nrs_policies | \
4112 awk '/name: tbf/ {print;exit}' | \
4113 awk -F ': ' '{print $2}')
4115 if [ "$output" != "tbf" ]; then
4116 error "The generic TBF output is '$output', not 'tbf'"
4119 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4121 run_test 77l "check the output of NRS policies for generic TBF"
4124 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4125 skip "Need OST version at least 2.9.54"
4128 local dir=$DIR/$tdir
4130 mkdir $dir || error "mkdir $dir failed"
4131 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4134 local nodes=$(comma_list $(osts_nodes))
4135 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4136 ost.OSS.ost_io.nrs_delay_min=4 \
4137 ost.OSS.ost_io.nrs_delay_max=4 \
4138 ost.OSS.ost_io.nrs_delay_pct=100
4139 [ $? -ne 0 ] && error "Failed to set delay policy"
4141 local start=$SECONDS
4142 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4143 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4144 oflag=direct conv=fdatasync ||
4145 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4146 error "dd on client failed (1)"; }
4147 local elapsed=$((SECONDS - start))
4149 # NRS delay doesn't do sub-second timing, so a request enqueued at
4150 # 0.9 seconds can be dequeued at 4.0
4151 [ $elapsed -lt 3 ] &&
4152 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4153 error "Single 1M write should take at least 3 seconds"; }
4156 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4157 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4158 oflag=direct conv=fdatasync ||
4159 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4160 error "dd on client failed (2)"; }
4161 elapsed=$((SECONDS - start))
4163 [ $elapsed -lt 30 ] &&
4164 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4165 error "Ten 1M writes should take at least 30 seconds"; }
4167 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4168 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4172 run_test 77m "check NRS Delay slows write RPC processing"
4174 test_77n() { #LU-10802
4175 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4176 skip "Need OST version at least 2.10.58"
4179 # Configure jobid_var
4180 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4181 if [ $saved_jobid_var != procname_uid ]; then
4182 set_persistent_param_and_check client \
4183 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4186 do_nodes $(comma_list $(osts_nodes)) \
4187 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4188 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4189 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4192 tbf_verify 20 20 "$RUNAS"
4194 do_nodes $(comma_list $(osts_nodes)) \
4195 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4196 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4201 do_nodes $(comma_list $(osts_nodes)) \
4202 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4203 ost.OSS.ost_io.nrs_policies="fifo"
4207 local current_jobid_var=$($LCTL get_param -n jobid_var)
4208 if [ $saved_jobid_var != $current_jobid_var ]; then
4209 set_persistent_param_and_check client \
4210 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4213 run_test 77n "check wildcard support for TBF JobID NRS policy"
4215 test_78() { #LU-6673
4218 oss=$(comma_list $(osts_nodes))
4219 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4220 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4222 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4223 # Valid return codes are:
4224 # 0: Tuning succeeded
4225 # ENODEV: Policy is still stopped
4226 # EAGAIN: Policy is being initialized
4227 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4228 error "Expected set_param to return 0|ENODEV|EAGAIN"
4230 # Cleanup the ORR policy
4231 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4232 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4235 run_test 78 "Enable policy and specify tunings right away"
4238 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4239 test_mkdir $DIR/$tdir
4241 # Prevent interference from layout intent RPCs due to
4242 # asynchronous writeback. These will be tested in 130c below.
4243 do_nodes ${CLIENTS:-$HOSTNAME} sync
4245 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4246 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4248 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4249 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4250 local facet=mds$((mdtidx + 1))
4252 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4253 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4257 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4258 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4263 run_test 79 "xattr: intent error"
4266 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4273 mkdir -p $DIR1/$tdir/dir
4274 createmany -o $DIR1/$tdir/dir/f 10 ||
4275 error "create files under remote dir failed $i"
4277 cp /etc/passwd $DIR1/$tdir/$tfile
4279 #migrate open file should fails
4280 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4282 # give multiop a chance to open
4285 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4286 error "migrate open files should failed with open files"
4290 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4291 error "migrate remote dir error"
4293 echo "Finish migration, then checking.."
4294 for file in $(find $DIR1/$tdir); do
4295 mdt_index=$($LFS getstripe -m $file)
4296 [ $mdt_index == $MDTIDX ] ||
4297 error "$file is not on MDT${MDTIDX}"
4300 diff /etc/passwd $DIR1/$tdir/$tfile ||
4301 error "file different after migration"
4303 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4305 run_test 80a "migrate directory when some children is being opened"
4309 kill -9 $migrate_pid
4313 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4314 local migrate_dir1=$DIR1/$tdir/migrate_dir
4315 local migrate_dir2=$DIR2/$tdir/migrate_dir
4316 local migrate_run=$LUSTRE/tests/migrate.sh
4324 trap cleanup_80b EXIT
4325 #prepare migrate directory
4326 mkdir -p $migrate_dir1
4327 for F in {1,2,3,4,5}; do
4328 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4329 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4332 #migrate the directories among MDTs
4335 mdt_idx=$((RANDOM % MDSCOUNT))
4336 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4338 [ $rc -ne 0 -o $rc -ne 16 ] || break
4343 echo "start migration thread $migrate_pid"
4344 #Access the files at the same time
4345 start_time=$(date +%s)
4346 echo "accessing the migrating directory for 5 minutes..."
4348 ls $migrate_dir2 > /dev/null || {
4349 echo "read dir fails"
4352 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4353 echo "access file1 fails"
4357 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4358 echo "access file2/3 fails"
4362 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4363 echo "access file4 fails"
4367 stat $migrate_dir2/file5 > /dev/null || {
4368 echo "stat file5 fails"
4372 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4373 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4374 echo "touch file failed with $rc1"
4378 if [ -e $migrate_dir2/source_file ]; then
4379 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4380 &>/dev/null || rc1=$?
4381 if [ -e $migrate_dir2/link_file ]; then
4382 rm -rf $migrate_dir2/link_file
4385 mrename $migrate_dir2/source_file \
4386 $migrate_dir2/target_file &>/dev/null || rc1=$?
4387 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4388 echo "rename failed with $rc1"
4392 if [ -e $migrate_dir2/target_file ]; then
4393 rm -rf $migrate_dir2/target_file &>/dev/null ||
4396 rm -rf $migrate_dir2/source_file &>/dev/null ||
4399 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4400 echo "unlink failed with $rc1"
4405 end_time=$(date +%s)
4406 duration=$((end_time - start_time))
4407 if [ $((duration % 10)) -eq 0 ]; then
4408 if [ $show_time -eq 1 ]; then
4409 echo "...$duration seconds"
4416 kill -0 $migrate_pid || {
4417 echo "migration stopped 1"
4421 [ $duration -ge 300 ] && break
4424 #check migration are still there
4425 kill -0 $migrate_pid || error "migration stopped 2"
4428 run_test 80b "Accessing directory during migration"
4431 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4435 mkdir -p $DIR1/$tdir
4437 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4438 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4441 touch d0/0 || error "create 0 failed"
4442 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4443 stat d0/0 && error "stat mv filed succeed"
4444 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4445 stat d0/0 || error "stat failed"
4447 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4449 if [ $t -ne 3 ]; then
4450 ls -ai $DIR1/$tdir/d0
4451 error "expect 3 get $t"
4456 run_test 81a "rename and stat under striped directory"
4459 [ $MDSCOUNT -lt 2 ] &&
4460 skip "We need at least 2 MDTs for this test"
4467 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4468 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4477 for i in $(seq $total); do
4478 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4482 kill -9 $setattr_pid
4484 run_test 81b "rename under striped directory doesn't deadlock"
4487 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4488 skip "Need MDS version at least 2.6.92"
4490 # Client 1 creates a file.
4491 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4493 # Client 2 opens the file.
4494 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4496 # Client 1 makes the file an orphan.
4497 rm $DIR1/$tfile || error "rm"
4498 # Client 2 sets EA "user.multiop".
4500 wait $pid2 || error "multiop 2"
4501 # Client 1 gets EA "user.multiop". This used to fail because the EA
4502 # cache refill would get "trusted.link" from mdd_xattr_list() but
4503 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4506 wait $pid1 || error "multiop 1"
4508 run_test 82 "fsetxattr and fgetxattr on orphan files"
4511 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4518 $LFS mkdir -i1 -c2 $tdir
4523 echo "start pid $pid1 to create/unlink striped directory"
4525 # Access the directory at the same time
4529 stat $tdir > /dev/null 2>&1
4533 echo "start pid $pid2 to stat striped directory"
4541 run_test 83 "access striped directory while it is being created/unlinked"
4544 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4545 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4549 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4550 error "create $tfile failed"
4551 mtime=$(stat -c%Y $DIR/$tfile)
4552 mtime=$((mtime + 200))
4554 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4555 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4557 touch -c -m $mtime $DIR/$tfile &
4559 # sleep a while to let 'touch' run first
4561 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4564 wait $setattr_pid || true
4566 run_test 84 "0-nlink race in lu_object_find()"
4569 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4574 [ "$SLOW" = "yes" ] && duration=600
4575 # Open/Create under striped directory
4579 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4580 touch $tdir/f{0..3} > /dev/null 2>&1
4584 echo "start pid $pid1 to open/create under striped directory"
4586 # unlink the striped directory at the same time
4590 rm -rf $tdir > /dev/null 2>&1
4594 echo "start pid $pid2 to unlink striped directory"
4603 run_test 90 "open/create and unlink striped directory"
4606 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4611 [ "$SLOW" = "yes" ] && duration=600
4612 # chmod striped directory
4616 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4617 chmod go+w $tdir > /dev/null 2>&1
4621 echo "start pid $pid1 to chmod striped directory"
4623 # unlink the striped directory at the same time
4627 rm -rf $tdir > /dev/null 2>&1
4631 echo "start pid $pid2 to unlink striped directory"
4640 run_test 91 "chmod and unlink striped directory"
4643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4646 local cmd="exec $fd<$DIR1/$tdir"
4647 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4650 trap "eval $cmd" EXIT
4651 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4652 rmdir ../$tdir || error "rmdir ../$tdir fails"
4654 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4655 $LCTL set_param fail_loc=0x1408
4656 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4657 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4658 error "create remote dir succeeds"
4659 $LCTL set_param fail_loc=0
4663 run_test 92 "create remote directory under orphan directory"
4670 mkdir -p $DIR1/$tfile-1/
4671 mkdir -p $DIR2/$tfile-2/
4672 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4673 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4674 do_facet $SINGLEMDS "$LCTL set_param -n \
4675 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4676 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4677 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4679 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4682 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4686 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4687 do_facet $SINGLEMDS "$LCTL set_param -n \
4688 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4690 $LFS getstripe $DIR1/$tfile-1/file1
4691 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4692 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4693 $LFS getstripe $DIR2/$tfile-2/file2
4694 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4695 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4696 echo "rc1=$rc1 and rc2=$rc2 "
4697 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4698 error "object allocate on same ost detected"
4700 run_test 93 "alloc_rr should not allocate on same ost"
4703 $LCTL set_param osc.*.idle_timeout=0
4704 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4706 local before=$(date +%s)
4710 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4711 $LCTL set_param fail_val=5 fail_loc=0x80000312
4712 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4716 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4717 $LCTL set_param fail_val=6 fail_loc=0x80000329
4718 $LCTL mark kill $pid
4721 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4724 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4726 evict=$(do_facet client $LCTL get_param \
4727 osc.$FSNAME-OST*-osc-*/state |
4728 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4730 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4731 (do_facet client $LCTL get_param \
4732 osc.$FSNAME-OST*-osc-*/state;
4733 error "eviction happened: $evict before:$before")
4734 $LCTL set_param osc.*.idle_timeout=debug
4736 run_test 94 "signal vs CP callback race"
4740 skip "Reserved for glimpse-ahead" && return
4741 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4742 skip "Need MDS version at least 2.10.55"
4746 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4748 lctl set_param -n mdc.*.stats=clear
4749 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4751 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4752 # first stat from server should return size data and save glimpse
4753 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4754 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4755 # second stat to check size is NOT cached on client without IO lock
4756 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4758 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4759 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4762 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4765 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4766 skip "Need MDS version at least 2.10.55"
4770 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4772 lctl set_param -n mdc.*.stats=clear
4773 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4774 cancel_lru_locks mdc
4775 # first stat data from server should have size
4776 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4777 # second stat to check size is cached on client
4778 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4780 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4781 # both stats should cause no glimpse requests
4782 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4785 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4788 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4789 skip "Need MDS version at least 2.10.55"
4793 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4795 lctl set_param -n mdc.*.stats=clear
4796 lctl set_param -n osc.*.stats=clear
4797 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4799 # check that size is merged from MDT and OST correctly
4800 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4801 error "Wrong size from stat #1"
4803 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4804 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4808 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4811 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4812 skip "Need MDS version at least 2.10.55"
4816 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4819 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4820 lctl set_param -n mdc.*.stats=clear
4821 $TRUNCATE $DIR2/$tdir/dom 4096
4823 # check that reported size is valid after file grows to OST and
4824 # is truncated back to MDT stripe size
4825 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4826 error "Wrong size from stat #1"
4828 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4829 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4833 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4836 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
4837 skip "Need MDS version at least 2.11.50"
4839 local dom=$DIR/$tdir/dom
4840 local dom2=$DIR2/$tdir/dom
4843 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4845 cancel_lru_locks mdc
4846 dd if=/dev/urandom of=$dom bs=12000 count=1
4847 $TRUNCATE $dom2 6000
4848 cancel_lru_locks mdc
4849 lctl set_param -n mdc.*.stats=clear
4850 # expect read-on-open to return all data before write
4851 cat /etc/hosts >> $dom
4852 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4853 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4855 run_test 100e "DoM: read on open and file size"
4858 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4859 skip "Need MDS version at least 2.10.55"
4861 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4863 $CHECKSTAT -t file $DIR1/$tfile
4865 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4866 sysctl -wq vm.dirty_writeback_centisecs=0
4868 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4871 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4872 error_noexit "Write fails"
4873 # must discard pages
4874 lctl set_param -n mdc.*.stats=clear
4875 rm $DIR2/$tfile || error "Unlink fails"
4877 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4878 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4880 run_test 101a "Discard DoM data on unlink"
4883 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4884 skip "Need MDS version at least 2.10.55"
4886 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4887 touch $DIR1/${tfile}_2
4889 $CHECKSTAT -t file $DIR1/$tfile
4891 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4892 sysctl -wq vm.dirty_writeback_centisecs=0
4894 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4897 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4898 # must discard pages
4899 lctl set_param -n mdc.*.stats=clear
4900 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4902 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4903 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4905 run_test 101b "Discard DoM data on rename"
4908 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
4909 skip "Need MDS version at least 2.10.55"
4911 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4913 $CHECKSTAT -t file $DIR1/$tfile
4915 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4916 sysctl -wq vm.dirty_writeback_centisecs=0
4918 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4921 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4922 $MULTIOP $DIR1/$tfile O_c &
4925 lctl set_param -n mdc.*.stats=clear
4926 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4927 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4929 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4930 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4932 run_test 101c "Discard DoM data on close-unlink"
4934 # test to verify file handle related system calls
4935 # (name_to_handle_at/open_by_handle_at)
4936 # The new system calls are supported in glibc >= 2.14.
4938 # test to verify we can open by handle an unlinked file from > 1 client
4939 # This test opens the file normally on $DIR1, which is on one mount, and then
4940 # opens it by handle on $DIR2, which is on a different mount.
4942 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
4943 skip "Needs MDS version 2.11.57 or later"
4945 echo "Test file_handle syscalls" > $DIR/$tfile ||
4946 error "write failed"
4947 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4948 error "check_fhandle_syscalls failed"
4951 run_test 102 "Test open by handle of unlinked file"
4953 # Compare file size between first & second mount, ensuring the client correctly
4954 # glimpses even with unused speculative locks - LU-11670
4956 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
4957 skip "Lockahead needs OST version at least 2.10.50"
4961 test_mkdir -p $DIR/$tdir
4963 # Force file on to OST0
4964 $LFS setstripe -i 0 $DIR/$tdir
4966 # Do not check multiple locks on glimpse
4967 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
4968 $LCTL set_param fail_loc=0x415
4970 # Delay write commit by 2 seconds to guarantee glimpse wins race
4971 # The same fail_loc is used on client & server so it can work in the
4972 # single node sanity setup
4973 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
4975 echo "Incorrect size expected (no glimpse fix):"
4976 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4978 if [ $rc -eq 0 ]; then
4979 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
4982 # guarantee write commit timeout has expired
4985 # Clear fail_loc on client
4986 $LCTL set_param fail_loc=0
4988 # Delay write commit by 2 seconds to guarantee glimpse wins race
4989 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4990 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
4992 # Write commit is still delayed by 2 seconds
4993 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
4995 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
4997 # guarantee write commit timeout has expired
5000 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5002 run_test 103 "Test size correctness with lockahead"
5008 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5019 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5020 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5021 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5022 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5030 local xtimes=($(get_stat_xtimes))
5031 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5033 echo "STAT a|m|ctime ${xtimes[*]}"
5034 echo "MDT a|m|ctime ${xtimes[*]}"
5035 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5036 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5037 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5038 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5039 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5040 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5044 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5045 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5046 skip "Need MDS version at least 2.12.4"
5049 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5050 local atime_diff=$(do_facet $SINGLEMDS \
5051 lctl get_param -n mdd.*MDT0000*.atime_diff)
5053 do_facet $SINGLEMDS \
5054 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5056 stack_trap "do_facet $SINGLEMDS \
5057 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5059 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5060 check_mdt_xtimes $mdtdev
5063 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5064 check_mdt_xtimes $mdtdev
5066 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5069 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5071 kill -USR1 $pid && wait $pid || error "multiop failure"
5072 check_mdt_xtimes $mdtdev
5077 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5078 # on the client side
5079 xtimes=($(get_stat_xtimes))
5080 $MULTIOP $DIR/$tfile O_c &
5083 kill -USR1 $pid && wait $pid || error "multiop failure"
5084 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5085 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5086 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5087 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5088 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5089 check_mdt_xtimes $mdtdev
5092 # Change ctime via chmod
5093 $MULTIOP $DIR/$tfile o_tc &
5096 kill -USR1 $pid && wait $pid || error "multiop failure"
5097 check_mdt_xtimes $mdtdev
5099 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5102 test_mkdir -p $DIR/$tdir
5103 echo test > $DIR/$tdir/$tfile
5104 $LCTL set_param fail_loc=0x416
5105 cancel_lru_locks osc & sleep 1
5106 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5108 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5110 run_test 105 "Glimpse and lock cancel race"
5112 log "cleanup: ======================================================"
5114 # kill and wait in each test only guarentee script finish, but command in script
5115 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5116 # otherwise umount below will fail
5117 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5122 check_and_cleanup_lustre