6 # bug number for skipped test: LU-1205 9977/LU-7105 LU-9452
7 ALWAYS_EXCEPT=" 18c 28 29 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
14 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
15 OPENFILE=${OPENFILE:-openfile}
16 OPENUNLINK=${OPENUNLINK:-openunlink}
17 export MULTIOP=${MULTIOP:-multiop}
18 export TMP=${TMP:-/tmp}
19 MOUNT_2=${MOUNT_2:-"yes"}
20 CHECK_GRANT=${CHECK_GRANT:-"yes"}
21 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
25 export NAME=${NAME:-local}
27 LUSTRE=${LUSTRE:-`dirname $0`/..}
28 . $LUSTRE/tests/test-framework.sh
32 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
35 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
36 # bug number for skipped test: LU-2776
37 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 51a"
38 # LU-2829 / LU-2887 - make allowances for ZFS slowness
39 TEST33_NFILES=${TEST33_NFILES:-1000}
42 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
49 check_and_setup_lustre
52 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
54 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
55 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
57 # $RUNAS_ID may get set incorrectly somewhere else
58 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
60 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
66 [ -f $DIR2/$tfile ] || error "Check create"
67 chmod 777 $DIR2/$tfile
68 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
69 error "Check attribute update for 0777"
71 chmod a-x $DIR2/$tfile
72 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
73 error "Check attribute update for 0666"
76 $CHECKSTAT -a $DIR1/$tfile ||
77 error "Check unlink - removes file on other mountpoint"
79 run_test 1 "Check attribute updates on 2 mount points"
85 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
87 run_test 2a "check cached attribute updates on 2 mtpt's ========"
93 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
95 run_test 2b "check cached attribute updates on 2 mtpt's ========"
97 # NEED TO SAVE ROOT DIR MODE
100 $CHECKSTAT -t dir -p 0777 $DIR2 || error
102 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
106 $CHECKSTAT -t dir -p 0755 $DIR2 || error
108 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
115 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
117 run_test 2e "check chmod on root is propagated to others"
120 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
122 local remote_dir=$tdir/remote_dir
125 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
126 error "Create remote directory failed"
128 touch $DIR1/$remote_dir/$tfile ||
129 error "Create file under remote directory failed"
130 chmod 777 $DIR1/$remote_dir/$tfile ||
131 error "Chmod file under remote directory failed"
133 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
134 error "Check attr of file under remote directory failed"
136 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
137 error "Chown file under remote directory failed"
139 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
140 error "Check owner of file under remote directory failed"
142 cd $DIR2/$remote_dir || error "enter remote dir"
143 rm -rf $DIR1/$remote_dir/$tfile ||
144 error "Unlink remote directory failed"
146 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
147 error "unlink file still exists!"
149 cd $DIR2/$tdir || error "exit remote dir"
150 rm -rf $DIR1/$tdir || error "unlink directory failed"
152 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
155 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
157 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
159 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
160 echo "$DIR1/$tfile has $block1 blocks"
161 echo "$DIR2/$tfile has $block2 blocks"
162 [ $block1 -eq $block2 ] || error
164 run_test 2g "check blocks update on sync write"
167 local target="this/is/good"
168 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
169 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
170 error "link $DIR2/$tfile not as expected"
172 run_test 3 "symlink on one mtpt, readlink on another ==========="
175 multifstat $DIR1/f4 $DIR2/f4
177 run_test 4 "fstat validation on multiple mount points =========="
181 $TRUNCATE $DIR2/f5 100
182 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
185 run_test 5 "create a file on one mount, truncate it on the other"
188 openunlink $DIR1/$tfile $DIR2/$tfile || \
189 error "openunlink $DIR1/$tfile $DIR2/$tfile"
191 run_test 6 "remove of open file on other node =================="
195 opendirunlink $DIR1/$dir $DIR2/$dir || \
196 error "opendirunlink $DIR1/$dir $DIR2/$dir"
198 run_test 7 "remove of open directory on other node ============="
201 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
202 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
204 run_test 8 "remove of open special file on other node =========="
210 for C in a b c d e f g h i j k l; do
211 dir=`eval echo \\$DIR$MTPT`
212 echo -n $C >> $dir/f9
213 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
215 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
216 error "`od -a $DIR1/f9` != abcdefghijkl"
218 run_test 9 "append of file with sub-page size on multiple mounts"
225 for C in a b c d e f g h i j k l; do
226 dir=`eval echo \\$DIR$MTPT`
227 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
228 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
229 OFFSET=`expr $OFFSET + 1`
231 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
232 error "`od -a $DIR1/f10` != abcdefghijkl"
234 run_test 10a "write of file with sub-page size on multiple mounts "
238 yes "R" | head -c 4000 >$TMP/f10b-seed
239 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
241 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
243 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
245 # create a test file locally to compare
246 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
247 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
248 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
249 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
251 run_test 10b "write of file with sub-page size on multiple mounts "
255 multiop_bg_pause $DIR1/d11/f O_c || return 1
257 cp -p /bin/ls $DIR1/d11/f
261 wait $MULTIPID || error
262 [ $RC -eq 0 ] && error || true
264 run_test 11 "execution of file opened for write should return error ===="
267 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
269 run_test 12 "test lock ordering (link, stat, unlink) ==========="
271 test_13() { # bug 2451 - directory coherency
272 test_mkdir $DIR1/d13 || error
273 cd $DIR1/d13 || error
275 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
277 rm -f $DIR2/d13/f13 || error
278 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
279 # need to run it twice
280 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
282 rm -f $DIR2/d13/f13 || error
283 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
285 run_test 13 "test directory page revocation ===================="
288 test_mkdir -p $DIR1/$tdir
289 cp -p /bin/ls $DIR1/$tdir/$tfile
290 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
293 $DIR2/$tdir/$tfile && error || true
295 wait $MULTIPID || return 2
297 run_test 14aa "execution of file open for write returns -ETXTBSY"
300 test_mkdir -p $DIR1/d14
301 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
302 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
304 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
305 kill -USR1 $MULTIOP_PID || return 2
306 wait $MULTIOP_PID || return 3
307 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
309 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
311 test_14b() { # bug 3192, 7040
312 test_mkdir -p $DIR1/d14
313 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
314 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
316 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
317 error "expected truncate error, got success"
318 kill -USR1 $MULTIOP_PID || return 2
319 wait $MULTIOP_PID || return 3
320 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
321 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
323 run_test 14b "truncate of executing file returns -ETXTBSY ======"
325 test_14c() { # bug 3430, 7040
326 test_mkdir -p $DIR1/d14
327 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
328 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
330 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
331 kill -USR1 $MULTIOP_PID || return 2
332 wait $MULTIOP_PID || return 3
333 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
334 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
336 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
338 test_14d() { # bug 10921
339 test_mkdir -p $DIR1/d14
340 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
341 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
344 chmod 600 $DIR1/d14/multiop || error "chmod failed"
345 kill -USR1 $MULTIOP_PID || return 2
346 wait $MULTIOP_PID || return 3
347 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
348 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
350 run_test 14d "chmod of executing file is still possible ========"
352 test_15() { # bug 974 - ENOSPC
354 sh oos2.sh $MOUNT1 $MOUNT2
355 wait_delete_completed
356 grant_error=`dmesg | grep "> available"`
357 [ -z "$grant_error" ] || error "$grant_error"
359 run_test 15 "test out-of-space with multiple writers ==========="
362 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
363 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
364 # pass a 2500 operation dual-mount run within the time limit.
365 if [ "$(facet_fstype ost1)" = "zfs" ]; then
366 FSXNUM=$((COUNT / 5))
368 elif [ "$SLOW" = "yes" ]; then
369 FSXNUM=$((COUNT * 5))
377 local file1=$DIR1/$tfile
378 local file2=$DIR2/$tfile
380 # to allocate grant because it may run out due to test_15.
381 $LFS setstripe -c -1 $file1
382 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
383 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
386 $LFS setstripe -c -1 $file1 # b=10919
387 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
388 || error "fsx failed"
391 # O_DIRECT reads and writes must be aligned to the device block size.
392 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
393 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
395 run_test 16 "$FSXNUM iterations of dual-mount fsx"
397 test_17() { # bug 3513, 3667
398 remote_ost_nodsh && skip "remote OST with nodsh" && return
400 lfs setstripe $DIR1/$tfile -i 0 -c 1
401 cp $SAMPLE_FILE $DIR1/$tfile
402 cancel_lru_locks osc > /dev/null
403 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
404 do_facet ost1 lctl set_param fail_loc=0x8000030a
405 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
406 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
408 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
410 run_test 17 "resource creation/LVB creation race ==============="
413 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
416 for idx in {a..z}; do
417 local ptr=EXCEPT_ALWAYS_18$idx
418 [ x${!ptr} = xtrue ] || continue
420 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
423 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
426 run_test 18 "mmap sanity check ================================="
428 test_19() { # bug3811
429 local node=$(facet_active_host ost1)
431 # check whether obdfilter is cache capable at all
432 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
433 echo "not cache-capable obdfilter"
437 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
439 set_osd_param $node '' readcache_max_filesize 4096
440 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
441 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
442 cp $TMP/$tfile $DIR1/$tfile
443 for i in `seq 1 20`; do
444 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
445 cancel_lru_locks osc > /dev/null
446 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
447 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
449 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
450 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
451 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
452 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
454 set_osd_param $node '' readcache_max_filesize $MAX
457 run_test 19 "test concurrent uncached read races ==============="
462 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
463 $MULTIOP $DIR1/f20 Ow8190c
464 $MULTIOP $DIR2/f20 Oz8194w8190c
465 $MULTIOP $DIR1/f20 Oz0r8190c
467 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
469 error $CNTD" page left in cache after lock cancel" || true
471 run_test 20 "test extra readahead page left in cache ===="
478 test_21() { # Bug 5907
479 test_mkdir $DIR1/$tdir
480 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
482 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
483 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
484 test -d $DIR1/$tdir || error "Mounted directory disappeared"
486 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
489 run_test 21 " Try to remove mountpoint on another dir ===="
491 test_23() { # Bug 5972
492 local at_diff=$(do_facet $SINGLEMDS \
493 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
494 echo "atime should be updated while another read" > $DIR1/$tfile
496 # clear the lock(mode: LCK_PW) gotten from creating operation
500 sleep $((at_diff + 1))
502 echo "starting reads"
503 multiop_bg_pause $DIR1/$tfile or20_c || return 1
504 # with SOM and opencache enabled, we need to close a file and cancel
505 # open lock to get atime propogated to MDS
506 kill -USR1 $! || return 2
509 time2=$(stat -c "%X" $DIR/$tfile)
510 echo "new atime is $time2"
512 [ $time2 -gt $time1 ] || error "atime was not updated"
513 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
516 run_test 23 " others should see updated atime while another read===="
520 lfs df || error "lfs df failed"
521 lfs df -ih || error "lfs df -ih failed"
522 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
523 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
524 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
525 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
527 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
528 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
529 lctl --device %$OSC deactivate
530 lfs df -i || error "lfs df -i with deactivated OSC failed"
531 lctl --device %$OSC activate
532 lfs df || error "lfs df with reactivated OSC failed"
534 run_test 24a "lfs df [-ih] [path] test ========================="
538 fsnum=$(lfs_df | grep -c "summary")
539 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
541 run_test 24b "lfs df should show both filesystems ==============="
544 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
546 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
549 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
550 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
552 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
553 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
554 error "setfacl $DIR2/$tdir #1"
555 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
556 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
557 error "setfacl $DIR2/$tdir #2"
558 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
559 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
560 error "setfacl $DIR2/$tdir #3"
561 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
562 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
563 error "setfacl $DIR2/$tdir #4"
564 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
568 run_test 25a "change ACL on one mountpoint be seen on another ==="
571 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
573 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
575 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
578 $LFS mkdir -i 1 $DIR1/$tdir
579 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
580 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
582 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
583 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
584 error "setfacl $DIR2/$tdir #1"
585 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
586 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
587 error "setfacl $DIR2/$tdir #2"
588 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
589 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
590 error "setfacl $DIR2/$tdir #3"
591 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
592 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
593 error "setfacl $DIR2/$tdir #4"
594 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
598 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
601 utime $DIR1/f26a -s $DIR2/f26a || error
603 run_test 26a "allow mtime to get older"
608 echo "aaa" >> $DIR1/$tfile
610 chmod a+x $DIR2/$tfile
611 mt1=`stat -c %Y $DIR1/$tfile`
612 mt2=`stat -c %Y $DIR2/$tfile`
614 if [ x"$mt1" != x"$mt2" ]; then
615 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
618 run_test 26b "sync mtime between ost and mds"
623 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
628 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
633 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
635 lctl set_param -n ldlm.dump_namespaces ""
636 wait $DD1_PID $DD2_PID
637 [ $? -ne 0 ] && lctl dk $TMP/debug || true
639 run_test 27 "align non-overlapping extent locks from request ==="
641 test_28() { # bug 9977
642 ECHO_UUID="ECHO_osc1_UUID"
643 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
645 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
646 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
647 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
651 attach echo_client ECHO_osc1 $ECHO_UUID
655 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
656 $LCTL --device $tECHOID destroy "${tOBJID}:0"
664 # reading of 1st stripe should pass
665 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
666 # reading of 2nd stripe should fail (this stripe was destroyed)
667 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
669 # now, recreating test file
670 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
671 # reading of 1st stripe should pass
672 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
673 # reading of 2nd stripe should pass
674 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
676 run_test 28 "read/write/truncate file with lost stripes"
678 test_29() { # bug 10999
680 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
681 lctl set_param fail_loc=0x8000030f
684 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
687 #bug 11549 - permanently turn test off in b1_5
688 run_test 29 "lock put race between glimpse and enqueue ========="
690 test_30() { #bug #11110, LU-2523
691 test_mkdir -p $DIR1/$tdir
692 cp -f /bin/bash $DIR1/$tdir/bash
693 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
694 cp /bin/bash $DIR2/$tdir' &
695 $DIR1/$tdir/bash -c 'sleep 2;
696 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
701 run_test 30 "recreate file race"
704 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
705 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
706 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
707 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
708 lctl set_param fail_loc=0x314
709 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
710 awk 'BEGIN { FS="+" } /in/ {print $1}')
711 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
713 run_test 31a "voluntary cancel / blocking ast race=============="
716 remote_ost || { skip "local OST" && return 0; }
717 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
719 # make sure there is no local locks due to destroy
720 wait_mds_ost_sync || error "wait_mds_ost_sync()"
721 wait_delete_completed || error "wait_delete_completed()"
723 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
724 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
725 cp /etc/hosts $DIR/$tdir/$tfile
726 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
727 lctl set_param fail_loc=0x314
728 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
729 do_facet ost1 lctl set_param fail_loc=0x316
731 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
732 lctl set_param fail_loc=0
733 do_facet ost1 lctl set_param fail_loc=0
734 # cleanup: reconnect the client back
737 run_test 31b "voluntary OST cancel / blocking ast race=============="
739 # enable/disable lockless truncate feature, depending on the arg 0/1
740 enable_lockless_truncate() {
741 lctl set_param -n osc.*.lockless_truncate $1
744 test_32a() { # bug 11270
745 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
746 save_lustre_params client "osc.*.lockless_truncate" > $p
748 enable_lockless_truncate 1
750 lfs setstripe -c -1 $DIR1/$tfile
751 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
753 clear_stats osc.*.osc_stats
755 log "checking cached lockless truncate"
756 $TRUNCATE $DIR1/$tfile 8000000
757 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
758 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
759 error "cached truncate isn't lockless"
761 log "checking not cached lockless truncate"
762 $TRUNCATE $DIR2/$tfile 5000000
763 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
764 [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
765 error "not cached truncate isn't lockless"
767 log "disabled lockless truncate"
768 enable_lockless_truncate 0
769 clear_stats osc.*.osc_stats
770 $TRUNCATE $DIR2/$tfile 3000000
771 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
772 [ $(calc_stats osc.*.osc_stats lockless_truncate) -eq 0 ] ||
773 error "lockless truncate disabling failed"
775 # restore lockless_truncate default values
776 restore_lustre_params < $p
779 run_test 32a "lockless truncate"
781 test_32b() { # bug 11270
782 remote_ost_nodsh && skip "remote OST with nodsh" && return
785 local facets=$(get_facets OST)
786 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
788 save_lustre_params client "osc.*.contention_seconds" > $p
789 save_lustre_params $facets \
790 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
791 save_lustre_params $facets \
792 "ldlm.namespaces.filter-*.contended_locks" >> $p
793 save_lustre_params $facets \
794 "ldlm.namespaces.filter-*.contention_seconds" >> $p
795 clear_stats osc.*.osc_stats
797 # agressive lockless i/o settings
798 do_nodes $(comma_list $(osts_nodes)) \
799 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
800 ldlm.namespaces.filter-*.contended_locks=0 \
801 ldlm.namespaces.filter-*.contention_seconds=60"
802 lctl set_param -n osc.*.contention_seconds=60
804 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
806 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
809 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -ne 0 ] ||
810 error "lockless i/o was not triggered"
811 # disable lockless i/o (it is disabled by default)
812 do_nodes $(comma_list $(osts_nodes)) \
813 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
814 ldlm.namespaces.filter-*.contended_locks=32 \
815 ldlm.namespaces.filter-*.contention_seconds=0"
816 # set contention_seconds to 0 at client too, otherwise Lustre still
817 # remembers lock contention
818 lctl set_param -n osc.*.contention_seconds=0
819 clear_stats osc.*.osc_stats
821 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
823 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
826 [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -eq 0 ] ||
827 error "lockless i/o works when disabled"
829 restore_lustre_params <$p
832 run_test 32b "lockless i/o"
836 local mdts=$(get_facets MDS)
841 for mds in ${mdts//,/ }; do
843 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
844 xargs readlink -f" ))
845 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
848 stat=$(( stat + val))
853 # commit on sharing tests
855 remote_mds_nodsh && skip "remote MDS with nodsh" && return
857 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
858 [ $CLIENTCOUNT -lt 2 ] &&
859 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
861 local nfiles=${TEST33_NFILES:-10000}
862 local param_file=$TMP/$tfile-params
863 local fstype=$(facet_fstype $SINGLEMDS)
865 save_lustre_params $(get_facets MDS) \
866 "mdt.*.commit_on_sharing" > $param_file
874 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
878 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
880 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
881 echo "=== START createmany old: $jbdold transaction"
882 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")
883 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
884 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
885 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
886 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
887 avgtime=$(( avgtime + elapsed ))
889 eval cos${COS}_jbd=$((avgjbd / 3))
890 eval cos${COS}_time=$((avgtime / 3))
893 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
894 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
895 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
896 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
898 restore_lustre_params < $param_file
902 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
904 # commit on sharing tests
906 remote_mds_nodsh && skip "remote MDS with nodsh" && return
908 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
909 [ $CLIENTCOUNT -ge 2 ] ||
910 { skip "Need two or more clients, have $CLIENTCOUNT" &&
912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
914 local nfiles=${TEST33_NFILES:-10000}
915 local param_file=$TMP/$tfile-params
917 save_lustre_params $(get_facets MDS) \
918 "mdt.*.commit_on_sharing" > $param_file
927 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
931 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
932 $DIR1/$tdir-\\\$(hostname)-$i"
934 jbdold=$(print_jbd_stat)
935 echo "=== START createmany old: $jbdold transaction"
936 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
937 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
938 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
940 jbdnew=$(print_jbd_stat)
941 jbd=$(( jbdnew - jbdold ))
942 echo "=== END createmany new: $jbdnew transaction : \
943 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
944 avgjbd=$(( avgjbd + jbd ))
945 avgtime=$(( avgtime + elapsed ))
947 eval cos${COS}_jbd=$((avgjbd / 3))
948 eval cos${COS}_time=$((avgtime / 3))
951 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
952 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
953 [ "$cos0_jbd" != 0 ] &&
954 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
955 [ "$cos0_time" != 0 ] &&
956 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
958 restore_lustre_params < $param_file
962 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
965 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
966 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
967 skip "DNE CoS not supported" && return
972 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
973 $LFS mkdir -i 1 $DIR/$tdir/d1
974 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
976 local sync_count=$(do_facet mds1 \
977 "lctl get_param -n mdt.*MDT0000.sync_count")
978 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
980 $LFS mkdir -i 1 $DIR/$tdir/d3
981 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
982 # during sleep remote mkdir should have been committed and canceled
983 # remote lock spontaneously, which shouldn't trigger sync
986 local sync_count=$(do_facet mds1 \
987 "lctl get_param -n mdt.*MDT0000.sync_count")
988 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
990 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
993 local nodes=$(comma_list $(mdts_nodes))
994 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
996 local async_commit_count=$(do_nodes $nodes \
997 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
998 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
1005 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1006 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1007 skip "DNE CoS not supported" && return
1010 # remote directory create
1012 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1013 # remote directory unlink
1014 $LFS mkdir -i 1 $DIR/$tdir
1015 ops_do_cos "rmdir $DIR/$tdir"
1016 # striped directory create
1018 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1019 # striped directory setattr
1020 $LFS mkdir -c 2 $DIR/$tdir
1022 ops_do_cos "chmod 713 $DIR/$tdir"
1023 # striped directory unlink
1024 $LFS mkdir -c 2 $DIR/$tdir
1026 ops_do_cos "rmdir $DIR/$tdir"
1028 $LFS mkdir -c 2 $DIR/$tdir
1029 $LFS mkdir -i 0 $DIR/$tdir/d1
1030 $LFS mkdir -i 1 $DIR/$tdir/d2
1031 touch $DIR/$tdir/d1/tgt
1032 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1034 $LFS mkdir -c 2 $DIR/$tdir
1035 $LFS mkdir -i 0 $DIR/$tdir/d1
1036 $LFS mkdir -i 1 $DIR/$tdir/d2
1037 touch $DIR/$tdir/d1/src
1038 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1040 $LFS mkdir -i 0 $DIR/$tdir
1041 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1044 run_test 33d "DNE distributed operation should trigger COS"
1047 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1048 [ $CLIENTCOUNT -ge 2 ] ||
1049 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1051 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1052 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1053 skip "DNE CoS not supported" && return
1055 local client2=${CLIENT2:-$(hostname)}
1059 local nodes=$(comma_list $(mdts_nodes))
1060 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1062 $LFS mkdir -c 2 $DIR/$tdir
1063 mkdir $DIR/$tdir/subdir
1064 echo abc > $DIR/$tdir/$tfile
1065 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1066 do_node $client2 touch $DIR/$tdir/subdir
1068 local async_commit_count=$(do_nodes $nodes \
1069 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1070 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1074 run_test 33e "DNE local operation shouldn't trigger COS"
1076 # End commit on sharing tests
1078 get_ost_lock_timeouts() {
1079 local nodes=${1:-$(comma_list $(osts_nodes))}
1081 local locks=$(do_nodes $nodes \
1082 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1090 do_nodes $(comma_list $(osts_nodes)) \
1091 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1092 for i in $(seq $OSTCOUNT); do
1093 wait_osc_import_state client ost$i FULL
1098 remote_ost_nodsh && skip "remote OST with nodsh" && return
1102 trap cleanup_34 EXIT RETURN
1103 for OPER in notimeout timeout ; do
1104 rm $DIR1/$tfile 2>/dev/null
1105 lock_in=$(get_ost_lock_timeouts)
1106 if [ $OPER == "timeout" ] ; then
1107 for j in `seq $OSTCOUNT`; do
1108 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1109 do_facet ost$j lctl set_param fail_loc=0x511
1111 echo lock should expire
1113 for j in `seq $OSTCOUNT`; do
1114 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1115 do_facet ost$j lctl set_param fail_loc=0x512
1117 echo lock should not expire
1119 echo writing on client1
1120 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1122 echo reading on client2
1123 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1124 # wait for a lock timeout
1126 lock_out=$(get_ost_lock_timeouts)
1127 if [ $OPER == "timeout" ] ; then
1128 if [ $lock_in == $lock_out ]; then
1129 error "no lock timeout happened"
1134 if [ $lock_in != $lock_out ]; then
1135 error "lock timeout happened"
1143 run_test 34 "no lock timeout under IO"
1145 test_35() { # bug 17645
1148 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1149 awk '/generation/{print $2}')
1151 generation[count]=$g
1155 test_mkdir -p $MOUNT1/$tfile
1156 cancel_lru_locks mdc
1158 # Let's initiate -EINTR situation by setting fail_loc and take
1159 # write lock on same file from same client. This will not cause
1160 # bl_ast yet as lock is already in local cache.
1161 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1162 do_facet client "lctl set_param fail_loc=0x80000317"
1163 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1164 let timeout=timeout*3
1166 while test $nr -lt 10; do
1167 log "Race attempt $nr"
1168 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1169 test "x$blk1" = "x" && blk1=0
1170 createmany -o $MOUNT2/$tfile/a 4000 &
1174 # Let's make conflict and bl_ast
1175 ls -la $MOUNT1/$tfile > /dev/null &
1178 log "Wait for $pid1 $pid2 for $timeout sec..."
1180 kill -9 $pid1 $pid2 > /dev/null 2>&1
1182 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1183 test "x$blk2" = "x" && blk2=0
1184 test $blk2 -gt $blk1 && break
1185 rm -fr $MOUNT1/$tfile/*
1186 cancel_lru_locks mdc
1189 do_facet client "lctl set_param fail_loc=0x0"
1190 df -h $MOUNT1 $MOUNT2
1192 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1193 awk '/generation/{print $2}')
1195 if ! test "$g" -eq "${generation[count]}"; then
1196 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1198 for imp in $list; do
1199 if [ $c = $count ]; then
1204 imp=$(echo "$imp" | awk -F"." '{print $2}')
1205 error "Eviction happened on import $imp"
1210 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1212 test_36() { #bug 16417
1217 test_mkdir -p $DIR1/$tdir
1218 $LFS setstripe -c -1 $DIR1/$tdir
1221 let SIZE_B=SIZE*1024*1024
1222 sync; sleep 2; sync # wait for delete thread
1223 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1224 wait_destroy_complete || error "wait_destroy_complete failed"
1226 while [ $i -le 10 ]; do
1227 lctl mark "start test - cycle ($i)"
1228 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1229 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1230 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1231 sync # sync data from client cache
1232 sync_all_data # sync data from server cache (delayed allocation)
1234 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1235 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1237 rm -f $DIR1/$tdir/$tfile
1238 kill -USR1 $read_pid
1240 sync; sleep 2; sync # Ensure new statfs
1241 wait_delete_completed
1242 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1243 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1245 # this free space! not used
1246 (( $after_dd <= $after)) ||
1247 error "space leaked after_dd:$after_dd > after:$after"
1251 run_test 36 "handle ESTALE/open-unlink correctly"
1253 test_37() { # bug 18695
1254 test_mkdir -p $DIR1/$tdir
1255 multiop_bg_pause $DIR1/$tdir D_c || return 1
1257 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1258 createmany -m $DIR2/$tdir/f 10000
1259 # set mtime/atime backward
1260 touch -t 198001010000 $DIR2/$tdir
1261 kill -USR1 $MULTIPID
1262 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1263 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1266 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1268 # this should be set to past
1269 TEST_39_MTIME=`date -d "1 year ago" +%s`
1273 local client1=${CLIENT1:-`hostname`}
1274 local client2=${CLIENT2:-`hostname`}
1276 do_node $client1 "touch $DIR1/$tfile"
1278 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1279 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1280 [ "$mtime1" = $TEST_39_MTIME ] || \
1281 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1283 local d1=`do_node $client1 date +%s`
1284 do_node $client1 'echo hello >> '$DIR1/$tfile
1285 local d2=`do_node $client1 date +%s`
1287 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1288 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1289 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1291 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1293 for (( i=0; i < 2; i++ )) ; do
1294 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1295 [ "$mtime2" = "$mtime3" ] || \
1296 error "mtime ($mtime2) changed (to $mtime3) on rename"
1298 cancel_lru_locks osc
1299 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1302 run_test 39a "test from 11063 =================================="
1305 local client1=${CLIENT1:-`hostname`}
1306 local client2=${CLIENT2:-`hostname`}
1310 local mtime1=`stat -c %Y $DIR1/$tfile`
1311 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1314 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1316 for (( i=0; i < 2; i++ )) ; do
1317 local mtime3=`stat -c %Y $DIR1/$tfile`
1318 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1320 [ "$mtime3" = "$mtime4" ] || \
1321 error "different mtime on clients: $mtime3, $mtime4"
1322 [ "$mtime3" = $TEST_39_MTIME ] || \
1323 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1325 cancel_lru_locks osc
1326 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1329 run_test 39b "11063 problem 1 =================================="
1332 local client1=${CLIENT1:-`hostname`}
1333 local client2=${CLIENT2:-`hostname`}
1335 echo hello > $DIR1/$tfile
1337 local mtime1=`stat -c %Y $DIR1/$tfile`
1338 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1339 [ "$mtime1" = "$mtime2" ] || \
1340 error "create: different mtime on clients: $mtime1, $mtime2"
1343 $TRUNCATE $DIR1/$tfile 1
1345 for (( i=0; i < 2; i++ )) ; do
1346 local mtime3=`stat -c %Y $DIR1/$tfile`
1347 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1349 [ "$mtime3" = "$mtime4" ] || \
1350 error "different mtime on clients: $mtime3, $mtime4"
1351 [ "$mtime3" -gt $mtime2 ] || \
1352 error "truncate did not update mtime: $mtime2, $mtime3"
1354 cancel_lru_locks osc
1355 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1358 run_test 39c "check truncate mtime update ======================"
1360 test_39d() { # LU-7310
1362 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1364 local mtime1=$(stat -c %Y $DIR2/$tfile)
1365 [ "$mtime1" = $TEST_39_MTIME ] ||
1366 error "mtime: $mtime1, should be $TEST_39_MTIME"
1369 # define OBD_FAIL_OSC_NO_GRANT 0x411
1370 $LCTL set_param fail_loc=0x411
1372 local d1=$(date +%s)
1373 echo hello >> $DIR1/$tfile
1374 local d2=$(date +%s)
1376 $LCTL set_param fail_loc=0
1378 cancel_lru_locks osc
1380 local mtime2=$(stat -c %Y $DIR2/$tfile)
1381 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1382 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1384 run_test 39d "sync write should update mtime"
1386 # check that pid exists hence second operation wasn't blocked by first one
1387 # if it is so then there is no conflict, return 0
1388 # else second operation is conflicting with first one, return 1
1389 check_pdo_conflict() {
1392 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1393 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1403 # test 40: check non-blocking operations
1405 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1406 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1407 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1409 mkdir $DIR1/$tfile &
1412 touch $DIR2/$tfile-2
1413 check_pdo_conflict $PID1 || error "create is blocked"
1414 mkdir $DIR2/$tfile-3
1415 check_pdo_conflict $PID1 || error "mkdir is blocked"
1416 link $DIR2/$tfile-2 $DIR2/$tfile-4
1417 check_pdo_conflict $PID1 || error "link is blocked"
1418 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1419 check_pdo_conflict $PID1 || error "rename is blocked"
1420 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1421 check_pdo_conflict $PID1 || error "getattr is blocked"
1422 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1423 rmdir $DIR2/$tfile-3
1424 check_pdo_conflict $PID1 || error "unlink is blocked"
1426 # all operations above shouldn't wait the first one
1427 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1432 run_test 40a "pdirops: create vs others =============="
1435 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1436 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1437 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1438 touch $DIR1/$tfile &
1442 touch $DIR2/$tfile-2
1443 check_pdo_conflict $PID1 || error "create is blocked"
1444 mkdir $DIR2/$tfile-3
1445 check_pdo_conflict $PID1 || error "mkdir is blocked"
1446 link $DIR2/$tfile-2 $DIR2/$tfile-4
1447 check_pdo_conflict $PID1 || error "link is blocked"
1448 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1449 check_pdo_conflict $PID1 || error "rename is blocked"
1450 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1451 check_pdo_conflict $PID1 || error "getattr is blocked"
1452 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1453 rmdir $DIR2/$tfile-3
1454 check_pdo_conflict $PID1 || error "unlink is blocked"
1455 # all operations above shouldn't wait the first one
1457 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1462 run_test 40b "pdirops: open|create and others =============="
1465 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1467 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1468 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1469 link $DIR1/$tfile $DIR1/$tfile-0 &
1473 touch $DIR2/$tfile-2
1474 check_pdo_conflict $PID1 || error "create is blocked"
1475 mkdir $DIR2/$tfile-3
1476 check_pdo_conflict $PID1 || error "mkdir is blocked"
1477 link $DIR2/$tfile-2 $DIR2/$tfile-4
1478 check_pdo_conflict $PID1 || error "link is blocked"
1479 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1480 check_pdo_conflict $PID1 || error "rename is blocked"
1481 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1482 check_pdo_conflict $PID1 || error "getattr is blocked"
1483 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1484 rmdir $DIR2/$tfile-3
1485 check_pdo_conflict $PID1 || error "unlink is blocked"
1487 # all operations above shouldn't wait the first one
1488 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1493 run_test 40c "pdirops: link and others =============="
1496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1498 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1499 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1504 touch $DIR2/$tfile-2
1505 check_pdo_conflict $PID1 || error "create is blocked"
1506 mkdir $DIR2/$tfile-3
1507 check_pdo_conflict $PID1 || error "mkdir is blocked"
1508 link $DIR2/$tfile-2 $DIR2/$tfile-4
1509 check_pdo_conflict $PID1 || error "link is blocked"
1510 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1511 check_pdo_conflict $PID1 || error "rename is blocked"
1512 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1513 check_pdo_conflict $PID1 || error "getattr is blocked"
1514 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1515 rmdir $DIR2/$tfile-3
1516 check_pdo_conflict $PID1 || error "unlink is blocked"
1518 # all operations above shouldn't wait the first one
1519 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1523 run_test 40d "pdirops: unlink and others =============="
1526 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1528 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1529 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1530 mv $DIR1/$tfile $DIR1/$tfile-0 &
1534 touch $DIR2/$tfile-2
1535 check_pdo_conflict $PID1 || error "create is blocked"
1536 mkdir $DIR2/$tfile-3
1537 check_pdo_conflict $PID1 || error "mkdir is blocked"
1538 link $DIR2/$tfile-2 $DIR2/$tfile-4
1539 check_pdo_conflict $PID1 || error "link is blocked"
1540 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1541 check_pdo_conflict $PID1 || error "getattr is blocked"
1542 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1543 rmdir $DIR2/$tfile-3
1544 check_pdo_conflict $PID1 || error "unlink is blocked"
1546 # all operations above shouldn't wait the first one
1547 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1552 run_test 40e "pdirops: rename and others =============="
1554 # test 41: create blocking operations
1556 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1557 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1558 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1561 mkdir $DIR2/$tfile && error "mkdir must fail"
1562 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1566 run_test 41a "pdirops: create vs mkdir =============="
1569 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1570 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1571 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1574 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1575 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1579 run_test 41b "pdirops: create vs create =============="
1582 touch $DIR1/$tfile-2
1583 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1584 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1585 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1588 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1589 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1593 run_test 41c "pdirops: create vs link =============="
1596 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1597 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1598 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1601 rm $DIR2/$tfile || error "unlink must succeed"
1602 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1606 run_test 41d "pdirops: create vs unlink =============="
1609 touch $DIR1/$tfile-2
1610 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1611 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1612 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1615 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1616 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1620 run_test 41e "pdirops: create and rename (tgt) =============="
1623 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1624 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1625 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1628 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1629 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1633 run_test 41f "pdirops: create and rename (src) =============="
1636 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1637 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1638 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1641 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1642 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1646 run_test 41g "pdirops: create vs getattr =============="
1649 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1650 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1651 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1654 ls -lia $DIR2/ > /dev/null
1655 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1659 run_test 41h "pdirops: create vs readdir =============="
1661 # test 42: unlink and blocking operations
1663 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1664 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1665 mkdir $DIR1/$tfile &
1668 mkdir $DIR2/$tfile && error "mkdir must fail"
1669 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1673 run_test 42a "pdirops: mkdir vs mkdir =============="
1676 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1677 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1678 mkdir $DIR1/$tfile &
1681 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1682 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1686 run_test 42b "pdirops: mkdir vs create =============="
1689 touch $DIR1/$tfile-2
1690 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1691 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1692 mkdir $DIR1/$tfile &
1695 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1696 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1700 run_test 42c "pdirops: mkdir vs link =============="
1703 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1704 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1705 mkdir $DIR1/$tfile &
1708 rmdir $DIR2/$tfile || error "unlink must succeed"
1709 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1713 run_test 42d "pdirops: mkdir vs unlink =============="
1716 touch $DIR1/$tfile-2
1717 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1718 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1719 mkdir $DIR1/$tfile &
1722 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1723 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1727 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1730 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1731 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1732 mkdir $DIR1/$tfile &
1735 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1736 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1740 run_test 42f "pdirops: mkdir and rename (src) =============="
1743 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1744 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1745 mkdir $DIR1/$tfile &
1748 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1749 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1753 run_test 42g "pdirops: mkdir vs getattr =============="
1756 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1757 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1758 mkdir $DIR1/$tfile &
1761 ls -lia $DIR2/ > /dev/null
1762 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1766 run_test 42h "pdirops: mkdir vs readdir =============="
1768 # test 43: unlink and blocking operations
1771 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1772 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1776 mkdir $DIR2/$tfile || error "mkdir must succeed"
1777 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1781 run_test 43a "pdirops: unlink vs mkdir =============="
1785 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1786 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1790 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1791 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1795 run_test 43b "pdirops: unlink vs create =============="
1799 touch $DIR1/$tfile-2
1800 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1801 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1805 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1806 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1810 run_test 43c "pdirops: unlink vs link =============="
1814 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1815 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1819 rm $DIR2/$tfile && error "unlink must fail"
1820 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1824 run_test 43d "pdirops: unlink vs unlink =============="
1828 touch $DIR1/$tfile-2
1829 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1830 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1834 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1835 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1839 run_test 43e "pdirops: unlink and rename (tgt) =============="
1843 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1844 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1848 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1849 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1853 run_test 43f "pdirops: unlink and rename (src) =============="
1857 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1858 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1862 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1863 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1867 run_test 43g "pdirops: unlink vs getattr =============="
1871 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1872 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1876 ls -lia $DIR2/ > /dev/null
1877 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1881 run_test 43h "pdirops: unlink vs readdir =============="
1884 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1886 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1887 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1891 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1892 check_pdo_conflict $PID1 &&
1893 { wait $PID1; error "remote mkdir isn't blocked"; }
1897 run_test 43i "pdirops: unlink vs remote mkdir"
1899 # test 44: rename tgt and blocking operations
1901 touch $DIR1/$tfile-2
1902 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1903 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1904 mv $DIR1/$tfile-2 $DIR1/$tfile &
1907 mkdir $DIR2/$tfile && error "mkdir must fail"
1908 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1912 run_test 44a "pdirops: rename tgt vs mkdir =============="
1915 touch $DIR1/$tfile-2
1916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1917 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1918 mv $DIR1/$tfile-2 $DIR1/$tfile &
1921 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1922 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1926 run_test 44b "pdirops: rename tgt vs create =============="
1929 touch $DIR1/$tfile-2
1930 touch $DIR1/$tfile-3
1931 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1932 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1933 mv $DIR1/$tfile-2 $DIR1/$tfile &
1936 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1937 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1941 run_test 44c "pdirops: rename tgt vs link =============="
1944 touch $DIR1/$tfile-2
1945 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1946 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1947 mv $DIR1/$tfile-2 $DIR1/$tfile &
1950 rm $DIR2/$tfile || error "unlink must succeed"
1951 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1955 run_test 44d "pdirops: rename tgt vs unlink =============="
1959 touch $DIR1/$tfile-2
1960 touch $DIR1/$tfile-3
1961 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1962 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1963 mv $DIR1/$tfile-2 $DIR1/$tfile &
1966 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1967 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1971 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1974 touch $DIR1/$tfile-2
1975 touch $DIR1/$tfile-3
1976 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1977 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1978 mv $DIR1/$tfile-2 $DIR1/$tfile &
1981 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1982 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1986 run_test 44f "pdirops: rename tgt and rename (src) =============="
1989 touch $DIR1/$tfile-2
1990 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1991 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1992 mv $DIR1/$tfile-2 $DIR1/$tfile &
1995 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1996 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2000 run_test 44g "pdirops: rename tgt vs getattr =============="
2003 touch $DIR1/$tfile-2
2004 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2005 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2006 mv $DIR1/$tfile-2 $DIR1/$tfile &
2009 ls -lia $DIR2/ > /dev/null
2010 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2014 run_test 44h "pdirops: rename tgt vs readdir =============="
2016 # test 44: rename tgt and blocking operations
2018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2019 touch $DIR1/$tfile-2
2020 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2021 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2022 mv $DIR1/$tfile-2 $DIR1/$tfile &
2025 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2026 check_pdo_conflict $PID1 && { wait $PID1;
2027 error "remote mkdir isn't blocked"; }
2031 run_test 44i "pdirops: rename tgt vs remote mkdir"
2033 # test 45: rename src and blocking operations
2036 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2037 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2038 mv $DIR1/$tfile $DIR1/$tfile-2 &
2041 mkdir $DIR2/$tfile || error "mkdir must succeed"
2042 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2046 run_test 45a "pdirops: rename src vs mkdir =============="
2050 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2051 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2052 mv $DIR1/$tfile $DIR1/$tfile-2 &
2055 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2056 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2060 run_test 45b "pdirops: rename src vs create =============="
2064 touch $DIR1/$tfile-3
2065 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2066 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2067 mv $DIR1/$tfile $DIR1/$tfile-2 &
2070 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2071 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2075 run_test 45c "pdirops: rename src vs link =============="
2079 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2080 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2081 mv $DIR1/$tfile $DIR1/$tfile-2 &
2084 rm $DIR2/$tfile && error "unlink must fail"
2085 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2089 run_test 45d "pdirops: rename src vs unlink =============="
2093 touch $DIR1/$tfile-3
2094 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2095 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2096 mv $DIR1/$tfile $DIR1/$tfile-2 &
2099 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2100 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2104 run_test 45e "pdirops: rename src and rename (tgt) =============="
2108 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2109 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2110 mv $DIR1/$tfile $DIR1/$tfile-2 &
2113 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2114 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2118 run_test 45f "pdirops: rename src and rename (src) =============="
2122 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2123 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2124 mv $DIR1/$tfile $DIR1/$tfile-2 &
2127 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2128 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2132 run_test 45g "pdirops: rename src vs getattr =============="
2136 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2137 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2138 mv $DIR1/$tfile $DIR1/$tfile-2 &
2141 ls -lia $DIR2/ > /dev/null
2142 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2146 run_test 45h "pdirops: unlink vs readdir =============="
2149 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2151 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2152 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2153 mv $DIR1/$tfile $DIR1/$tfile-2 &
2156 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2157 check_pdo_conflict $PID1 && { wait $PID1;
2158 error "create remote dir isn't blocked"; }
2162 run_test 45i "pdirops: rename src vs remote mkdir"
2164 # test 46: link and blocking operations
2166 touch $DIR1/$tfile-2
2167 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2168 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2169 link $DIR1/$tfile-2 $DIR1/$tfile &
2172 mkdir $DIR2/$tfile && error "mkdir must fail"
2173 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2177 run_test 46a "pdirops: link vs mkdir =============="
2180 touch $DIR1/$tfile-2
2181 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2182 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2183 link $DIR1/$tfile-2 $DIR1/$tfile &
2186 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2187 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2191 run_test 46b "pdirops: link vs create =============="
2194 touch $DIR1/$tfile-2
2195 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2196 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2197 link $DIR1/$tfile-2 $DIR1/$tfile &
2200 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2201 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2205 run_test 46c "pdirops: link vs link =============="
2208 touch $DIR1/$tfile-2
2209 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2210 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2211 link $DIR1/$tfile-2 $DIR1/$tfile &
2214 rm $DIR2/$tfile || error "unlink must succeed"
2215 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2219 run_test 46d "pdirops: link vs unlink =============="
2222 touch $DIR1/$tfile-2
2223 touch $DIR1/$tfile-3
2224 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2225 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2226 link $DIR1/$tfile-2 $DIR1/$tfile &
2229 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2230 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2234 run_test 46e "pdirops: link and rename (tgt) =============="
2237 touch $DIR1/$tfile-2
2238 touch $DIR1/$tfile-3
2239 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2240 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2241 link $DIR1/$tfile-2 $DIR1/$tfile &
2244 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2245 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2249 run_test 46f "pdirops: link and rename (src) =============="
2252 touch $DIR1/$tfile-2
2253 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2254 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2255 link $DIR1/$tfile-2 $DIR1/$tfile &
2258 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2259 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2263 run_test 46g "pdirops: link vs getattr =============="
2266 touch $DIR1/$tfile-2
2267 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2268 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2269 link $DIR1/$tfile-2 $DIR1/$tfile &
2272 ls -lia $DIR2/ > /dev/null
2273 check_pdo_conflict $PID1 && { wait $PID1;
2274 error "readdir isn't blocked"; }
2278 run_test 46h "pdirops: link vs readdir =============="
2281 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2282 touch $DIR1/$tfile-2
2283 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2284 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2285 link $DIR1/$tfile-2 $DIR1/$tfile &
2288 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2289 check_pdo_conflict $PID1 && { wait $PID1;
2290 error "remote mkdir isn't blocked"; }
2294 run_test 46i "pdirops: link vs remote mkdir"
2296 # test 47: remote mkdir and blocking operations
2298 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2299 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2300 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2301 $LFS mkdir -i 1 $DIR1/$tfile &
2304 mkdir $DIR2/$tfile && error "mkdir must fail"
2305 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2309 run_test 47a "pdirops: remote mkdir vs mkdir"
2312 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2313 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2314 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2315 $LFS mkdir -i 1 $DIR1/$tfile &
2318 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2319 check_pdo_conflict $PID1 && { wait $PID1;
2320 error "create isn't blocked"; }
2324 run_test 47b "pdirops: remote mkdir vs create"
2327 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2328 touch $DIR1/$tfile-2
2329 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2330 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2331 $LFS mkdir -i 1 $DIR1/$tfile &
2334 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2335 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2339 run_test 47c "pdirops: remote mkdir vs link"
2342 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2343 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2344 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2345 $LFS mkdir -i 1 $DIR1/$tfile &
2348 rmdir $DIR2/$tfile || error "unlink must succeed"
2349 check_pdo_conflict $PID1 && { wait $PID1;
2350 error "unlink isn't blocked"; }
2354 run_test 47d "pdirops: remote mkdir vs unlink"
2357 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2358 touch $DIR1/$tfile-2
2359 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2360 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2361 $LFS mkdir -i 1 $DIR1/$tfile &
2364 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2365 check_pdo_conflict $PID1 && { wait $PID1;
2366 error "rename isn't blocked"; }
2370 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2373 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2374 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2375 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2376 $LFS mkdir -i 1 $DIR1/$tfile &
2379 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2380 check_pdo_conflict $PID1 && { wait $PID1;
2381 error "rename isn't blocked"; }
2385 run_test 47f "pdirops: remote mkdir and rename (src)"
2388 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2389 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2390 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2391 $LFS mkdir -i 1 $DIR1/$tfile &
2394 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2395 check_pdo_conflict $PID1 && { wait $PID1;
2396 error "getattr isn't blocked"; }
2400 run_test 47g "pdirops: remote mkdir vs getattr"
2404 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2405 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2406 do_facet client "lctl set_param fail_loc=0x410"
2407 $TRUNCATE $DIR2/$tfile $trunc_size
2408 do_facet client "lctl set_param fail_loc=0x0"
2410 size=`stat -c %s $DIR2/$tfile`
2411 [ $size -eq $trunc_size ] || error "wrong size"
2413 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2417 local origfile=/etc/hosts
2419 filesize=$(stat -c %s $origfile)
2421 # create an empty file
2422 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2423 # cache layout lock on both mount point
2424 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2425 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2427 # open and sleep 2 seconds then read
2428 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2432 # create the layout of testing file
2433 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2434 error "dd $DIR1/$tfile failed"
2436 # MULTIOP proc should be able to read enough bytes and exit
2438 kill -0 $pid 2> /dev/null && error "multiop is still there"
2439 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2443 run_test 51a "layout lock: refresh layout should work"
2446 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2447 { skip "Need MDS version at least 2.3.59"; return 0; }
2449 local tmpfile=`mktemp`
2451 # create an empty file
2452 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2454 # delay glimpse so that layout has changed when glimpse finish
2455 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2456 $LCTL set_param fail_loc=0x1404
2457 stat -c %s $DIR2/$tfile |tee $tmpfile &
2461 # create layout of testing file
2462 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2463 error "dd $DIR1/$tfile failed"
2466 local fsize=$(cat $tmpfile)
2468 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2470 rm -f $DIR1/$tfile $tmpfile
2472 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2475 [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; }
2477 # set default layout to have 1 stripe
2479 $LFS setstripe -c 1 $DIR1/$tdir
2481 # create a file with empty layout
2482 $MCREATE $DIR1/$tdir/$tfile ||
2483 error "$MCREATE $DIR1/$tdir/$tfile failed"
2485 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2486 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2488 # change the layout of testing file
2489 echo "Setting layout to have $OSTCOUNT stripes ..."
2490 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2494 # write something to the file, it should be blocked on fetching layout
2495 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2496 local stripecnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2499 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2500 # count to succeed with only 3/4 of the number of stripes (rounded up),
2501 # so creating striped files does not fail if an OST is offline or full
2502 [ $stripecnt -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2503 error "layout wrong: getstripe -c $stripecnt < $OSTCOUNT * 3/4"
2507 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2510 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2511 cancel_lru_locks mdc
2513 # open should grant LAYOUT lock, mmap and read will install pages
2514 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2518 # rss before revoking
2519 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2520 echo "Before revoking layout lock: $br KB mapped"
2522 # delete the file will revoke layout lock
2525 # rss after revoking
2526 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2531 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2533 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2537 echo "==> rename vs getattr vs setxattr should not deadlock"
2538 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2540 do_facet mds1 $LCTL set_param fail_loc=$1
2542 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2550 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2551 wait $PID1 || error "(3) mv failed"
2552 wait $PID2 || error "(4) stat failed"
2559 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2560 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2562 do_facet mds1 $LCTL set_param fail_loc=$1
2564 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2572 $MULTIOP $DIR2/d1/d2 Oc &
2576 stat $DIR/d1 || error "(2) stat failed"
2578 wait $PID1 || error "(3) mv failed"
2579 wait $PID2 || error "(4) stat failed"
2580 wait $PID3 && error "(5) multiop failed"
2586 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2587 save_lustre_params client "llite.*.xattr_cache" > $p
2588 lctl set_param llite.*.xattr_cache 1 ||
2589 { skip "xattr cache is not supported"; return 0; }
2591 #define OBD_FAIL_MDS_RENAME 0x153
2592 #define OBD_FAIL_MDS_RENAME2 0x154
2593 test_54_part1 0x80000153 || error 10
2594 test_54_part1 0x80000154 || error 11
2595 test_54_part2 0x80000153 || error 12
2596 test_54_part2 0x80000154 || error 13
2598 restore_lustre_params < $p
2601 run_test 54 "rename locking"
2604 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2606 #define OBD_FAIL_MDS_RENAME4 0x156
2607 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2609 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2614 wait $PID1 && error "(2) mv succeeded"
2618 run_test 55a "rename vs unlink target dir"
2622 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2624 #define OBD_FAIL_MDS_RENAME4 0x156
2625 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2627 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2632 wait $PID1 && error "(2) mv succeeded"
2636 run_test 55b "rename vs unlink source dir"
2640 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2642 #define OBD_FAIL_MDS_RENAME4 0x156
2643 do_facet mds1 $LCTL set_param fail_loc=0x156
2645 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2649 # while rename is sleeping, open and remove d3
2650 $MULTIOP $DIR2/d3 D_c &
2656 # while rename is sleeping 2nd time, close d3
2658 wait $PID2 || error "(3) multiop failed"
2660 wait $PID1 && error "(2) mv succeeded"
2664 run_test 55c "rename vs unlink orphan target dir"
2670 #define OBD_FAIL_MDS_RENAME3 0x155
2671 do_facet mds1 $LCTL set_param fail_loc=0x155
2672 mv $DIR/f1 $DIR/$tdir &
2676 # while rename is sleeping, create $tdir, but as a directory
2677 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2679 # link in reverse locking order
2680 ln $DIR2/f1 $DIR2/$tdir/
2682 wait $PID1 && error "(2) mv succeeded"
2685 run_test 55d "rename file vs link"
2688 local MDSVER=$(lustre_build_version $SINGLEMDS)
2689 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2690 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2693 test_mkdir -p $DIR1/$tdir
2694 file1=$DIR1/$tdir/file
2695 file2=$DIR2/$tdir/file
2697 echo orig > $file2 || error "Could not create $file2"
2698 version=$($LFS data_version $file1)
2701 echo append >> $file2 || error "Could not append to $file2"
2702 version2=$($LFS data_version $file1)
2703 [ "$version" != "$version2" ] ||
2704 error "append did not change data version: $version"
2707 echo overwrite > $file2 || error "Could not overwrite $file2"
2708 version3=$($LFS data_version $file1)
2709 [ "$version2" != "$version3" ] ||
2710 error "overwrite did not change data version: $version2"
2712 # Truncate before EOF
2713 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2714 version4=$($LFS data_version $file1)
2715 [ "$version3" != "$version4" ] ||
2716 error "truncate did not change data version: $version3"
2718 # Truncate after EOF
2719 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2720 version5=$($LFS data_version $file1)
2721 [ "$version4" != "$version5" ] ||
2722 error "truncate did not change data version: $version4"
2724 # Chmod do not change version
2725 chmod 400 $file2 || error "Could not chmod 400 $file2"
2726 version6=$($LFS data_version $file1)
2727 [ "$version5" == "$version6" ] ||
2728 error "chmod should not change data version: $version5 != $version6"
2730 # Chown do not change version
2731 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2732 version7=$($LFS data_version $file1)
2733 [ "$version5" == "$version7" ] ||
2734 error "chown should not change data version: $version5 != $version7"
2736 run_test 60 "Verify data_version behaviour"
2739 local test_dir=$tdir/test_dir
2741 mkdir -p $DIR1/$tdir
2742 if [ $MDSCOUNT -ge 2 ]; then
2744 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2745 error "Create remote directory failed"
2747 mkdir -p $DIR1/$test_dir
2749 cd $DIR2/$test_dir || error "cd directory failed"
2750 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2752 cd $DIR2/$tdir || error "exit directory"
2754 run_test 70a "cd directory && rm directory"
2756 test_70b() { # LU-2781
2758 mkdir -p $DIR1/$tdir
2760 touch $DIR1/$tdir/file
2761 for ((i = 0; i < 32; i++)); do
2762 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2764 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2766 touch $DIR1/$tdir/file
2767 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2768 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2769 rm -rf $DIR1/$tdir/test_dir ||
2770 error "cannot remove directory after rm_entry"
2771 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2773 run_test 70b "remove files after calling rm_entry"
2776 local server_version=$(lustre_version_code $SINGLEMDS)
2778 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2779 skip "Need MDS version at least 2.1.6" && return
2781 # Patch not applied to 2.2 and 2.3 branches
2782 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2783 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2784 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2787 checkfiemap --test ||
2788 { skip "checkfiemap not runnable: $?" && return; }
2789 # write data this way: hole - data - hole - data
2790 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2791 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2793 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2794 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2795 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2797 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2799 checkfiemap $DIR2/$tfile 81920 ||
2800 error "data is not flushed from client"
2801 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2804 # common case of "create file, copy file" on a single node
2805 # should not flush data from ost
2806 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2807 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2809 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2811 checkfiemap $DIR1/$tfile 81920 ||
2813 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2815 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2817 run_test 71a "correct file map just after write operation is finished"
2820 local server_version=$(lustre_version_code $SINGLEMDS)
2822 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2823 skip "Need MDS version at least 2.1.6" && return
2825 # Patch not applied to 2.2 and 2.3 branches
2826 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2827 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2828 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2830 [[ $OSTCOUNT -ge 2 ]] || { skip "need at least 2 osts"; return; }
2832 checkfiemap --test ||
2833 { skip "error $?: checkfiemap failed" && return; }
2835 mkdir -p $DIR1/$tdir
2837 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2838 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2839 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2841 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2842 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2844 run_test 71b "check fiemap support for stripecount > 1"
2847 local p="$TMP/sanityN-$TESTNAME.parameters"
2850 save_lustre_params client "llite.*.xattr_cache" > $p
2851 lctl set_param llite.*.xattr_cache 1 ||
2852 { skip "xattr cache is not supported"; return 0; }
2855 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2856 error "setfattr1 failed"
2857 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2858 error "getfattr1 failed"
2859 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2860 error "setfattr2 failed"
2861 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2862 error "getfattr2 failed"
2864 # check that trusted.link is consistent
2865 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2866 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2867 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2868 echo "$tlink1 $tlink2"
2869 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2873 restore_lustre_params < $p
2876 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2879 local p="$TMP/sanityN-$TESTNAME.parameters"
2880 save_lustre_params client "llite.*.xattr_cache" > $p
2881 lctl set_param llite.*.xattr_cache 1 ||
2882 { skip "xattr cache is not supported"; return 0; }
2885 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2886 error "setfattr1 failed"
2887 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2888 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2889 clear_stats llite.*.stats
2890 # PR lock should be cached by now on both clients
2891 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2892 # 2 hits for getfattr(0)+getfattr(size)
2893 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2894 error "not cached in $DIR1"
2895 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2896 # 4 hits for more getfattr(0)+getfattr(size)
2897 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2898 error "not cached in $DIR2"
2901 restore_lustre_params < $p
2904 run_test 73 "getxattr should not cause xattr lock cancellation"
2907 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2908 skip "Need MDS version at least 2.4.93" && return
2910 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2911 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2912 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2914 run_test 74 "flock deadlock: different mounts =============="
2918 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2919 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2920 cancel_lru_locks osc
2922 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2925 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2926 $LCTL set_param fail_loc=0x31d
2927 stat -c %s $DIR1/$tfile &
2932 # For bad lock error handler we should ASSERT and got kernel panic here
2934 $LCTL set_param fail_loc=0
2936 run_test 75 "osc: upcall after unuse lock==================="
2939 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2940 skip "Need MDS version at least 2.5.53" && return
2942 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2943 local fcount=$((MDSCOUNT * 256))
2948 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2954 test_mkdir -p $DIR/$tdir
2956 # drop all open locks and close any cached "open" files on the client
2957 cancel_lru_locks mdc
2959 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2960 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2961 local already=${#fid_list[@]}
2962 for (( i = 0; i < $already; i++ )) ; do
2963 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2966 echo -n "opening files: "
2967 ulimit -n $((fcount + 50))
2968 for ((i = 0; i < $fcount; i++)); do
2969 touch $DIR/$tdir/f_$i
2970 local fd=$(free_fd ${fd_list[i]})
2971 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
2976 (( $i % 32 == 0 )) && echo -n "."
2980 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2982 # Possible errors in openfiles FID list.
2983 # 1. Missing FIDs. Check 1
2984 # 2. Extra FIDs. Check 1
2985 # 3. Duplicated FID. Check 2
2986 # 4. Invalid FIDs. Check 2
2987 # 5. Valid FID, points to some other file. Check 3
2990 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
2991 error "${#fid_list[@]} != $fcount (+$already old) open files"
2993 echo -n "closing files: "
2994 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
2995 local close_cmd="exec ${fd_list[fd]}<&-"
2997 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
2999 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3000 echo "skip old open file $filename"
3002 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3006 rm --interactive=no $filename
3008 error "Nonexisting fid ${fid_list[fid]} listed."
3009 (( $fd % 32 == 0 )) && echo -n "."
3014 ls_op=$(ls $DIR2/$tdir | wc -l)
3016 error "Some openfiles are missing in lproc output"
3020 run_test 76 "Verify MDT open_files listing"
3024 local dir=$DIR/$tdir
3027 mkdir $dir || error "mkdir $dir failed"
3028 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3031 do_nodes $CLIENTS $myRUNAS \
3032 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3033 error "dd at 0 on client failed (1)"
3035 for ((i = 0; i < $n; i++)); do
3036 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3037 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3038 error "dd at ${i}MB on client failed (2)" &
3041 do_nodes $CLIENTS sync;
3042 cancel_lru_locks osc
3044 for ((i = 0; i < $n; i++)); do
3045 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3046 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3047 error "dd at ${i}MB on client failed (3)" &
3050 cancel_lru_locks osc
3052 for ((i = 0; i < $n; i++)); do
3056 rm -rf $dir || error "rm -rf $dir failed"
3059 test_77a() { #LU-3266
3060 oss=$(comma_list $(osts_nodes))
3061 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
3066 run_test 77a "check FIFO NRS policy"
3068 test_77b() { #LU-3266
3069 oss=$(comma_list $(osts_nodes))
3071 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3072 ost.OSS.*.nrs_crrn_quantum=1
3074 echo "policy: crr-n, crrn_quantum 1"
3077 do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
3079 echo "policy: crr-n, crrn_quantum 64"
3083 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3086 run_test 77b "check CRR-N NRS policy"
3091 oss=$(comma_list $(osts_nodes))
3093 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3094 ost.OSS.*.nrs_"$policy"_quantum=1 \
3095 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3096 ost.OSS.*.nrs_"$policy"_supported="reads"
3098 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
3101 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
3102 ost.OSS.*.nrs_${policy}_quantum=64
3104 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
3107 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3108 ost.OSS.*.nrs_${policy}_offset_type="logical"
3109 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3113 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3117 test_77c() { #LU-3266
3121 run_test 77c "check ORR NRS policy"
3123 test_77d() { #LU-3266
3127 run_test 77d "check TRR nrs policy"
3134 do_facet $facet lctl set_param \
3135 ost.OSS.ost_io.nrs_tbf_rule="$*"
3137 error "failed to run operate '$*' on TBF rules"
3140 cleanup_tbf_verify()
3144 echo "cleanup_tbf $DIR/$tdir"
3147 wait_delete_completed
3152 local dir=$DIR/$tdir
3153 local client1=${CLIENT1:-$(hostname)}
3156 mkdir $dir || error "mkdir $dir failed"
3157 $LFS setstripe -c 1 $dir || error "setstripe to $dir failed"
3160 trap cleanup_tbf_verify EXIT
3161 echo "Limited write rate: $1, read rate: $2"
3162 echo "Verify the write rate is under TBF control"
3163 local runtime=$(do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3164 bs=1M count=100 oflag=direct 2>&1 | awk '/bytes/ {print $6}')
3165 local rate=$(bc <<< "scale=6; 100 / $runtime")
3166 echo "Write runtime is $runtime s, speed is $rate IOPS"
3168 # verify the write rate does not exceed 110% of TBF limited rate
3169 [ $(bc <<< "$rate < 1.1 * $1") -eq 1 ] ||
3170 error "The write rate ($rate) exceeds 110% of preset rate ($1)"
3172 cancel_lru_locks osc
3174 echo "Verify the read rate is under TBF control"
3175 runtime=$(do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3176 bs=1M count=100 iflag=direct 2>&1 | awk '/bytes/ {print $6}')
3177 rate=$(bc <<< "scale=6; 100 / $runtime")
3178 echo "Read runtime is $runtime s, speed is $rate IOPS"
3180 # verify the read rate does not exceed 110% of TBF limited rate
3181 [ $(bc <<< "$rate < 1.1 * $2") -eq 1 ] ||
3182 error "The read rate ($rate) exceeds 110% of preset rate ($2)"
3184 cancel_lru_locks osc
3185 cleanup_tbf_verify || error "rm -rf $dir failed"
3189 local server_version=$(lustre_version_code ost1)
3190 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3191 { skip "Need server version newer than 2.7.57"; return 0; }
3193 oss=$(comma_list $(osts_nodes))
3195 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3196 [ $? -ne 0 ] && error "failed to set TBF policy"
3200 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3205 # Only operate rules on ost1 since OSTs might run on the same OSS
3207 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3208 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3209 local client_nids=$(nids_list $address "\\")
3210 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3211 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3215 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3216 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3217 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3221 tbf_rule_operate ost1 "stop\ localhost"
3222 tbf_rule_operate ost1 "stop\ clients"
3223 tbf_rule_operate ost1 "stop\ others"
3226 # Cleanup the TBF policy
3227 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3228 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3232 run_test 77e "check TBF NID nrs policy"
3235 local server_version=$(lustre_version_code ost1)
3236 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3237 { skip "Need server version newer than 2.7.57"; return 0; }
3239 oss=$(comma_list $(osts_nodes))
3241 # Configure jobid_var
3242 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3243 if [ $saved_jobid_var != procname_uid ]; then
3244 set_conf_param_and_check client \
3245 "$LCTL get_param -n jobid_var" \
3246 "$FSNAME.sys.jobid_var" procname_uid
3249 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3250 [ $? -ne 0 ] && error "failed to set TBF policy"
3254 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3259 # Only operate rules on ost1 since OSTs might run on the same OSS
3261 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3262 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3263 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3264 nrs_write_read "$RUNAS"
3267 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3268 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3269 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3270 nrs_write_read "$RUNAS"
3273 tbf_rule_operate ost1 "stop\ runas"
3274 tbf_rule_operate ost1 "stop\ iozone_runas"
3275 tbf_rule_operate ost1 "stop\ dd_runas"
3276 nrs_write_read "$RUNAS"
3278 # Cleanup the TBF policy
3279 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3280 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3281 nrs_write_read "$RUNAS"
3283 local current_jobid_var=$($LCTL get_param -n jobid_var)
3284 if [ $saved_jobid_var != $current_jobid_var ]; then
3285 set_conf_param_and_check client \
3286 "$LCTL get_param -n jobid_var" \
3287 "$FSNAME.sys.jobid_var" $saved_jobid_var
3291 run_test 77f "check TBF JobID nrs policy"
3294 local server_version=$(lustre_version_code ost1)
3295 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3296 { skip "Need server version newer than 2.7.57"; return 0; }
3298 oss=$(comma_list $(osts_nodes))
3300 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3301 [ $? -ne 0 ] && error "failed to set TBF policy"
3303 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3304 [ $? -ne 0 ] && error "failed to set TBF policy"
3308 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3313 # Add a rule that only valid for Jobid TBF. If direct change between
3314 # TBF types is not supported, this operation will fail.
3315 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3317 # Cleanup the TBF policy
3318 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3319 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3322 run_test 77g "Change TBF type directly"
3325 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3326 { skip "Need OST version at least 2.8.55"; return 0; }
3328 local old_policy=$(do_facet ost1 \
3329 lctl get_param ost.OSS.ost_io.nrs_policies)
3332 do_facet ost1 lctl set_param \
3333 ost.OSS.ost_io.nrs_policies="abc"
3334 [ $? -eq 0 ] && error "should return error"
3336 do_facet ost1 lctl set_param \
3337 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3338 [ $? -eq 0 ] && error "should return error"
3340 do_facet ost1 lctl set_param \
3341 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3342 [ $? -eq 0 ] && error "should return error"
3344 do_facet ost1 lctl set_param \
3345 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3346 [ $? -eq 0 ] && error "should return error"
3348 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3349 [ $? -eq 0 ] || error "shouldn't LBUG"
3351 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3355 run_test 77h "Wrong policy name should report error, not LBUG"
3361 local error_message=$3
3363 for rule in $expected; do
3364 rule_number=$((rule_number + 1))
3366 local stop_line=$(($rule_number + 3))
3367 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3369 local output=$(do_facet $facet lctl get_param \
3370 ost.OSS.ost_io.nrs_tbf_rule |
3374 if [ "$output" != "$expected" ]; then
3375 error "$error_message, expected '$expected', got '$output'"
3380 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3381 { skip "Need OST version at least 2.8.55"; return 0; }
3383 for i in $(seq 1 $OSTCOUNT)
3385 do_facet ost"$i" lctl set_param \
3386 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3388 error "failed to set TBF policy"
3391 tbf_rule_check ost1 "default" "error before inserting any rule"
3393 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3394 tbf_rule_check ost1 "before default" \
3395 "error when inserting rule 'before'"
3397 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3398 tbf_rule_check ost1 "before after default" \
3399 "error when inserting rule 'after'"
3401 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3402 tbf_rule_check ost1 "before target after default" \
3403 "error when inserting rule 'target'"
3405 echo "Move before itself"
3406 tbf_rule_operate ost1 "change\ target\ rank=target"
3407 tbf_rule_check ost1 "before target after default" \
3408 "error when moving before itself"
3410 echo "Move to higher rank"
3411 tbf_rule_operate ost1 "change\ target\ rank=before"
3412 tbf_rule_check ost1 "target before after default" \
3413 "error when moving to higher rank"
3415 echo "Move to lower rank"
3416 tbf_rule_operate ost1 "change\ target\ rank=after"
3417 tbf_rule_check ost1 "before target after default" \
3418 "error when moving to lower rank"
3420 echo "Move before default"
3421 tbf_rule_operate ost1 "change\ target\ rank=default"
3422 tbf_rule_check ost1 "before after target default" \
3423 error "error when moving before default"
3425 # Cleanup the TBF policy
3426 do_nodes $(comma_list $(osts_nodes)) \
3427 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3430 run_test 77i "Change rank of TBF rule"
3435 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.60) ]; then
3440 do_nodes $(comma_list $(osts_nodes)) \
3441 lctl set_param jobid_var=procname_uid \
3442 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3443 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3444 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3445 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3450 do_nodes $(comma_list $(osts_nodes)) \
3451 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3452 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3453 ost.OSS.ost_io.nrs_policies="fifo"
3455 # sleep 3 seconds to wait the tbf policy stop completely,
3456 # or the next test case is possible get -EAGAIN when
3457 # setting the tbf policy
3460 run_test 77j "check TBF-OPCode NRS policy"
3463 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3464 { skip "Need OST version at least 2.9.53"; return 0; }
3466 do_nodes $(comma_list $(osts_nodes)) \
3467 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3468 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3469 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3471 nrs_write_read "$RUNAS"
3472 tbf_verify 20 10 "$RUNAS"
3474 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3475 local client_nids=$(nids_list $address "\\")
3476 do_nodes $(comma_list $(osts_nodes)) \
3477 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3478 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3479 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3480 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3485 do_nodes $(comma_list $(osts_nodes)) \
3486 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3487 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3488 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3490 nrs_write_read "$RUNAS"
3491 tbf_verify 20 20 "$RUNAS"
3493 do_nodes $(comma_list $(osts_nodes)) \
3494 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3495 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3496 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3498 nrs_write_read "$RUNAS"
3499 # with parameter "RUNAS", it will match the latest rule
3500 # "ext_b" first, so the limited write rate is 10.
3501 tbf_verify 10 10 "$RUNAS"
3504 do_nodes $(comma_list $(osts_nodes)) \
3505 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3506 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3507 ost.OSS.ost_io.nrs_policies="fifo"
3511 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3514 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3515 skip "Need OST version at least 2.9.54"
3519 local dir=$DIR/$tdir
3521 mkdir $dir || error "mkdir $dir failed"
3522 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3525 local nodes=$(comma_list $(osts_nodes))
3526 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3527 ost.OSS.ost_io.nrs_delay_min=4 \
3528 ost.OSS.ost_io.nrs_delay_max=4 \
3529 ost.OSS.ost_io.nrs_delay_pct=100
3530 [ $? -ne 0 ] && error "Failed to set delay policy"
3532 local start=$SECONDS
3533 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3534 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3535 oflag=direct conv=fdatasync ||
3536 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3537 error "dd on client failed (1)"; }
3538 local elapsed=$((SECONDS - start))
3540 # NRS delay doesn't do sub-second timing, so a request enqueued at
3541 # 0.9 seconds can be dequeued at 4.0
3542 [ $elapsed -lt 3 ] &&
3543 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3544 error "Single 1M write should take at least 3 seconds"; }
3547 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3548 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3549 oflag=direct conv=fdatasync ||
3550 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3551 error "dd on client failed (2)"; }
3552 elapsed=$((SECONDS - start))
3554 [ $elapsed -lt 30 ] &&
3555 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3556 error "Ten 1M writes should take at least 30 seconds"; }
3558 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3559 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3563 run_test 77l "check NRS Delay slows write RPC processing"
3565 test_78() { #LU-6673
3566 local server_version=$(lustre_version_code ost1)
3567 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3568 { skip "Need server version newer than 2.7.57"; return 0; }
3572 oss=$(comma_list $(osts_nodes))
3573 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3574 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3576 # Valid return codes are:
3577 # 0: Tuning succeeded
3578 # ENODEV: Policy is still stopped
3579 # EAGAIN: Policy is being initialized
3580 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3581 error "Expected set_param to return 0|ENODEV|EAGAIN"
3583 # Cleanup the ORR policy
3584 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3585 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3588 run_test 78 "Enable policy and specify tunings right away"
3591 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3592 test_mkdir -p $DIR/$tdir
3594 # Prevent interference from layout intent RPCs due to
3595 # asynchronous writeback. These will be tested in 130c below.
3596 do_nodes ${CLIENTS:-$HOSTNAME} sync
3598 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3599 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3601 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3602 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3603 local facet=mds$((mdtidx + 1))
3605 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3606 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3610 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3611 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3616 run_test 79 "xattr: intent error"
3619 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3626 mkdir -p $DIR1/$tdir/dir
3627 createmany -o $DIR1/$tdir/dir/f 10 ||
3628 error "create files under remote dir failed $i"
3630 cp /etc/passwd $DIR1/$tdir/$tfile
3632 #migrate open file should fails
3633 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3635 # give multiop a chance to open
3638 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3639 error "migrate open files should failed with open files"
3643 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3644 error "migrate remote dir error"
3646 echo "Finish migration, then checking.."
3647 for file in $(find $DIR1/$tdir); do
3648 mdt_index=$($LFS getstripe -M $file)
3649 [ $mdt_index == $MDTIDX ] ||
3650 error "$file is not on MDT${MDTIDX}"
3653 diff /etc/passwd $DIR1/$tdir/$tfile ||
3654 error "file different after migration"
3656 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3658 run_test 80a "migrate directory when some children is being opened"
3662 kill -9 $migrate_pid
3666 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3667 local migrate_dir1=$DIR1/$tdir/migrate_dir
3668 local migrate_dir2=$DIR2/$tdir/migrate_dir
3669 local migrate_run=$LUSTRE/tests/migrate.sh
3677 trap cleanup_80b EXIT
3678 #prepare migrate directory
3679 mkdir -p $migrate_dir1
3680 for F in {1,2,3,4,5}; do
3681 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3682 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3685 #migrate the directories among MDTs
3688 mdt_idx=$((RANDOM % MDSCOUNT))
3689 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3691 [ $rc -ne 0 -o $rc -ne 16 ] || break
3696 echo "start migration thread $migrate_pid"
3697 #Access the files at the same time
3698 start_time=$(date +%s)
3699 echo "accessing the migrating directory for 5 minutes..."
3701 ls $migrate_dir2 > /dev/null || {
3702 echo "read dir fails"
3705 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3706 echo "access file1 fails"
3710 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3711 echo "access file2/3 fails"
3715 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3716 echo "access file4 fails"
3720 stat $migrate_dir2/file5 > /dev/null || {
3721 echo "stat file5 fails"
3725 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3726 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3727 echo "touch file failed with $rc1"
3731 if [ -e $migrate_dir2/source_file ]; then
3732 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3733 &>/dev/null || rc1=$?
3734 if [ -e $migrate_dir2/link_file ]; then
3735 rm -rf $migrate_dir2/link_file
3738 mrename $migrate_dir2/source_file \
3739 $migrate_dir2/target_file &>/dev/null || rc1=$?
3740 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3741 echo "rename failed with $rc1"
3745 if [ -e $migrate_dir2/target_file ]; then
3746 rm -rf $migrate_dir2/target_file &>/dev/null ||
3749 rm -rf $migrate_dir2/source_file &>/dev/null ||
3752 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3753 echo "unlink failed with $rc1"
3758 end_time=$(date +%s)
3759 duration=$((end_time - start_time))
3760 if [ $((duration % 10)) -eq 0 ]; then
3761 if [ $show_time -eq 1 ]; then
3762 echo "...$duration seconds"
3769 kill -0 $migrate_pid || {
3770 echo "migration stopped 1"
3774 [ $duration -ge 300 ] && break
3777 #check migration are still there
3778 kill -0 $migrate_pid || error "migration stopped 2"
3781 run_test 80b "Accessing directory during migration"
3784 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3788 mkdir -p $DIR1/$tdir
3790 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3791 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3794 touch d0/0 || error "create 0 failed"
3795 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3796 stat d0/0 && error "stat mv filed succeed"
3797 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3798 stat d0/0 || error "stat failed"
3800 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3802 if [ $t -ne 3 ]; then
3803 ls -ai $DIR1/$tdir/d0
3804 error "expect 3 get $t"
3809 run_test 81 "rename and stat under striped directory"
3812 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3813 { skip "Need MDS version at least 2.6.92"; return 0; }
3815 # Client 1 creates a file.
3816 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3818 # Client 2 opens the file.
3819 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3821 # Client 1 makes the file an orphan.
3822 rm $DIR1/$tfile || error "rm"
3823 # Client 2 sets EA "user.multiop".
3825 wait $pid2 || error "multiop 2"
3826 # Client 1 gets EA "user.multiop". This used to fail because the EA
3827 # cache refill would get "trusted.link" from mdd_xattr_list() but
3828 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3831 wait $pid1 || error "multiop 1"
3833 run_test 82 "fsetxattr and fgetxattr on orphan files"
3836 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3843 $LFS mkdir -i1 -c2 $tdir
3848 echo "start pid $pid1 to create/unlink striped directory"
3850 # Access the directory at the same time
3854 stat $tdir > /dev/null 2>&1
3858 echo "start pid $pid2 to stat striped directory"
3866 run_test 83 "access striped directory while it is being created/unlinked"
3869 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3874 [ "$SLOW" = "yes" ] && duration=600
3875 # Open/Create under striped directory
3879 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3880 touch $tdir/f{0..3} > /dev/null 2>&1
3884 echo "start pid $pid1 to open/create under striped directory"
3886 # unlink the striped directory at the same time
3890 rm -rf $tdir > /dev/null 2>&1
3894 echo "start pid $pid2 to unlink striped directory"
3903 run_test 90 "open/create and unlink striped directory"
3906 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3911 [ "$SLOW" = "yes" ] && duration=600
3912 # chmod striped directory
3916 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3917 chmod go+w $tdir > /dev/null 2>&1
3921 echo "start pid $pid1 to chmod striped directory"
3923 # unlink the striped directory at the same time
3927 rm -rf $tdir > /dev/null 2>&1
3931 echo "start pid $pid2 to unlink striped directory"
3940 run_test 91 "chmod and unlink striped directory"
3943 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3946 local cmd="exec $fd<$DIR1/$tdir"
3947 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3950 trap "eval $cmd" EXIT
3951 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3952 rmdir ../$tdir || error "rmdir ../$tdir fails"
3954 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3955 $LCTL set_param fail_loc=0x1408
3956 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3957 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3958 error "create remote dir succeeds"
3959 $LCTL set_param fail_loc=0
3963 run_test 92 "create remote directory under orphan directory"
3970 mkdir -p $DIR1/$tfile-1/
3971 mkdir -p $DIR2/$tfile-2/
3972 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
3973 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
3974 do_facet $SINGLEMDS lctl set_param -n \
3975 'lod.lustre-MDT*/qos_threshold_rr' 100
3976 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
3977 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
3979 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
3982 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
3986 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
3987 do_facet $SINGLEMDS "lctl set_param -n \
3988 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
3990 $GETSTRIPE $DIR1/$tfile-1/file1
3991 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
3992 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
3993 $GETSTRIPE $DIR2/$tfile-2/file2
3994 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
3995 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
3996 echo "rc1=$rc1 and rc2=$rc2 "
3997 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
3998 error "object allocate on same ost detected"
4000 run_test 93 "alloc_rr should not allocate on same ost"
4002 log "cleanup: ======================================================"
4004 # kill and wait in each test only guarentee script finish, but command in script
4005 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4006 # otherwise umount below will fail
4007 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4012 check_and_cleanup_lustre