6 # bug number for skipped test: LU-1205 9977/LU-7105 LU-9452
7 ALWAYS_EXCEPT=" 18c 28 29 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
14 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
15 OPENFILE=${OPENFILE:-openfile}
16 OPENUNLINK=${OPENUNLINK:-openunlink}
17 export MULTIOP=${MULTIOP:-multiop}
18 export TMP=${TMP:-/tmp}
19 MOUNT_2=${MOUNT_2:-"yes"}
20 CHECK_GRANT=${CHECK_GRANT:-"yes"}
21 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
25 export NAME=${NAME:-local}
27 LUSTRE=${LUSTRE:-`dirname $0`/..}
28 . $LUSTRE/tests/test-framework.sh
32 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
35 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
36 # bug number for skipped test: LU-2776
37 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 51a"
38 # LU-2829 / LU-2887 - make allowances for ZFS slowness
39 TEST33_NFILES=${TEST33_NFILES:-1000}
42 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
49 check_and_setup_lustre
52 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
54 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
55 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
57 # $RUNAS_ID may get set incorrectly somewhere else
58 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
60 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
66 [ -f $DIR2/$tfile ] || error "Check create"
67 chmod 777 $DIR2/$tfile
68 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
69 error "Check attribute update for 0777"
71 chmod a-x $DIR2/$tfile
72 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
73 error "Check attribute update for 0666"
76 $CHECKSTAT -a $DIR1/$tfile ||
77 error "Check unlink - removes file on other mountpoint"
79 run_test 1 "Check attribute updates on 2 mount points"
85 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
87 run_test 2a "check cached attribute updates on 2 mtpt's ========"
93 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
95 run_test 2b "check cached attribute updates on 2 mtpt's ========"
97 # NEED TO SAVE ROOT DIR MODE
100 $CHECKSTAT -t dir -p 0777 $DIR2 || error
102 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
106 $CHECKSTAT -t dir -p 0755 $DIR2 || error
108 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
115 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
117 run_test 2e "check chmod on root is propagated to others"
120 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
122 local remote_dir=$tdir/remote_dir
125 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
126 error "Create remote directory failed"
128 touch $DIR1/$remote_dir/$tfile ||
129 error "Create file under remote directory failed"
130 chmod 777 $DIR1/$remote_dir/$tfile ||
131 error "Chmod file under remote directory failed"
133 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
134 error "Check attr of file under remote directory failed"
136 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
137 error "Chown file under remote directory failed"
139 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
140 error "Check owner of file under remote directory failed"
142 cd $DIR2/$remote_dir || error "enter remote dir"
143 rm -rf $DIR1/$remote_dir/$tfile ||
144 error "Unlink remote directory failed"
146 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
147 error "unlink file still exists!"
149 cd $DIR2/$tdir || error "exit remote dir"
150 rm -rf $DIR1/$tdir || error "unlink directory failed"
152 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
155 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
157 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
159 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
160 echo "$DIR1/$tfile has $block1 blocks"
161 echo "$DIR2/$tfile has $block2 blocks"
162 [ $block1 -eq $block2 ] || error
164 run_test 2g "check blocks update on sync write"
167 local target="this/is/good"
168 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
169 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
170 error "link $DIR2/$tfile not as expected"
172 run_test 3 "symlink on one mtpt, readlink on another ==========="
175 multifstat $DIR1/f4 $DIR2/f4
177 run_test 4 "fstat validation on multiple mount points =========="
181 $TRUNCATE $DIR2/f5 100
182 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
185 run_test 5 "create a file on one mount, truncate it on the other"
188 openunlink $DIR1/$tfile $DIR2/$tfile || \
189 error "openunlink $DIR1/$tfile $DIR2/$tfile"
191 run_test 6 "remove of open file on other node =================="
195 opendirunlink $DIR1/$dir $DIR2/$dir || \
196 error "opendirunlink $DIR1/$dir $DIR2/$dir"
198 run_test 7 "remove of open directory on other node ============="
201 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
202 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
204 run_test 8 "remove of open special file on other node =========="
210 for C in a b c d e f g h i j k l; do
211 dir=`eval echo \\$DIR$MTPT`
212 echo -n $C >> $dir/f9
213 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
215 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
216 error "`od -a $DIR1/f9` != abcdefghijkl"
218 run_test 9 "append of file with sub-page size on multiple mounts"
225 for C in a b c d e f g h i j k l; do
226 dir=`eval echo \\$DIR$MTPT`
227 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
228 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
229 OFFSET=`expr $OFFSET + 1`
231 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
232 error "`od -a $DIR1/f10` != abcdefghijkl"
234 run_test 10a "write of file with sub-page size on multiple mounts "
238 yes "R" | head -c 4000 >$TMP/f10b-seed
239 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
241 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
243 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
245 # create a test file locally to compare
246 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
247 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
248 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
249 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
251 run_test 10b "write of file with sub-page size on multiple mounts "
255 multiop_bg_pause $DIR1/d11/f O_c || return 1
257 cp -p /bin/ls $DIR1/d11/f
261 wait $MULTIPID || error
262 [ $RC -eq 0 ] && error || true
264 run_test 11 "execution of file opened for write should return error ===="
267 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
269 run_test 12 "test lock ordering (link, stat, unlink) ==========="
271 test_13() { # bug 2451 - directory coherency
272 test_mkdir $DIR1/d13 || error
273 cd $DIR1/d13 || error
275 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
277 rm -f $DIR2/d13/f13 || error
278 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
279 # need to run it twice
280 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
282 rm -f $DIR2/d13/f13 || error
283 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
285 run_test 13 "test directory page revocation ===================="
288 test_mkdir -p $DIR1/$tdir
289 cp -p /bin/ls $DIR1/$tdir/$tfile
290 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
293 $DIR2/$tdir/$tfile && error || true
295 wait $MULTIPID || return 2
297 run_test 14aa "execution of file open for write returns -ETXTBSY"
300 test_mkdir -p $DIR1/d14
301 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
302 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
304 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
305 kill -USR1 $MULTIOP_PID || return 2
306 wait $MULTIOP_PID || return 3
307 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
309 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
311 test_14b() { # bug 3192, 7040
312 test_mkdir -p $DIR1/d14
313 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
314 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
316 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
317 error "expected truncate error, got success"
318 kill -USR1 $MULTIOP_PID || return 2
319 wait $MULTIOP_PID || return 3
320 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
321 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
323 run_test 14b "truncate of executing file returns -ETXTBSY ======"
325 test_14c() { # bug 3430, 7040
326 test_mkdir -p $DIR1/d14
327 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
328 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
330 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
331 kill -USR1 $MULTIOP_PID || return 2
332 wait $MULTIOP_PID || return 3
333 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
334 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
336 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
338 test_14d() { # bug 10921
339 test_mkdir -p $DIR1/d14
340 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
341 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
344 chmod 600 $DIR1/d14/multiop || error "chmod failed"
345 kill -USR1 $MULTIOP_PID || return 2
346 wait $MULTIOP_PID || return 3
347 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
348 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
350 run_test 14d "chmod of executing file is still possible ========"
352 test_15() { # bug 974 - ENOSPC
354 sh oos2.sh $MOUNT1 $MOUNT2
355 wait_delete_completed
356 grant_error=`dmesg | grep "> available"`
357 [ -z "$grant_error" ] || error "$grant_error"
359 run_test 15 "test out-of-space with multiple writers ==========="
362 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
363 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
364 # pass a 2500 operation dual-mount run within the time limit.
365 if [ "$(facet_fstype ost1)" = "zfs" ]; then
366 FSXNUM=$((COUNT / 5))
368 elif [ "$SLOW" = "yes" ]; then
369 FSXNUM=$((COUNT * 5))
377 local file1=$DIR1/$tfile
378 local file2=$DIR2/$tfile
380 # to allocate grant because it may run out due to test_15.
381 lfs setstripe -c -1 $file1
382 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
383 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
386 lfs setstripe -c -1 $file1 # b=10919
387 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
389 run_test 16 "$FSXNUM iterations of dual-mount fsx"
391 test_17() { # bug 3513, 3667
392 remote_ost_nodsh && skip "remote OST with nodsh" && return
394 lfs setstripe $DIR1/$tfile -i 0 -c 1
395 cp $SAMPLE_FILE $DIR1/$tfile
396 cancel_lru_locks osc > /dev/null
397 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
398 do_facet ost1 lctl set_param fail_loc=0x8000030a
399 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
400 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
402 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
404 run_test 17 "resource creation/LVB creation race ==============="
407 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
410 for idx in {a..z}; do
411 local ptr=EXCEPT_ALWAYS_18$idx
412 [ x${!ptr} = xtrue ] || continue
414 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
417 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
420 run_test 18 "mmap sanity check ================================="
422 test_19() { # bug3811
423 local node=$(facet_active_host ost1)
425 # check whether obdfilter is cache capable at all
426 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
427 echo "not cache-capable obdfilter"
431 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
433 set_osd_param $node '' readcache_max_filesize 4096
434 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
435 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
436 cp $TMP/$tfile $DIR1/$tfile
437 for i in `seq 1 20`; do
438 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
439 cancel_lru_locks osc > /dev/null
440 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
441 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
443 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
444 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
445 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
446 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
448 set_osd_param $node '' readcache_max_filesize $MAX
451 run_test 19 "test concurrent uncached read races ==============="
456 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
457 $MULTIOP $DIR1/f20 Ow8190c
458 $MULTIOP $DIR2/f20 Oz8194w8190c
459 $MULTIOP $DIR1/f20 Oz0r8190c
461 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
463 error $CNTD" page left in cache after lock cancel" || true
465 run_test 20 "test extra readahead page left in cache ===="
472 test_21() { # Bug 5907
473 test_mkdir $DIR1/$tdir
474 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
476 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
477 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
478 test -d $DIR1/$tdir || error "Mounted directory disappeared"
480 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
483 run_test 21 " Try to remove mountpoint on another dir ===="
485 test_23() { # Bug 5972
486 local at_diff=$(do_facet $SINGLEMDS \
487 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
488 echo "atime should be updated while another read" > $DIR1/$tfile
490 # clear the lock(mode: LCK_PW) gotten from creating operation
494 sleep $((at_diff + 1))
496 echo "starting reads"
497 multiop_bg_pause $DIR1/$tfile or20_c || return 1
498 # with SOM and opencache enabled, we need to close a file and cancel
499 # open lock to get atime propogated to MDS
500 kill -USR1 $! || return 2
503 time2=$(stat -c "%X" $DIR/$tfile)
504 echo "new atime is $time2"
506 [ $time2 -gt $time1 ] || error "atime was not updated"
507 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
510 run_test 23 " others should see updated atime while another read===="
514 lfs df || error "lfs df failed"
515 lfs df -ih || error "lfs df -ih failed"
516 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
517 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
518 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
519 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
521 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
522 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
523 lctl --device %$OSC deactivate
524 lfs df -i || error "lfs df -i with deactivated OSC failed"
525 lctl --device %$OSC activate
526 lfs df || error "lfs df with reactivated OSC failed"
528 run_test 24a "lfs df [-ih] [path] test ========================="
532 fsnum=$(lfs_df | grep -c "summary")
533 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
535 run_test 24b "lfs df should show both filesystems ==============="
538 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
540 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
543 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
544 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
546 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
547 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
548 error "setfacl $DIR2/$tdir #1"
549 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
550 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
551 error "setfacl $DIR2/$tdir #2"
552 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
553 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
554 error "setfacl $DIR2/$tdir #3"
555 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
556 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
557 error "setfacl $DIR2/$tdir #4"
558 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
562 run_test 25a "change ACL on one mountpoint be seen on another ==="
565 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
567 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
569 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
572 $LFS mkdir -i 1 $DIR1/$tdir
573 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
574 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
576 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
577 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
578 error "setfacl $DIR2/$tdir #1"
579 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
580 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
581 error "setfacl $DIR2/$tdir #2"
582 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
583 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
584 error "setfacl $DIR2/$tdir #3"
585 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
586 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
587 error "setfacl $DIR2/$tdir #4"
588 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
592 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
595 utime $DIR1/f26a -s $DIR2/f26a || error
597 run_test 26a "allow mtime to get older"
602 echo "aaa" >> $DIR1/$tfile
604 chmod a+x $DIR2/$tfile
605 mt1=`stat -c %Y $DIR1/$tfile`
606 mt2=`stat -c %Y $DIR2/$tfile`
608 if [ x"$mt1" != x"$mt2" ]; then
609 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
612 run_test 26b "sync mtime between ost and mds"
617 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
622 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
627 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
629 lctl set_param -n ldlm.dump_namespaces ""
630 wait $DD1_PID $DD2_PID
631 [ $? -ne 0 ] && lctl dk $TMP/debug || true
633 run_test 27 "align non-overlapping extent locks from request ==="
635 test_28() { # bug 9977
636 ECHO_UUID="ECHO_osc1_UUID"
637 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
639 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
640 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
641 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
645 attach echo_client ECHO_osc1 $ECHO_UUID
649 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
650 $LCTL --device $tECHOID destroy "${tOBJID}:0"
658 # reading of 1st stripe should pass
659 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
660 # reading of 2nd stripe should fail (this stripe was destroyed)
661 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
663 # now, recreating test file
664 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
665 # reading of 1st stripe should pass
666 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
667 # reading of 2nd stripe should pass
668 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
670 run_test 28 "read/write/truncate file with lost stripes"
672 test_29() { # bug 10999
674 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
675 lctl set_param fail_loc=0x8000030f
678 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
681 #bug 11549 - permanently turn test off in b1_5
682 run_test 29 "lock put race between glimpse and enqueue ========="
684 test_30() { #bug #11110, LU-2523
685 test_mkdir -p $DIR1/$tdir
686 cp -f /bin/bash $DIR1/$tdir/bash
687 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
688 cp /bin/bash $DIR2/$tdir' &
689 $DIR1/$tdir/bash -c 'sleep 2;
690 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
695 run_test 30 "recreate file race"
698 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
699 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
700 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
701 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
702 lctl set_param fail_loc=0x314
703 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
704 awk 'BEGIN { FS="+" } /in/ {print $1}')
705 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
707 run_test 31a "voluntary cancel / blocking ast race=============="
710 remote_ost || { skip "local OST" && return 0; }
711 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
713 # make sure there is no local locks due to destroy
714 wait_mds_ost_sync || error "wait_mds_ost_sync()"
715 wait_delete_completed || error "wait_delete_completed()"
717 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
718 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
719 cp /etc/hosts $DIR/$tdir/$tfile
720 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
721 lctl set_param fail_loc=0x314
722 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
723 do_facet ost1 lctl set_param fail_loc=0x316
725 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
726 lctl set_param fail_loc=0
727 do_facet ost1 lctl set_param fail_loc=0
728 # cleanup: reconnect the client back
731 run_test 31b "voluntary OST cancel / blocking ast race=============="
733 # enable/disable lockless truncate feature, depending on the arg 0/1
734 enable_lockless_truncate() {
735 lctl set_param -n osc.*.lockless_truncate $1
738 test_32a() { # bug 11270
739 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
740 save_lustre_params client "osc.*.lockless_truncate" > $p
742 enable_lockless_truncate 1
744 lfs setstripe -c -1 $DIR1/$tfile
745 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
747 clear_stats osc.*.osc_stats
749 log "checking cached lockless truncate"
750 $TRUNCATE $DIR1/$tfile 8000000
751 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
752 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
753 error "cached truncate isn't lockless"
755 log "checking not cached lockless truncate"
756 $TRUNCATE $DIR2/$tfile 5000000
757 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
758 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
759 error "not cached truncate isn't lockless"
761 log "disabled lockless truncate"
762 enable_lockless_truncate 0
763 clear_stats osc.*.osc_stats
764 $TRUNCATE $DIR2/$tfile 3000000
765 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
766 [ $(calc_stats osc.*.osc_stats lockless_truncate) -eq 0 ] ||
767 error "lockless truncate disabling failed"
769 # restore lockless_truncate default values
770 restore_lustre_params < $p
773 run_test 32a "lockless truncate"
775 test_32b() { # bug 11270
776 remote_ost_nodsh && skip "remote OST with nodsh" && return
779 local facets=$(get_facets OST)
780 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
782 save_lustre_params client "osc.*.contention_seconds" > $p
783 save_lustre_params $facets \
784 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
785 save_lustre_params $facets \
786 "ldlm.namespaces.filter-*.contended_locks" >> $p
787 save_lustre_params $facets \
788 "ldlm.namespaces.filter-*.contention_seconds" >> $p
789 clear_stats osc.*.osc_stats
791 # agressive lockless i/o settings
792 do_nodes $(comma_list $(osts_nodes)) \
793 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
794 ldlm.namespaces.filter-*.contended_locks=0 \
795 ldlm.namespaces.filter-*.contention_seconds=60"
796 lctl set_param -n osc.*.contention_seconds=60
798 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
800 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
803 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -ne 0 ] ||
804 error "lockless i/o was not triggered"
805 # disable lockless i/o (it is disabled by default)
806 do_nodes $(comma_list $(osts_nodes)) \
807 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
808 ldlm.namespaces.filter-*.contended_locks=32 \
809 ldlm.namespaces.filter-*.contention_seconds=0"
810 # set contention_seconds to 0 at client too, otherwise Lustre still
811 # remembers lock contention
812 lctl set_param -n osc.*.contention_seconds=0
813 clear_stats osc.*.osc_stats
815 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
817 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
820 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -eq 0 ] ||
821 error "lockless i/o works when disabled"
823 restore_lustre_params <$p
826 run_test 32b "lockless i/o"
830 local mdts=$(get_facets MDS)
835 for mds in ${mdts//,/ }; do
837 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
838 xargs readlink -f" ))
839 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
842 stat=$(( stat + val))
847 # commit on sharing tests
849 remote_mds_nodsh && skip "remote MDS with nodsh" && return
851 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
852 [ $CLIENTCOUNT -lt 2 ] &&
853 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
855 local nfiles=${TEST33_NFILES:-10000}
856 local param_file=$TMP/$tfile-params
857 local fstype=$(facet_fstype $SINGLEMDS)
859 save_lustre_params $(get_facets MDS) \
860 "mdt.*.commit_on_sharing" > $param_file
868 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
872 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
874 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
875 echo "=== START createmany old: $jbdold transaction"
876 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")
877 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
878 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
879 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
880 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
881 avgtime=$(( avgtime + elapsed ))
883 eval cos${COS}_jbd=$((avgjbd / 3))
884 eval cos${COS}_time=$((avgtime / 3))
887 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
888 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
889 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
890 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
892 restore_lustre_params < $param_file
896 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
898 # commit on sharing tests
900 remote_mds_nodsh && skip "remote MDS with nodsh" && return
902 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
903 [ $CLIENTCOUNT -ge 2 ] ||
904 { skip "Need two or more clients, have $CLIENTCOUNT" &&
906 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
908 local nfiles=${TEST33_NFILES:-10000}
909 local param_file=$TMP/$tfile-params
911 save_lustre_params $(get_facets MDS) \
912 "mdt.*.commit_on_sharing" > $param_file
921 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
925 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
926 $DIR1/$tdir-\\\$(hostname)-$i"
928 jbdold=$(print_jbd_stat)
929 echo "=== START createmany old: $jbdold transaction"
930 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
931 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
932 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
934 jbdnew=$(print_jbd_stat)
935 jbd=$(( jbdnew - jbdold ))
936 echo "=== END createmany new: $jbdnew transaction : \
937 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
938 avgjbd=$(( avgjbd + jbd ))
939 avgtime=$(( avgtime + elapsed ))
941 eval cos${COS}_jbd=$((avgjbd / 3))
942 eval cos${COS}_time=$((avgtime / 3))
945 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
946 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
947 [ "$cos0_jbd" != 0 ] &&
948 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
949 [ "$cos0_time" != 0 ] &&
950 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
952 restore_lustre_params < $param_file
956 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
959 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
960 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
961 skip "DNE CoS not supported" && return
966 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
967 $LFS mkdir -i 1 $DIR/$tdir/d1
968 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
970 local sync_count=$(do_facet mds1 \
971 "lctl get_param -n mdt.*MDT0000.sync_count")
972 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
974 $LFS mkdir -i 1 $DIR/$tdir/d3
975 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
976 # during sleep remote mkdir should have been committed and canceled
977 # remote lock spontaneously, which shouldn't trigger sync
980 local sync_count=$(do_facet mds1 \
981 "lctl get_param -n mdt.*MDT0000.sync_count")
982 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
984 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
987 local nodes=$(comma_list $(mdts_nodes))
988 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
990 local async_commit_count=$(do_nodes $nodes \
991 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
992 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1000 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1001 skip "DNE CoS not supported" && return
1004 # remote directory create
1006 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1007 # remote directory unlink
1008 $LFS mkdir -i 1 $DIR/$tdir
1009 ops_do_cos "rmdir $DIR/$tdir"
1010 # striped directory create
1012 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1013 # striped directory setattr
1014 $LFS mkdir -c 2 $DIR/$tdir
1016 ops_do_cos "chmod 713 $DIR/$tdir"
1017 # striped directory unlink
1018 $LFS mkdir -c 2 $DIR/$tdir
1020 ops_do_cos "rmdir $DIR/$tdir"
1022 $LFS mkdir -c 2 $DIR/$tdir
1023 $LFS mkdir -i 0 $DIR/$tdir/d1
1024 $LFS mkdir -i 1 $DIR/$tdir/d2
1025 touch $DIR/$tdir/d1/tgt
1026 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1028 $LFS mkdir -c 2 $DIR/$tdir
1029 $LFS mkdir -i 0 $DIR/$tdir/d1
1030 $LFS mkdir -i 1 $DIR/$tdir/d2
1031 touch $DIR/$tdir/d1/src
1032 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1034 $LFS mkdir -i 0 $DIR/$tdir
1035 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1038 run_test 33d "DNE distributed operation should trigger COS"
1041 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1042 [ $CLIENTCOUNT -ge 2 ] ||
1043 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1045 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1046 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1047 skip "DNE CoS not supported" && return
1049 local client2=${CLIENT2:-$(hostname)}
1053 local nodes=$(comma_list $(mdts_nodes))
1054 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1056 $LFS mkdir -c 2 $DIR/$tdir
1057 mkdir $DIR/$tdir/subdir
1058 echo abc > $DIR/$tdir/$tfile
1059 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1060 do_node $client2 touch $DIR/$tdir/subdir
1062 local async_commit_count=$(do_nodes $nodes \
1063 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1064 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1068 run_test 33e "DNE local operation shouldn't trigger COS"
1070 # End commit on sharing tests
1072 get_ost_lock_timeouts() {
1073 local nodes=${1:-$(comma_list $(osts_nodes))}
1075 local locks=$(do_nodes $nodes \
1076 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1084 do_nodes $(comma_list $(osts_nodes)) \
1085 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1086 for i in $(seq $OSTCOUNT); do
1087 wait_osc_import_state client ost$i FULL
1092 remote_ost_nodsh && skip "remote OST with nodsh" && return
1096 trap cleanup_34 EXIT RETURN
1097 for OPER in notimeout timeout ; do
1098 rm $DIR1/$tfile 2>/dev/null
1099 lock_in=$(get_ost_lock_timeouts)
1100 if [ $OPER == "timeout" ] ; then
1101 for j in `seq $OSTCOUNT`; do
1102 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1103 do_facet ost$j lctl set_param fail_loc=0x511
1105 echo lock should expire
1107 for j in `seq $OSTCOUNT`; do
1108 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1109 do_facet ost$j lctl set_param fail_loc=0x512
1111 echo lock should not expire
1113 echo writing on client1
1114 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1116 echo reading on client2
1117 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1118 # wait for a lock timeout
1120 lock_out=$(get_ost_lock_timeouts)
1121 if [ $OPER == "timeout" ] ; then
1122 if [ $lock_in == $lock_out ]; then
1123 error "no lock timeout happened"
1128 if [ $lock_in != $lock_out ]; then
1129 error "lock timeout happened"
1137 run_test 34 "no lock timeout under IO"
1139 test_35() { # bug 17645
1142 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1143 awk '/generation/{print $2}')
1145 generation[count]=$g
1149 test_mkdir -p $MOUNT1/$tfile
1150 cancel_lru_locks mdc
1152 # Let's initiate -EINTR situation by setting fail_loc and take
1153 # write lock on same file from same client. This will not cause
1154 # bl_ast yet as lock is already in local cache.
1155 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1156 do_facet client "lctl set_param fail_loc=0x80000317"
1157 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1158 let timeout=timeout*3
1160 while test $nr -lt 10; do
1161 log "Race attempt $nr"
1162 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1163 test "x$blk1" = "x" && blk1=0
1164 createmany -o $MOUNT2/$tfile/a 4000 &
1168 # Let's make conflict and bl_ast
1169 ls -la $MOUNT1/$tfile > /dev/null &
1172 log "Wait for $pid1 $pid2 for $timeout sec..."
1174 kill -9 $pid1 $pid2 > /dev/null 2>&1
1176 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1177 test "x$blk2" = "x" && blk2=0
1178 test $blk2 -gt $blk1 && break
1179 rm -fr $MOUNT1/$tfile/*
1180 cancel_lru_locks mdc
1183 do_facet client "lctl set_param fail_loc=0x0"
1184 df -h $MOUNT1 $MOUNT2
1186 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1187 awk '/generation/{print $2}')
1189 if ! test "$g" -eq "${generation[count]}"; then
1190 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1192 for imp in $list; do
1193 if [ $c = $count ]; then
1198 imp=$(echo "$imp" | awk -F"." '{print $2}')
1199 error "Eviction happened on import $imp"
1204 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1206 test_36() { #bug 16417
1211 test_mkdir -p $DIR1/$tdir
1212 $LFS setstripe -c -1 $DIR1/$tdir
1215 let SIZE_B=SIZE*1024*1024
1216 sync; sleep 2; sync # wait for delete thread
1217 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1218 wait_destroy_complete || error "wait_destroy_complete failed"
1220 while [ $i -le 10 ]; do
1221 lctl mark "start test - cycle ($i)"
1222 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1223 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1224 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1225 sync # sync data from client cache
1226 sync_all_data # sync data from server cache (delayed allocation)
1228 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1229 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1231 rm -f $DIR1/$tdir/$tfile
1232 kill -USR1 $read_pid
1234 sync; sleep 2; sync # Ensure new statfs
1235 wait_delete_completed
1236 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1237 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1239 # this free space! not used
1240 (( $after_dd <= $after)) ||
1241 error "space leaked after_dd:$after_dd > after:$after"
1245 run_test 36 "handle ESTALE/open-unlink correctly"
1247 test_37() { # bug 18695
1248 test_mkdir -p $DIR1/$tdir
1249 multiop_bg_pause $DIR1/$tdir D_c || return 1
1251 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1252 createmany -m $DIR2/$tdir/f 10000
1253 # set mtime/atime backward
1254 touch -t 198001010000 $DIR2/$tdir
1255 kill -USR1 $MULTIPID
1256 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1257 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1260 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1262 # this should be set to past
1263 TEST_39_MTIME=`date -d "1 year ago" +%s`
1267 local client1=${CLIENT1:-`hostname`}
1268 local client2=${CLIENT2:-`hostname`}
1270 do_node $client1 "touch $DIR1/$tfile"
1272 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1273 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1274 [ "$mtime1" = $TEST_39_MTIME ] || \
1275 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1277 local d1=`do_node $client1 date +%s`
1278 do_node $client1 'echo hello >> '$DIR1/$tfile
1279 local d2=`do_node $client1 date +%s`
1281 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1282 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1283 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1285 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1287 for (( i=0; i < 2; i++ )) ; do
1288 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1289 [ "$mtime2" = "$mtime3" ] || \
1290 error "mtime ($mtime2) changed (to $mtime3) on rename"
1292 cancel_lru_locks osc
1293 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1296 run_test 39a "test from 11063 =================================="
1299 local client1=${CLIENT1:-`hostname`}
1300 local client2=${CLIENT2:-`hostname`}
1304 local mtime1=`stat -c %Y $DIR1/$tfile`
1305 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1308 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1310 for (( i=0; i < 2; i++ )) ; do
1311 local mtime3=`stat -c %Y $DIR1/$tfile`
1312 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1314 [ "$mtime3" = "$mtime4" ] || \
1315 error "different mtime on clients: $mtime3, $mtime4"
1316 [ "$mtime3" = $TEST_39_MTIME ] || \
1317 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1319 cancel_lru_locks osc
1320 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1323 run_test 39b "11063 problem 1 =================================="
1326 local client1=${CLIENT1:-`hostname`}
1327 local client2=${CLIENT2:-`hostname`}
1329 echo hello > $DIR1/$tfile
1331 local mtime1=`stat -c %Y $DIR1/$tfile`
1332 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1333 [ "$mtime1" = "$mtime2" ] || \
1334 error "create: different mtime on clients: $mtime1, $mtime2"
1337 $TRUNCATE $DIR1/$tfile 1
1339 for (( i=0; i < 2; i++ )) ; do
1340 local mtime3=`stat -c %Y $DIR1/$tfile`
1341 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1343 [ "$mtime3" = "$mtime4" ] || \
1344 error "different mtime on clients: $mtime3, $mtime4"
1345 [ "$mtime3" -gt $mtime2 ] || \
1346 error "truncate did not update mtime: $mtime2, $mtime3"
1348 cancel_lru_locks osc
1349 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1352 run_test 39c "check truncate mtime update ======================"
1354 test_39d() { # LU-7310
1356 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1358 local mtime1=$(stat -c %Y $DIR2/$tfile)
1359 [ "$mtime1" = $TEST_39_MTIME ] ||
1360 error "mtime: $mtime1, should be $TEST_39_MTIME"
1363 # define OBD_FAIL_OSC_NO_GRANT 0x411
1364 $LCTL set_param fail_loc=0x411
1366 local d1=$(date +%s)
1367 echo hello >> $DIR1/$tfile
1368 local d2=$(date +%s)
1370 $LCTL set_param fail_loc=0
1372 cancel_lru_locks osc
1374 local mtime2=$(stat -c %Y $DIR2/$tfile)
1375 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1376 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1378 run_test 39d "sync write should update mtime"
1380 # check that pid exists hence second operation wasn't blocked by first one
1381 # if it is so then there is no conflict, return 0
1382 # else second operation is conflicting with first one, return 1
1383 check_pdo_conflict() {
1386 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1387 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1397 # test 40: check non-blocking operations
1399 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1400 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1401 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1403 mkdir $DIR1/$tfile &
1406 touch $DIR2/$tfile-2
1407 check_pdo_conflict $PID1 || error "create is blocked"
1408 mkdir $DIR2/$tfile-3
1409 check_pdo_conflict $PID1 || error "mkdir is blocked"
1410 link $DIR2/$tfile-2 $DIR2/$tfile-4
1411 check_pdo_conflict $PID1 || error "link is blocked"
1412 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1413 check_pdo_conflict $PID1 || error "rename is blocked"
1414 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1415 check_pdo_conflict $PID1 || error "getattr is blocked"
1416 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1417 rmdir $DIR2/$tfile-3
1418 check_pdo_conflict $PID1 || error "unlink is blocked"
1420 # all operations above shouldn't wait the first one
1421 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1426 run_test 40a "pdirops: create vs others =============="
1429 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1430 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1431 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1432 touch $DIR1/$tfile &
1436 touch $DIR2/$tfile-2
1437 check_pdo_conflict $PID1 || error "create is blocked"
1438 mkdir $DIR2/$tfile-3
1439 check_pdo_conflict $PID1 || error "mkdir is blocked"
1440 link $DIR2/$tfile-2 $DIR2/$tfile-4
1441 check_pdo_conflict $PID1 || error "link is blocked"
1442 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1443 check_pdo_conflict $PID1 || error "rename is blocked"
1444 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1445 check_pdo_conflict $PID1 || error "getattr is blocked"
1446 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1447 rmdir $DIR2/$tfile-3
1448 check_pdo_conflict $PID1 || error "unlink is blocked"
1449 # all operations above shouldn't wait the first one
1451 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1456 run_test 40b "pdirops: open|create and others =============="
1459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1461 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1462 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1463 link $DIR1/$tfile $DIR1/$tfile-0 &
1467 touch $DIR2/$tfile-2
1468 check_pdo_conflict $PID1 || error "create is blocked"
1469 mkdir $DIR2/$tfile-3
1470 check_pdo_conflict $PID1 || error "mkdir is blocked"
1471 link $DIR2/$tfile-2 $DIR2/$tfile-4
1472 check_pdo_conflict $PID1 || error "link is blocked"
1473 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1474 check_pdo_conflict $PID1 || error "rename is blocked"
1475 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1476 check_pdo_conflict $PID1 || error "getattr is blocked"
1477 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1478 rmdir $DIR2/$tfile-3
1479 check_pdo_conflict $PID1 || error "unlink is blocked"
1481 # all operations above shouldn't wait the first one
1482 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1487 run_test 40c "pdirops: link and others =============="
1490 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1492 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1493 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1498 touch $DIR2/$tfile-2
1499 check_pdo_conflict $PID1 || error "create is blocked"
1500 mkdir $DIR2/$tfile-3
1501 check_pdo_conflict $PID1 || error "mkdir is blocked"
1502 link $DIR2/$tfile-2 $DIR2/$tfile-4
1503 check_pdo_conflict $PID1 || error "link is blocked"
1504 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1505 check_pdo_conflict $PID1 || error "rename is blocked"
1506 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1507 check_pdo_conflict $PID1 || error "getattr is blocked"
1508 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1509 rmdir $DIR2/$tfile-3
1510 check_pdo_conflict $PID1 || error "unlink is blocked"
1512 # all operations above shouldn't wait the first one
1513 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1517 run_test 40d "pdirops: unlink and others =============="
1520 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1522 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1523 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1524 mv $DIR1/$tfile $DIR1/$tfile-0 &
1528 touch $DIR2/$tfile-2
1529 check_pdo_conflict $PID1 || error "create is blocked"
1530 mkdir $DIR2/$tfile-3
1531 check_pdo_conflict $PID1 || error "mkdir is blocked"
1532 link $DIR2/$tfile-2 $DIR2/$tfile-4
1533 check_pdo_conflict $PID1 || error "link is blocked"
1534 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1535 check_pdo_conflict $PID1 || error "getattr is blocked"
1536 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1537 rmdir $DIR2/$tfile-3
1538 check_pdo_conflict $PID1 || error "unlink is blocked"
1540 # all operations above shouldn't wait the first one
1541 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1546 run_test 40e "pdirops: rename and others =============="
1548 # test 41: create blocking operations
1550 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1551 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1552 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1555 mkdir $DIR2/$tfile && error "mkdir must fail"
1556 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1560 run_test 41a "pdirops: create vs mkdir =============="
1563 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1564 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1565 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1568 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1569 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1573 run_test 41b "pdirops: create vs create =============="
1576 touch $DIR1/$tfile-2
1577 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1578 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1579 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1582 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1583 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1587 run_test 41c "pdirops: create vs link =============="
1590 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1591 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1592 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1595 rm $DIR2/$tfile || error "unlink must succeed"
1596 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1600 run_test 41d "pdirops: create vs unlink =============="
1603 touch $DIR1/$tfile-2
1604 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1605 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1606 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1609 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1610 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1614 run_test 41e "pdirops: create and rename (tgt) =============="
1617 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1618 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1619 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1622 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1623 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1627 run_test 41f "pdirops: create and rename (src) =============="
1630 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1631 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1632 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1635 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1636 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1640 run_test 41g "pdirops: create vs getattr =============="
1643 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1644 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1645 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1648 ls -lia $DIR2/ > /dev/null
1649 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1653 run_test 41h "pdirops: create vs readdir =============="
1655 # test 42: unlink and blocking operations
1657 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1658 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1659 mkdir $DIR1/$tfile &
1662 mkdir $DIR2/$tfile && error "mkdir must fail"
1663 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1667 run_test 42a "pdirops: mkdir vs mkdir =============="
1670 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1671 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1672 mkdir $DIR1/$tfile &
1675 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1676 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1680 run_test 42b "pdirops: mkdir vs create =============="
1683 touch $DIR1/$tfile-2
1684 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1685 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1686 mkdir $DIR1/$tfile &
1689 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1690 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1694 run_test 42c "pdirops: mkdir vs link =============="
1697 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1698 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1699 mkdir $DIR1/$tfile &
1702 rmdir $DIR2/$tfile || error "unlink must succeed"
1703 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1707 run_test 42d "pdirops: mkdir vs unlink =============="
1710 touch $DIR1/$tfile-2
1711 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1712 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1713 mkdir $DIR1/$tfile &
1716 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1717 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1721 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1724 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1725 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1726 mkdir $DIR1/$tfile &
1729 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1730 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1734 run_test 42f "pdirops: mkdir and rename (src) =============="
1737 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1738 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1739 mkdir $DIR1/$tfile &
1742 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1743 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1747 run_test 42g "pdirops: mkdir vs getattr =============="
1750 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1751 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1752 mkdir $DIR1/$tfile &
1755 ls -lia $DIR2/ > /dev/null
1756 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1760 run_test 42h "pdirops: mkdir vs readdir =============="
1762 # test 43: unlink and blocking operations
1765 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1766 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1770 mkdir $DIR2/$tfile || error "mkdir must succeed"
1771 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1775 run_test 43a "pdirops: unlink vs mkdir =============="
1779 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1780 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1784 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1785 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1789 run_test 43b "pdirops: unlink vs create =============="
1793 touch $DIR1/$tfile-2
1794 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1795 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1799 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1800 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1804 run_test 43c "pdirops: unlink vs link =============="
1808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1809 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1813 rm $DIR2/$tfile && error "unlink must fail"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1818 run_test 43d "pdirops: unlink vs unlink =============="
1822 touch $DIR1/$tfile-2
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1828 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1833 run_test 43e "pdirops: unlink and rename (tgt) =============="
1837 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1838 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1842 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1843 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1847 run_test 43f "pdirops: unlink and rename (src) =============="
1851 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1852 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1856 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1857 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1861 run_test 43g "pdirops: unlink vs getattr =============="
1865 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1866 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1870 ls -lia $DIR2/ > /dev/null
1871 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1875 run_test 43h "pdirops: unlink vs readdir =============="
1878 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1880 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1881 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1885 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1886 check_pdo_conflict $PID1 &&
1887 { wait $PID1; error "remote mkdir isn't blocked"; }
1891 run_test 43i "pdirops: unlink vs remote mkdir"
1893 # test 44: rename tgt and blocking operations
1895 touch $DIR1/$tfile-2
1896 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1897 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1898 mv $DIR1/$tfile-2 $DIR1/$tfile &
1901 mkdir $DIR2/$tfile && error "mkdir must fail"
1902 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1906 run_test 44a "pdirops: rename tgt vs mkdir =============="
1909 touch $DIR1/$tfile-2
1910 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1911 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1912 mv $DIR1/$tfile-2 $DIR1/$tfile &
1915 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1916 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1920 run_test 44b "pdirops: rename tgt vs create =============="
1923 touch $DIR1/$tfile-2
1924 touch $DIR1/$tfile-3
1925 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1926 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1927 mv $DIR1/$tfile-2 $DIR1/$tfile &
1930 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1931 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1935 run_test 44c "pdirops: rename tgt vs link =============="
1938 touch $DIR1/$tfile-2
1939 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1940 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1941 mv $DIR1/$tfile-2 $DIR1/$tfile &
1944 rm $DIR2/$tfile || error "unlink must succeed"
1945 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1949 run_test 44d "pdirops: rename tgt vs unlink =============="
1953 touch $DIR1/$tfile-2
1954 touch $DIR1/$tfile-3
1955 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1956 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1957 mv $DIR1/$tfile-2 $DIR1/$tfile &
1960 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1961 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1965 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1968 touch $DIR1/$tfile-2
1969 touch $DIR1/$tfile-3
1970 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1971 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1972 mv $DIR1/$tfile-2 $DIR1/$tfile &
1975 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1976 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1980 run_test 44f "pdirops: rename tgt and rename (src) =============="
1983 touch $DIR1/$tfile-2
1984 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1985 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1986 mv $DIR1/$tfile-2 $DIR1/$tfile &
1989 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1990 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1994 run_test 44g "pdirops: rename tgt vs getattr =============="
1997 touch $DIR1/$tfile-2
1998 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1999 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2000 mv $DIR1/$tfile-2 $DIR1/$tfile &
2003 ls -lia $DIR2/ > /dev/null
2004 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2008 run_test 44h "pdirops: rename tgt vs readdir =============="
2010 # test 44: rename tgt and blocking operations
2012 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2013 touch $DIR1/$tfile-2
2014 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2015 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2016 mv $DIR1/$tfile-2 $DIR1/$tfile &
2019 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2020 check_pdo_conflict $PID1 && { wait $PID1;
2021 error "remote mkdir isn't blocked"; }
2025 run_test 44i "pdirops: rename tgt vs remote mkdir"
2027 # test 45: rename src and blocking operations
2030 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2031 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2032 mv $DIR1/$tfile $DIR1/$tfile-2 &
2035 mkdir $DIR2/$tfile || error "mkdir must succeed"
2036 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2040 run_test 45a "pdirops: rename src vs mkdir =============="
2044 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2045 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2046 mv $DIR1/$tfile $DIR1/$tfile-2 &
2049 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2050 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2054 run_test 45b "pdirops: rename src vs create =============="
2058 touch $DIR1/$tfile-3
2059 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2060 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2061 mv $DIR1/$tfile $DIR1/$tfile-2 &
2064 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2065 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2069 run_test 45c "pdirops: rename src vs link =============="
2073 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2074 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2075 mv $DIR1/$tfile $DIR1/$tfile-2 &
2078 rm $DIR2/$tfile && error "unlink must fail"
2079 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2083 run_test 45d "pdirops: rename src vs unlink =============="
2087 touch $DIR1/$tfile-3
2088 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2089 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2090 mv $DIR1/$tfile $DIR1/$tfile-2 &
2093 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2094 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2098 run_test 45e "pdirops: rename src and rename (tgt) =============="
2102 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2103 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2104 mv $DIR1/$tfile $DIR1/$tfile-2 &
2107 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2108 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2112 run_test 45f "pdirops: rename src and rename (src) =============="
2116 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2117 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2118 mv $DIR1/$tfile $DIR1/$tfile-2 &
2121 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2122 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2126 run_test 45g "pdirops: rename src vs getattr =============="
2130 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2131 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2132 mv $DIR1/$tfile $DIR1/$tfile-2 &
2135 ls -lia $DIR2/ > /dev/null
2136 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2140 run_test 45h "pdirops: unlink vs readdir =============="
2143 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2145 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2146 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2147 mv $DIR1/$tfile $DIR1/$tfile-2 &
2150 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2151 check_pdo_conflict $PID1 && { wait $PID1;
2152 error "create remote dir isn't blocked"; }
2156 run_test 45i "pdirops: rename src vs remote mkdir"
2158 # test 46: link and blocking operations
2160 touch $DIR1/$tfile-2
2161 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2162 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2163 link $DIR1/$tfile-2 $DIR1/$tfile &
2166 mkdir $DIR2/$tfile && error "mkdir must fail"
2167 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2171 run_test 46a "pdirops: link vs mkdir =============="
2174 touch $DIR1/$tfile-2
2175 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2176 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2177 link $DIR1/$tfile-2 $DIR1/$tfile &
2180 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2181 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2185 run_test 46b "pdirops: link vs create =============="
2188 touch $DIR1/$tfile-2
2189 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2190 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2191 link $DIR1/$tfile-2 $DIR1/$tfile &
2194 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2195 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2199 run_test 46c "pdirops: link vs link =============="
2202 touch $DIR1/$tfile-2
2203 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2204 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2205 link $DIR1/$tfile-2 $DIR1/$tfile &
2208 rm $DIR2/$tfile || error "unlink must succeed"
2209 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2213 run_test 46d "pdirops: link vs unlink =============="
2216 touch $DIR1/$tfile-2
2217 touch $DIR1/$tfile-3
2218 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2219 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2220 link $DIR1/$tfile-2 $DIR1/$tfile &
2223 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2224 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2228 run_test 46e "pdirops: link and rename (tgt) =============="
2231 touch $DIR1/$tfile-2
2232 touch $DIR1/$tfile-3
2233 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2234 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2235 link $DIR1/$tfile-2 $DIR1/$tfile &
2238 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2239 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2243 run_test 46f "pdirops: link and rename (src) =============="
2246 touch $DIR1/$tfile-2
2247 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2248 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2249 link $DIR1/$tfile-2 $DIR1/$tfile &
2252 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2253 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2257 run_test 46g "pdirops: link vs getattr =============="
2260 touch $DIR1/$tfile-2
2261 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2262 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2263 link $DIR1/$tfile-2 $DIR1/$tfile &
2266 ls -lia $DIR2/ > /dev/null
2267 check_pdo_conflict $PID1 && { wait $PID1;
2268 error "readdir isn't blocked"; }
2272 run_test 46h "pdirops: link vs readdir =============="
2275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2276 touch $DIR1/$tfile-2
2277 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2278 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2279 link $DIR1/$tfile-2 $DIR1/$tfile &
2282 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2283 check_pdo_conflict $PID1 && { wait $PID1;
2284 error "remote mkdir isn't blocked"; }
2288 run_test 46i "pdirops: link vs remote mkdir"
2290 # test 47: remote mkdir and blocking operations
2292 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2293 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2294 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2295 $LFS mkdir -i 1 $DIR1/$tfile &
2298 mkdir $DIR2/$tfile && error "mkdir must fail"
2299 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2303 run_test 47a "pdirops: remote mkdir vs mkdir"
2306 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2307 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2308 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2309 $LFS mkdir -i 1 $DIR1/$tfile &
2312 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2313 check_pdo_conflict $PID1 && { wait $PID1;
2314 error "create isn't blocked"; }
2318 run_test 47b "pdirops: remote mkdir vs create"
2321 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2322 touch $DIR1/$tfile-2
2323 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2324 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2325 $LFS mkdir -i 1 $DIR1/$tfile &
2328 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2329 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2333 run_test 47c "pdirops: remote mkdir vs link"
2336 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2337 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2338 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2339 $LFS mkdir -i 1 $DIR1/$tfile &
2342 rmdir $DIR2/$tfile || error "unlink must succeed"
2343 check_pdo_conflict $PID1 && { wait $PID1;
2344 error "unlink isn't blocked"; }
2348 run_test 47d "pdirops: remote mkdir vs unlink"
2351 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2352 touch $DIR1/$tfile-2
2353 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2354 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2355 $LFS mkdir -i 1 $DIR1/$tfile &
2358 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2359 check_pdo_conflict $PID1 && { wait $PID1;
2360 error "rename isn't blocked"; }
2364 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2367 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2368 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2369 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2370 $LFS mkdir -i 1 $DIR1/$tfile &
2373 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2374 check_pdo_conflict $PID1 && { wait $PID1;
2375 error "rename isn't blocked"; }
2379 run_test 47f "pdirops: remote mkdir and rename (src)"
2382 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2383 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2384 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2385 $LFS mkdir -i 1 $DIR1/$tfile &
2388 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2389 check_pdo_conflict $PID1 && { wait $PID1;
2390 error "getattr isn't blocked"; }
2394 run_test 47g "pdirops: remote mkdir vs getattr"
2398 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2399 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2400 do_facet client "lctl set_param fail_loc=0x410"
2401 $TRUNCATE $DIR2/$tfile $trunc_size
2402 do_facet client "lctl set_param fail_loc=0x0"
2404 size=`stat -c %s $DIR2/$tfile`
2405 [ $size -eq $trunc_size ] || error "wrong size"
2407 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2411 local origfile=/etc/hosts
2413 filesize=$(stat -c %s $origfile)
2415 # create an empty file
2416 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2417 # cache layout lock on both mount point
2418 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2419 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2421 # open and sleep 2 seconds then read
2422 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2426 # create the layout of testing file
2427 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2428 error "dd $DIR1/$tfile failed"
2430 # MULTIOP proc should be able to read enough bytes and exit
2432 kill -0 $pid 2> /dev/null && error "multiop is still there"
2433 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2437 run_test 51a "layout lock: refresh layout should work"
2440 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2441 { skip "Need MDS version at least 2.3.59"; return 0; }
2443 local tmpfile=`mktemp`
2445 # create an empty file
2446 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2448 # delay glimpse so that layout has changed when glimpse finish
2449 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2450 $LCTL set_param fail_loc=0x1404
2451 stat -c %s $DIR2/$tfile |tee $tmpfile &
2455 # create layout of testing file
2456 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2457 error "dd $DIR1/$tfile failed"
2460 local fsize=$(cat $tmpfile)
2462 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2464 rm -f $DIR1/$tfile $tmpfile
2466 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2469 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2471 # set default layout to have 1 stripe
2473 $LFS setstripe -c 1 $DIR1/$tdir
2475 # create a file with empty layout
2476 $MCREATE $DIR1/$tdir/$tfile ||
2477 error "$MCREATE $DIR1/$tdir/$tfile failed"
2479 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2480 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2482 # change the layout of testing file
2483 echo "Setting layout to have $OSTCOUNT stripes ..."
2484 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2488 # write something to the file, it should be blocked on fetching layout
2489 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2490 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2493 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2494 # count to succeed with only 3/4 of the number of stripes (rounded up),
2495 # so creating striped files does not fail if an OST is offline or full
2496 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2497 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2501 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2504 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2505 cancel_lru_locks mdc
2507 # open should grant LAYOUT lock, mmap and read will install pages
2508 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2512 # rss before revoking
2513 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2514 echo "Before revoking layout lock: $br KB mapped"
2516 # delete the file will revoke layout lock
2519 # rss after revoking
2520 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2525 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2527 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2531 echo "==> rename vs getattr vs setxattr should not deadlock"
2532 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2534 do_facet mds1 $LCTL set_param fail_loc=$1
2536 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2544 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2545 wait $PID1 || error "(3) mv failed"
2546 wait $PID2 || error "(4) stat failed"
2553 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2554 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2556 do_facet mds1 $LCTL set_param fail_loc=$1
2558 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2566 $MULTIOP $DIR2/d1/d2 Oc &
2570 stat $DIR/d1 || error "(2) stat failed"
2572 wait $PID1 || error "(3) mv failed"
2573 wait $PID2 || error "(4) stat failed"
2574 wait $PID3 && error "(5) multiop failed"
2580 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2581 save_lustre_params client "llite.*.xattr_cache" > $p
2582 lctl set_param llite.*.xattr_cache 1 ||
2583 { skip "xattr cache is not supported"; return 0; }
2585 #define OBD_FAIL_MDS_RENAME 0x153
2586 #define OBD_FAIL_MDS_RENAME2 0x154
2587 test_54_part1 0x80000153 || error 10
2588 test_54_part1 0x80000154 || error 11
2589 test_54_part2 0x80000153 || error 12
2590 test_54_part2 0x80000154 || error 13
2592 restore_lustre_params < $p
2595 run_test 54 "rename locking"
2598 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2600 #define OBD_FAIL_MDS_RENAME4 0x156
2601 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2603 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2608 wait $PID1 && error "(2) mv succeeded"
2612 run_test 55a "rename vs unlink target dir"
2616 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2618 #define OBD_FAIL_MDS_RENAME4 0x156
2619 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2621 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2626 wait $PID1 && error "(2) mv succeeded"
2630 run_test 55b "rename vs unlink source dir"
2634 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2636 #define OBD_FAIL_MDS_RENAME4 0x156
2637 do_facet mds1 $LCTL set_param fail_loc=0x156
2639 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2643 # while rename is sleeping, open and remove d3
2644 $MULTIOP $DIR2/d3 D_c &
2650 # while rename is sleeping 2nd time, close d3
2652 wait $PID2 || error "(3) multiop failed"
2654 wait $PID1 && error "(2) mv succeeded"
2658 run_test 55c "rename vs unlink orphan target dir"
2664 #define OBD_FAIL_MDS_RENAME3 0x155
2665 do_facet mds1 $LCTL set_param fail_loc=0x155
2666 mv $DIR/f1 $DIR/$tdir &
2670 # while rename is sleeping, create $tdir, but as a directory
2671 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2673 # link in reverse locking order
2674 ln $DIR2/f1 $DIR2/$tdir/
2676 wait $PID1 && error "(2) mv succeeded"
2679 run_test 55d "rename file vs link"
2682 local MDSVER=$(lustre_build_version $SINGLEMDS)
2683 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2684 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2687 test_mkdir -p $DIR1/$tdir
2688 file1=$DIR1/$tdir/file
2689 file2=$DIR2/$tdir/file
2691 echo orig > $file2 || error "Could not create $file2"
2692 version=$($LFS data_version $file1)
2695 echo append >> $file2 || error "Could not append to $file2"
2696 version2=$($LFS data_version $file1)
2697 [ "$version" != "$version2" ] ||
2698 error "append did not change data version: $version"
2701 echo overwrite > $file2 || error "Could not overwrite $file2"
2702 version3=$($LFS data_version $file1)
2703 [ "$version2" != "$version3" ] ||
2704 error "overwrite did not change data version: $version2"
2706 # Truncate before EOF
2707 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2708 version4=$($LFS data_version $file1)
2709 [ "$version3" != "$version4" ] ||
2710 error "truncate did not change data version: $version3"
2712 # Truncate after EOF
2713 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2714 version5=$($LFS data_version $file1)
2715 [ "$version4" != "$version5" ] ||
2716 error "truncate did not change data version: $version4"
2718 # Chmod do not change version
2719 chmod 400 $file2 || error "Could not chmod 400 $file2"
2720 version6=$($LFS data_version $file1)
2721 [ "$version5" == "$version6" ] ||
2722 error "chmod should not change data version: $version5 != $version6"
2724 # Chown do not change version
2725 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2726 version7=$($LFS data_version $file1)
2727 [ "$version5" == "$version7" ] ||
2728 error "chown should not change data version: $version5 != $version7"
2730 run_test 60 "Verify data_version behaviour"
2733 local test_dir=$tdir/test_dir
2735 mkdir -p $DIR1/$tdir
2736 if [ $MDSCOUNT -ge 2 ]; then
2738 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2739 error "Create remote directory failed"
2741 mkdir -p $DIR1/$test_dir
2743 cd $DIR2/$test_dir || error "cd directory failed"
2744 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2746 cd $DIR2/$tdir || error "exit directory"
2748 run_test 70a "cd directory && rm directory"
2750 test_70b() { # LU-2781
2752 mkdir -p $DIR1/$tdir
2754 touch $DIR1/$tdir/file
2755 for ((i = 0; i < 32; i++)); do
2756 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2758 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2760 touch $DIR1/$tdir/file
2761 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2762 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2763 rm -rf $DIR1/$tdir/test_dir ||
2764 error "cannot remove directory after rm_entry"
2765 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2767 run_test 70b "remove files after calling rm_entry"
2770 local server_version=$(lustre_version_code $SINGLEMDS)
2772 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2773 skip "Need MDS version at least 2.1.6" && return
2775 # Patch not applied to 2.2 and 2.3 branches
2776 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2777 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2778 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2781 checkfiemap --test ||
2782 { skip "checkfiemap not runnable: $?" && return; }
2783 # write data this way: hole - data - hole - data
2784 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2785 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2787 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2788 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2789 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2791 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2793 checkfiemap $DIR2/$tfile 81920 ||
2794 error "data is not flushed from client"
2795 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2798 # common case of "create file, copy file" on a single node
2799 # should not flush data from ost
2800 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2801 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2803 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2805 checkfiemap $DIR1/$tfile 81920 ||
2807 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2809 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2811 run_test 71a "correct file map just after write operation is finished"
2814 local server_version=$(lustre_version_code $SINGLEMDS)
2816 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2817 skip "Need MDS version at least 2.1.6" && return
2819 # Patch not applied to 2.2 and 2.3 branches
2820 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2821 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2822 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2824 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2826 checkfiemap --test ||
2827 { skip "error $?: checkfiemap failed" && return; }
2829 mkdir -p $DIR1/$tdir
2831 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2832 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2833 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2835 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2836 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2838 run_test 71b "check fiemap support for stripecount > 1"
2841 local p="$TMP/sanityN-$TESTNAME.parameters"
2844 save_lustre_params client "llite.*.xattr_cache" > $p
2845 lctl set_param llite.*.xattr_cache 1 ||
2846 { skip "xattr cache is not supported"; return 0; }
2849 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2850 error "setfattr1 failed"
2851 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2852 error "getfattr1 failed"
2853 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2854 error "setfattr2 failed"
2855 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2856 error "getfattr2 failed"
2858 # check that trusted.link is consistent
2859 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2860 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2861 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2862 echo "$tlink1 $tlink2"
2863 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2867 restore_lustre_params < $p
2870 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2873 local p="$TMP/sanityN-$TESTNAME.parameters"
2874 save_lustre_params client "llite.*.xattr_cache" > $p
2875 lctl set_param llite.*.xattr_cache 1 ||
2876 { skip "xattr cache is not supported"; return 0; }
2879 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2880 error "setfattr1 failed"
2881 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2882 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2883 clear_stats llite.*.stats
2884 # PR lock should be cached by now on both clients
2885 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2886 # 2 hits for getfattr(0)+getfattr(size)
2887 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2888 error "not cached in $DIR1"
2889 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2890 # 4 hits for more getfattr(0)+getfattr(size)
2891 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2892 error "not cached in $DIR2"
2895 restore_lustre_params < $p
2898 run_test 73 "getxattr should not cause xattr lock cancellation"
2901 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2902 skip "Need MDS version at least 2.4.93" && return
2904 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2905 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2906 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2908 run_test 74 "flock deadlock: different mounts =============="
2912 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2913 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2914 cancel_lru_locks osc
2916 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2919 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2920 $LCTL set_param fail_loc=0x31d
2921 stat -c %s $DIR1/$tfile &
2926 # For bad lock error handler we should ASSERT and got kernel panic here
2928 $LCTL set_param fail_loc=0
2930 run_test 75 "osc: upcall after unuse lock==================="
2933 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2934 skip "Need MDS version at least 2.5.53" && return
2936 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2937 local fcount=$((MDSCOUNT * 256))
2942 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2948 test_mkdir -p $DIR/$tdir
2950 # drop all open locks and close any cached "open" files on the client
2951 cancel_lru_locks mdc
2953 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2954 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2955 local already=${#fid_list[@]}
2956 for (( i = 0; i < $already; i++ )) ; do
2957 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2960 echo -n "opening files: "
2961 ulimit -n $((fcount + 50))
2962 for ((i = 0; i < $fcount; i++)); do
2963 touch $DIR/$tdir/f_$i
2964 local fd=$(free_fd ${fd_list[i]})
2965 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
2970 (( $i % 32 == 0 )) && echo -n "."
2974 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2976 # Possible errors in openfiles FID list.
2977 # 1. Missing FIDs. Check 1
2978 # 2. Extra FIDs. Check 1
2979 # 3. Duplicated FID. Check 2
2980 # 4. Invalid FIDs. Check 2
2981 # 5. Valid FID, points to some other file. Check 3
2984 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
2985 error "${#fid_list[@]} != $fcount (+$already old) open files"
2987 echo -n "closing files: "
2988 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
2989 local close_cmd="exec ${fd_list[fd]}<&-"
2991 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
2993 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
2994 echo "skip old open file $filename"
2996 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3000 rm --interactive=no $filename
3002 error "Nonexisting fid ${fid_list[fid]} listed."
3003 (( $fd % 32 == 0 )) && echo -n "."
3008 ls_op=$(ls $DIR2/$tdir | wc -l)
3010 error "Some openfiles are missing in lproc output"
3014 run_test 76 "Verify MDT open_files listing"
3018 local dir=$DIR/$tdir
3021 mkdir $dir || error "mkdir $dir failed"
3022 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3025 do_nodes $CLIENTS $myRUNAS \
3026 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3027 error "dd at 0 on client failed (1)"
3029 for ((i = 0; i < $n; i++)); do
3030 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3031 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3032 error "dd at ${i}MB on client failed (2)" &
3035 do_nodes $CLIENTS sync;
3036 cancel_lru_locks osc
3038 for ((i = 0; i < $n; i++)); do
3039 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3040 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3041 error "dd at ${i}MB on client failed (3)" &
3044 cancel_lru_locks osc
3046 for ((i = 0; i < $n; i++)); do
3050 rm -rf $dir || error "rm -rf $dir failed"
3053 test_77a() { #LU-3266
3054 oss=$(comma_list $(osts_nodes))
3055 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
3060 run_test 77a "check FIFO NRS policy"
3062 test_77b() { #LU-3266
3063 oss=$(comma_list $(osts_nodes))
3065 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3066 ost.OSS.*.nrs_crrn_quantum=1
3068 echo "policy: crr-n, crrn_quantum 1"
3071 do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
3073 echo "policy: crr-n, crrn_quantum 64"
3077 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3080 run_test 77b "check CRR-N NRS policy"
3085 oss=$(comma_list $(osts_nodes))
3087 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3088 ost.OSS.*.nrs_"$policy"_quantum=1 \
3089 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3090 ost.OSS.*.nrs_"$policy"_supported="reads"
3092 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
3095 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
3096 ost.OSS.*.nrs_${policy}_quantum=64
3098 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
3101 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3102 ost.OSS.*.nrs_${policy}_offset_type="logical"
3103 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3107 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3111 test_77c() { #LU-3266
3115 run_test 77c "check ORR NRS policy"
3117 test_77d() { #LU-3266
3121 run_test 77d "check TRR nrs policy"
3128 do_facet $facet lctl set_param \
3129 ost.OSS.ost_io.nrs_tbf_rule="$*"
3131 error "failed to run operate '$*' on TBF rules"
3134 cleanup_tbf_verify()
3138 echo "cleanup_tbf $DIR/$tdir"
3141 wait_delete_completed
3146 local dir=$DIR/$tdir
3147 local client1=${CLIENT1:-$(hostname)}
3150 local np=$(check_cpt_number ost1)
3151 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3152 echo "cpu_npartitions on ost1 is $np"
3154 mkdir $dir || error "mkdir $dir failed"
3155 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3158 trap cleanup_tbf_verify EXIT
3159 echo "Limited write rate: $1, read rate: $2"
3160 echo "Verify the write rate is under TBF control"
3161 local start=$SECONDS
3162 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3163 bs=1M count=100 oflag=direct 2>&1
3164 local runtime=$((SECONDS - start + 1))
3165 local rate=$(bc <<< "scale=6; 100 / $runtime")
3166 echo "Write runtime is $runtime s, speed is $rate IOPS"
3168 # verify the write rate does not exceed TBF rate limit
3169 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3170 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3172 cancel_lru_locks osc
3174 echo "Verify the read rate is under TBF control"
3176 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3177 bs=1M count=100 iflag=direct 2>&1
3178 runtime=$((SECONDS - start + 1))
3179 rate=$(bc <<< "scale=6; 100 / $runtime")
3180 echo "Read runtime is $runtime s, speed is $rate IOPS"
3182 # verify the read rate does not exceed TBF rate limit
3183 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3184 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3186 cancel_lru_locks osc
3187 cleanup_tbf_verify || error "rm -rf $dir failed"
3191 local server_version=$(lustre_version_code ost1)
3192 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3193 { skip "Need server version newer than 2.7.57"; return 0; }
3195 oss=$(comma_list $(osts_nodes))
3197 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3198 [ $? -ne 0 ] && error "failed to set TBF policy"
3202 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3207 # Only operate rules on ost1 since OSTs might run on the same OSS
3209 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3210 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3211 local client_nids=$(nids_list $address "\\")
3212 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3213 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3217 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3218 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3219 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3223 tbf_rule_operate ost1 "stop\ localhost"
3224 tbf_rule_operate ost1 "stop\ clients"
3225 tbf_rule_operate ost1 "stop\ others"
3228 # Cleanup the TBF policy
3229 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3230 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3234 run_test 77e "check TBF NID nrs policy"
3237 local server_version=$(lustre_version_code ost1)
3238 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3239 { skip "Need server version newer than 2.7.57"; return 0; }
3241 oss=$(comma_list $(osts_nodes))
3243 # Configure jobid_var
3244 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3245 if [ $saved_jobid_var != procname_uid ]; then
3246 set_conf_param_and_check client \
3247 "$LCTL get_param -n jobid_var" \
3248 "$FSNAME.sys.jobid_var" procname_uid
3251 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3252 [ $? -ne 0 ] && error "failed to set TBF policy"
3256 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3261 # Only operate rules on ost1 since OSTs might run on the same OSS
3263 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3264 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3265 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3266 nrs_write_read "$RUNAS"
3269 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3270 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3271 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3272 nrs_write_read "$RUNAS"
3275 tbf_rule_operate ost1 "stop\ runas"
3276 tbf_rule_operate ost1 "stop\ iozone_runas"
3277 tbf_rule_operate ost1 "stop\ dd_runas"
3278 nrs_write_read "$RUNAS"
3280 # Cleanup the TBF policy
3281 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3282 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3283 nrs_write_read "$RUNAS"
3285 local current_jobid_var=$($LCTL get_param -n jobid_var)
3286 if [ $saved_jobid_var != $current_jobid_var ]; then
3287 set_conf_param_and_check client \
3288 "$LCTL get_param -n jobid_var" \
3289 "$FSNAME.sys.jobid_var" $saved_jobid_var
3293 run_test 77f "check TBF JobID nrs policy"
3296 local server_version=$(lustre_version_code ost1)
3297 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3298 { skip "Need server version newer than 2.7.57"; return 0; }
3300 oss=$(comma_list $(osts_nodes))
3302 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3303 [ $? -ne 0 ] && error "failed to set TBF policy"
3305 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3306 [ $? -ne 0 ] && error "failed to set TBF policy"
3310 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3315 # Add a rule that only valid for Jobid TBF. If direct change between
3316 # TBF types is not supported, this operation will fail.
3317 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3319 # Cleanup the TBF policy
3320 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3321 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3324 run_test 77g "Change TBF type directly"
3327 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3328 { skip "Need OST version at least 2.8.55"; return 0; }
3330 local old_policy=$(do_facet ost1 \
3331 lctl get_param ost.OSS.ost_io.nrs_policies)
3334 do_facet ost1 lctl set_param \
3335 ost.OSS.ost_io.nrs_policies="abc"
3336 [ $? -eq 0 ] && error "should return error"
3338 do_facet ost1 lctl set_param \
3339 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3340 [ $? -eq 0 ] && error "should return error"
3342 do_facet ost1 lctl set_param \
3343 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3344 [ $? -eq 0 ] && error "should return error"
3346 do_facet ost1 lctl set_param \
3347 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3348 [ $? -eq 0 ] && error "should return error"
3350 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3351 [ $? -eq 0 ] || error "shouldn't LBUG"
3353 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3357 run_test 77h "Wrong policy name should report error, not LBUG"
3363 local error_message=$3
3365 for rule in $expected; do
3366 rule_number=$((rule_number + 1))
3368 local stop_line=$(($rule_number + 3))
3369 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3371 local output=$(do_facet $facet lctl get_param \
3372 ost.OSS.ost_io.nrs_tbf_rule |
3376 if [ "$output" != "$expected" ]; then
3377 error "$error_message, expected '$expected', got '$output'"
3382 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3383 { skip "Need OST version at least 2.8.55"; return 0; }
3385 for i in $(seq 1 $OSTCOUNT)
3387 do_facet ost"$i" lctl set_param \
3388 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3390 error "failed to set TBF policy"
3393 tbf_rule_check ost1 "default" "error before inserting any rule"
3395 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3396 tbf_rule_check ost1 "before default" \
3397 "error when inserting rule 'before'"
3399 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3400 tbf_rule_check ost1 "before after default" \
3401 "error when inserting rule 'after'"
3403 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3404 tbf_rule_check ost1 "before target after default" \
3405 "error when inserting rule 'target'"
3407 echo "Move before itself"
3408 tbf_rule_operate ost1 "change\ target\ rank=target"
3409 tbf_rule_check ost1 "before target after default" \
3410 "error when moving before itself"
3412 echo "Move to higher rank"
3413 tbf_rule_operate ost1 "change\ target\ rank=before"
3414 tbf_rule_check ost1 "target before after default" \
3415 "error when moving to higher rank"
3417 echo "Move to lower rank"
3418 tbf_rule_operate ost1 "change\ target\ rank=after"
3419 tbf_rule_check ost1 "before target after default" \
3420 "error when moving to lower rank"
3422 echo "Move before default"
3423 tbf_rule_operate ost1 "change\ target\ rank=default"
3424 tbf_rule_check ost1 "before after target default" \
3425 error "error when moving before default"
3427 # Cleanup the TBF policy
3428 do_nodes $(comma_list $(osts_nodes)) \
3429 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3432 run_test 77i "Change rank of TBF rule"
3437 local ost_version=$(lustre_version_code ost1)
3439 [ $ost_version -ge $(version_code 2.9.53) ] ||
3440 { skip "Need OST version at least 2.9.53"; return 0; }
3441 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3446 do_nodes $(comma_list $(osts_nodes)) \
3447 lctl set_param jobid_var=procname_uid \
3448 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3449 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3450 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3451 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3456 do_nodes $(comma_list $(osts_nodes)) \
3457 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3458 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3459 ost.OSS.ost_io.nrs_policies="fifo"
3461 # sleep 3 seconds to wait the tbf policy stop completely,
3462 # or the next test case is possible get -EAGAIN when
3463 # setting the tbf policy
3466 run_test 77j "check TBF-OPCode NRS policy"
3469 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3470 { skip "Need OST version at least 2.9.53"; return 0; }
3472 do_nodes $(comma_list $(osts_nodes)) \
3473 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3474 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3475 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3477 nrs_write_read "$RUNAS"
3478 tbf_verify 20 10 "$RUNAS"
3480 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3481 local client_nids=$(nids_list $address "\\")
3482 do_nodes $(comma_list $(osts_nodes)) \
3483 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3484 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3485 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3486 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3491 do_nodes $(comma_list $(osts_nodes)) \
3492 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3493 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3494 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3496 nrs_write_read "$RUNAS"
3497 tbf_verify 20 20 "$RUNAS"
3499 do_nodes $(comma_list $(osts_nodes)) \
3500 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3501 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3502 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3504 nrs_write_read "$RUNAS"
3505 # with parameter "RUNAS", it will match the latest rule
3506 # "ext_b" first, so the limited write rate is 10.
3507 tbf_verify 10 10 "$RUNAS"
3510 do_nodes $(comma_list $(osts_nodes)) \
3511 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3512 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3513 ost.OSS.ost_io.nrs_policies="fifo"
3517 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3520 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3521 skip "Need OST version at least 2.9.54"
3525 local dir=$DIR/$tdir
3527 mkdir $dir || error "mkdir $dir failed"
3528 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3531 local nodes=$(comma_list $(osts_nodes))
3532 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3533 ost.OSS.ost_io.nrs_delay_min=4 \
3534 ost.OSS.ost_io.nrs_delay_max=4 \
3535 ost.OSS.ost_io.nrs_delay_pct=100
3536 [ $? -ne 0 ] && error "Failed to set delay policy"
3538 local start=$SECONDS
3539 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3540 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3541 oflag=direct conv=fdatasync ||
3542 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3543 error "dd on client failed (1)"; }
3544 local elapsed=$((SECONDS - start))
3546 # NRS delay doesn't do sub-second timing, so a request enqueued at
3547 # 0.9 seconds can be dequeued at 4.0
3548 [ $elapsed -lt 3 ] &&
3549 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3550 error "Single 1M write should take at least 3 seconds"; }
3553 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3554 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3555 oflag=direct conv=fdatasync ||
3556 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3557 error "dd on client failed (2)"; }
3558 elapsed=$((SECONDS - start))
3560 [ $elapsed -lt 30 ] &&
3561 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3562 error "Ten 1M writes should take at least 30 seconds"; }
3564 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3565 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3569 run_test 77l "check NRS Delay slows write RPC processing"
3571 test_78() { #LU-6673
3572 local server_version=$(lustre_version_code ost1)
3573 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3574 { skip "Need server version newer than 2.7.57"; return 0; }
3578 oss=$(comma_list $(osts_nodes))
3579 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3580 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3582 # Valid return codes are:
3583 # 0: Tuning succeeded
3584 # ENODEV: Policy is still stopped
3585 # EAGAIN: Policy is being initialized
3586 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3587 error "Expected set_param to return 0|ENODEV|EAGAIN"
3589 # Cleanup the ORR policy
3590 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3591 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3594 run_test 78 "Enable policy and specify tunings right away"
3597 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3598 test_mkdir -p $DIR/$tdir
3600 # Prevent interference from layout intent RPCs due to
3601 # asynchronous writeback. These will be tested in 130c below.
3602 do_nodes ${CLIENTS:-$HOSTNAME} sync
3604 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3605 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3607 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3608 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3609 local facet=mds$((mdtidx + 1))
3611 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3612 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3616 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3617 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3622 run_test 79 "xattr: intent error"
3625 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3632 mkdir -p $DIR1/$tdir/dir
3633 createmany -o $DIR1/$tdir/dir/f 10 ||
3634 error "create files under remote dir failed $i"
3636 cp /etc/passwd $DIR1/$tdir/$tfile
3638 #migrate open file should fails
3639 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3641 # give multiop a chance to open
3644 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3645 error "migrate open files should failed with open files"
3649 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3650 error "migrate remote dir error"
3652 echo "Finish migration, then checking.."
3653 for file in $(find $DIR1/$tdir); do
3654 mdt_index=$($LFS getstripe -M $file)
3655 [ $mdt_index == $MDTIDX ] ||
3656 error "$file is not on MDT${MDTIDX}"
3659 diff /etc/passwd $DIR1/$tdir/$tfile ||
3660 error "file different after migration"
3662 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3664 run_test 80a "migrate directory when some children is being opened"
3668 kill -9 $migrate_pid
3672 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3673 local migrate_dir1=$DIR1/$tdir/migrate_dir
3674 local migrate_dir2=$DIR2/$tdir/migrate_dir
3675 local migrate_run=$LUSTRE/tests/migrate.sh
3683 trap cleanup_80b EXIT
3684 #prepare migrate directory
3685 mkdir -p $migrate_dir1
3686 for F in {1,2,3,4,5}; do
3687 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3688 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3691 #migrate the directories among MDTs
3694 mdt_idx=$((RANDOM % MDSCOUNT))
3695 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3697 [ $rc -ne 0 -o $rc -ne 16 ] || break
3702 echo "start migration thread $migrate_pid"
3703 #Access the files at the same time
3704 start_time=$(date +%s)
3705 echo "accessing the migrating directory for 5 minutes..."
3707 ls $migrate_dir2 > /dev/null || {
3708 echo "read dir fails"
3711 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3712 echo "access file1 fails"
3716 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3717 echo "access file2/3 fails"
3721 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3722 echo "access file4 fails"
3726 stat $migrate_dir2/file5 > /dev/null || {
3727 echo "stat file5 fails"
3731 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3732 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3733 echo "touch file failed with $rc1"
3737 if [ -e $migrate_dir2/source_file ]; then
3738 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3739 &>/dev/null || rc1=$?
3740 if [ -e $migrate_dir2/link_file ]; then
3741 rm -rf $migrate_dir2/link_file
3744 mrename $migrate_dir2/source_file \
3745 $migrate_dir2/target_file &>/dev/null || rc1=$?
3746 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3747 echo "rename failed with $rc1"
3751 if [ -e $migrate_dir2/target_file ]; then
3752 rm -rf $migrate_dir2/target_file &>/dev/null ||
3755 rm -rf $migrate_dir2/source_file &>/dev/null ||
3758 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3759 echo "unlink failed with $rc1"
3764 end_time=$(date +%s)
3765 duration=$((end_time - start_time))
3766 if [ $((duration % 10)) -eq 0 ]; then
3767 if [ $show_time -eq 1 ]; then
3768 echo "...$duration seconds"
3775 kill -0 $migrate_pid || {
3776 echo "migration stopped 1"
3780 [ $duration -ge 300 ] && break
3783 #check migration are still there
3784 kill -0 $migrate_pid || error "migration stopped 2"
3787 run_test 80b "Accessing directory during migration"
3790 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3794 mkdir -p $DIR1/$tdir
3796 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3797 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3800 touch d0/0 || error "create 0 failed"
3801 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3802 stat d0/0 && error "stat mv filed succeed"
3803 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3804 stat d0/0 || error "stat failed"
3806 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3808 if [ $t -ne 3 ]; then
3809 ls -ai $DIR1/$tdir/d0
3810 error "expect 3 get $t"
3815 run_test 81 "rename and stat under striped directory"
3818 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3819 { skip "Need MDS version at least 2.6.92"; return 0; }
3821 # Client 1 creates a file.
3822 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3824 # Client 2 opens the file.
3825 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3827 # Client 1 makes the file an orphan.
3828 rm $DIR1/$tfile || error "rm"
3829 # Client 2 sets EA "user.multiop".
3831 wait $pid2 || error "multiop 2"
3832 # Client 1 gets EA "user.multiop". This used to fail because the EA
3833 # cache refill would get "trusted.link" from mdd_xattr_list() but
3834 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3837 wait $pid1 || error "multiop 1"
3839 run_test 82 "fsetxattr and fgetxattr on orphan files"
3842 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3849 $LFS mkdir -i1 -c2 $tdir
3854 echo "start pid $pid1 to create/unlink striped directory"
3856 # Access the directory at the same time
3860 stat $tdir > /dev/null 2>&1
3864 echo "start pid $pid2 to stat striped directory"
3872 run_test 83 "access striped directory while it is being created/unlinked"
3875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3880 [ "$SLOW" = "yes" ] && duration=600
3881 # Open/Create under striped directory
3885 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3886 touch $tdir/f{0..3} > /dev/null 2>&1
3890 echo "start pid $pid1 to open/create under striped directory"
3892 # unlink the striped directory at the same time
3896 rm -rf $tdir > /dev/null 2>&1
3900 echo "start pid $pid2 to unlink striped directory"
3909 run_test 90 "open/create and unlink striped directory"
3912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3917 [ "$SLOW" = "yes" ] && duration=600
3918 # chmod striped directory
3922 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3923 chmod go+w $tdir > /dev/null 2>&1
3927 echo "start pid $pid1 to chmod striped directory"
3929 # unlink the striped directory at the same time
3933 rm -rf $tdir > /dev/null 2>&1
3937 echo "start pid $pid2 to unlink striped directory"
3946 run_test 91 "chmod and unlink striped directory"
3949 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3952 local cmd="exec $fd<$DIR1/$tdir"
3953 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3956 trap "eval $cmd" EXIT
3957 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3958 rmdir ../$tdir || error "rmdir ../$tdir fails"
3960 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3961 $LCTL set_param fail_loc=0x1408
3962 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3963 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3964 error "create remote dir succeeds"
3965 $LCTL set_param fail_loc=0
3969 run_test 92 "create remote directory under orphan directory"
3976 mkdir -p $DIR1/$tfile-1/
3977 mkdir -p $DIR2/$tfile-2/
3978 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
3979 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
3980 do_facet $SINGLEMDS lctl set_param -n \
3981 'lod.lustre-MDT*/qos_threshold_rr' 100
3982 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
3983 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
3985 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
3988 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
3992 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
3993 do_facet $SINGLEMDS "lctl set_param -n \
3994 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
3996 $GETSTRIPE $DIR1/$tfile-1/file1
3997 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
3998 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
3999 $GETSTRIPE $DIR2/$tfile-2/file2
4000 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4001 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4002 echo "rc1=$rc1 and rc2=$rc2 "
4003 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4004 error "object allocate on same ost detected"
4006 run_test 93 "alloc_rr should not allocate on same ost"
4008 log "cleanup: ======================================================"
4010 # kill and wait in each test only guarentee script finish, but command in script
4011 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4012 # otherwise umount below will fail
4013 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4018 check_and_cleanup_lustre