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_30() { #b=11110, LU-2523
683 test_mkdir $DIR1/$tdir
684 cp -f /bin/bash $DIR1/$tdir/bash
685 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
686 $DIR1/$tdir/bash -c 'sleep 2;
687 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
691 run_test 30 "recreate file race"
694 test_mkdir $DIR1/$tdir
695 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
696 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
697 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
698 lctl set_param fail_loc=0x314
699 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
700 awk 'BEGIN { FS="+" } /in/ {print $1}')
701 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
703 run_test 31a "voluntary cancel / blocking ast race=============="
706 remote_ost || { skip "local OST" && return 0; }
707 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
709 # make sure there is no local locks due to destroy
710 wait_mds_ost_sync || error "wait_mds_ost_sync()"
711 wait_delete_completed || error "wait_delete_completed()"
713 test_mkdir $DIR1/$tdir
714 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
715 cp /etc/hosts $DIR/$tdir/$tfile
716 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
717 lctl set_param fail_loc=0x314
718 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
719 do_facet ost1 lctl set_param fail_loc=0x316
721 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
722 lctl set_param fail_loc=0
723 do_facet ost1 lctl set_param fail_loc=0
724 # cleanup: reconnect the client back
727 run_test 31b "voluntary OST cancel / blocking ast race=============="
729 # enable/disable lockless truncate feature, depending on the arg 0/1
730 enable_lockless_truncate() {
731 lctl set_param -n osc.*.lockless_truncate $1
734 test_32a() { # bug 11270
735 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
736 save_lustre_params client "osc.*.lockless_truncate" > $p
738 enable_lockless_truncate 1
740 lfs setstripe -c -1 $DIR1/$tfile
741 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
743 clear_stats osc.*.osc_stats
745 log "checking cached lockless truncate"
746 $TRUNCATE $DIR1/$tfile 8000000
747 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
748 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
749 error "cached truncate isn't lockless"
751 log "checking not cached lockless truncate"
752 $TRUNCATE $DIR2/$tfile 5000000
753 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
754 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
755 error "not cached truncate isn't lockless"
757 log "disabled lockless truncate"
758 enable_lockless_truncate 0
759 clear_stats osc.*.osc_stats
760 $TRUNCATE $DIR2/$tfile 3000000
761 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
762 [ $(calc_stats osc.*.osc_stats lockless_truncate) -eq 0 ] ||
763 error "lockless truncate disabling failed"
765 # restore lockless_truncate default values
766 restore_lustre_params < $p
769 run_test 32a "lockless truncate"
771 test_32b() { # bug 11270
772 remote_ost_nodsh && skip "remote OST with nodsh" && return
775 local facets=$(get_facets OST)
776 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
778 save_lustre_params client "osc.*.contention_seconds" > $p
779 save_lustre_params $facets \
780 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
781 save_lustre_params $facets \
782 "ldlm.namespaces.filter-*.contended_locks" >> $p
783 save_lustre_params $facets \
784 "ldlm.namespaces.filter-*.contention_seconds" >> $p
785 clear_stats osc.*.osc_stats
787 # agressive lockless i/o settings
788 do_nodes $(comma_list $(osts_nodes)) \
789 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
790 ldlm.namespaces.filter-*.contended_locks=0 \
791 ldlm.namespaces.filter-*.contention_seconds=60"
792 lctl set_param -n osc.*.contention_seconds=60
794 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
796 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
799 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -ne 0 ] ||
800 error "lockless i/o was not triggered"
801 # disable lockless i/o (it is disabled by default)
802 do_nodes $(comma_list $(osts_nodes)) \
803 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
804 ldlm.namespaces.filter-*.contended_locks=32 \
805 ldlm.namespaces.filter-*.contention_seconds=0"
806 # set contention_seconds to 0 at client too, otherwise Lustre still
807 # remembers lock contention
808 lctl set_param -n osc.*.contention_seconds=0
809 clear_stats osc.*.osc_stats
811 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
813 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
816 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -eq 0 ] ||
817 error "lockless i/o works when disabled"
819 restore_lustre_params <$p
822 run_test 32b "lockless i/o"
826 local mdts=$(get_facets MDS)
831 for mds in ${mdts//,/ }; do
833 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
834 xargs readlink -f" ))
835 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
838 stat=$(( stat + val))
843 # commit on sharing tests
845 remote_mds_nodsh && skip "remote MDS with nodsh" && return
847 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
848 [ $CLIENTCOUNT -lt 2 ] &&
849 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
851 local nfiles=${TEST33_NFILES:-10000}
852 local param_file=$TMP/$tfile-params
853 local fstype=$(facet_fstype $SINGLEMDS)
855 save_lustre_params $(get_facets MDS) \
856 "mdt.*.commit_on_sharing" > $param_file
864 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
868 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
870 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
871 echo "=== START createmany old: $jbdold transaction"
872 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")
873 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
874 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
875 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
876 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
877 avgtime=$(( avgtime + elapsed ))
879 eval cos${COS}_jbd=$((avgjbd / 3))
880 eval cos${COS}_time=$((avgtime / 3))
883 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
884 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
885 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
886 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
888 restore_lustre_params < $param_file
892 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
894 # commit on sharing tests
896 remote_mds_nodsh && skip "remote MDS with nodsh" && return
898 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
899 [ $CLIENTCOUNT -ge 2 ] ||
900 { skip "Need two or more clients, have $CLIENTCOUNT" &&
902 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
904 local nfiles=${TEST33_NFILES:-10000}
905 local param_file=$TMP/$tfile-params
907 save_lustre_params $(get_facets MDS) \
908 "mdt.*.commit_on_sharing" > $param_file
917 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
921 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
922 $DIR1/$tdir-\\\$(hostname)-$i"
924 jbdold=$(print_jbd_stat)
925 echo "=== START createmany old: $jbdold transaction"
926 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
927 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
928 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
930 jbdnew=$(print_jbd_stat)
931 jbd=$(( jbdnew - jbdold ))
932 echo "=== END createmany new: $jbdnew transaction : \
933 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
934 avgjbd=$(( avgjbd + jbd ))
935 avgtime=$(( avgtime + elapsed ))
937 eval cos${COS}_jbd=$((avgjbd / 3))
938 eval cos${COS}_time=$((avgtime / 3))
941 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
942 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
943 [ "$cos0_jbd" != 0 ] &&
944 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
945 [ "$cos0_time" != 0 ] &&
946 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
948 restore_lustre_params < $param_file
952 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
955 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
956 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
957 skip "DNE CoS not supported" && return
962 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
963 $LFS mkdir -i 1 $DIR/$tdir/d1
964 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
966 local sync_count=$(do_facet mds1 \
967 "lctl get_param -n mdt.*MDT0000.sync_count")
968 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
970 $LFS mkdir -i 1 $DIR/$tdir/d3
971 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
972 # during sleep remote mkdir should have been committed and canceled
973 # remote lock spontaneously, which shouldn't trigger sync
976 local sync_count=$(do_facet mds1 \
977 "lctl get_param -n mdt.*MDT0000.sync_count")
978 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
980 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
983 local nodes=$(comma_list $(mdts_nodes))
984 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
986 local async_commit_count=$(do_nodes $nodes \
987 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
988 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
996 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
997 skip "DNE CoS not supported" && return
1000 # remote directory create
1002 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1003 # remote directory unlink
1004 $LFS mkdir -i 1 $DIR/$tdir
1005 ops_do_cos "rmdir $DIR/$tdir"
1006 # striped directory create
1008 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1009 # striped directory setattr
1010 $LFS mkdir -c 2 $DIR/$tdir
1012 ops_do_cos "chmod 713 $DIR/$tdir"
1013 # striped directory unlink
1014 $LFS mkdir -c 2 $DIR/$tdir
1016 ops_do_cos "rmdir $DIR/$tdir"
1018 $LFS mkdir -c 2 $DIR/$tdir
1019 $LFS mkdir -i 0 $DIR/$tdir/d1
1020 $LFS mkdir -i 1 $DIR/$tdir/d2
1021 touch $DIR/$tdir/d1/tgt
1022 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1024 $LFS mkdir -c 2 $DIR/$tdir
1025 $LFS mkdir -i 0 $DIR/$tdir/d1
1026 $LFS mkdir -i 1 $DIR/$tdir/d2
1027 touch $DIR/$tdir/d1/src
1028 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1030 $LFS mkdir -i 0 $DIR/$tdir
1031 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1034 run_test 33d "DNE distributed operation should trigger COS"
1037 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1038 [ $CLIENTCOUNT -ge 2 ] ||
1039 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1041 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1042 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1043 skip "DNE CoS not supported" && return
1045 local client2=${CLIENT2:-$(hostname)}
1049 local nodes=$(comma_list $(mdts_nodes))
1050 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1052 $LFS mkdir -c 2 $DIR/$tdir
1053 mkdir $DIR/$tdir/subdir
1054 echo abc > $DIR/$tdir/$tfile
1055 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1056 do_node $client2 touch $DIR/$tdir/subdir
1058 local async_commit_count=$(do_nodes $nodes \
1059 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1060 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1064 run_test 33e "DNE local operation shouldn't trigger COS"
1066 # End commit on sharing tests
1068 get_ost_lock_timeouts() {
1069 local nodes=${1:-$(comma_list $(osts_nodes))}
1071 local locks=$(do_nodes $nodes \
1072 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1080 do_nodes $(comma_list $(osts_nodes)) \
1081 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1082 for i in $(seq $OSTCOUNT); do
1083 wait_osc_import_state client ost$i FULL
1088 remote_ost_nodsh && skip "remote OST with nodsh" && return
1092 trap cleanup_34 EXIT RETURN
1093 for OPER in notimeout timeout ; do
1094 rm $DIR1/$tfile 2>/dev/null
1095 lock_in=$(get_ost_lock_timeouts)
1096 if [ $OPER == "timeout" ] ; then
1097 for j in `seq $OSTCOUNT`; do
1098 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1099 do_facet ost$j lctl set_param fail_loc=0x511
1101 echo lock should expire
1103 for j in `seq $OSTCOUNT`; do
1104 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1105 do_facet ost$j lctl set_param fail_loc=0x512
1107 echo lock should not expire
1109 echo writing on client1
1110 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1112 echo reading on client2
1113 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1114 # wait for a lock timeout
1116 lock_out=$(get_ost_lock_timeouts)
1117 if [ $OPER == "timeout" ] ; then
1118 if [ $lock_in == $lock_out ]; then
1119 error "no lock timeout happened"
1124 if [ $lock_in != $lock_out ]; then
1125 error "lock timeout happened"
1133 run_test 34 "no lock timeout under IO"
1135 test_35() { # bug 17645
1138 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1139 awk '/generation/{print $2}')
1141 generation[count]=$g
1145 test_mkdir $MOUNT1/$tdir
1146 cancel_lru_locks mdc
1148 # Let's initiate -EINTR situation by setting fail_loc and take
1149 # write lock on same file from same client. This will not cause
1150 # bl_ast yet as lock is already in local cache.
1151 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1152 do_facet client "lctl set_param fail_loc=0x80000317"
1153 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1154 let timeout=timeout*3
1156 while test $nr -lt 10; do
1157 log "Race attempt $nr"
1158 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1159 awk '/ldlm_bl_callback/ { print $2 }')
1160 test "x$blk1" = "x" && blk1=0
1161 createmany -o $MOUNT2/$tdir/a 4000 &
1165 # Let's make conflict and bl_ast
1166 ls -la $MOUNT1/$tdir > /dev/null &
1169 log "Wait for $pid1 $pid2 for $timeout sec..."
1171 kill -9 $pid1 $pid2 > /dev/null 2>&1
1173 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1174 awk '/ldlm_bl_callback/ { print $2 }')
1175 test "x$blk2" = "x" && blk2=0
1176 test $blk2 -gt $blk1 && break
1177 rm -fr $MOUNT1/$tdir
1178 cancel_lru_locks mdc
1181 do_facet client "lctl set_param fail_loc=0x0"
1182 df -h $MOUNT1 $MOUNT2
1184 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1185 awk '/generation/{print $2}')
1187 if ! test "$g" -eq "${generation[count]}"; then
1188 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1190 for imp in $list; do
1191 if [ $c = $count ]; then
1196 imp=$(echo "$imp" | awk -F"." '{print $2}')
1197 error "Eviction happened on import $imp"
1202 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1204 test_36() { #bug 16417
1209 test_mkdir $DIR1/$tdir
1210 $LFS setstripe -c -1 $DIR1/$tdir
1213 let SIZE_B=SIZE*1024*1024
1214 sync; sleep 2; sync # wait for delete thread
1215 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1216 wait_destroy_complete || error "wait_destroy_complete failed"
1218 while [ $i -le 10 ]; do
1219 lctl mark "start test - cycle ($i)"
1220 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1221 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1222 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1223 sync # sync data from client cache
1224 sync_all_data # sync data from server cache (delayed allocation)
1226 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1227 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1229 rm -f $DIR1/$tdir/$tfile
1230 kill -USR1 $read_pid
1232 sync; sleep 2; sync # Ensure new statfs
1233 wait_delete_completed
1234 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1235 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1237 # this free space! not used
1238 (( $after_dd <= $after)) ||
1239 error "space leaked after_dd:$after_dd > after:$after"
1243 run_test 36 "handle ESTALE/open-unlink correctly"
1245 test_37() { # bug 18695
1246 test_mkdir $DIR1/$tdir
1247 multiop_bg_pause $DIR1/$tdir D_c || return 1
1249 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1250 createmany -m $DIR2/$tdir/f 10000
1251 # set mtime/atime backward
1252 touch -t 198001010000 $DIR2/$tdir
1253 kill -USR1 $MULTIPID
1254 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1255 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1258 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1260 # this should be set to past
1261 TEST_39_MTIME=`date -d "1 year ago" +%s`
1265 local client1=${CLIENT1:-`hostname`}
1266 local client2=${CLIENT2:-`hostname`}
1268 do_node $client1 "touch $DIR1/$tfile"
1270 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1271 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1272 [ "$mtime1" = $TEST_39_MTIME ] || \
1273 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1275 local d1=`do_node $client1 date +%s`
1276 do_node $client1 'echo hello >> '$DIR1/$tfile
1277 local d2=`do_node $client1 date +%s`
1279 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1280 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1281 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1283 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1285 for (( i=0; i < 2; i++ )) ; do
1286 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1287 [ "$mtime2" = "$mtime3" ] || \
1288 error "mtime ($mtime2) changed (to $mtime3) on rename"
1290 cancel_lru_locks osc
1291 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1294 run_test 39a "test from 11063 =================================="
1297 local client1=${CLIENT1:-`hostname`}
1298 local client2=${CLIENT2:-`hostname`}
1302 local mtime1=`stat -c %Y $DIR1/$tfile`
1303 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1306 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1308 for (( i=0; i < 2; i++ )) ; do
1309 local mtime3=`stat -c %Y $DIR1/$tfile`
1310 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1312 [ "$mtime3" = "$mtime4" ] || \
1313 error "different mtime on clients: $mtime3, $mtime4"
1314 [ "$mtime3" = $TEST_39_MTIME ] || \
1315 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1317 cancel_lru_locks osc
1318 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1321 run_test 39b "11063 problem 1 =================================="
1324 local client1=${CLIENT1:-`hostname`}
1325 local client2=${CLIENT2:-`hostname`}
1327 echo hello > $DIR1/$tfile
1329 local mtime1=`stat -c %Y $DIR1/$tfile`
1330 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1331 [ "$mtime1" = "$mtime2" ] || \
1332 error "create: different mtime on clients: $mtime1, $mtime2"
1335 $TRUNCATE $DIR1/$tfile 1
1337 for (( i=0; i < 2; i++ )) ; do
1338 local mtime3=`stat -c %Y $DIR1/$tfile`
1339 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1341 [ "$mtime3" = "$mtime4" ] || \
1342 error "different mtime on clients: $mtime3, $mtime4"
1343 [ "$mtime3" -gt $mtime2 ] || \
1344 error "truncate did not update mtime: $mtime2, $mtime3"
1346 cancel_lru_locks osc
1347 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1350 run_test 39c "check truncate mtime update ======================"
1352 test_39d() { # LU-7310
1354 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1356 local mtime1=$(stat -c %Y $DIR2/$tfile)
1357 [ "$mtime1" = $TEST_39_MTIME ] ||
1358 error "mtime: $mtime1, should be $TEST_39_MTIME"
1361 # define OBD_FAIL_OSC_NO_GRANT 0x411
1362 $LCTL set_param fail_loc=0x411
1364 local d1=$(date +%s)
1365 echo hello >> $DIR1/$tfile
1366 local d2=$(date +%s)
1368 $LCTL set_param fail_loc=0
1370 cancel_lru_locks osc
1372 local mtime2=$(stat -c %Y $DIR2/$tfile)
1373 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1374 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1376 run_test 39d "sync write should update mtime"
1378 # check that pid exists hence second operation wasn't blocked by first one
1379 # if it is so then there is no conflict, return 0
1380 # else second operation is conflicting with first one, return 1
1381 check_pdo_conflict() {
1384 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1385 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1395 # test 40: check non-blocking operations
1397 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1398 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1399 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1401 mkdir $DIR1/$tfile &
1404 touch $DIR2/$tfile-2
1405 check_pdo_conflict $PID1 || error "create is blocked"
1406 mkdir $DIR2/$tfile-3
1407 check_pdo_conflict $PID1 || error "mkdir is blocked"
1408 link $DIR2/$tfile-2 $DIR2/$tfile-4
1409 check_pdo_conflict $PID1 || error "link is blocked"
1410 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1411 check_pdo_conflict $PID1 || error "rename is blocked"
1412 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1413 check_pdo_conflict $PID1 || error "getattr is blocked"
1414 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1415 rmdir $DIR2/$tfile-3
1416 check_pdo_conflict $PID1 || error "unlink is blocked"
1418 # all operations above shouldn't wait the first one
1419 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1424 run_test 40a "pdirops: create vs others =============="
1427 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1428 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1429 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1430 touch $DIR1/$tfile &
1434 touch $DIR2/$tfile-2
1435 check_pdo_conflict $PID1 || error "create is blocked"
1436 mkdir $DIR2/$tfile-3
1437 check_pdo_conflict $PID1 || error "mkdir is blocked"
1438 link $DIR2/$tfile-2 $DIR2/$tfile-4
1439 check_pdo_conflict $PID1 || error "link is blocked"
1440 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1441 check_pdo_conflict $PID1 || error "rename is blocked"
1442 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1443 check_pdo_conflict $PID1 || error "getattr is blocked"
1444 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1445 rmdir $DIR2/$tfile-3
1446 check_pdo_conflict $PID1 || error "unlink is blocked"
1447 # all operations above shouldn't wait the first one
1449 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1454 run_test 40b "pdirops: open|create and others =============="
1457 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1459 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1460 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1461 link $DIR1/$tfile $DIR1/$tfile-0 &
1465 touch $DIR2/$tfile-2
1466 check_pdo_conflict $PID1 || error "create is blocked"
1467 mkdir $DIR2/$tfile-3
1468 check_pdo_conflict $PID1 || error "mkdir is blocked"
1469 link $DIR2/$tfile-2 $DIR2/$tfile-4
1470 check_pdo_conflict $PID1 || error "link is blocked"
1471 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1472 check_pdo_conflict $PID1 || error "rename is blocked"
1473 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1474 check_pdo_conflict $PID1 || error "getattr is blocked"
1475 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1476 rmdir $DIR2/$tfile-3
1477 check_pdo_conflict $PID1 || error "unlink is blocked"
1479 # all operations above shouldn't wait the first one
1480 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1485 run_test 40c "pdirops: link and others =============="
1488 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1490 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1491 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1496 touch $DIR2/$tfile-2
1497 check_pdo_conflict $PID1 || error "create is blocked"
1498 mkdir $DIR2/$tfile-3
1499 check_pdo_conflict $PID1 || error "mkdir is blocked"
1500 link $DIR2/$tfile-2 $DIR2/$tfile-4
1501 check_pdo_conflict $PID1 || error "link is blocked"
1502 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1503 check_pdo_conflict $PID1 || error "rename is blocked"
1504 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1505 check_pdo_conflict $PID1 || error "getattr is blocked"
1506 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1507 rmdir $DIR2/$tfile-3
1508 check_pdo_conflict $PID1 || error "unlink is blocked"
1510 # all operations above shouldn't wait the first one
1511 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1515 run_test 40d "pdirops: unlink and others =============="
1518 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1520 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1521 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1522 mv $DIR1/$tfile $DIR1/$tfile-0 &
1526 touch $DIR2/$tfile-2
1527 check_pdo_conflict $PID1 || error "create is blocked"
1528 mkdir $DIR2/$tfile-3
1529 check_pdo_conflict $PID1 || error "mkdir is blocked"
1530 link $DIR2/$tfile-2 $DIR2/$tfile-4
1531 check_pdo_conflict $PID1 || error "link is blocked"
1532 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1533 check_pdo_conflict $PID1 || error "getattr is blocked"
1534 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1535 rmdir $DIR2/$tfile-3
1536 check_pdo_conflict $PID1 || error "unlink is blocked"
1538 # all operations above shouldn't wait the first one
1539 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1544 run_test 40e "pdirops: rename and others =============="
1546 # test 41: create blocking operations
1548 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1549 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1550 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1553 mkdir $DIR2/$tfile && error "mkdir must fail"
1554 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1558 run_test 41a "pdirops: create vs mkdir =============="
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 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1567 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1571 run_test 41b "pdirops: create vs create =============="
1574 touch $DIR1/$tfile-2
1575 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1576 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1577 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1580 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1581 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1585 run_test 41c "pdirops: create vs link =============="
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 rm $DIR2/$tfile || error "unlink must succeed"
1594 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1598 run_test 41d "pdirops: create vs unlink =============="
1601 touch $DIR1/$tfile-2
1602 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1603 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1604 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1607 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1608 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1612 run_test 41e "pdirops: create and rename (tgt) =============="
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 $DIR2/$tfile-2 || error "rename must succeed"
1621 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1625 run_test 41f "pdirops: create and rename (src) =============="
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 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1634 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1638 run_test 41g "pdirops: create vs getattr =============="
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 ls -lia $DIR2/ > /dev/null
1647 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1651 run_test 41h "pdirops: create vs readdir =============="
1653 # test 42: unlink and blocking operations
1655 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1656 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1657 mkdir $DIR1/$tfile &
1660 mkdir $DIR2/$tfile && error "mkdir must fail"
1661 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1665 run_test 42a "pdirops: mkdir vs mkdir =============="
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 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1674 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1678 run_test 42b "pdirops: mkdir vs create =============="
1681 touch $DIR1/$tfile-2
1682 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1683 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1684 mkdir $DIR1/$tfile &
1687 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1688 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1692 run_test 42c "pdirops: mkdir vs link =============="
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 rmdir $DIR2/$tfile || error "unlink must succeed"
1701 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1705 run_test 42d "pdirops: mkdir vs unlink =============="
1708 touch $DIR1/$tfile-2
1709 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1710 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1711 mkdir $DIR1/$tfile &
1714 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1715 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1719 run_test 42e "pdirops: mkdir and rename (tgt) =============="
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 $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1728 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1732 run_test 42f "pdirops: mkdir and rename (src) =============="
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 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1741 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1745 run_test 42g "pdirops: mkdir vs getattr =============="
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 ls -lia $DIR2/ > /dev/null
1754 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1758 run_test 42h "pdirops: mkdir vs readdir =============="
1760 # test 43: unlink and blocking operations
1763 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1764 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1768 mkdir $DIR2/$tfile || error "mkdir must succeed"
1769 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1773 run_test 43a "pdirops: unlink vs mkdir =============="
1777 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1778 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1782 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1783 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1787 run_test 43b "pdirops: unlink vs create =============="
1791 touch $DIR1/$tfile-2
1792 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1793 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1797 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1798 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1802 run_test 43c "pdirops: unlink vs link =============="
1806 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1807 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1811 rm $DIR2/$tfile && error "unlink must fail"
1812 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1816 run_test 43d "pdirops: unlink vs unlink =============="
1820 touch $DIR1/$tfile-2
1821 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1822 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1826 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1827 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1831 run_test 43e "pdirops: unlink and rename (tgt) =============="
1835 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1836 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1840 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1841 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1845 run_test 43f "pdirops: unlink and rename (src) =============="
1849 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1850 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1854 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1855 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1859 run_test 43g "pdirops: unlink vs getattr =============="
1863 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1864 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1868 ls -lia $DIR2/ > /dev/null
1869 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1873 run_test 43h "pdirops: unlink vs readdir =============="
1876 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1878 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1879 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1883 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1884 check_pdo_conflict $PID1 &&
1885 { wait $PID1; error "remote mkdir isn't blocked"; }
1889 run_test 43i "pdirops: unlink vs remote mkdir"
1891 # test 44: rename tgt and blocking operations
1893 touch $DIR1/$tfile-2
1894 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1895 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1896 mv $DIR1/$tfile-2 $DIR1/$tfile &
1899 mkdir $DIR2/$tfile && error "mkdir must fail"
1900 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1904 run_test 44a "pdirops: rename tgt vs mkdir =============="
1907 touch $DIR1/$tfile-2
1908 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1909 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1910 mv $DIR1/$tfile-2 $DIR1/$tfile &
1913 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1914 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1918 run_test 44b "pdirops: rename tgt vs create =============="
1921 touch $DIR1/$tfile-2
1922 touch $DIR1/$tfile-3
1923 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1924 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1925 mv $DIR1/$tfile-2 $DIR1/$tfile &
1928 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1929 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1933 run_test 44c "pdirops: rename tgt vs link =============="
1936 touch $DIR1/$tfile-2
1937 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1938 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1939 mv $DIR1/$tfile-2 $DIR1/$tfile &
1942 rm $DIR2/$tfile || error "unlink must succeed"
1943 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1947 run_test 44d "pdirops: rename tgt vs unlink =============="
1951 touch $DIR1/$tfile-2
1952 touch $DIR1/$tfile-3
1953 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1954 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1955 mv $DIR1/$tfile-2 $DIR1/$tfile &
1958 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1959 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1963 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1966 touch $DIR1/$tfile-2
1967 touch $DIR1/$tfile-3
1968 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1969 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1970 mv $DIR1/$tfile-2 $DIR1/$tfile &
1973 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1974 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1978 run_test 44f "pdirops: rename tgt and rename (src) =============="
1981 touch $DIR1/$tfile-2
1982 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1983 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1984 mv $DIR1/$tfile-2 $DIR1/$tfile &
1987 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1988 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1992 run_test 44g "pdirops: rename tgt vs getattr =============="
1995 touch $DIR1/$tfile-2
1996 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1997 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1998 mv $DIR1/$tfile-2 $DIR1/$tfile &
2001 ls -lia $DIR2/ > /dev/null
2002 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2006 run_test 44h "pdirops: rename tgt vs readdir =============="
2008 # test 44: rename tgt and blocking operations
2010 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2011 touch $DIR1/$tfile-2
2012 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2013 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2014 mv $DIR1/$tfile-2 $DIR1/$tfile &
2017 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2018 check_pdo_conflict $PID1 && { wait $PID1;
2019 error "remote mkdir isn't blocked"; }
2023 run_test 44i "pdirops: rename tgt vs remote mkdir"
2025 # test 45: rename src and blocking operations
2028 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2029 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2030 mv $DIR1/$tfile $DIR1/$tfile-2 &
2033 mkdir $DIR2/$tfile || error "mkdir must succeed"
2034 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2038 run_test 45a "pdirops: rename src vs mkdir =============="
2042 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2043 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2044 mv $DIR1/$tfile $DIR1/$tfile-2 &
2047 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2048 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2052 run_test 45b "pdirops: rename src vs create =============="
2056 touch $DIR1/$tfile-3
2057 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2058 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2059 mv $DIR1/$tfile $DIR1/$tfile-2 &
2062 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2063 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2067 run_test 45c "pdirops: rename src vs link =============="
2071 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2072 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2073 mv $DIR1/$tfile $DIR1/$tfile-2 &
2076 rm $DIR2/$tfile && error "unlink must fail"
2077 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2081 run_test 45d "pdirops: rename src vs unlink =============="
2085 touch $DIR1/$tfile-3
2086 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2087 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2088 mv $DIR1/$tfile $DIR1/$tfile-2 &
2091 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2092 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2096 run_test 45e "pdirops: rename src and rename (tgt) =============="
2100 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2101 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2102 mv $DIR1/$tfile $DIR1/$tfile-2 &
2105 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2106 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2110 run_test 45f "pdirops: rename src and rename (src) =============="
2114 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2115 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2116 mv $DIR1/$tfile $DIR1/$tfile-2 &
2119 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2120 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2124 run_test 45g "pdirops: rename src vs getattr =============="
2128 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2129 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2130 mv $DIR1/$tfile $DIR1/$tfile-2 &
2133 ls -lia $DIR2/ > /dev/null
2134 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2138 run_test 45h "pdirops: unlink vs readdir =============="
2141 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2143 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2144 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2145 mv $DIR1/$tfile $DIR1/$tfile-2 &
2148 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2149 check_pdo_conflict $PID1 && { wait $PID1;
2150 error "create remote dir isn't blocked"; }
2154 run_test 45i "pdirops: rename src vs remote mkdir"
2156 # test 46: link and blocking operations
2158 touch $DIR1/$tfile-2
2159 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2160 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2161 link $DIR1/$tfile-2 $DIR1/$tfile &
2164 mkdir $DIR2/$tfile && error "mkdir must fail"
2165 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2169 run_test 46a "pdirops: link vs mkdir =============="
2172 touch $DIR1/$tfile-2
2173 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2174 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2175 link $DIR1/$tfile-2 $DIR1/$tfile &
2178 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2179 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2183 run_test 46b "pdirops: link vs create =============="
2186 touch $DIR1/$tfile-2
2187 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2188 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2189 link $DIR1/$tfile-2 $DIR1/$tfile &
2192 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2193 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2197 run_test 46c "pdirops: link vs link =============="
2200 touch $DIR1/$tfile-2
2201 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2202 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2203 link $DIR1/$tfile-2 $DIR1/$tfile &
2206 rm $DIR2/$tfile || error "unlink must succeed"
2207 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2211 run_test 46d "pdirops: link vs unlink =============="
2214 touch $DIR1/$tfile-2
2215 touch $DIR1/$tfile-3
2216 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2217 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2218 link $DIR1/$tfile-2 $DIR1/$tfile &
2221 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2222 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2226 run_test 46e "pdirops: link and rename (tgt) =============="
2229 touch $DIR1/$tfile-2
2230 touch $DIR1/$tfile-3
2231 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2232 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2233 link $DIR1/$tfile-2 $DIR1/$tfile &
2236 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2237 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2241 run_test 46f "pdirops: link and rename (src) =============="
2244 touch $DIR1/$tfile-2
2245 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2246 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2247 link $DIR1/$tfile-2 $DIR1/$tfile &
2250 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2251 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2255 run_test 46g "pdirops: link vs getattr =============="
2258 touch $DIR1/$tfile-2
2259 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2260 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2261 link $DIR1/$tfile-2 $DIR1/$tfile &
2264 ls -lia $DIR2/ > /dev/null
2265 check_pdo_conflict $PID1 && { wait $PID1;
2266 error "readdir isn't blocked"; }
2270 run_test 46h "pdirops: link vs readdir =============="
2273 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2274 touch $DIR1/$tfile-2
2275 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2276 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2277 link $DIR1/$tfile-2 $DIR1/$tfile &
2280 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2281 check_pdo_conflict $PID1 && { wait $PID1;
2282 error "remote mkdir isn't blocked"; }
2286 run_test 46i "pdirops: link vs remote mkdir"
2288 # test 47: remote mkdir and blocking operations
2290 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2291 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2292 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2293 $LFS mkdir -i 1 $DIR1/$tfile &
2296 mkdir $DIR2/$tfile && error "mkdir must fail"
2297 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2301 run_test 47a "pdirops: remote mkdir vs mkdir"
2304 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2305 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2306 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2307 $LFS mkdir -i 1 $DIR1/$tfile &
2310 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2311 check_pdo_conflict $PID1 && { wait $PID1;
2312 error "create isn't blocked"; }
2316 run_test 47b "pdirops: remote mkdir vs create"
2319 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2320 touch $DIR1/$tfile-2
2321 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2322 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2323 $LFS mkdir -i 1 $DIR1/$tfile &
2326 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2327 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2331 run_test 47c "pdirops: remote mkdir vs link"
2334 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2335 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2336 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2337 $LFS mkdir -i 1 $DIR1/$tfile &
2340 rmdir $DIR2/$tfile || error "unlink must succeed"
2341 check_pdo_conflict $PID1 && { wait $PID1;
2342 error "unlink isn't blocked"; }
2346 run_test 47d "pdirops: remote mkdir vs unlink"
2349 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2350 touch $DIR1/$tfile-2
2351 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2352 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2353 $LFS mkdir -i 1 $DIR1/$tfile &
2356 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2357 check_pdo_conflict $PID1 && { wait $PID1;
2358 error "rename isn't blocked"; }
2362 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2365 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2366 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2367 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2368 $LFS mkdir -i 1 $DIR1/$tfile &
2371 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2372 check_pdo_conflict $PID1 && { wait $PID1;
2373 error "rename isn't blocked"; }
2377 run_test 47f "pdirops: remote mkdir and rename (src)"
2380 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2381 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2382 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2383 $LFS mkdir -i 1 $DIR1/$tfile &
2386 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2387 check_pdo_conflict $PID1 && { wait $PID1;
2388 error "getattr isn't blocked"; }
2392 run_test 47g "pdirops: remote mkdir vs getattr"
2396 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2397 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2398 do_facet client "lctl set_param fail_loc=0x410"
2399 $TRUNCATE $DIR2/$tfile $trunc_size
2400 do_facet client "lctl set_param fail_loc=0x0"
2402 size=`stat -c %s $DIR2/$tfile`
2403 [ $size -eq $trunc_size ] || error "wrong size"
2405 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2409 local origfile=/etc/hosts
2411 filesize=$(stat -c %s $origfile)
2413 # create an empty file
2414 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2415 # cache layout lock on both mount point
2416 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2417 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2419 # open and sleep 2 seconds then read
2420 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2424 # create the layout of testing file
2425 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2426 error "dd $DIR1/$tfile failed"
2428 # MULTIOP proc should be able to read enough bytes and exit
2429 for ((i = 0; i < 6; i++)); do
2431 kill -0 $pid || break
2433 kill -0 $pid 2> /dev/null && error "multiop is still there"
2434 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2438 run_test 51a "layout lock: refresh layout should work"
2441 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2442 { skip "Need MDS version at least 2.3.59"; return 0; }
2444 local tmpfile=`mktemp`
2446 # create an empty file
2447 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2449 # delay glimpse so that layout has changed when glimpse finish
2450 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2451 $LCTL set_param fail_loc=0x1404
2452 stat -c %s $DIR2/$tfile |tee $tmpfile &
2456 # create layout of testing file
2457 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2458 error "dd $DIR1/$tfile failed"
2461 local fsize=$(cat $tmpfile)
2463 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2465 rm -f $DIR1/$tfile $tmpfile
2467 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2470 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2472 # set default layout to have 1 stripe
2474 $LFS setstripe -c 1 $DIR1/$tdir
2476 # create a file with empty layout
2477 $MCREATE $DIR1/$tdir/$tfile ||
2478 error "$MCREATE $DIR1/$tdir/$tfile failed"
2480 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2481 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2483 # change the layout of testing file
2484 echo "Setting layout to have $OSTCOUNT stripes ..."
2485 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2489 # write something to the file, it should be blocked on fetching layout
2490 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2491 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2494 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2495 # count to succeed with only 3/4 of the number of stripes (rounded up),
2496 # so creating striped files does not fail if an OST is offline or full
2497 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2498 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2502 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2505 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2506 cancel_lru_locks mdc
2508 # open should grant LAYOUT lock, mmap and read will install pages
2509 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2513 # rss before revoking
2514 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2515 echo "Before revoking layout lock: $br KB mapped"
2517 # delete the file will revoke layout lock
2520 # rss after revoking
2521 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2526 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2528 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2532 echo "==> rename vs getattr vs setxattr should not deadlock"
2533 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2535 do_facet mds1 $LCTL set_param fail_loc=$1
2537 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2545 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2546 wait $PID1 || error "(3) mv failed"
2547 wait $PID2 || error "(4) stat failed"
2554 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2555 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2557 do_facet mds1 $LCTL set_param fail_loc=$1
2559 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2567 $MULTIOP $DIR2/d1/d2 Oc &
2571 stat $DIR/d1 || error "(2) stat failed"
2573 wait $PID1 || error "(3) mv failed"
2574 wait $PID2 || error "(4) stat failed"
2575 wait $PID3 && error "(5) multiop failed"
2581 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2582 save_lustre_params client "llite.*.xattr_cache" > $p
2583 lctl set_param llite.*.xattr_cache 1 ||
2584 { skip "xattr cache is not supported"; return 0; }
2586 #define OBD_FAIL_MDS_RENAME 0x153
2587 #define OBD_FAIL_MDS_RENAME2 0x154
2588 test_54_part1 0x80000153 || error 10
2589 test_54_part1 0x80000154 || error 11
2590 test_54_part2 0x80000153 || error 12
2591 test_54_part2 0x80000154 || error 13
2593 restore_lustre_params < $p
2596 run_test 54 "rename locking"
2599 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2601 #define OBD_FAIL_MDS_RENAME4 0x156
2602 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2604 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2609 wait $PID1 && error "(2) mv succeeded"
2613 run_test 55a "rename vs unlink target dir"
2617 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2619 #define OBD_FAIL_MDS_RENAME4 0x156
2620 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2622 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2627 wait $PID1 && error "(2) mv succeeded"
2631 run_test 55b "rename vs unlink source dir"
2635 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2637 #define OBD_FAIL_MDS_RENAME4 0x156
2638 do_facet mds1 $LCTL set_param fail_loc=0x156
2640 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2644 # while rename is sleeping, open and remove d3
2645 $MULTIOP $DIR2/d3 D_c &
2651 # while rename is sleeping 2nd time, close d3
2653 wait $PID2 || error "(3) multiop failed"
2655 wait $PID1 && error "(2) mv succeeded"
2659 run_test 55c "rename vs unlink orphan target dir"
2665 #define OBD_FAIL_MDS_RENAME3 0x155
2666 do_facet mds1 $LCTL set_param fail_loc=0x155
2667 mv $DIR/f1 $DIR/$tdir &
2671 # while rename is sleeping, create $tdir, but as a directory
2672 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2674 # link in reverse locking order
2675 ln $DIR2/f1 $DIR2/$tdir/
2677 wait $PID1 && error "(2) mv succeeded"
2680 run_test 55d "rename file vs link"
2683 local MDSVER=$(lustre_build_version $SINGLEMDS)
2684 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2685 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2688 test_mkdir $DIR1/$tdir
2689 file1=$DIR1/$tdir/file
2690 file2=$DIR2/$tdir/file
2692 echo orig > $file2 || error "Could not create $file2"
2693 version=$($LFS data_version $file1)
2696 echo append >> $file2 || error "Could not append to $file2"
2697 version2=$($LFS data_version $file1)
2698 [ "$version" != "$version2" ] ||
2699 error "append did not change data version: $version"
2702 echo overwrite > $file2 || error "Could not overwrite $file2"
2703 version3=$($LFS data_version $file1)
2704 [ "$version2" != "$version3" ] ||
2705 error "overwrite did not change data version: $version2"
2707 # Truncate before EOF
2708 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2709 version4=$($LFS data_version $file1)
2710 [ "$version3" != "$version4" ] ||
2711 error "truncate did not change data version: $version3"
2713 # Truncate after EOF
2714 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2715 version5=$($LFS data_version $file1)
2716 [ "$version4" != "$version5" ] ||
2717 error "truncate did not change data version: $version4"
2719 # Chmod do not change version
2720 chmod 400 $file2 || error "Could not chmod 400 $file2"
2721 version6=$($LFS data_version $file1)
2722 [ "$version5" == "$version6" ] ||
2723 error "chmod should not change data version: $version5 != $version6"
2725 # Chown do not change version
2726 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2727 version7=$($LFS data_version $file1)
2728 [ "$version5" == "$version7" ] ||
2729 error "chown should not change data version: $version5 != $version7"
2731 run_test 60 "Verify data_version behaviour"
2734 local test_dir=$tdir/test_dir
2736 mkdir -p $DIR1/$tdir
2737 if [ $MDSCOUNT -ge 2 ]; then
2739 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2740 error "Create remote directory failed"
2742 mkdir -p $DIR1/$test_dir
2744 cd $DIR2/$test_dir || error "cd directory failed"
2745 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2747 cd $DIR2/$tdir || error "exit directory"
2749 run_test 70a "cd directory && rm directory"
2751 test_70b() { # LU-2781
2753 mkdir -p $DIR1/$tdir
2755 touch $DIR1/$tdir/file
2756 for ((i = 0; i < 32; i++)); do
2757 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2759 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2761 touch $DIR1/$tdir/file
2762 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2763 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2764 rm -rf $DIR1/$tdir/test_dir ||
2765 error "cannot remove directory after rm_entry"
2766 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2768 run_test 70b "remove files after calling rm_entry"
2771 local server_version=$(lustre_version_code $SINGLEMDS)
2773 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2774 skip "Need MDS version at least 2.1.6" && return
2776 # Patch not applied to 2.2 and 2.3 branches
2777 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2778 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2779 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2782 checkfiemap --test ||
2783 { skip "checkfiemap not runnable: $?" && return; }
2784 # write data this way: hole - data - hole - data
2785 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2786 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2788 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2789 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2790 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2792 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2794 checkfiemap $DIR2/$tfile 81920 ||
2795 error "data is not flushed from client"
2796 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2799 # common case of "create file, copy file" on a single node
2800 # should not flush data from ost
2801 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2802 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2804 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2806 checkfiemap $DIR1/$tfile 81920 ||
2808 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2810 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2812 run_test 71a "correct file map just after write operation is finished"
2815 local server_version=$(lustre_version_code $SINGLEMDS)
2817 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2818 skip "Need MDS version at least 2.1.6" && return
2820 # Patch not applied to 2.2 and 2.3 branches
2821 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2822 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2823 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2825 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2827 checkfiemap --test ||
2828 { skip "error $?: checkfiemap failed" && return; }
2830 mkdir -p $DIR1/$tdir
2832 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2833 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2834 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2836 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2837 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2839 run_test 71b "check fiemap support for stripecount > 1"
2842 local p="$TMP/sanityN-$TESTNAME.parameters"
2845 save_lustre_params client "llite.*.xattr_cache" > $p
2846 lctl set_param llite.*.xattr_cache 1 ||
2847 { skip "xattr cache is not supported"; return 0; }
2850 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2851 error "setfattr1 failed"
2852 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2853 error "getfattr1 failed"
2854 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2855 error "setfattr2 failed"
2856 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2857 error "getfattr2 failed"
2859 # check that trusted.link is consistent
2860 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2861 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2862 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2863 echo "$tlink1 $tlink2"
2864 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2868 restore_lustre_params < $p
2871 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2874 local p="$TMP/sanityN-$TESTNAME.parameters"
2875 save_lustre_params client "llite.*.xattr_cache" > $p
2876 lctl set_param llite.*.xattr_cache 1 ||
2877 { skip "xattr cache is not supported"; return 0; }
2880 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2881 error "setfattr1 failed"
2882 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2883 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2884 clear_stats llite.*.stats
2885 # PR lock should be cached by now on both clients
2886 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2887 # 2 hits for getfattr(0)+getfattr(size)
2888 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2889 error "not cached in $DIR1"
2890 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2891 # 4 hits for more getfattr(0)+getfattr(size)
2892 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2893 error "not cached in $DIR2"
2896 restore_lustre_params < $p
2899 run_test 73 "getxattr should not cause xattr lock cancellation"
2902 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2903 skip "Need MDS version at least 2.4.93" && return
2905 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2906 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2907 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2909 run_test 74 "flock deadlock: different mounts =============="
2913 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2914 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2915 cancel_lru_locks osc
2917 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2920 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2921 $LCTL set_param fail_loc=0x31d
2922 stat -c %s $DIR1/$tfile &
2927 # For bad lock error handler we should ASSERT and got kernel panic here
2929 $LCTL set_param fail_loc=0
2931 run_test 75 "osc: upcall after unuse lock==================="
2934 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2935 skip "Need MDS version at least 2.5.53" && return
2937 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2938 local fcount=$((MDSCOUNT * 256))
2943 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2949 test_mkdir $DIR/$tdir
2951 # drop all open locks and close any cached "open" files on the client
2952 cancel_lru_locks mdc
2954 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2955 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2956 local already=${#fid_list[@]}
2957 for (( i = 0; i < $already; i++ )) ; do
2958 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2961 echo -n "opening files: "
2962 ulimit -n $((fcount + 50))
2963 for ((i = 0; i < $fcount; i++)); do
2964 touch $DIR/$tdir/f_$i
2965 local fd=$(free_fd ${fd_list[i]})
2966 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
2971 (( $i % 32 == 0 )) && echo -n "."
2975 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2977 # Possible errors in openfiles FID list.
2978 # 1. Missing FIDs. Check 1
2979 # 2. Extra FIDs. Check 1
2980 # 3. Duplicated FID. Check 2
2981 # 4. Invalid FIDs. Check 2
2982 # 5. Valid FID, points to some other file. Check 3
2985 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
2986 error "${#fid_list[@]} != $fcount (+$already old) open files"
2988 echo -n "closing files: "
2989 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
2990 local close_cmd="exec ${fd_list[fd]}<&-"
2992 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
2994 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
2995 echo "skip old open file $filename"
2997 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3001 rm --interactive=no $filename
3003 error "Nonexisting fid ${fid_list[fid]} listed."
3004 (( $fd % 32 == 0 )) && echo -n "."
3009 ls_op=$(ls $DIR2/$tdir | wc -l)
3011 error "Some openfiles are missing in lproc output"
3015 run_test 76 "Verify MDT open_files listing"
3019 local dir=$DIR/$tdir
3022 mkdir $dir || error "mkdir $dir failed"
3023 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3026 do_nodes $CLIENTS $myRUNAS \
3027 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3028 error "dd at 0 on client failed (1)"
3030 for ((i = 0; i < $n; i++)); do
3031 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3032 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3033 error "dd at ${i}MB on client failed (2)" &
3036 do_nodes $CLIENTS sync;
3037 cancel_lru_locks osc
3039 for ((i = 0; i < $n; i++)); do
3040 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3041 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3042 error "dd at ${i}MB on client failed (3)" &
3045 cancel_lru_locks osc
3047 for ((i = 0; i < $n; i++)); do
3051 rm -rf $dir || error "rm -rf $dir failed"
3054 test_77a() { #LU-3266
3055 oss=$(comma_list $(osts_nodes))
3056 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
3061 run_test 77a "check FIFO NRS policy"
3063 test_77b() { #LU-3266
3064 oss=$(comma_list $(osts_nodes))
3066 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3067 ost.OSS.*.nrs_crrn_quantum=1
3069 echo "policy: crr-n, crrn_quantum 1"
3072 do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
3074 echo "policy: crr-n, crrn_quantum 64"
3078 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3081 run_test 77b "check CRR-N NRS policy"
3086 oss=$(comma_list $(osts_nodes))
3088 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3089 ost.OSS.*.nrs_"$policy"_quantum=1 \
3090 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3091 ost.OSS.*.nrs_"$policy"_supported="reads"
3093 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
3096 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
3097 ost.OSS.*.nrs_${policy}_quantum=64
3099 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
3102 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3103 ost.OSS.*.nrs_${policy}_offset_type="logical"
3104 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3108 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3112 test_77c() { #LU-3266
3116 run_test 77c "check ORR NRS policy"
3118 test_77d() { #LU-3266
3122 run_test 77d "check TRR nrs policy"
3129 do_facet $facet lctl set_param \
3130 ost.OSS.ost_io.nrs_tbf_rule="$*"
3132 error "failed to run operate '$*' on TBF rules"
3135 cleanup_tbf_verify()
3139 echo "cleanup_tbf $DIR/$tdir"
3142 wait_delete_completed
3147 local dir=$DIR/$tdir
3148 local client1=${CLIENT1:-$(hostname)}
3151 local np=$(check_cpt_number ost1)
3152 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3153 echo "cpu_npartitions on ost1 is $np"
3155 mkdir $dir || error "mkdir $dir failed"
3156 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3159 trap cleanup_tbf_verify EXIT
3160 echo "Limited write rate: $1, read rate: $2"
3161 echo "Verify the write rate is under TBF control"
3162 local start=$SECONDS
3163 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3164 bs=1M count=100 oflag=direct 2>&1
3165 local runtime=$((SECONDS - start + 1))
3166 local rate=$(bc <<< "scale=6; 100 / $runtime")
3167 echo "Write runtime is $runtime s, speed is $rate IOPS"
3169 # verify the write rate does not exceed TBF rate limit
3170 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3171 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3173 cancel_lru_locks osc
3175 echo "Verify the read rate is under TBF control"
3177 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3178 bs=1M count=100 iflag=direct 2>&1
3179 runtime=$((SECONDS - start + 1))
3180 rate=$(bc <<< "scale=6; 100 / $runtime")
3181 echo "Read runtime is $runtime s, speed is $rate IOPS"
3183 # verify the read rate does not exceed TBF rate limit
3184 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3185 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3187 cancel_lru_locks osc
3188 cleanup_tbf_verify || error "rm -rf $dir failed"
3192 local server_version=$(lustre_version_code ost1)
3193 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3194 { skip "Need server version newer than 2.7.57"; return 0; }
3196 oss=$(comma_list $(osts_nodes))
3198 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3199 [ $? -ne 0 ] && error "failed to set TBF policy"
3203 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3208 # Only operate rules on ost1 since OSTs might run on the same OSS
3210 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3211 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3212 local client_nids=$(nids_list $address "\\")
3213 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3214 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3218 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3219 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3220 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3224 tbf_rule_operate ost1 "stop\ localhost"
3225 tbf_rule_operate ost1 "stop\ clients"
3226 tbf_rule_operate ost1 "stop\ others"
3229 # Cleanup the TBF policy
3230 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3231 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3235 run_test 77e "check TBF NID nrs policy"
3238 local server_version=$(lustre_version_code ost1)
3239 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3240 { skip "Need server version newer than 2.7.57"; return 0; }
3242 oss=$(comma_list $(osts_nodes))
3244 # Configure jobid_var
3245 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3246 if [ $saved_jobid_var != procname_uid ]; then
3247 set_conf_param_and_check client \
3248 "$LCTL get_param -n jobid_var" \
3249 "$FSNAME.sys.jobid_var" procname_uid
3252 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3253 [ $? -ne 0 ] && error "failed to set TBF policy"
3257 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3262 # Only operate rules on ost1 since OSTs might run on the same OSS
3264 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3265 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3266 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3267 nrs_write_read "$RUNAS"
3270 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3271 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3272 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3273 nrs_write_read "$RUNAS"
3276 tbf_rule_operate ost1 "stop\ runas"
3277 tbf_rule_operate ost1 "stop\ iozone_runas"
3278 tbf_rule_operate ost1 "stop\ dd_runas"
3279 nrs_write_read "$RUNAS"
3281 # Cleanup the TBF policy
3282 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3283 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3284 nrs_write_read "$RUNAS"
3286 local current_jobid_var=$($LCTL get_param -n jobid_var)
3287 if [ $saved_jobid_var != $current_jobid_var ]; then
3288 set_conf_param_and_check client \
3289 "$LCTL get_param -n jobid_var" \
3290 "$FSNAME.sys.jobid_var" $saved_jobid_var
3294 run_test 77f "check TBF JobID nrs policy"
3297 local server_version=$(lustre_version_code ost1)
3298 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3299 { skip "Need server version newer than 2.7.57"; return 0; }
3301 oss=$(comma_list $(osts_nodes))
3303 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3304 [ $? -ne 0 ] && error "failed to set TBF policy"
3306 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3307 [ $? -ne 0 ] && error "failed to set TBF policy"
3311 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3316 # Add a rule that only valid for Jobid TBF. If direct change between
3317 # TBF types is not supported, this operation will fail.
3318 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3320 # Cleanup the TBF policy
3321 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3322 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3325 run_test 77g "Change TBF type directly"
3328 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3329 { skip "Need OST version at least 2.8.55"; return 0; }
3331 local old_policy=$(do_facet ost1 \
3332 lctl get_param ost.OSS.ost_io.nrs_policies)
3335 do_facet ost1 lctl set_param \
3336 ost.OSS.ost_io.nrs_policies="abc"
3337 [ $? -eq 0 ] && error "should return error"
3339 do_facet ost1 lctl set_param \
3340 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3341 [ $? -eq 0 ] && error "should return error"
3343 do_facet ost1 lctl set_param \
3344 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3345 [ $? -eq 0 ] && error "should return error"
3347 do_facet ost1 lctl set_param \
3348 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3349 [ $? -eq 0 ] && error "should return error"
3351 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3352 [ $? -eq 0 ] || error "shouldn't LBUG"
3354 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3358 run_test 77h "Wrong policy name should report error, not LBUG"
3364 local error_message=$3
3366 for rule in $expected; do
3367 rule_number=$((rule_number + 1))
3369 local stop_line=$(($rule_number + 3))
3370 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3372 local output=$(do_facet $facet lctl get_param \
3373 ost.OSS.ost_io.nrs_tbf_rule |
3377 if [ "$output" != "$expected" ]; then
3378 error "$error_message, expected '$expected', got '$output'"
3383 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3384 { skip "Need OST version at least 2.8.55"; return 0; }
3386 for i in $(seq 1 $OSTCOUNT)
3388 do_facet ost"$i" lctl set_param \
3389 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3391 error "failed to set TBF policy"
3394 tbf_rule_check ost1 "default" "error before inserting any rule"
3396 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3397 tbf_rule_check ost1 "before default" \
3398 "error when inserting rule 'before'"
3400 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3401 tbf_rule_check ost1 "before after default" \
3402 "error when inserting rule 'after'"
3404 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3405 tbf_rule_check ost1 "before target after default" \
3406 "error when inserting rule 'target'"
3408 echo "Move before itself"
3409 tbf_rule_operate ost1 "change\ target\ rank=target"
3410 tbf_rule_check ost1 "before target after default" \
3411 "error when moving before itself"
3413 echo "Move to higher rank"
3414 tbf_rule_operate ost1 "change\ target\ rank=before"
3415 tbf_rule_check ost1 "target before after default" \
3416 "error when moving to higher rank"
3418 echo "Move to lower rank"
3419 tbf_rule_operate ost1 "change\ target\ rank=after"
3420 tbf_rule_check ost1 "before target after default" \
3421 "error when moving to lower rank"
3423 echo "Move before default"
3424 tbf_rule_operate ost1 "change\ target\ rank=default"
3425 tbf_rule_check ost1 "before after target default" \
3426 error "error when moving before default"
3428 # Cleanup the TBF policy
3429 do_nodes $(comma_list $(osts_nodes)) \
3430 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3433 run_test 77i "Change rank of TBF rule"
3438 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.60) ]; then
3443 do_nodes $(comma_list $(osts_nodes)) \
3444 lctl set_param jobid_var=procname_uid \
3445 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3446 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3447 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3448 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3453 do_nodes $(comma_list $(osts_nodes)) \
3454 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3455 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3456 ost.OSS.ost_io.nrs_policies="fifo"
3458 # sleep 3 seconds to wait the tbf policy stop completely,
3459 # or the next test case is possible get -EAGAIN when
3460 # setting the tbf policy
3463 run_test 77j "check TBF-OPCode NRS policy"
3466 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3467 { skip "Need OST version at least 2.9.53"; return 0; }
3469 do_nodes $(comma_list $(osts_nodes)) \
3470 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3471 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3472 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3474 nrs_write_read "$RUNAS"
3475 tbf_verify 20 10 "$RUNAS"
3477 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3478 local client_nids=$(nids_list $address "\\")
3479 do_nodes $(comma_list $(osts_nodes)) \
3480 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3481 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3482 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3483 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3488 do_nodes $(comma_list $(osts_nodes)) \
3489 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3490 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3491 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3493 nrs_write_read "$RUNAS"
3494 tbf_verify 20 20 "$RUNAS"
3496 do_nodes $(comma_list $(osts_nodes)) \
3497 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3498 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3499 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3501 nrs_write_read "$RUNAS"
3502 # with parameter "RUNAS", it will match the latest rule
3503 # "ext_b" first, so the limited write rate is 10.
3504 tbf_verify 10 10 "$RUNAS"
3507 do_nodes $(comma_list $(osts_nodes)) \
3508 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3509 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3510 ost.OSS.ost_io.nrs_policies="fifo"
3514 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3517 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3518 skip "Need OST version at least 2.9.54"
3522 local dir=$DIR/$tdir
3524 mkdir $dir || error "mkdir $dir failed"
3525 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3528 local nodes=$(comma_list $(osts_nodes))
3529 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3530 ost.OSS.ost_io.nrs_delay_min=4 \
3531 ost.OSS.ost_io.nrs_delay_max=4 \
3532 ost.OSS.ost_io.nrs_delay_pct=100
3533 [ $? -ne 0 ] && error "Failed to set delay policy"
3535 local start=$SECONDS
3536 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3537 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3538 oflag=direct conv=fdatasync ||
3539 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3540 error "dd on client failed (1)"; }
3541 local elapsed=$((SECONDS - start))
3543 # NRS delay doesn't do sub-second timing, so a request enqueued at
3544 # 0.9 seconds can be dequeued at 4.0
3545 [ $elapsed -lt 3 ] &&
3546 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3547 error "Single 1M write should take at least 3 seconds"; }
3550 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3551 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3552 oflag=direct conv=fdatasync ||
3553 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3554 error "dd on client failed (2)"; }
3555 elapsed=$((SECONDS - start))
3557 [ $elapsed -lt 30 ] &&
3558 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3559 error "Ten 1M writes should take at least 30 seconds"; }
3561 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3562 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3566 run_test 77l "check NRS Delay slows write RPC processing"
3568 test_78() { #LU-6673
3569 local server_version=$(lustre_version_code ost1)
3570 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3571 { skip "Need server version newer than 2.7.57"; return 0; }
3575 oss=$(comma_list $(osts_nodes))
3576 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3577 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3579 # Valid return codes are:
3580 # 0: Tuning succeeded
3581 # ENODEV: Policy is still stopped
3582 # EAGAIN: Policy is being initialized
3583 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3584 error "Expected set_param to return 0|ENODEV|EAGAIN"
3586 # Cleanup the ORR policy
3587 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3588 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3591 run_test 78 "Enable policy and specify tunings right away"
3594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3595 test_mkdir $DIR/$tdir
3597 # Prevent interference from layout intent RPCs due to
3598 # asynchronous writeback. These will be tested in 130c below.
3599 do_nodes ${CLIENTS:-$HOSTNAME} sync
3601 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3602 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3604 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3605 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3606 local facet=mds$((mdtidx + 1))
3608 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3609 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3613 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3614 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3619 run_test 79 "xattr: intent error"
3622 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3629 mkdir -p $DIR1/$tdir/dir
3630 createmany -o $DIR1/$tdir/dir/f 10 ||
3631 error "create files under remote dir failed $i"
3633 cp /etc/passwd $DIR1/$tdir/$tfile
3635 #migrate open file should fails
3636 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3638 # give multiop a chance to open
3641 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3642 error "migrate open files should failed with open files"
3646 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3647 error "migrate remote dir error"
3649 echo "Finish migration, then checking.."
3650 for file in $(find $DIR1/$tdir); do
3651 mdt_index=$($LFS getstripe -M $file)
3652 [ $mdt_index == $MDTIDX ] ||
3653 error "$file is not on MDT${MDTIDX}"
3656 diff /etc/passwd $DIR1/$tdir/$tfile ||
3657 error "file different after migration"
3659 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3661 run_test 80a "migrate directory when some children is being opened"
3665 kill -9 $migrate_pid
3669 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3670 local migrate_dir1=$DIR1/$tdir/migrate_dir
3671 local migrate_dir2=$DIR2/$tdir/migrate_dir
3672 local migrate_run=$LUSTRE/tests/migrate.sh
3680 trap cleanup_80b EXIT
3681 #prepare migrate directory
3682 mkdir -p $migrate_dir1
3683 for F in {1,2,3,4,5}; do
3684 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3685 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3688 #migrate the directories among MDTs
3691 mdt_idx=$((RANDOM % MDSCOUNT))
3692 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3694 [ $rc -ne 0 -o $rc -ne 16 ] || break
3699 echo "start migration thread $migrate_pid"
3700 #Access the files at the same time
3701 start_time=$(date +%s)
3702 echo "accessing the migrating directory for 5 minutes..."
3704 ls $migrate_dir2 > /dev/null || {
3705 echo "read dir fails"
3708 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3709 echo "access file1 fails"
3713 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3714 echo "access file2/3 fails"
3718 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3719 echo "access file4 fails"
3723 stat $migrate_dir2/file5 > /dev/null || {
3724 echo "stat file5 fails"
3728 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3729 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3730 echo "touch file failed with $rc1"
3734 if [ -e $migrate_dir2/source_file ]; then
3735 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3736 &>/dev/null || rc1=$?
3737 if [ -e $migrate_dir2/link_file ]; then
3738 rm -rf $migrate_dir2/link_file
3741 mrename $migrate_dir2/source_file \
3742 $migrate_dir2/target_file &>/dev/null || rc1=$?
3743 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3744 echo "rename failed with $rc1"
3748 if [ -e $migrate_dir2/target_file ]; then
3749 rm -rf $migrate_dir2/target_file &>/dev/null ||
3752 rm -rf $migrate_dir2/source_file &>/dev/null ||
3755 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3756 echo "unlink failed with $rc1"
3761 end_time=$(date +%s)
3762 duration=$((end_time - start_time))
3763 if [ $((duration % 10)) -eq 0 ]; then
3764 if [ $show_time -eq 1 ]; then
3765 echo "...$duration seconds"
3772 kill -0 $migrate_pid || {
3773 echo "migration stopped 1"
3777 [ $duration -ge 300 ] && break
3780 #check migration are still there
3781 kill -0 $migrate_pid || error "migration stopped 2"
3784 run_test 80b "Accessing directory during migration"
3787 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3791 mkdir -p $DIR1/$tdir
3793 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3794 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3797 touch d0/0 || error "create 0 failed"
3798 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3799 stat d0/0 && error "stat mv filed succeed"
3800 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3801 stat d0/0 || error "stat failed"
3803 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3805 if [ $t -ne 3 ]; then
3806 ls -ai $DIR1/$tdir/d0
3807 error "expect 3 get $t"
3812 run_test 81 "rename and stat under striped directory"
3815 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3816 { skip "Need MDS version at least 2.6.92"; return 0; }
3818 # Client 1 creates a file.
3819 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3821 # Client 2 opens the file.
3822 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3824 # Client 1 makes the file an orphan.
3825 rm $DIR1/$tfile || error "rm"
3826 # Client 2 sets EA "user.multiop".
3828 wait $pid2 || error "multiop 2"
3829 # Client 1 gets EA "user.multiop". This used to fail because the EA
3830 # cache refill would get "trusted.link" from mdd_xattr_list() but
3831 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3834 wait $pid1 || error "multiop 1"
3836 run_test 82 "fsetxattr and fgetxattr on orphan files"
3839 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3846 $LFS mkdir -i1 -c2 $tdir
3851 echo "start pid $pid1 to create/unlink striped directory"
3853 # Access the directory at the same time
3857 stat $tdir > /dev/null 2>&1
3861 echo "start pid $pid2 to stat striped directory"
3869 run_test 83 "access striped directory while it is being created/unlinked"
3872 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3877 [ "$SLOW" = "yes" ] && duration=600
3878 # Open/Create under striped directory
3882 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3883 touch $tdir/f{0..3} > /dev/null 2>&1
3887 echo "start pid $pid1 to open/create under striped directory"
3889 # unlink the striped directory at the same time
3893 rm -rf $tdir > /dev/null 2>&1
3897 echo "start pid $pid2 to unlink striped directory"
3906 run_test 90 "open/create and unlink striped directory"
3909 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3914 [ "$SLOW" = "yes" ] && duration=600
3915 # chmod striped directory
3919 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3920 chmod go+w $tdir > /dev/null 2>&1
3924 echo "start pid $pid1 to chmod striped directory"
3926 # unlink the striped directory at the same time
3930 rm -rf $tdir > /dev/null 2>&1
3934 echo "start pid $pid2 to unlink striped directory"
3943 run_test 91 "chmod and unlink striped directory"
3946 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3949 local cmd="exec $fd<$DIR1/$tdir"
3950 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3953 trap "eval $cmd" EXIT
3954 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3955 rmdir ../$tdir || error "rmdir ../$tdir fails"
3957 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3958 $LCTL set_param fail_loc=0x1408
3959 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3960 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3961 error "create remote dir succeeds"
3962 $LCTL set_param fail_loc=0
3966 run_test 92 "create remote directory under orphan directory"
3973 mkdir -p $DIR1/$tfile-1/
3974 mkdir -p $DIR2/$tfile-2/
3975 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
3976 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
3977 do_facet $SINGLEMDS lctl set_param -n \
3978 'lod.lustre-MDT*/qos_threshold_rr' 100
3979 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
3980 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
3982 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
3985 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
3989 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
3990 do_facet $SINGLEMDS "lctl set_param -n \
3991 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
3993 $GETSTRIPE $DIR1/$tfile-1/file1
3994 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
3995 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
3996 $GETSTRIPE $DIR2/$tfile-2/file2
3997 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
3998 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
3999 echo "rc1=$rc1 and rc2=$rc2 "
4000 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4001 error "object allocate on same ost detected"
4003 run_test 93 "alloc_rr should not allocate on same ost"
4005 log "cleanup: ======================================================"
4007 # kill and wait in each test only guarentee script finish, but command in script
4008 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4009 # otherwise umount below will fail
4010 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4015 check_and_cleanup_lustre