6 # bug number for skipped test: 9977/LU-7105 LU-9452
7 ALWAYS_EXCEPT=" 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:
37 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
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
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 $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 $DIR1/$tdir
301 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
302 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
305 $MULTIOP $DIR2/$tdir/multiop Oc && error "expected error, got success"
306 kill -USR1 $MULTIOP_PID || return 2
307 wait $MULTIOP_PID || return 3
308 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
310 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
312 test_14b() { # bug 3192, 7040
313 test_mkdir $DIR1/$tdir
314 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
315 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
318 $TRUNCATE $DIR2/$tdir/multiop 0 && kill -9 $MULTIOP_PID && \
319 error "expected truncate error, got success"
320 kill -USR1 $MULTIOP_PID || return 2
321 wait $MULTIOP_PID || return 3
322 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
323 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
325 run_test 14b "truncate of executing file returns -ETXTBSY ======"
327 test_14c() { # bug 3430, 7040
328 test_mkdir $DIR1/$tdir
329 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
330 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
333 cp /etc/hosts $DIR2/$tdir/multiop && error "expected error, got success"
334 kill -USR1 $MULTIOP_PID || return 2
335 wait $MULTIOP_PID || return 3
336 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
337 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
339 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
341 test_14d() { # bug 10921
342 test_mkdir $DIR1/$tdir
343 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
344 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
348 chmod 600 $DIR1/$tdir/multiop || error "chmod failed"
349 kill -USR1 $MULTIOP_PID || return 2
350 wait $MULTIOP_PID || return 3
351 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
352 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
354 run_test 14d "chmod of executing file is still possible ========"
356 test_15() { # bug 974 - ENOSPC
358 sh oos2.sh $MOUNT1 $MOUNT2
359 wait_delete_completed
360 grant_error=`dmesg | grep "> available"`
361 [ -z "$grant_error" ] || error "$grant_error"
363 run_test 15 "test out-of-space with multiple writers ==========="
366 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
367 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
368 # pass a 2500 operation dual-mount run within the time limit.
369 if [ "$(facet_fstype ost1)" = "zfs" ]; then
370 FSXNUM=$((COUNT / 5))
372 elif [ "$SLOW" = "yes" ]; then
373 FSXNUM=$((COUNT * 5))
381 local file1=$DIR1/$tfile
382 local file2=$DIR2/$tfile
384 # to allocate grant because it may run out due to test_15.
385 $LFS setstripe -c -1 $file1
386 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
387 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
390 $LFS setstripe -c -1 $file1 # b=10919
391 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
392 || error "fsx failed"
395 # O_DIRECT reads and writes must be aligned to the device block size.
396 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
397 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
399 run_test 16 "$FSXNUM iterations of dual-mount fsx"
401 test_17() { # bug 3513, 3667
402 remote_ost_nodsh && skip "remote OST with nodsh" && return
404 lfs setstripe $DIR1/$tfile -i 0 -c 1
405 cp $SAMPLE_FILE $DIR1/$tfile
406 cancel_lru_locks osc > /dev/null
407 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
408 do_facet ost1 lctl set_param fail_loc=0x8000030a
409 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
410 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
412 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
414 run_test 17 "resource creation/LVB creation race ==============="
417 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
420 for idx in {a..z}; do
421 local ptr=EXCEPT_ALWAYS_18$idx
422 [ x${!ptr} = xtrue ] || continue
424 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
427 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
430 run_test 18 "mmap sanity check ================================="
432 test_19() { # bug3811
433 local node=$(facet_active_host ost1)
435 # check whether obdfilter is cache capable at all
436 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
437 echo "not cache-capable obdfilter"
441 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
443 set_osd_param $node '' readcache_max_filesize 4096
444 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
445 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
446 cp $TMP/$tfile $DIR1/$tfile
447 for i in `seq 1 20`; do
448 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
449 cancel_lru_locks osc > /dev/null
450 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
451 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
453 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
454 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
455 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
456 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
458 set_osd_param $node '' readcache_max_filesize $MAX
461 run_test 19 "test concurrent uncached read races ==============="
466 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
467 $MULTIOP $DIR1/f20 Ow8190c
468 $MULTIOP $DIR2/f20 Oz8194w8190c
469 $MULTIOP $DIR1/f20 Oz0r8190c
471 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
473 error $CNTD" page left in cache after lock cancel" || true
475 run_test 20 "test extra readahead page left in cache ===="
482 test_21() { # Bug 5907
483 test_mkdir $DIR1/$tdir
484 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
486 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
487 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
488 test -d $DIR1/$tdir || error "Mounted directory disappeared"
490 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
493 run_test 21 " Try to remove mountpoint on another dir ===="
495 test_23() { # Bug 5972
496 local at_diff=$(do_facet $SINGLEMDS \
497 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
498 echo "atime should be updated while another read" > $DIR1/$tfile
500 # clear the lock(mode: LCK_PW) gotten from creating operation
504 sleep $((at_diff + 1))
506 echo "starting reads"
507 multiop_bg_pause $DIR1/$tfile or20_c || return 1
508 # with SOM and opencache enabled, we need to close a file and cancel
509 # open lock to get atime propogated to MDS
510 kill -USR1 $! || return 2
513 time2=$(stat -c "%X" $DIR/$tfile)
514 echo "new atime is $time2"
516 [ $time2 -gt $time1 ] || error "atime was not updated"
517 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
520 run_test 23 " others should see updated atime while another read===="
524 lfs df || error "lfs df failed"
525 lfs df -ih || error "lfs df -ih failed"
526 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
527 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
528 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
529 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
531 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
532 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
533 lctl --device %$OSC deactivate
534 lfs df -i || error "lfs df -i with deactivated OSC failed"
535 lctl --device %$OSC activate
536 lfs df || error "lfs df with reactivated OSC failed"
538 run_test 24a "lfs df [-ih] [path] test ========================="
542 fsnum=$(lfs_df | grep -c "summary")
543 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
545 run_test 24b "lfs df should show both filesystems ==============="
548 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
550 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
553 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
554 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
556 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
557 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
558 error "setfacl $DIR2/$tdir #1"
559 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
560 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
561 error "setfacl $DIR2/$tdir #2"
562 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
563 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
564 error "setfacl $DIR2/$tdir #3"
565 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
566 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
567 error "setfacl $DIR2/$tdir #4"
568 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
572 run_test 25a "change ACL on one mountpoint be seen on another ==="
575 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
577 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
579 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
582 $LFS mkdir -i 1 $DIR1/$tdir
583 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
584 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
586 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
587 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
588 error "setfacl $DIR2/$tdir #1"
589 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
590 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
591 error "setfacl $DIR2/$tdir #2"
592 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
593 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
594 error "setfacl $DIR2/$tdir #3"
595 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
596 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
597 error "setfacl $DIR2/$tdir #4"
598 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
602 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
605 utime $DIR1/f26a -s $DIR2/f26a || error
607 run_test 26a "allow mtime to get older"
612 echo "aaa" >> $DIR1/$tfile
614 chmod a+x $DIR2/$tfile
615 mt1=`stat -c %Y $DIR1/$tfile`
616 mt2=`stat -c %Y $DIR2/$tfile`
618 if [ x"$mt1" != x"$mt2" ]; then
619 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
622 run_test 26b "sync mtime between ost and mds"
627 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
632 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
637 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
639 lctl set_param -n ldlm.dump_namespaces ""
640 wait $DD1_PID $DD2_PID
641 [ $? -ne 0 ] && lctl dk $TMP/debug || true
643 run_test 27 "align non-overlapping extent locks from request ==="
645 test_28() { # bug 9977
646 ECHO_UUID="ECHO_osc1_UUID"
647 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
649 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
650 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
651 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
655 attach echo_client ECHO_osc1 $ECHO_UUID
659 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
660 $LCTL --device $tECHOID destroy "${tOBJID}:0"
668 # reading of 1st stripe should pass
669 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
670 # reading of 2nd stripe should fail (this stripe was destroyed)
671 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
673 # now, recreating test file
674 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
675 # reading of 1st stripe should pass
676 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
677 # reading of 2nd stripe should pass
678 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
680 run_test 28 "read/write/truncate file with lost stripes"
682 test_29() { # bug 10999
684 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
685 lctl set_param fail_loc=0x8000030f
688 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
691 #bug 11549 - permanently turn test off in b1_5
692 run_test 29 "lock put race between glimpse and enqueue ========="
694 test_30() { #bug #11110, LU-2523
695 test_mkdir $DIR1/$tdir
696 cp -f /bin/bash $DIR1/$tdir/bash
697 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
698 $DIR1/$tdir/bash -c 'sleep 2;
699 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
704 run_test 30 "recreate file race"
707 test_mkdir $DIR1/$tdir
708 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
709 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
710 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
711 lctl set_param fail_loc=0x314
712 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
713 awk 'BEGIN { FS="+" } /in/ {print $1}')
714 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
716 run_test 31a "voluntary cancel / blocking ast race=============="
719 remote_ost || { skip "local OST" && return 0; }
720 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
722 # make sure there is no local locks due to destroy
723 wait_mds_ost_sync || error "wait_mds_ost_sync()"
724 wait_delete_completed || error "wait_delete_completed()"
726 test_mkdir $DIR1/$tdir
727 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
728 cp /etc/hosts $DIR/$tdir/$tfile
729 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
730 lctl set_param fail_loc=0x314
731 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
732 do_facet ost1 lctl set_param fail_loc=0x316
734 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
735 lctl set_param fail_loc=0
736 do_facet ost1 lctl set_param fail_loc=0
737 # cleanup: reconnect the client back
740 run_test 31b "voluntary OST cancel / blocking ast race=============="
742 # enable/disable lockless truncate feature, depending on the arg 0/1
743 enable_lockless_truncate() {
744 lctl set_param -n osc.*.lockless_truncate $1
747 test_32a() { # bug 11270
748 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
749 save_lustre_params client "osc.*.lockless_truncate" > $p
751 enable_lockless_truncate 1
753 lfs setstripe -c -1 $DIR1/$tfile
754 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
756 clear_stats osc.*.osc_stats
758 log "checking cached lockless truncate"
759 $TRUNCATE $DIR1/$tfile 8000000
760 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
761 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
762 error "cached truncate isn't lockless"
764 log "checking not cached lockless truncate"
765 $TRUNCATE $DIR2/$tfile 5000000
766 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
767 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
768 error "not cached truncate isn't lockless"
770 log "disabled lockless truncate"
771 enable_lockless_truncate 0
772 clear_stats osc.*.osc_stats
773 $TRUNCATE $DIR2/$tfile 3000000
774 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
775 [ $(calc_stats osc.*.osc_stats lockless_truncate) -eq 0 ] ||
776 error "lockless truncate disabling failed"
778 # restore lockless_truncate default values
779 restore_lustre_params < $p
782 run_test 32a "lockless truncate"
784 test_32b() { # bug 11270
785 remote_ost_nodsh && skip "remote OST with nodsh" && return
788 local facets=$(get_facets OST)
789 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
791 save_lustre_params client "osc.*.contention_seconds" > $p
792 save_lustre_params $facets \
793 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
794 save_lustre_params $facets \
795 "ldlm.namespaces.filter-*.contended_locks" >> $p
796 save_lustre_params $facets \
797 "ldlm.namespaces.filter-*.contention_seconds" >> $p
798 clear_stats osc.*.osc_stats
800 # agressive lockless i/o settings
801 do_nodes $(comma_list $(osts_nodes)) \
802 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
803 ldlm.namespaces.filter-*.contended_locks=0 \
804 ldlm.namespaces.filter-*.contention_seconds=60"
805 lctl set_param -n osc.*.contention_seconds=60
807 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
809 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
812 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -ne 0 ] ||
813 error "lockless i/o was not triggered"
814 # disable lockless i/o (it is disabled by default)
815 do_nodes $(comma_list $(osts_nodes)) \
816 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
817 ldlm.namespaces.filter-*.contended_locks=32 \
818 ldlm.namespaces.filter-*.contention_seconds=0"
819 # set contention_seconds to 0 at client too, otherwise Lustre still
820 # remembers lock contention
821 lctl set_param -n osc.*.contention_seconds=0
822 clear_stats osc.*.osc_stats
824 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
826 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
829 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -eq 0 ] ||
830 error "lockless i/o works when disabled"
832 restore_lustre_params <$p
835 run_test 32b "lockless i/o"
839 local mdts=$(get_facets MDS)
844 for mds in ${mdts//,/ }; do
846 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
847 xargs readlink -f" ))
848 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
851 stat=$(( stat + val))
856 # commit on sharing tests
858 remote_mds_nodsh && skip "remote MDS with nodsh" && return
860 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
861 [ $CLIENTCOUNT -lt 2 ] &&
862 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
864 local nfiles=${TEST33_NFILES:-10000}
865 local param_file=$TMP/$tfile-params
866 local fstype=$(facet_fstype $SINGLEMDS)
868 save_lustre_params $(get_facets MDS) \
869 "mdt.*.commit_on_sharing" > $param_file
877 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
881 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
883 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
884 echo "=== START createmany old: $jbdold transaction"
885 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")
886 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
887 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
888 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
889 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
890 avgtime=$(( avgtime + elapsed ))
892 eval cos${COS}_jbd=$((avgjbd / 3))
893 eval cos${COS}_time=$((avgtime / 3))
896 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
897 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
898 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
899 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
901 restore_lustre_params < $param_file
905 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
907 # commit on sharing tests
909 remote_mds_nodsh && skip "remote MDS with nodsh" && return
911 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
912 [ $CLIENTCOUNT -ge 2 ] ||
913 { skip "Need two or more clients, have $CLIENTCOUNT" &&
915 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
917 local nfiles=${TEST33_NFILES:-10000}
918 local param_file=$TMP/$tfile-params
920 save_lustre_params $(get_facets MDS) \
921 "mdt.*.commit_on_sharing" > $param_file
930 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
934 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
935 $DIR1/$tdir-\\\$(hostname)-$i"
937 jbdold=$(print_jbd_stat)
938 echo "=== START createmany old: $jbdold transaction"
939 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
940 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
941 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
943 jbdnew=$(print_jbd_stat)
944 jbd=$(( jbdnew - jbdold ))
945 echo "=== END createmany new: $jbdnew transaction : \
946 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
947 avgjbd=$(( avgjbd + jbd ))
948 avgtime=$(( avgtime + elapsed ))
950 eval cos${COS}_jbd=$((avgjbd / 3))
951 eval cos${COS}_time=$((avgtime / 3))
954 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
955 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
956 [ "$cos0_jbd" != 0 ] &&
957 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
958 [ "$cos0_time" != 0 ] &&
959 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
961 restore_lustre_params < $param_file
965 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
968 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
969 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
970 skip "DNE CoS not supported" && return
975 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
976 $LFS mkdir -i 1 $DIR/$tdir/d1
977 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
979 local sync_count=$(do_facet mds1 \
980 "lctl get_param -n mdt.*MDT0000.sync_count")
981 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
983 $LFS mkdir -i 1 $DIR/$tdir/d3
984 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
985 # during sleep remote mkdir should have been committed and canceled
986 # remote lock spontaneously, which shouldn't trigger sync
989 local sync_count=$(do_facet mds1 \
990 "lctl get_param -n mdt.*MDT0000.sync_count")
991 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
993 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
996 local nodes=$(comma_list $(mdts_nodes))
997 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
999 local async_commit_count=$(do_nodes $nodes \
1000 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1001 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
1008 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1009 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1010 skip "DNE CoS not supported" && return
1013 # remote directory create
1015 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1016 # remote directory unlink
1017 $LFS mkdir -i 1 $DIR/$tdir
1018 ops_do_cos "rmdir $DIR/$tdir"
1019 # striped directory create
1021 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1022 # striped directory setattr
1023 $LFS mkdir -c 2 $DIR/$tdir
1025 ops_do_cos "chmod 713 $DIR/$tdir"
1026 # striped directory unlink
1027 $LFS mkdir -c 2 $DIR/$tdir
1029 ops_do_cos "rmdir $DIR/$tdir"
1031 $LFS mkdir -c 2 $DIR/$tdir
1032 $LFS mkdir -i 0 $DIR/$tdir/d1
1033 $LFS mkdir -i 1 $DIR/$tdir/d2
1034 touch $DIR/$tdir/d1/tgt
1035 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1037 $LFS mkdir -c 2 $DIR/$tdir
1038 $LFS mkdir -i 0 $DIR/$tdir/d1
1039 $LFS mkdir -i 1 $DIR/$tdir/d2
1040 touch $DIR/$tdir/d1/src
1041 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1043 $LFS mkdir -i 0 $DIR/$tdir
1044 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1047 run_test 33d "DNE distributed operation should trigger COS"
1050 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1051 [ $CLIENTCOUNT -ge 2 ] ||
1052 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1054 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1055 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1056 skip "DNE CoS not supported" && return
1058 local client2=${CLIENT2:-$(hostname)}
1062 local nodes=$(comma_list $(mdts_nodes))
1063 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1065 $LFS mkdir -c 2 $DIR/$tdir
1066 mkdir $DIR/$tdir/subdir
1067 echo abc > $DIR/$tdir/$tfile
1068 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1069 do_node $client2 touch $DIR/$tdir/subdir
1071 local async_commit_count=$(do_nodes $nodes \
1072 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1073 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1077 run_test 33e "DNE local operation shouldn't trigger COS"
1079 # End commit on sharing tests
1081 get_ost_lock_timeouts() {
1082 local nodes=${1:-$(comma_list $(osts_nodes))}
1084 local locks=$(do_nodes $nodes \
1085 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1093 do_nodes $(comma_list $(osts_nodes)) \
1094 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1095 for i in $(seq $OSTCOUNT); do
1096 wait_osc_import_state client ost$i FULL
1101 remote_ost_nodsh && skip "remote OST with nodsh" && return
1105 trap cleanup_34 EXIT RETURN
1106 for OPER in notimeout timeout ; do
1107 rm $DIR1/$tfile 2>/dev/null
1108 lock_in=$(get_ost_lock_timeouts)
1109 if [ $OPER == "timeout" ] ; then
1110 for j in `seq $OSTCOUNT`; do
1111 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1112 do_facet ost$j lctl set_param fail_loc=0x511
1114 echo lock should expire
1116 for j in `seq $OSTCOUNT`; do
1117 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1118 do_facet ost$j lctl set_param fail_loc=0x512
1120 echo lock should not expire
1122 echo writing on client1
1123 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1125 echo reading on client2
1126 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1127 # wait for a lock timeout
1129 lock_out=$(get_ost_lock_timeouts)
1130 if [ $OPER == "timeout" ] ; then
1131 if [ $lock_in == $lock_out ]; then
1132 error "no lock timeout happened"
1137 if [ $lock_in != $lock_out ]; then
1138 error "lock timeout happened"
1146 run_test 34 "no lock timeout under IO"
1148 test_35() { # bug 17645
1151 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1152 awk '/generation/{print $2}')
1154 generation[count]=$g
1158 test_mkdir $MOUNT1/$tdir
1159 cancel_lru_locks mdc
1161 # Let's initiate -EINTR situation by setting fail_loc and take
1162 # write lock on same file from same client. This will not cause
1163 # bl_ast yet as lock is already in local cache.
1164 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1165 do_facet client "lctl set_param fail_loc=0x80000317"
1166 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1167 let timeout=timeout*3
1169 while test $nr -lt 10; do
1170 log "Race attempt $nr"
1171 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1172 awk '/ldlm_bl_callback/ { print $2 }')
1173 test "x$blk1" = "x" && blk1=0
1174 createmany -o $MOUNT2/$tdir/a 4000 &
1178 # Let's make conflict and bl_ast
1179 ls -la $MOUNT1/$tdir > /dev/null &
1182 log "Wait for $pid1 $pid2 for $timeout sec..."
1184 kill -9 $pid1 $pid2 > /dev/null 2>&1
1186 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1187 awk '/ldlm_bl_callback/ { print $2 }')
1188 test "x$blk2" = "x" && blk2=0
1189 test $blk2 -gt $blk1 && break
1190 rm -fr $MOUNT1/$tdir
1191 cancel_lru_locks mdc
1194 do_facet client "lctl set_param fail_loc=0x0"
1195 df -h $MOUNT1 $MOUNT2
1197 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1198 awk '/generation/{print $2}')
1200 if ! test "$g" -eq "${generation[count]}"; then
1201 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1203 for imp in $list; do
1204 if [ $c = $count ]; then
1209 imp=$(echo "$imp" | awk -F"." '{print $2}')
1210 error "Eviction happened on import $imp"
1215 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1217 test_36() { #bug 16417
1222 test_mkdir $DIR1/$tdir
1223 $LFS setstripe -c -1 $DIR1/$tdir
1226 let SIZE_B=SIZE*1024*1024
1227 sync; sleep 2; sync # wait for delete thread
1228 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1229 wait_destroy_complete || error "wait_destroy_complete failed"
1231 while [ $i -le 10 ]; do
1232 lctl mark "start test - cycle ($i)"
1233 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1234 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1235 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1236 sync # sync data from client cache
1237 sync_all_data # sync data from server cache (delayed allocation)
1239 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1240 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1242 rm -f $DIR1/$tdir/$tfile
1243 kill -USR1 $read_pid
1245 sync; sleep 2; sync # Ensure new statfs
1246 wait_delete_completed
1247 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1248 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1250 # this free space! not used
1251 (( $after_dd <= $after)) ||
1252 error "space leaked after_dd:$after_dd > after:$after"
1256 run_test 36 "handle ESTALE/open-unlink correctly"
1258 test_37() { # bug 18695
1259 test_mkdir $DIR1/$tdir
1260 multiop_bg_pause $DIR1/$tdir D_c || return 1
1262 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1263 createmany -m $DIR2/$tdir/f 10000
1264 # set mtime/atime backward
1265 touch -t 198001010000 $DIR2/$tdir
1266 kill -USR1 $MULTIPID
1267 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1268 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1271 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1273 # this should be set to past
1274 TEST_39_MTIME=`date -d "1 year ago" +%s`
1278 local client1=${CLIENT1:-`hostname`}
1279 local client2=${CLIENT2:-`hostname`}
1281 do_node $client1 "touch $DIR1/$tfile"
1283 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1284 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1285 [ "$mtime1" = $TEST_39_MTIME ] || \
1286 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1288 local d1=`do_node $client1 date +%s`
1289 do_node $client1 'echo hello >> '$DIR1/$tfile
1290 local d2=`do_node $client1 date +%s`
1292 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1293 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1294 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1296 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1298 for (( i=0; i < 2; i++ )) ; do
1299 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1300 [ "$mtime2" = "$mtime3" ] || \
1301 error "mtime ($mtime2) changed (to $mtime3) on rename"
1303 cancel_lru_locks osc
1304 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1307 run_test 39a "test from 11063 =================================="
1310 local client1=${CLIENT1:-`hostname`}
1311 local client2=${CLIENT2:-`hostname`}
1315 local mtime1=`stat -c %Y $DIR1/$tfile`
1316 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1319 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1321 for (( i=0; i < 2; i++ )) ; do
1322 local mtime3=`stat -c %Y $DIR1/$tfile`
1323 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1325 [ "$mtime3" = "$mtime4" ] || \
1326 error "different mtime on clients: $mtime3, $mtime4"
1327 [ "$mtime3" = $TEST_39_MTIME ] || \
1328 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1330 cancel_lru_locks osc
1331 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1334 run_test 39b "11063 problem 1 =================================="
1337 local client1=${CLIENT1:-`hostname`}
1338 local client2=${CLIENT2:-`hostname`}
1340 echo hello > $DIR1/$tfile
1342 local mtime1=`stat -c %Y $DIR1/$tfile`
1343 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1344 [ "$mtime1" = "$mtime2" ] || \
1345 error "create: different mtime on clients: $mtime1, $mtime2"
1348 $TRUNCATE $DIR1/$tfile 1
1350 for (( i=0; i < 2; i++ )) ; do
1351 local mtime3=`stat -c %Y $DIR1/$tfile`
1352 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1354 [ "$mtime3" = "$mtime4" ] || \
1355 error "different mtime on clients: $mtime3, $mtime4"
1356 [ "$mtime3" -gt $mtime2 ] || \
1357 error "truncate did not update mtime: $mtime2, $mtime3"
1359 cancel_lru_locks osc
1360 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1363 run_test 39c "check truncate mtime update ======================"
1365 test_39d() { # LU-7310
1367 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1369 local mtime1=$(stat -c %Y $DIR2/$tfile)
1370 [ "$mtime1" = $TEST_39_MTIME ] ||
1371 error "mtime: $mtime1, should be $TEST_39_MTIME"
1374 # define OBD_FAIL_OSC_NO_GRANT 0x411
1375 $LCTL set_param fail_loc=0x411
1377 local d1=$(date +%s)
1378 echo hello >> $DIR1/$tfile
1379 local d2=$(date +%s)
1381 $LCTL set_param fail_loc=0
1383 cancel_lru_locks osc
1385 local mtime2=$(stat -c %Y $DIR2/$tfile)
1386 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1387 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1389 run_test 39d "sync write should update mtime"
1391 # check that pid exists hence second operation wasn't blocked by first one
1392 # if it is so then there is no conflict, return 0
1393 # else second operation is conflicting with first one, return 1
1394 check_pdo_conflict() {
1397 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1398 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1408 # test 40: check non-blocking operations
1410 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1411 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1412 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1414 mkdir $DIR1/$tfile &
1417 touch $DIR2/$tfile-2
1418 check_pdo_conflict $PID1 || error "create is blocked"
1419 mkdir $DIR2/$tfile-3
1420 check_pdo_conflict $PID1 || error "mkdir is blocked"
1421 link $DIR2/$tfile-2 $DIR2/$tfile-4
1422 check_pdo_conflict $PID1 || error "link is blocked"
1423 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1424 check_pdo_conflict $PID1 || error "rename is blocked"
1425 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1426 check_pdo_conflict $PID1 || error "getattr is blocked"
1427 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1428 rmdir $DIR2/$tfile-3
1429 check_pdo_conflict $PID1 || error "unlink is blocked"
1431 # all operations above shouldn't wait the first one
1432 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1437 run_test 40a "pdirops: create vs others =============="
1440 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1441 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1442 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1443 touch $DIR1/$tfile &
1447 touch $DIR2/$tfile-2
1448 check_pdo_conflict $PID1 || error "create is blocked"
1449 mkdir $DIR2/$tfile-3
1450 check_pdo_conflict $PID1 || error "mkdir is blocked"
1451 link $DIR2/$tfile-2 $DIR2/$tfile-4
1452 check_pdo_conflict $PID1 || error "link is blocked"
1453 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1454 check_pdo_conflict $PID1 || error "rename is blocked"
1455 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1456 check_pdo_conflict $PID1 || error "getattr is blocked"
1457 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1458 rmdir $DIR2/$tfile-3
1459 check_pdo_conflict $PID1 || error "unlink is blocked"
1460 # all operations above shouldn't wait the first one
1462 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1467 run_test 40b "pdirops: open|create and others =============="
1470 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1472 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1473 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1474 link $DIR1/$tfile $DIR1/$tfile-0 &
1478 touch $DIR2/$tfile-2
1479 check_pdo_conflict $PID1 || error "create is blocked"
1480 mkdir $DIR2/$tfile-3
1481 check_pdo_conflict $PID1 || error "mkdir is blocked"
1482 link $DIR2/$tfile-2 $DIR2/$tfile-4
1483 check_pdo_conflict $PID1 || error "link is blocked"
1484 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1485 check_pdo_conflict $PID1 || error "rename is blocked"
1486 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1487 check_pdo_conflict $PID1 || error "getattr is blocked"
1488 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1489 rmdir $DIR2/$tfile-3
1490 check_pdo_conflict $PID1 || error "unlink is blocked"
1492 # all operations above shouldn't wait the first one
1493 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1498 run_test 40c "pdirops: link and others =============="
1501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1503 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1504 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1509 touch $DIR2/$tfile-2
1510 check_pdo_conflict $PID1 || error "create is blocked"
1511 mkdir $DIR2/$tfile-3
1512 check_pdo_conflict $PID1 || error "mkdir is blocked"
1513 link $DIR2/$tfile-2 $DIR2/$tfile-4
1514 check_pdo_conflict $PID1 || error "link is blocked"
1515 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1516 check_pdo_conflict $PID1 || error "rename is blocked"
1517 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1518 check_pdo_conflict $PID1 || error "getattr is blocked"
1519 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1520 rmdir $DIR2/$tfile-3
1521 check_pdo_conflict $PID1 || error "unlink is blocked"
1523 # all operations above shouldn't wait the first one
1524 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1528 run_test 40d "pdirops: unlink and others =============="
1531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1534 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1535 mv $DIR1/$tfile $DIR1/$tfile-0 &
1539 touch $DIR2/$tfile-2
1540 check_pdo_conflict $PID1 || error "create is blocked"
1541 mkdir $DIR2/$tfile-3
1542 check_pdo_conflict $PID1 || error "mkdir is blocked"
1543 link $DIR2/$tfile-2 $DIR2/$tfile-4
1544 check_pdo_conflict $PID1 || error "link is blocked"
1545 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1546 check_pdo_conflict $PID1 || error "getattr is blocked"
1547 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1548 rmdir $DIR2/$tfile-3
1549 check_pdo_conflict $PID1 || error "unlink is blocked"
1551 # all operations above shouldn't wait the first one
1552 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1557 run_test 40e "pdirops: rename and others =============="
1559 # test 41: create blocking operations
1561 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1562 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1563 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1566 mkdir $DIR2/$tfile && error "mkdir must fail"
1567 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1571 run_test 41a "pdirops: create vs mkdir =============="
1574 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1575 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1576 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1579 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1580 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1584 run_test 41b "pdirops: create vs create =============="
1587 touch $DIR1/$tfile-2
1588 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1589 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1590 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1593 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1594 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1598 run_test 41c "pdirops: create vs link =============="
1601 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1602 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1603 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1606 rm $DIR2/$tfile || error "unlink must succeed"
1607 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1611 run_test 41d "pdirops: create vs unlink =============="
1614 touch $DIR1/$tfile-2
1615 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1616 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1617 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1620 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1621 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1625 run_test 41e "pdirops: create and rename (tgt) =============="
1628 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1629 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1630 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1633 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1634 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1638 run_test 41f "pdirops: create and rename (src) =============="
1641 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1642 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1643 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1646 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1647 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1651 run_test 41g "pdirops: create vs getattr =============="
1654 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1655 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1656 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1659 ls -lia $DIR2/ > /dev/null
1660 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1664 run_test 41h "pdirops: create vs readdir =============="
1666 # test 42: unlink and blocking operations
1668 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1669 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1670 mkdir $DIR1/$tfile &
1673 mkdir $DIR2/$tfile && error "mkdir must fail"
1674 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1678 run_test 42a "pdirops: mkdir vs mkdir =============="
1681 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1682 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1683 mkdir $DIR1/$tfile &
1686 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1687 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1691 run_test 42b "pdirops: mkdir vs create =============="
1694 touch $DIR1/$tfile-2
1695 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1696 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1697 mkdir $DIR1/$tfile &
1700 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1701 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1705 run_test 42c "pdirops: mkdir vs link =============="
1708 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1709 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1710 mkdir $DIR1/$tfile &
1713 rmdir $DIR2/$tfile || error "unlink must succeed"
1714 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1718 run_test 42d "pdirops: mkdir vs unlink =============="
1721 touch $DIR1/$tfile-2
1722 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1723 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1724 mkdir $DIR1/$tfile &
1727 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1728 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1732 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1735 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1736 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1737 mkdir $DIR1/$tfile &
1740 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1741 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1745 run_test 42f "pdirops: mkdir and rename (src) =============="
1748 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1749 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1750 mkdir $DIR1/$tfile &
1753 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1754 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1758 run_test 42g "pdirops: mkdir vs getattr =============="
1761 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1762 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1763 mkdir $DIR1/$tfile &
1766 ls -lia $DIR2/ > /dev/null
1767 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1771 run_test 42h "pdirops: mkdir vs readdir =============="
1773 # test 43: unlink and blocking operations
1776 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1777 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1781 mkdir $DIR2/$tfile || error "mkdir must succeed"
1782 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1786 run_test 43a "pdirops: unlink vs mkdir =============="
1790 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1791 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1795 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1796 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1800 run_test 43b "pdirops: unlink vs create =============="
1804 touch $DIR1/$tfile-2
1805 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1806 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1810 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1811 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1815 run_test 43c "pdirops: unlink vs link =============="
1819 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1820 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1824 rm $DIR2/$tfile && error "unlink must fail"
1825 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1829 run_test 43d "pdirops: unlink vs unlink =============="
1833 touch $DIR1/$tfile-2
1834 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1835 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1839 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1840 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1844 run_test 43e "pdirops: unlink and rename (tgt) =============="
1848 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1849 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1853 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1854 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1858 run_test 43f "pdirops: unlink and rename (src) =============="
1862 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1863 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1867 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1868 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1872 run_test 43g "pdirops: unlink vs getattr =============="
1876 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1877 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1881 ls -lia $DIR2/ > /dev/null
1882 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1886 run_test 43h "pdirops: unlink vs readdir =============="
1889 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1891 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1892 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1896 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1897 check_pdo_conflict $PID1 &&
1898 { wait $PID1; error "remote mkdir isn't blocked"; }
1902 run_test 43i "pdirops: unlink vs remote mkdir"
1904 # test 44: rename tgt and blocking operations
1906 touch $DIR1/$tfile-2
1907 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1908 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1909 mv $DIR1/$tfile-2 $DIR1/$tfile &
1912 mkdir $DIR2/$tfile && error "mkdir must fail"
1913 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1917 run_test 44a "pdirops: rename tgt vs mkdir =============="
1920 touch $DIR1/$tfile-2
1921 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1922 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1923 mv $DIR1/$tfile-2 $DIR1/$tfile &
1926 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1927 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1931 run_test 44b "pdirops: rename tgt vs create =============="
1934 touch $DIR1/$tfile-2
1935 touch $DIR1/$tfile-3
1936 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1937 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1938 mv $DIR1/$tfile-2 $DIR1/$tfile &
1941 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1942 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1946 run_test 44c "pdirops: rename tgt vs link =============="
1949 touch $DIR1/$tfile-2
1950 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1951 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1952 mv $DIR1/$tfile-2 $DIR1/$tfile &
1955 rm $DIR2/$tfile || error "unlink must succeed"
1956 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1960 run_test 44d "pdirops: rename tgt vs unlink =============="
1964 touch $DIR1/$tfile-2
1965 touch $DIR1/$tfile-3
1966 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1967 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1968 mv $DIR1/$tfile-2 $DIR1/$tfile &
1971 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1972 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1976 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1979 touch $DIR1/$tfile-2
1980 touch $DIR1/$tfile-3
1981 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1982 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1983 mv $DIR1/$tfile-2 $DIR1/$tfile &
1986 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1987 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1991 run_test 44f "pdirops: rename tgt and rename (src) =============="
1994 touch $DIR1/$tfile-2
1995 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1996 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1997 mv $DIR1/$tfile-2 $DIR1/$tfile &
2000 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2001 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2005 run_test 44g "pdirops: rename tgt vs getattr =============="
2008 touch $DIR1/$tfile-2
2009 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2010 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2011 mv $DIR1/$tfile-2 $DIR1/$tfile &
2014 ls -lia $DIR2/ > /dev/null
2015 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2019 run_test 44h "pdirops: rename tgt vs readdir =============="
2021 # test 44: rename tgt and blocking operations
2023 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2024 touch $DIR1/$tfile-2
2025 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2026 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2027 mv $DIR1/$tfile-2 $DIR1/$tfile &
2030 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2031 check_pdo_conflict $PID1 && { wait $PID1;
2032 error "remote mkdir isn't blocked"; }
2036 run_test 44i "pdirops: rename tgt vs remote mkdir"
2038 # test 45: rename src and blocking operations
2041 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2042 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2043 mv $DIR1/$tfile $DIR1/$tfile-2 &
2046 mkdir $DIR2/$tfile || error "mkdir must succeed"
2047 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2051 run_test 45a "pdirops: rename src vs mkdir =============="
2055 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2056 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2057 mv $DIR1/$tfile $DIR1/$tfile-2 &
2060 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2061 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2065 run_test 45b "pdirops: rename src vs create =============="
2069 touch $DIR1/$tfile-3
2070 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2071 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2072 mv $DIR1/$tfile $DIR1/$tfile-2 &
2075 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2076 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2080 run_test 45c "pdirops: rename src vs link =============="
2084 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2085 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2086 mv $DIR1/$tfile $DIR1/$tfile-2 &
2089 rm $DIR2/$tfile && error "unlink must fail"
2090 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2094 run_test 45d "pdirops: rename src vs unlink =============="
2098 touch $DIR1/$tfile-3
2099 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2100 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2101 mv $DIR1/$tfile $DIR1/$tfile-2 &
2104 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2105 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2109 run_test 45e "pdirops: rename src and rename (tgt) =============="
2113 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2114 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2115 mv $DIR1/$tfile $DIR1/$tfile-2 &
2118 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2119 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2123 run_test 45f "pdirops: rename src and rename (src) =============="
2127 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2128 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2129 mv $DIR1/$tfile $DIR1/$tfile-2 &
2132 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2133 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2137 run_test 45g "pdirops: rename src vs getattr =============="
2141 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2142 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2143 mv $DIR1/$tfile $DIR1/$tfile-2 &
2146 ls -lia $DIR2/ > /dev/null
2147 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2151 run_test 45h "pdirops: unlink vs readdir =============="
2154 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2156 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2157 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2158 mv $DIR1/$tfile $DIR1/$tfile-2 &
2161 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2162 check_pdo_conflict $PID1 && { wait $PID1;
2163 error "create remote dir isn't blocked"; }
2167 run_test 45i "pdirops: rename src vs remote mkdir"
2169 # test 46: link and blocking operations
2171 touch $DIR1/$tfile-2
2172 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2173 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2174 link $DIR1/$tfile-2 $DIR1/$tfile &
2177 mkdir $DIR2/$tfile && error "mkdir must fail"
2178 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2182 run_test 46a "pdirops: link vs mkdir =============="
2185 touch $DIR1/$tfile-2
2186 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2187 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2188 link $DIR1/$tfile-2 $DIR1/$tfile &
2191 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2192 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2196 run_test 46b "pdirops: link vs create =============="
2199 touch $DIR1/$tfile-2
2200 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2201 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2202 link $DIR1/$tfile-2 $DIR1/$tfile &
2205 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2206 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2210 run_test 46c "pdirops: link vs link =============="
2213 touch $DIR1/$tfile-2
2214 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2215 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2216 link $DIR1/$tfile-2 $DIR1/$tfile &
2219 rm $DIR2/$tfile || error "unlink must succeed"
2220 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2224 run_test 46d "pdirops: link vs unlink =============="
2227 touch $DIR1/$tfile-2
2228 touch $DIR1/$tfile-3
2229 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2230 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2231 link $DIR1/$tfile-2 $DIR1/$tfile &
2234 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2235 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2239 run_test 46e "pdirops: link and rename (tgt) =============="
2242 touch $DIR1/$tfile-2
2243 touch $DIR1/$tfile-3
2244 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2245 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2246 link $DIR1/$tfile-2 $DIR1/$tfile &
2249 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2250 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2254 run_test 46f "pdirops: link and rename (src) =============="
2257 touch $DIR1/$tfile-2
2258 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2259 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2260 link $DIR1/$tfile-2 $DIR1/$tfile &
2263 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2264 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2268 run_test 46g "pdirops: link vs getattr =============="
2271 touch $DIR1/$tfile-2
2272 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2273 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2274 link $DIR1/$tfile-2 $DIR1/$tfile &
2277 ls -lia $DIR2/ > /dev/null
2278 check_pdo_conflict $PID1 && { wait $PID1;
2279 error "readdir isn't blocked"; }
2283 run_test 46h "pdirops: link vs readdir =============="
2286 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2287 touch $DIR1/$tfile-2
2288 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2289 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2290 link $DIR1/$tfile-2 $DIR1/$tfile &
2293 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2294 check_pdo_conflict $PID1 && { wait $PID1;
2295 error "remote mkdir isn't blocked"; }
2299 run_test 46i "pdirops: link vs remote mkdir"
2301 # test 47: remote mkdir and blocking operations
2303 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2304 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2305 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2306 $LFS mkdir -i 1 $DIR1/$tfile &
2309 mkdir $DIR2/$tfile && error "mkdir must fail"
2310 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2314 run_test 47a "pdirops: remote mkdir vs mkdir"
2317 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2318 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2319 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2320 $LFS mkdir -i 1 $DIR1/$tfile &
2323 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2324 check_pdo_conflict $PID1 && { wait $PID1;
2325 error "create isn't blocked"; }
2329 run_test 47b "pdirops: remote mkdir vs create"
2332 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2333 touch $DIR1/$tfile-2
2334 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2335 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2336 $LFS mkdir -i 1 $DIR1/$tfile &
2339 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2340 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2344 run_test 47c "pdirops: remote mkdir vs link"
2347 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2348 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2349 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2350 $LFS mkdir -i 1 $DIR1/$tfile &
2353 rmdir $DIR2/$tfile || error "unlink must succeed"
2354 check_pdo_conflict $PID1 && { wait $PID1;
2355 error "unlink isn't blocked"; }
2359 run_test 47d "pdirops: remote mkdir vs unlink"
2362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2363 touch $DIR1/$tfile-2
2364 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2365 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2366 $LFS mkdir -i 1 $DIR1/$tfile &
2369 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2370 check_pdo_conflict $PID1 && { wait $PID1;
2371 error "rename isn't blocked"; }
2375 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2378 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2379 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2380 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2381 $LFS mkdir -i 1 $DIR1/$tfile &
2384 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2385 check_pdo_conflict $PID1 && { wait $PID1;
2386 error "rename isn't blocked"; }
2390 run_test 47f "pdirops: remote mkdir and rename (src)"
2393 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2394 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2395 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2396 $LFS mkdir -i 1 $DIR1/$tfile &
2399 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2400 check_pdo_conflict $PID1 && { wait $PID1;
2401 error "getattr isn't blocked"; }
2405 run_test 47g "pdirops: remote mkdir vs getattr"
2409 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2410 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2411 do_facet client "lctl set_param fail_loc=0x410"
2412 $TRUNCATE $DIR2/$tfile $trunc_size
2413 do_facet client "lctl set_param fail_loc=0x0"
2415 size=`stat -c %s $DIR2/$tfile`
2416 [ $size -eq $trunc_size ] || error "wrong size"
2418 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2422 local origfile=/etc/hosts
2424 filesize=$(stat -c %s $origfile)
2426 # create an empty file
2427 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2428 # cache layout lock on both mount point
2429 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2430 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2432 # open and sleep 2 seconds then read
2433 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2437 # create the layout of testing file
2438 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2439 error "dd $DIR1/$tfile failed"
2441 # MULTIOP proc should be able to read enough bytes and exit
2442 for ((i = 0; i < 6; i++)); do
2444 kill -0 $pid || break
2446 kill -0 $pid 2> /dev/null && error "multiop is still there"
2447 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2451 run_test 51a "layout lock: refresh layout should work"
2454 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2455 { skip "Need MDS version at least 2.3.59"; return 0; }
2457 local tmpfile=`mktemp`
2459 # create an empty file
2460 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2462 # delay glimpse so that layout has changed when glimpse finish
2463 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2464 $LCTL set_param fail_loc=0x1404
2465 stat -c %s $DIR2/$tfile |tee $tmpfile &
2469 # create layout of testing file
2470 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2471 error "dd $DIR1/$tfile failed"
2474 local fsize=$(cat $tmpfile)
2476 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2478 rm -f $DIR1/$tfile $tmpfile
2480 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2483 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2485 # set default layout to have 1 stripe
2487 $LFS setstripe -c 1 $DIR1/$tdir
2489 # create a file with empty layout
2490 $MCREATE $DIR1/$tdir/$tfile ||
2491 error "$MCREATE $DIR1/$tdir/$tfile failed"
2493 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2494 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2496 # change the layout of testing file
2497 echo "Setting layout to have $OSTCOUNT stripes ..."
2498 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2502 # write something to the file, it should be blocked on fetching layout
2503 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2504 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2507 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2508 # count to succeed with only 3/4 of the number of stripes (rounded up),
2509 # so creating striped files does not fail if an OST is offline or full
2510 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2511 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2515 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2518 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2519 cancel_lru_locks mdc
2521 # open should grant LAYOUT lock, mmap and read will install pages
2522 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2526 # rss before revoking
2527 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2528 echo "Before revoking layout lock: $br KB mapped"
2530 # delete the file will revoke layout lock
2533 # rss after revoking
2534 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2539 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2541 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2545 echo "==> rename vs getattr vs setxattr should not deadlock"
2546 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2548 do_facet mds1 $LCTL set_param fail_loc=$1
2550 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2558 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2559 wait $PID1 || error "(3) mv failed"
2560 wait $PID2 || error "(4) stat failed"
2567 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2568 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2570 do_facet mds1 $LCTL set_param fail_loc=$1
2572 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2580 $MULTIOP $DIR2/d1/d2 Oc &
2584 stat $DIR/d1 || error "(2) stat failed"
2586 wait $PID1 || error "(3) mv failed"
2587 wait $PID2 || error "(4) stat failed"
2588 wait $PID3 && error "(5) multiop failed"
2594 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2595 save_lustre_params client "llite.*.xattr_cache" > $p
2596 lctl set_param llite.*.xattr_cache 1 ||
2597 { skip "xattr cache is not supported"; return 0; }
2599 #define OBD_FAIL_MDS_RENAME 0x153
2600 #define OBD_FAIL_MDS_RENAME2 0x154
2601 test_54_part1 0x80000153 || error 10
2602 test_54_part1 0x80000154 || error 11
2603 test_54_part2 0x80000153 || error 12
2604 test_54_part2 0x80000154 || error 13
2606 restore_lustre_params < $p
2609 run_test 54 "rename locking"
2612 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2614 #define OBD_FAIL_MDS_RENAME4 0x156
2615 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2617 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2622 wait $PID1 && error "(2) mv succeeded"
2626 run_test 55a "rename vs unlink target dir"
2630 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2632 #define OBD_FAIL_MDS_RENAME4 0x156
2633 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2635 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2640 wait $PID1 && error "(2) mv succeeded"
2644 run_test 55b "rename vs unlink source dir"
2648 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2650 #define OBD_FAIL_MDS_RENAME4 0x156
2651 do_facet mds1 $LCTL set_param fail_loc=0x156
2653 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2657 # while rename is sleeping, open and remove d3
2658 $MULTIOP $DIR2/d3 D_c &
2664 # while rename is sleeping 2nd time, close d3
2666 wait $PID2 || error "(3) multiop failed"
2668 wait $PID1 && error "(2) mv succeeded"
2672 run_test 55c "rename vs unlink orphan target dir"
2678 #define OBD_FAIL_MDS_RENAME3 0x155
2679 do_facet mds1 $LCTL set_param fail_loc=0x155
2680 mv $DIR/f1 $DIR/$tdir &
2684 # while rename is sleeping, create $tdir, but as a directory
2685 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2687 # link in reverse locking order
2688 ln $DIR2/f1 $DIR2/$tdir/
2690 wait $PID1 && error "(2) mv succeeded"
2693 run_test 55d "rename file vs link"
2696 local MDSVER=$(lustre_build_version $SINGLEMDS)
2697 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2698 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2701 test_mkdir $DIR1/$tdir
2702 file1=$DIR1/$tdir/file
2703 file2=$DIR2/$tdir/file
2705 echo orig > $file2 || error "Could not create $file2"
2706 version=$($LFS data_version $file1)
2709 echo append >> $file2 || error "Could not append to $file2"
2710 version2=$($LFS data_version $file1)
2711 [ "$version" != "$version2" ] ||
2712 error "append did not change data version: $version"
2715 echo overwrite > $file2 || error "Could not overwrite $file2"
2716 version3=$($LFS data_version $file1)
2717 [ "$version2" != "$version3" ] ||
2718 error "overwrite did not change data version: $version2"
2720 # Truncate before EOF
2721 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2722 version4=$($LFS data_version $file1)
2723 [ "$version3" != "$version4" ] ||
2724 error "truncate did not change data version: $version3"
2726 # Truncate after EOF
2727 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2728 version5=$($LFS data_version $file1)
2729 [ "$version4" != "$version5" ] ||
2730 error "truncate did not change data version: $version4"
2732 # Chmod do not change version
2733 chmod 400 $file2 || error "Could not chmod 400 $file2"
2734 version6=$($LFS data_version $file1)
2735 [ "$version5" == "$version6" ] ||
2736 error "chmod should not change data version: $version5 != $version6"
2738 # Chown do not change version
2739 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2740 version7=$($LFS data_version $file1)
2741 [ "$version5" == "$version7" ] ||
2742 error "chown should not change data version: $version5 != $version7"
2744 run_test 60 "Verify data_version behaviour"
2747 local test_dir=$tdir/test_dir
2749 mkdir -p $DIR1/$tdir
2750 if [ $MDSCOUNT -ge 2 ]; then
2752 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2753 error "Create remote directory failed"
2755 mkdir -p $DIR1/$test_dir
2757 cd $DIR2/$test_dir || error "cd directory failed"
2758 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2760 cd $DIR2/$tdir || error "exit directory"
2762 run_test 70a "cd directory && rm directory"
2764 test_70b() { # LU-2781
2766 mkdir -p $DIR1/$tdir
2768 touch $DIR1/$tdir/file
2769 for ((i = 0; i < 32; i++)); do
2770 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2772 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2774 touch $DIR1/$tdir/file
2775 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2776 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2777 rm -rf $DIR1/$tdir/test_dir ||
2778 error "cannot remove directory after rm_entry"
2779 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2781 run_test 70b "remove files after calling rm_entry"
2784 local server_version=$(lustre_version_code $SINGLEMDS)
2786 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2787 skip "Need MDS version at least 2.1.6" && return
2789 # Patch not applied to 2.2 and 2.3 branches
2790 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2791 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2792 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2795 checkfiemap --test ||
2796 { skip "checkfiemap not runnable: $?" && return; }
2797 # write data this way: hole - data - hole - data
2798 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2799 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2801 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2802 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2803 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2805 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2807 checkfiemap $DIR2/$tfile 81920 ||
2808 error "data is not flushed from client"
2809 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2812 # common case of "create file, copy file" on a single node
2813 # should not flush data from ost
2814 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2815 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2817 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2819 checkfiemap $DIR1/$tfile 81920 ||
2821 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2823 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2825 run_test 71a "correct file map just after write operation is finished"
2828 local server_version=$(lustre_version_code $SINGLEMDS)
2830 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2831 skip "Need MDS version at least 2.1.6" && return
2833 # Patch not applied to 2.2 and 2.3 branches
2834 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2835 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2836 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2838 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2840 checkfiemap --test ||
2841 { skip "error $?: checkfiemap failed" && return; }
2843 mkdir -p $DIR1/$tdir
2845 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2846 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2847 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2849 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2850 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2852 run_test 71b "check fiemap support for stripecount > 1"
2855 local p="$TMP/sanityN-$TESTNAME.parameters"
2858 save_lustre_params client "llite.*.xattr_cache" > $p
2859 lctl set_param llite.*.xattr_cache 1 ||
2860 { skip "xattr cache is not supported"; return 0; }
2863 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2864 error "setfattr1 failed"
2865 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2866 error "getfattr1 failed"
2867 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2868 error "setfattr2 failed"
2869 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2870 error "getfattr2 failed"
2872 # check that trusted.link is consistent
2873 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2874 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2875 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2876 echo "$tlink1 $tlink2"
2877 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2881 restore_lustre_params < $p
2884 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2887 local p="$TMP/sanityN-$TESTNAME.parameters"
2888 save_lustre_params client "llite.*.xattr_cache" > $p
2889 lctl set_param llite.*.xattr_cache 1 ||
2890 { skip "xattr cache is not supported"; return 0; }
2893 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2894 error "setfattr1 failed"
2895 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2896 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2897 clear_stats llite.*.stats
2898 # PR lock should be cached by now on both clients
2899 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2900 # 2 hits for getfattr(0)+getfattr(size)
2901 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2902 error "not cached in $DIR1"
2903 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2904 # 4 hits for more getfattr(0)+getfattr(size)
2905 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2906 error "not cached in $DIR2"
2909 restore_lustre_params < $p
2912 run_test 73 "getxattr should not cause xattr lock cancellation"
2915 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2916 skip "Need MDS version at least 2.4.93" && return
2918 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2919 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2920 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2922 run_test 74 "flock deadlock: different mounts =============="
2926 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2927 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2928 cancel_lru_locks osc
2930 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2933 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2934 $LCTL set_param fail_loc=0x31d
2935 stat -c %s $DIR1/$tfile &
2940 # For bad lock error handler we should ASSERT and got kernel panic here
2942 $LCTL set_param fail_loc=0
2944 run_test 75 "osc: upcall after unuse lock==================="
2947 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2948 skip "Need MDS version at least 2.5.53" && return
2950 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2951 local fcount=$((MDSCOUNT * 256))
2956 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2962 test_mkdir $DIR/$tdir
2964 # drop all open locks and close any cached "open" files on the client
2965 cancel_lru_locks mdc
2967 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2968 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2969 local already=${#fid_list[@]}
2970 for (( i = 0; i < $already; i++ )) ; do
2971 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2974 echo -n "opening files: "
2975 ulimit -n $((fcount + 50))
2976 for ((i = 0; i < $fcount; i++)); do
2977 touch $DIR/$tdir/f_$i
2978 local fd=$(free_fd ${fd_list[i]})
2979 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
2984 (( $i % 32 == 0 )) && echo -n "."
2988 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2990 # Possible errors in openfiles FID list.
2991 # 1. Missing FIDs. Check 1
2992 # 2. Extra FIDs. Check 1
2993 # 3. Duplicated FID. Check 2
2994 # 4. Invalid FIDs. Check 2
2995 # 5. Valid FID, points to some other file. Check 3
2998 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
2999 error "${#fid_list[@]} != $fcount (+$already old) open files"
3001 echo -n "closing files: "
3002 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3003 local close_cmd="exec ${fd_list[fd]}<&-"
3005 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3007 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3008 echo "skip old open file $filename"
3010 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3014 rm --interactive=no $filename
3016 error "Nonexisting fid ${fid_list[fid]} listed."
3017 (( $fd % 32 == 0 )) && echo -n "."
3022 ls_op=$(ls $DIR2/$tdir | wc -l)
3024 error "Some openfiles are missing in lproc output"
3028 run_test 76 "Verify MDT open_files listing"
3032 local dir=$DIR/$tdir
3035 mkdir $dir || error "mkdir $dir failed"
3036 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3039 do_nodes $CLIENTS $myRUNAS \
3040 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3041 error "dd at 0 on client failed (1)"
3043 for ((i = 0; i < $n; i++)); do
3044 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3045 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3046 error "dd at ${i}MB on client failed (2)" &
3049 do_nodes $CLIENTS sync;
3050 cancel_lru_locks osc
3052 for ((i = 0; i < $n; i++)); do
3053 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3054 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3055 error "dd at ${i}MB on client failed (3)" &
3058 cancel_lru_locks osc
3060 for ((i = 0; i < $n; i++)); do
3064 rm -rf $dir || error "rm -rf $dir failed"
3067 test_77a() { #LU-3266
3068 oss=$(comma_list $(osts_nodes))
3069 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
3074 run_test 77a "check FIFO NRS policy"
3076 test_77b() { #LU-3266
3077 oss=$(comma_list $(osts_nodes))
3079 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3080 ost.OSS.*.nrs_crrn_quantum=1
3082 echo "policy: crr-n, crrn_quantum 1"
3085 do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
3087 echo "policy: crr-n, crrn_quantum 64"
3091 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3094 run_test 77b "check CRR-N NRS policy"
3099 oss=$(comma_list $(osts_nodes))
3101 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3102 ost.OSS.*.nrs_"$policy"_quantum=1 \
3103 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3104 ost.OSS.*.nrs_"$policy"_supported="reads"
3106 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
3109 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
3110 ost.OSS.*.nrs_${policy}_quantum=64
3112 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
3115 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3116 ost.OSS.*.nrs_${policy}_offset_type="logical"
3117 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3121 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3125 test_77c() { #LU-3266
3129 run_test 77c "check ORR NRS policy"
3131 test_77d() { #LU-3266
3135 run_test 77d "check TRR nrs policy"
3142 do_facet $facet lctl set_param \
3143 ost.OSS.ost_io.nrs_tbf_rule="$*"
3145 error "failed to run operate '$*' on TBF rules"
3148 cleanup_tbf_verify()
3152 echo "cleanup_tbf $DIR/$tdir"
3155 wait_delete_completed
3160 local dir=$DIR/$tdir
3161 local client1=${CLIENT1:-$(hostname)}
3164 local np=$(check_cpt_number ost1)
3165 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3166 echo "cpu_npartitions on ost1 is $np"
3168 mkdir $dir || error "mkdir $dir failed"
3169 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3172 trap cleanup_tbf_verify EXIT
3173 echo "Limited write rate: $1, read rate: $2"
3174 echo "Verify the write rate is under TBF control"
3175 local start=$SECONDS
3176 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3177 bs=1M count=100 oflag=direct 2>&1
3178 local runtime=$((SECONDS - start + 1))
3179 local rate=$(bc <<< "scale=6; 100 / $runtime")
3180 echo "Write runtime is $runtime s, speed is $rate IOPS"
3182 # verify the write rate does not exceed TBF rate limit
3183 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3184 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3186 cancel_lru_locks osc
3188 echo "Verify the read rate is under TBF control"
3190 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3191 bs=1M count=100 iflag=direct 2>&1
3192 runtime=$((SECONDS - start + 1))
3193 rate=$(bc <<< "scale=6; 100 / $runtime")
3194 echo "Read runtime is $runtime s, speed is $rate IOPS"
3196 # verify the read rate does not exceed TBF rate limit
3197 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3198 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3200 cancel_lru_locks osc
3201 cleanup_tbf_verify || error "rm -rf $dir failed"
3205 local server_version=$(lustre_version_code ost1)
3206 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3207 { skip "Need server version newer than 2.7.57"; return 0; }
3209 oss=$(comma_list $(osts_nodes))
3211 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3212 [ $? -ne 0 ] && error "failed to set TBF policy"
3216 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3221 # Only operate rules on ost1 since OSTs might run on the same OSS
3223 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3224 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3225 local client_nids=$(nids_list $address "\\")
3226 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3227 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3231 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3232 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3233 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3237 tbf_rule_operate ost1 "stop\ localhost"
3238 tbf_rule_operate ost1 "stop\ clients"
3239 tbf_rule_operate ost1 "stop\ others"
3242 # Cleanup the TBF policy
3243 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3244 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3248 run_test 77e "check TBF NID nrs policy"
3251 local server_version=$(lustre_version_code ost1)
3252 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3253 { skip "Need server version newer than 2.7.57"; return 0; }
3255 oss=$(comma_list $(osts_nodes))
3257 # Configure jobid_var
3258 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3259 if [ $saved_jobid_var != procname_uid ]; then
3260 set_conf_param_and_check client \
3261 "$LCTL get_param -n jobid_var" \
3262 "$FSNAME.sys.jobid_var" procname_uid
3265 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3266 [ $? -ne 0 ] && error "failed to set TBF policy"
3270 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3275 # Only operate rules on ost1 since OSTs might run on the same OSS
3277 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3278 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3279 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3280 nrs_write_read "$RUNAS"
3283 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3284 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3285 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3286 nrs_write_read "$RUNAS"
3289 tbf_rule_operate ost1 "stop\ runas"
3290 tbf_rule_operate ost1 "stop\ iozone_runas"
3291 tbf_rule_operate ost1 "stop\ dd_runas"
3292 nrs_write_read "$RUNAS"
3294 # Cleanup the TBF policy
3295 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3296 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3297 nrs_write_read "$RUNAS"
3299 local current_jobid_var=$($LCTL get_param -n jobid_var)
3300 if [ $saved_jobid_var != $current_jobid_var ]; then
3301 set_conf_param_and_check client \
3302 "$LCTL get_param -n jobid_var" \
3303 "$FSNAME.sys.jobid_var" $saved_jobid_var
3307 run_test 77f "check TBF JobID nrs policy"
3310 local server_version=$(lustre_version_code ost1)
3311 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3312 { skip "Need server version newer than 2.7.57"; return 0; }
3314 oss=$(comma_list $(osts_nodes))
3316 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3317 [ $? -ne 0 ] && error "failed to set TBF policy"
3319 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3320 [ $? -ne 0 ] && error "failed to set TBF policy"
3324 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3329 # Add a rule that only valid for Jobid TBF. If direct change between
3330 # TBF types is not supported, this operation will fail.
3331 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3333 # Cleanup the TBF policy
3334 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3335 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3338 run_test 77g "Change TBF type directly"
3341 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3342 { skip "Need OST version at least 2.8.55"; return 0; }
3344 local old_policy=$(do_facet ost1 \
3345 lctl get_param ost.OSS.ost_io.nrs_policies)
3348 do_facet ost1 lctl set_param \
3349 ost.OSS.ost_io.nrs_policies="abc"
3350 [ $? -eq 0 ] && error "should return error"
3352 do_facet ost1 lctl set_param \
3353 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3354 [ $? -eq 0 ] && error "should return error"
3356 do_facet ost1 lctl set_param \
3357 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3358 [ $? -eq 0 ] && error "should return error"
3360 do_facet ost1 lctl set_param \
3361 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3362 [ $? -eq 0 ] && error "should return error"
3364 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3365 [ $? -eq 0 ] || error "shouldn't LBUG"
3367 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3371 run_test 77h "Wrong policy name should report error, not LBUG"
3377 local error_message=$3
3379 for rule in $expected; do
3380 rule_number=$((rule_number + 1))
3382 local stop_line=$(($rule_number + 3))
3383 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3385 local output=$(do_facet $facet lctl get_param \
3386 ost.OSS.ost_io.nrs_tbf_rule |
3390 if [ "$output" != "$expected" ]; then
3391 error "$error_message, expected '$expected', got '$output'"
3396 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3397 { skip "Need OST version at least 2.8.55"; return 0; }
3399 for i in $(seq 1 $OSTCOUNT)
3401 do_facet ost"$i" lctl set_param \
3402 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3404 error "failed to set TBF policy"
3407 tbf_rule_check ost1 "default" "error before inserting any rule"
3409 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3410 tbf_rule_check ost1 "before default" \
3411 "error when inserting rule 'before'"
3413 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3414 tbf_rule_check ost1 "before after default" \
3415 "error when inserting rule 'after'"
3417 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3418 tbf_rule_check ost1 "before target after default" \
3419 "error when inserting rule 'target'"
3421 echo "Move before itself"
3422 tbf_rule_operate ost1 "change\ target\ rank=target"
3423 tbf_rule_check ost1 "before target after default" \
3424 "error when moving before itself"
3426 echo "Move to higher rank"
3427 tbf_rule_operate ost1 "change\ target\ rank=before"
3428 tbf_rule_check ost1 "target before after default" \
3429 "error when moving to higher rank"
3431 echo "Move to lower rank"
3432 tbf_rule_operate ost1 "change\ target\ rank=after"
3433 tbf_rule_check ost1 "before target after default" \
3434 "error when moving to lower rank"
3436 echo "Move before default"
3437 tbf_rule_operate ost1 "change\ target\ rank=default"
3438 tbf_rule_check ost1 "before after target default" \
3439 error "error when moving before default"
3441 # Cleanup the TBF policy
3442 do_nodes $(comma_list $(osts_nodes)) \
3443 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3446 run_test 77i "Change rank of TBF rule"
3451 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.60) ]; then
3456 do_nodes $(comma_list $(osts_nodes)) \
3457 lctl set_param jobid_var=procname_uid \
3458 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3459 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3460 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3461 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3466 do_nodes $(comma_list $(osts_nodes)) \
3467 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3468 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3469 ost.OSS.ost_io.nrs_policies="fifo"
3471 # sleep 3 seconds to wait the tbf policy stop completely,
3472 # or the next test case is possible get -EAGAIN when
3473 # setting the tbf policy
3476 run_test 77j "check TBF-OPCode NRS policy"
3479 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3480 { skip "Need OST version at least 2.9.53"; return 0; }
3482 do_nodes $(comma_list $(osts_nodes)) \
3483 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3484 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3485 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3487 nrs_write_read "$RUNAS"
3488 tbf_verify 20 10 "$RUNAS"
3490 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3491 local client_nids=$(nids_list $address "\\")
3492 do_nodes $(comma_list $(osts_nodes)) \
3493 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3494 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3495 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3496 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3501 do_nodes $(comma_list $(osts_nodes)) \
3502 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3503 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3504 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3506 nrs_write_read "$RUNAS"
3507 tbf_verify 20 20 "$RUNAS"
3509 do_nodes $(comma_list $(osts_nodes)) \
3510 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3511 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3512 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3514 nrs_write_read "$RUNAS"
3515 # with parameter "RUNAS", it will match the latest rule
3516 # "ext_b" first, so the limited write rate is 10.
3517 tbf_verify 10 10 "$RUNAS"
3520 do_nodes $(comma_list $(osts_nodes)) \
3521 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3522 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3523 ost.OSS.ost_io.nrs_policies="fifo"
3527 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3530 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3531 skip "Need OST version at least 2.9.54"
3535 local dir=$DIR/$tdir
3537 mkdir $dir || error "mkdir $dir failed"
3538 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3541 local nodes=$(comma_list $(osts_nodes))
3542 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3543 ost.OSS.ost_io.nrs_delay_min=4 \
3544 ost.OSS.ost_io.nrs_delay_max=4 \
3545 ost.OSS.ost_io.nrs_delay_pct=100
3546 [ $? -ne 0 ] && error "Failed to set delay policy"
3548 local start=$SECONDS
3549 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3550 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3551 oflag=direct conv=fdatasync ||
3552 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3553 error "dd on client failed (1)"; }
3554 local elapsed=$((SECONDS - start))
3556 # NRS delay doesn't do sub-second timing, so a request enqueued at
3557 # 0.9 seconds can be dequeued at 4.0
3558 [ $elapsed -lt 3 ] &&
3559 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3560 error "Single 1M write should take at least 3 seconds"; }
3563 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3564 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3565 oflag=direct conv=fdatasync ||
3566 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3567 error "dd on client failed (2)"; }
3568 elapsed=$((SECONDS - start))
3570 [ $elapsed -lt 30 ] &&
3571 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3572 error "Ten 1M writes should take at least 30 seconds"; }
3574 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3575 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3579 run_test 77l "check NRS Delay slows write RPC processing"
3581 test_78() { #LU-6673
3582 local server_version=$(lustre_version_code ost1)
3583 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3584 { skip "Need server version newer than 2.7.57"; return 0; }
3588 oss=$(comma_list $(osts_nodes))
3589 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3590 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3592 # Valid return codes are:
3593 # 0: Tuning succeeded
3594 # ENODEV: Policy is still stopped
3595 # EAGAIN: Policy is being initialized
3596 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3597 error "Expected set_param to return 0|ENODEV|EAGAIN"
3599 # Cleanup the ORR policy
3600 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3601 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3604 run_test 78 "Enable policy and specify tunings right away"
3607 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3608 test_mkdir $DIR/$tdir
3610 # Prevent interference from layout intent RPCs due to
3611 # asynchronous writeback. These will be tested in 130c below.
3612 do_nodes ${CLIENTS:-$HOSTNAME} sync
3614 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3615 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3617 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3618 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3619 local facet=mds$((mdtidx + 1))
3621 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3622 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3626 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3627 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3632 run_test 79 "xattr: intent error"
3635 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3642 mkdir -p $DIR1/$tdir/dir
3643 createmany -o $DIR1/$tdir/dir/f 10 ||
3644 error "create files under remote dir failed $i"
3646 cp /etc/passwd $DIR1/$tdir/$tfile
3648 #migrate open file should fails
3649 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3651 # give multiop a chance to open
3654 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3655 error "migrate open files should failed with open files"
3659 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3660 error "migrate remote dir error"
3662 echo "Finish migration, then checking.."
3663 for file in $(find $DIR1/$tdir); do
3664 mdt_index=$($LFS getstripe -M $file)
3665 [ $mdt_index == $MDTIDX ] ||
3666 error "$file is not on MDT${MDTIDX}"
3669 diff /etc/passwd $DIR1/$tdir/$tfile ||
3670 error "file different after migration"
3672 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3674 run_test 80a "migrate directory when some children is being opened"
3678 kill -9 $migrate_pid
3682 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3683 local migrate_dir1=$DIR1/$tdir/migrate_dir
3684 local migrate_dir2=$DIR2/$tdir/migrate_dir
3685 local migrate_run=$LUSTRE/tests/migrate.sh
3693 trap cleanup_80b EXIT
3694 #prepare migrate directory
3695 mkdir -p $migrate_dir1
3696 for F in {1,2,3,4,5}; do
3697 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3698 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3701 #migrate the directories among MDTs
3704 mdt_idx=$((RANDOM % MDSCOUNT))
3705 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3707 [ $rc -ne 0 -o $rc -ne 16 ] || break
3712 echo "start migration thread $migrate_pid"
3713 #Access the files at the same time
3714 start_time=$(date +%s)
3715 echo "accessing the migrating directory for 5 minutes..."
3717 ls $migrate_dir2 > /dev/null || {
3718 echo "read dir fails"
3721 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3722 echo "access file1 fails"
3726 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3727 echo "access file2/3 fails"
3731 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3732 echo "access file4 fails"
3736 stat $migrate_dir2/file5 > /dev/null || {
3737 echo "stat file5 fails"
3741 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3742 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3743 echo "touch file failed with $rc1"
3747 if [ -e $migrate_dir2/source_file ]; then
3748 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3749 &>/dev/null || rc1=$?
3750 if [ -e $migrate_dir2/link_file ]; then
3751 rm -rf $migrate_dir2/link_file
3754 mrename $migrate_dir2/source_file \
3755 $migrate_dir2/target_file &>/dev/null || rc1=$?
3756 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3757 echo "rename failed with $rc1"
3761 if [ -e $migrate_dir2/target_file ]; then
3762 rm -rf $migrate_dir2/target_file &>/dev/null ||
3765 rm -rf $migrate_dir2/source_file &>/dev/null ||
3768 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3769 echo "unlink failed with $rc1"
3774 end_time=$(date +%s)
3775 duration=$((end_time - start_time))
3776 if [ $((duration % 10)) -eq 0 ]; then
3777 if [ $show_time -eq 1 ]; then
3778 echo "...$duration seconds"
3785 kill -0 $migrate_pid || {
3786 echo "migration stopped 1"
3790 [ $duration -ge 300 ] && break
3793 #check migration are still there
3794 kill -0 $migrate_pid || error "migration stopped 2"
3797 run_test 80b "Accessing directory during migration"
3800 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3804 mkdir -p $DIR1/$tdir
3806 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3807 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3810 touch d0/0 || error "create 0 failed"
3811 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3812 stat d0/0 && error "stat mv filed succeed"
3813 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3814 stat d0/0 || error "stat failed"
3816 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3818 if [ $t -ne 3 ]; then
3819 ls -ai $DIR1/$tdir/d0
3820 error "expect 3 get $t"
3825 run_test 81 "rename and stat under striped directory"
3828 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3829 { skip "Need MDS version at least 2.6.92"; return 0; }
3831 # Client 1 creates a file.
3832 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3834 # Client 2 opens the file.
3835 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3837 # Client 1 makes the file an orphan.
3838 rm $DIR1/$tfile || error "rm"
3839 # Client 2 sets EA "user.multiop".
3841 wait $pid2 || error "multiop 2"
3842 # Client 1 gets EA "user.multiop". This used to fail because the EA
3843 # cache refill would get "trusted.link" from mdd_xattr_list() but
3844 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3847 wait $pid1 || error "multiop 1"
3849 run_test 82 "fsetxattr and fgetxattr on orphan files"
3852 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3859 $LFS mkdir -i1 -c2 $tdir
3864 echo "start pid $pid1 to create/unlink striped directory"
3866 # Access the directory at the same time
3870 stat $tdir > /dev/null 2>&1
3874 echo "start pid $pid2 to stat striped directory"
3882 run_test 83 "access striped directory while it is being created/unlinked"
3885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3890 [ "$SLOW" = "yes" ] && duration=600
3891 # Open/Create under striped directory
3895 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3896 touch $tdir/f{0..3} > /dev/null 2>&1
3900 echo "start pid $pid1 to open/create under striped directory"
3902 # unlink the striped directory at the same time
3906 rm -rf $tdir > /dev/null 2>&1
3910 echo "start pid $pid2 to unlink striped directory"
3919 run_test 90 "open/create and unlink striped directory"
3922 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3927 [ "$SLOW" = "yes" ] && duration=600
3928 # chmod striped directory
3932 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3933 chmod go+w $tdir > /dev/null 2>&1
3937 echo "start pid $pid1 to chmod striped directory"
3939 # unlink the striped directory at the same time
3943 rm -rf $tdir > /dev/null 2>&1
3947 echo "start pid $pid2 to unlink striped directory"
3956 run_test 91 "chmod and unlink striped directory"
3959 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3962 local cmd="exec $fd<$DIR1/$tdir"
3963 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3966 trap "eval $cmd" EXIT
3967 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3968 rmdir ../$tdir || error "rmdir ../$tdir fails"
3970 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3971 $LCTL set_param fail_loc=0x1408
3972 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3973 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3974 error "create remote dir succeeds"
3975 $LCTL set_param fail_loc=0
3979 run_test 92 "create remote directory under orphan directory"
3986 mkdir -p $DIR1/$tfile-1/
3987 mkdir -p $DIR2/$tfile-2/
3988 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
3989 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
3990 do_facet $SINGLEMDS lctl set_param -n \
3991 'lod.lustre-MDT*/qos_threshold_rr' 100
3992 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
3993 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
3995 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
3998 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4002 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4003 do_facet $SINGLEMDS "lctl set_param -n \
4004 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4006 $GETSTRIPE $DIR1/$tfile-1/file1
4007 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4008 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4009 $GETSTRIPE $DIR2/$tfile-2/file2
4010 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4011 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4012 echo "rc1=$rc1 and rc2=$rc2 "
4013 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4014 error "object allocate on same ost detected"
4016 run_test 93 "alloc_rr should not allocate on same ost"
4018 log "cleanup: ======================================================"
4020 # kill and wait in each test only guarentee script finish, but command in script
4021 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4022 # otherwise umount below will fail
4023 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4028 check_and_cleanup_lustre