6 # bug number for skipped test: 9977/LU-7105 LU-9452
7 ALWAYS_EXCEPT=" 28 29 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
14 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
15 OPENFILE=${OPENFILE:-openfile}
16 OPENUNLINK=${OPENUNLINK:-openunlink}
17 export MULTIOP=${MULTIOP:-multiop}
18 export TMP=${TMP:-/tmp}
19 MOUNT_2=${MOUNT_2:-"yes"}
20 CHECK_GRANT=${CHECK_GRANT:-"yes"}
21 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
25 export NAME=${NAME:-local}
27 LUSTRE=${LUSTRE:-`dirname $0`/..}
28 . $LUSTRE/tests/test-framework.sh
32 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
35 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
36 # bug number for skipped test:
37 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
38 # LU-2829 / LU-2887 - make allowances for ZFS slowness
39 TEST33_NFILES=${TEST33_NFILES:-1000}
42 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
49 check_and_setup_lustre
54 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
56 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
57 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
59 # $RUNAS_ID may get set incorrectly somewhere else
60 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
62 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
68 [ -f $DIR2/$tfile ] || error "Check create"
69 chmod 777 $DIR2/$tfile
70 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
71 error "Check attribute update for 0777"
73 chmod a-x $DIR2/$tfile
74 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
75 error "Check attribute update for 0666"
78 $CHECKSTAT -a $DIR1/$tfile ||
79 error "Check unlink - removes file on other mountpoint"
81 run_test 1 "Check attribute updates on 2 mount points"
87 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
89 run_test 2a "check cached attribute updates on 2 mtpt's ========"
95 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
97 run_test 2b "check cached attribute updates on 2 mtpt's ========"
99 # NEED TO SAVE ROOT DIR MODE
102 $CHECKSTAT -t dir -p 0777 $DIR2 || error
104 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
108 $CHECKSTAT -t dir -p 0755 $DIR2 || error
110 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
117 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
119 run_test 2e "check chmod on root is propagated to others"
122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
124 local remote_dir=$tdir/remote_dir
127 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
128 error "Create remote directory failed"
130 touch $DIR1/$remote_dir/$tfile ||
131 error "Create file under remote directory failed"
132 chmod 777 $DIR1/$remote_dir/$tfile ||
133 error "Chmod file under remote directory failed"
135 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
136 error "Check attr of file under remote directory failed"
138 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
139 error "Chown file under remote directory failed"
141 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
142 error "Check owner of file under remote directory failed"
144 cd $DIR2/$remote_dir || error "enter remote dir"
145 rm -rf $DIR1/$remote_dir/$tfile ||
146 error "Unlink remote directory failed"
148 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
149 error "unlink file still exists!"
151 cd $DIR2/$tdir || error "exit remote dir"
152 rm -rf $DIR1/$tdir || error "unlink directory failed"
154 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
157 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
159 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
161 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
162 echo "$DIR1/$tfile has $block1 blocks"
163 echo "$DIR2/$tfile has $block2 blocks"
164 [ $block1 -eq $block2 ] || error
166 run_test 2g "check blocks update on sync write"
169 local target="this/is/good"
170 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
171 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
172 error "link $DIR2/$tfile not as expected"
174 run_test 3 "symlink on one mtpt, readlink on another ==========="
177 multifstat $DIR1/f4 $DIR2/f4
179 run_test 4 "fstat validation on multiple mount points =========="
183 $TRUNCATE $DIR2/f5 100
184 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
187 run_test 5 "create a file on one mount, truncate it on the other"
190 openunlink $DIR1/$tfile $DIR2/$tfile || \
191 error "openunlink $DIR1/$tfile $DIR2/$tfile"
193 run_test 6 "remove of open file on other node =================="
197 opendirunlink $DIR1/$dir $DIR2/$dir || \
198 error "opendirunlink $DIR1/$dir $DIR2/$dir"
200 run_test 7 "remove of open directory on other node ============="
203 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
204 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
206 run_test 8 "remove of open special file on other node =========="
212 for C in a b c d e f g h i j k l; do
213 dir=`eval echo \\$DIR$MTPT`
214 echo -n $C >> $dir/f9
215 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
217 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
218 error "`od -a $DIR1/f9` != abcdefghijkl"
220 run_test 9 "append of file with sub-page size on multiple mounts"
227 for C in a b c d e f g h i j k l; do
228 dir=`eval echo \\$DIR$MTPT`
229 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
230 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
231 OFFSET=`expr $OFFSET + 1`
233 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
234 error "`od -a $DIR1/f10` != abcdefghijkl"
236 run_test 10a "write of file with sub-page size on multiple mounts "
240 yes "R" | head -c 4000 >$TMP/f10b-seed
241 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
243 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
245 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
247 # create a test file locally to compare
248 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
249 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
250 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
251 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
253 run_test 10b "write of file with sub-page size on multiple mounts "
257 multiop_bg_pause $DIR1/d11/f O_c || return 1
259 cp -p /bin/ls $DIR1/d11/f
263 wait $MULTIPID || error
264 [ $RC -eq 0 ] && error || true
266 run_test 11 "execution of file opened for write should return error ===="
269 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
271 run_test 12 "test lock ordering (link, stat, unlink)"
273 test_13() { # bug 2451 - directory coherency
275 cd $DIR1/d13 || error
277 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
279 rm -f $DIR2/d13/f13 || error
280 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
281 # need to run it twice
282 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
284 rm -f $DIR2/d13/f13 || error
285 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
287 run_test 13 "test directory page revocation"
290 test_mkdir $DIR1/$tdir
291 cp -p /bin/ls $DIR1/$tdir/$tfile
292 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
295 $DIR2/$tdir/$tfile && error || true
297 wait $MULTIPID || return 2
299 run_test 14aa "execution of file open for write returns -ETXTBSY"
302 test_mkdir $DIR1/$tdir
303 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
304 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
307 $MULTIOP $DIR2/$tdir/multiop Oc && error "expected error, got success"
308 kill -USR1 $MULTIOP_PID || return 2
309 wait $MULTIOP_PID || return 3
310 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
312 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
314 test_14b() { # bug 3192, 7040
315 test_mkdir $DIR1/$tdir
316 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
317 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
320 $TRUNCATE $DIR2/$tdir/multiop 0 && kill -9 $MULTIOP_PID && \
321 error "expected truncate error, got success"
322 kill -USR1 $MULTIOP_PID || return 2
323 wait $MULTIOP_PID || return 3
324 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
325 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
327 run_test 14b "truncate of executing file returns -ETXTBSY ======"
329 test_14c() { # bug 3430, 7040
330 test_mkdir $DIR1/$tdir
331 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
332 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
335 cp /etc/hosts $DIR2/$tdir/multiop && error "expected error, got success"
336 kill -USR1 $MULTIOP_PID || return 2
337 wait $MULTIOP_PID || return 3
338 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
339 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
341 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
343 test_14d() { # bug 10921
344 test_mkdir $DIR1/$tdir
345 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
346 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
350 chmod 600 $DIR1/$tdir/multiop || error "chmod failed"
351 kill -USR1 $MULTIOP_PID || return 2
352 wait $MULTIOP_PID || return 3
353 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
354 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
356 run_test 14d "chmod of executing file is still possible ========"
358 test_15() { # bug 974 - ENOSPC
360 sh oos2.sh $MOUNT1 $MOUNT2
361 wait_delete_completed
362 grant_error=`dmesg | grep "> available"`
363 [ -z "$grant_error" ] || error "$grant_error"
365 run_test 15 "test out-of-space with multiple writers ==========="
368 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
369 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
370 # pass a 2500 operation dual-mount run within the time limit.
371 if [ "$(facet_fstype ost1)" = "zfs" ]; then
372 FSXNUM=$((COUNT / 5))
374 elif [ "$SLOW" = "yes" ]; then
375 FSXNUM=$((COUNT * 5))
383 local file1=$DIR1/$tfile
384 local file2=$DIR2/$tfile
386 # to allocate grant because it may run out due to test_15.
387 $LFS setstripe -c -1 $file1
388 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
389 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
392 $LFS setstripe -c -1 $file1 # b=10919
393 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
394 || error "fsx failed"
397 # O_DIRECT reads and writes must be aligned to the device block size.
398 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
399 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
401 run_test 16 "$FSXNUM iterations of dual-mount fsx"
403 test_17() { # bug 3513, 3667
404 remote_ost_nodsh && skip "remote OST with nodsh" && return
406 lfs setstripe $DIR1/$tfile -i 0 -c 1
407 cp $SAMPLE_FILE $DIR1/$tfile
408 cancel_lru_locks osc > /dev/null
409 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
410 do_facet ost1 lctl set_param fail_loc=0x8000030a
411 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
412 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
414 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
416 run_test 17 "resource creation/LVB creation race ==============="
419 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
422 for idx in {a..z}; do
423 local ptr=EXCEPT_ALWAYS_18$idx
424 [ x${!ptr} = xtrue ] || continue
426 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
429 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
432 run_test 18 "mmap sanity check ================================="
434 test_19() { # bug3811
435 local node=$(facet_active_host ost1)
437 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
439 # check whether obdfilter is cache capable at all
440 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
441 echo "not cache-capable obdfilter"
445 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
447 set_osd_param $node '' readcache_max_filesize 4096
448 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
449 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
450 cp $TMP/$tfile $DIR1/$tfile
451 for i in `seq 1 20`; do
452 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
453 cancel_lru_locks $OSC > /dev/null
454 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
455 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
457 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
458 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
459 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
460 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
462 set_osd_param $node '' readcache_max_filesize $MAX
465 run_test 19 "test concurrent uncached read races ==============="
469 cancel_lru_locks $OSC
470 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
471 $MULTIOP $DIR1/f20 Ow8190c
472 $MULTIOP $DIR2/f20 Oz8194w8190c
473 $MULTIOP $DIR1/f20 Oz0r8190c
474 cancel_lru_locks $OSC
475 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
477 error $CNTD" page left in cache after lock cancel" || true
479 run_test 20 "test extra readahead page left in cache ===="
486 test_21() { # Bug 5907
487 test_mkdir $DIR1/$tdir
488 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
490 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
491 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
492 test -d $DIR1/$tdir || error "Mounted directory disappeared"
494 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
497 run_test 21 " Try to remove mountpoint on another dir ===="
499 test_23() { # Bug 5972
500 local at_diff=$(do_facet $SINGLEMDS \
501 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
502 echo "atime should be updated while another read" > $DIR1/$tfile
504 # clear the lock(mode: LCK_PW) gotten from creating operation
505 cancel_lru_locks $OSC
508 sleep $((at_diff + 1))
510 echo "starting reads"
511 multiop_bg_pause $DIR1/$tfile or20_c || return 1
512 # with SOM and opencache enabled, we need to close a file and cancel
513 # open lock to get atime propogated to MDS
514 kill -USR1 $! || return 2
517 time2=$(stat -c "%X" $DIR/$tfile)
518 echo "new atime is $time2"
520 [ $time2 -gt $time1 ] || error "atime was not updated"
521 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
524 run_test 23 " others should see updated atime while another read===="
528 lfs df || error "lfs df failed"
529 lfs df -ih || error "lfs df -ih failed"
530 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
531 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
532 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
533 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
535 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
536 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
537 lctl --device %osc deactivate
538 lfs df -i || error "lfs df -i with deactivated OSC failed"
539 lctl --device %osc activate
540 lfs df || error "lfs df with reactivated OSC failed"
542 run_test 24a "lfs df [-ih] [path] test ========================="
546 fsnum=$(lfs_df | grep -c "summary")
547 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
549 run_test 24b "lfs df should show both filesystems ==============="
552 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
554 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
557 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
558 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
560 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
561 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
562 error "setfacl $DIR2/$tdir #1"
563 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
564 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
565 error "setfacl $DIR2/$tdir #2"
566 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
567 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
568 error "setfacl $DIR2/$tdir #3"
569 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
570 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
571 error "setfacl $DIR2/$tdir #4"
572 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
576 run_test 25a "change ACL on one mountpoint be seen on another ==="
579 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
581 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
583 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
586 $LFS mkdir -i 1 $DIR1/$tdir
587 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
588 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
590 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
591 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
592 error "setfacl $DIR2/$tdir #1"
593 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
594 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
595 error "setfacl $DIR2/$tdir #2"
596 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
597 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
598 error "setfacl $DIR2/$tdir #3"
599 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
600 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
601 error "setfacl $DIR2/$tdir #4"
602 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
606 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
609 utime $DIR1/f26a -s $DIR2/f26a || error
611 run_test 26a "allow mtime to get older"
616 echo "aaa" >> $DIR1/$tfile
618 chmod a+x $DIR2/$tfile
619 mt1=`stat -c %Y $DIR1/$tfile`
620 mt2=`stat -c %Y $DIR2/$tfile`
622 if [ x"$mt1" != x"$mt2" ]; then
623 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
626 run_test 26b "sync mtime between ost and mds"
629 cancel_lru_locks $OSC
631 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
636 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
641 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
643 lctl set_param -n ldlm.dump_namespaces ""
644 wait $DD1_PID $DD2_PID
645 [ $? -ne 0 ] && lctl dk $TMP/debug || true
647 run_test 27 "align non-overlapping extent locks from request ==="
649 test_28() { # bug 9977
650 ECHO_UUID="ECHO_osc1_UUID"
651 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
653 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
654 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
655 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
659 attach echo_client ECHO_osc1 $ECHO_UUID
663 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
664 $LCTL --device $tECHOID destroy "${tOBJID}:0"
672 # reading of 1st stripe should pass
673 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
674 # reading of 2nd stripe should fail (this stripe was destroyed)
675 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
677 # now, recreating test file
678 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
679 # reading of 1st stripe should pass
680 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
681 # reading of 2nd stripe should pass
682 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
684 run_test 28 "read/write/truncate file with lost stripes"
686 test_29() { # bug 10999
688 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
689 lctl set_param fail_loc=0x8000030f
692 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
695 #bug 11549 - permanently turn test off in b1_5
696 run_test 29 "lock put race between glimpse and enqueue ========="
698 test_30() { #bug #11110, LU-2523
699 test_mkdir $DIR1/$tdir
700 cp -f /bin/bash $DIR1/$tdir/bash
701 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
702 $DIR1/$tdir/bash -c 'sleep 2;
703 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
708 run_test 30 "recreate file race"
711 test_mkdir $DIR1/$tdir
712 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
713 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
714 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
715 lctl set_param fail_loc=0x314
716 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
717 awk 'BEGIN { FS="+" } /in/ {print $1}')
718 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
720 run_test 31a "voluntary cancel / blocking ast race=============="
723 remote_ost || { skip "local OST" && return 0; }
724 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
726 # make sure there is no local locks due to destroy
727 wait_mds_ost_sync || error "wait_mds_ost_sync()"
728 wait_delete_completed || error "wait_delete_completed()"
730 test_mkdir $DIR1/$tdir
731 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
732 cp /etc/hosts $DIR/$tdir/$tfile
733 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
734 lctl set_param fail_loc=0x314
735 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
736 do_facet ost1 lctl set_param fail_loc=0x316
738 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
739 lctl set_param fail_loc=0
740 do_facet ost1 lctl set_param fail_loc=0
741 # cleanup: reconnect the client back
744 run_test 31b "voluntary OST cancel / blocking ast race=============="
746 # enable/disable lockless truncate feature, depending on the arg 0/1
747 enable_lockless_truncate() {
748 lctl set_param -n $OSC.*.lockless_truncate $1
751 test_32a() { # bug 11270
752 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
754 save_lustre_params client "$OSC.*.lockless_truncate" > $p
755 cancel_lru_locks $OSC
756 enable_lockless_truncate 1
758 lfs setstripe -c -1 $DIR1/$tfile
759 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
761 clear_stats $OSC.*.${OSC}_stats
763 log "checking cached lockless truncate"
764 $TRUNCATE $DIR1/$tfile 8000000
765 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
766 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
767 error "cached truncate isn't lockless"
769 log "checking not cached lockless truncate"
770 $TRUNCATE $DIR2/$tfile 5000000
771 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
772 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
773 error "not cached truncate isn't lockless"
775 log "disabled lockless truncate"
776 enable_lockless_truncate 0
777 clear_stats $OSC.*.${OSC}_stats
778 $TRUNCATE $DIR2/$tfile 3000000
779 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
780 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
781 error "lockless truncate disabling failed"
783 # restore lockless_truncate default values
784 restore_lustre_params < $p
787 run_test 32a "lockless truncate"
789 test_32b() { # bug 11270
790 remote_ost_nodsh && skip "remote OST with nodsh" && return
793 local facets=$(get_facets OST)
794 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
796 save_lustre_params client "osc.*.contention_seconds" > $p
797 save_lustre_params $facets \
798 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
799 save_lustre_params $facets \
800 "ldlm.namespaces.filter-*.contended_locks" >> $p
801 save_lustre_params $facets \
802 "ldlm.namespaces.filter-*.contention_seconds" >> $p
803 clear_stats $OSC.*.${OSC}_stats
805 # agressive lockless i/o settings
806 do_nodes $(comma_list $(osts_nodes)) \
807 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
808 ldlm.namespaces.filter-*.contended_locks=0 \
809 ldlm.namespaces.filter-*.contention_seconds=60"
810 lctl set_param -n $OSC.*.contention_seconds=60
812 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
814 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
817 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
818 error "lockless i/o was not triggered"
819 # disable lockless i/o (it is disabled by default)
820 do_nodes $(comma_list $(osts_nodes)) \
821 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
822 ldlm.namespaces.filter-*.contended_locks=32 \
823 ldlm.namespaces.filter-*.contention_seconds=0"
824 # set contention_seconds to 0 at client too, otherwise Lustre still
825 # remembers lock contention
826 lctl set_param -n $OSC.*.contention_seconds=0
827 clear_stats $OSC.*.${OSC}_stats
829 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
831 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
834 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
835 error "lockless i/o works when disabled"
837 restore_lustre_params <$p
840 run_test 32b "lockless i/o"
844 local mdts=$(get_facets MDS)
849 for mds in ${mdts//,/ }; do
851 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
852 xargs readlink -f" ))
853 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
856 stat=$(( stat + val))
861 # commit on sharing tests
863 remote_mds_nodsh && skip "remote MDS with nodsh" && return
865 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
866 [ $CLIENTCOUNT -lt 2 ] &&
867 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
869 local nfiles=${TEST33_NFILES:-10000}
870 local param_file=$TMP/$tfile-params
871 local fstype=$(facet_fstype $SINGLEMDS)
873 save_lustre_params $(get_facets MDS) \
874 "mdt.*.commit_on_sharing" > $param_file
882 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
886 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
888 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
889 echo "=== START createmany old: $jbdold transaction"
890 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")
891 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
892 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
893 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
894 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
895 avgtime=$(( avgtime + elapsed ))
897 eval cos${COS}_jbd=$((avgjbd / 3))
898 eval cos${COS}_time=$((avgtime / 3))
901 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
902 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
903 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
904 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
906 restore_lustre_params < $param_file
910 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
912 # commit on sharing tests
914 remote_mds_nodsh && skip "remote MDS with nodsh" && return
916 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
917 [ $CLIENTCOUNT -ge 2 ] ||
918 { skip "Need two or more clients, have $CLIENTCOUNT" &&
920 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
922 local nfiles=${TEST33_NFILES:-10000}
923 local param_file=$TMP/$tfile-params
925 save_lustre_params $(get_facets MDS) \
926 "mdt.*.commit_on_sharing" > $param_file
935 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
939 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
940 $DIR1/$tdir-\\\$(hostname)-$i"
942 jbdold=$(print_jbd_stat)
943 echo "=== START createmany old: $jbdold transaction"
944 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
945 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
946 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
948 jbdnew=$(print_jbd_stat)
949 jbd=$(( jbdnew - jbdold ))
950 echo "=== END createmany new: $jbdnew transaction : \
951 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
952 avgjbd=$(( avgjbd + jbd ))
953 avgtime=$(( avgtime + elapsed ))
955 eval cos${COS}_jbd=$((avgjbd / 3))
956 eval cos${COS}_time=$((avgtime / 3))
959 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
960 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
961 [ "$cos0_jbd" != 0 ] &&
962 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
963 [ "$cos0_time" != 0 ] &&
964 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
966 restore_lustre_params < $param_file
970 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
973 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
974 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
975 skip "DNE CoS not supported" && return
980 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
981 $LFS mkdir -i 1 $DIR/$tdir/d1
982 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
984 local sync_count=$(do_facet mds1 \
985 "lctl get_param -n mdt.*MDT0000.sync_count")
986 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
988 $LFS mkdir -i 1 $DIR/$tdir/d3
989 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
990 # during sleep remote mkdir should have been committed and canceled
991 # remote lock spontaneously, which shouldn't trigger sync
994 local sync_count=$(do_facet mds1 \
995 "lctl get_param -n mdt.*MDT0000.sync_count")
996 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
998 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1001 local nodes=$(comma_list $(mdts_nodes))
1002 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1004 local async_commit_count=$(do_nodes $nodes \
1005 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1006 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
1013 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1014 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1015 skip "DNE CoS not supported" && return
1018 # remote directory create
1020 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1021 # remote directory unlink
1022 $LFS mkdir -i 1 $DIR/$tdir
1023 ops_do_cos "rmdir $DIR/$tdir"
1024 # striped directory create
1026 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1027 # striped directory setattr
1028 $LFS mkdir -c 2 $DIR/$tdir
1030 ops_do_cos "chmod 713 $DIR/$tdir"
1031 # striped directory unlink
1032 $LFS mkdir -c 2 $DIR/$tdir
1034 ops_do_cos "rmdir $DIR/$tdir"
1036 $LFS mkdir -c 2 $DIR/$tdir
1037 $LFS mkdir -i 0 $DIR/$tdir/d1
1038 $LFS mkdir -i 1 $DIR/$tdir/d2
1039 touch $DIR/$tdir/d1/tgt
1040 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1042 $LFS mkdir -c 2 $DIR/$tdir
1043 $LFS mkdir -i 0 $DIR/$tdir/d1
1044 $LFS mkdir -i 1 $DIR/$tdir/d2
1045 touch $DIR/$tdir/d1/src
1046 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1048 $LFS mkdir -i 0 $DIR/$tdir
1049 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1052 run_test 33d "DNE distributed operation should trigger COS"
1055 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1056 [ $CLIENTCOUNT -ge 2 ] ||
1057 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1059 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1060 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1061 skip "DNE CoS not supported" && return
1063 local client2=${CLIENT2:-$(hostname)}
1067 local nodes=$(comma_list $(mdts_nodes))
1068 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1070 $LFS mkdir -c 2 $DIR/$tdir
1071 mkdir $DIR/$tdir/subdir
1072 echo abc > $DIR/$tdir/$tfile
1073 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1074 do_node $client2 touch $DIR/$tdir/subdir
1076 local async_commit_count=$(do_nodes $nodes \
1077 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1078 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1082 run_test 33e "DNE local operation shouldn't trigger COS"
1084 # End commit on sharing tests
1086 get_ost_lock_timeouts() {
1087 local nodes=${1:-$(comma_list $(osts_nodes))}
1089 local locks=$(do_nodes $nodes \
1090 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1098 do_nodes $(comma_list $(osts_nodes)) \
1099 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1100 for i in $(seq $OSTCOUNT); do
1101 wait_osc_import_state client ost$i FULL
1106 remote_ost_nodsh && skip "remote OST with nodsh" && return
1110 trap cleanup_34 EXIT RETURN
1111 for OPER in notimeout timeout ; do
1112 rm $DIR1/$tfile 2>/dev/null
1113 lock_in=$(get_ost_lock_timeouts)
1114 if [ $OPER == "timeout" ] ; then
1115 for j in `seq $OSTCOUNT`; do
1116 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1117 do_facet ost$j lctl set_param fail_loc=0x511
1119 echo lock should expire
1121 for j in `seq $OSTCOUNT`; do
1122 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1123 do_facet ost$j lctl set_param fail_loc=0x512
1125 echo lock should not expire
1127 echo writing on client1
1128 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1130 echo reading on client2
1131 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1132 # wait for a lock timeout
1134 lock_out=$(get_ost_lock_timeouts)
1135 if [ $OPER == "timeout" ] ; then
1136 if [ $lock_in == $lock_out ]; then
1137 error "no lock timeout happened"
1142 if [ $lock_in != $lock_out ]; then
1143 error "lock timeout happened"
1151 run_test 34 "no lock timeout under IO"
1153 test_35() { # bug 17645
1156 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1157 awk '/generation/{print $2}')
1159 generation[count]=$g
1163 test_mkdir $MOUNT1/$tdir
1164 cancel_lru_locks mdc
1166 # Let's initiate -EINTR situation by setting fail_loc and take
1167 # write lock on same file from same client. This will not cause
1168 # bl_ast yet as lock is already in local cache.
1169 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1170 do_facet client "lctl set_param fail_loc=0x80000317"
1171 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1172 let timeout=timeout*3
1174 while test $nr -lt 10; do
1175 log "Race attempt $nr"
1176 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1177 awk '/ldlm_bl_callback/ { print $2 }')
1178 test "x$blk1" = "x" && blk1=0
1179 createmany -o $MOUNT2/$tdir/a 4000 &
1183 # Let's make conflict and bl_ast
1184 ls -la $MOUNT1/$tdir > /dev/null &
1187 log "Wait for $pid1 $pid2 for $timeout sec..."
1189 kill -9 $pid1 $pid2 > /dev/null 2>&1
1191 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1192 awk '/ldlm_bl_callback/ { print $2 }')
1193 test "x$blk2" = "x" && blk2=0
1194 test $blk2 -gt $blk1 && break
1195 rm -fr $MOUNT1/$tdir
1196 cancel_lru_locks mdc
1199 do_facet client "lctl set_param fail_loc=0x0"
1200 df -h $MOUNT1 $MOUNT2
1202 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1203 awk '/generation/{print $2}')
1205 if ! test "$g" -eq "${generation[count]}"; then
1206 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1208 for imp in $list; do
1209 if [ $c = $count ]; then
1214 imp=$(echo "$imp" | awk -F"." '{print $2}')
1215 error "Eviction happened on import $imp"
1220 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1222 test_36() { #bug 16417
1227 test_mkdir $DIR1/$tdir
1228 $LFS setstripe -c -1 $DIR1/$tdir
1231 let SIZE_B=SIZE*1024*1024
1232 sync; sleep 2; sync # wait for delete thread
1233 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1234 wait_destroy_complete || error "wait_destroy_complete failed"
1236 while [ $i -le 10 ]; do
1237 lctl mark "start test - cycle ($i)"
1238 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1239 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1240 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1241 sync # sync data from client cache
1242 sync_all_data # sync data from server cache (delayed allocation)
1244 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1245 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1247 rm -f $DIR1/$tdir/$tfile
1248 kill -USR1 $read_pid
1250 sync; sleep 2; sync # Ensure new statfs
1251 wait_delete_completed
1252 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1253 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1255 # this free space! not used
1256 (( $after_dd <= $after)) ||
1257 error "space leaked after_dd:$after_dd > after:$after"
1261 run_test 36 "handle ESTALE/open-unlink correctly"
1263 test_37() { # bug 18695
1264 test_mkdir $DIR1/$tdir
1265 multiop_bg_pause $DIR1/$tdir D_c || return 1
1267 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1268 createmany -m $DIR2/$tdir/f 10000
1269 # set mtime/atime backward
1270 touch -t 198001010000 $DIR2/$tdir
1271 kill -USR1 $MULTIPID
1272 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1273 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1276 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1278 # this should be set to past
1279 TEST_39_MTIME=`date -d "1 year ago" +%s`
1283 local client1=${CLIENT1:-`hostname`}
1284 local client2=${CLIENT2:-`hostname`}
1286 do_node $client1 "touch $DIR1/$tfile"
1288 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1289 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1290 [ "$mtime1" = $TEST_39_MTIME ] || \
1291 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1293 local d1=`do_node $client1 date +%s`
1294 do_node $client1 'echo hello >> '$DIR1/$tfile
1295 local d2=`do_node $client1 date +%s`
1297 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1298 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1299 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1301 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1303 for (( i=0; i < 2; i++ )) ; do
1304 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1305 [ "$mtime2" = "$mtime3" ] || \
1306 error "mtime ($mtime2) changed (to $mtime3) on rename"
1308 cancel_lru_locks osc
1309 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1312 run_test 39a "test from 11063 =================================="
1315 local client1=${CLIENT1:-`hostname`}
1316 local client2=${CLIENT2:-`hostname`}
1320 local mtime1=`stat -c %Y $DIR1/$tfile`
1321 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1324 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1326 for (( i=0; i < 2; i++ )) ; do
1327 local mtime3=`stat -c %Y $DIR1/$tfile`
1328 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1330 [ "$mtime3" = "$mtime4" ] || \
1331 error "different mtime on clients: $mtime3, $mtime4"
1332 [ "$mtime3" = $TEST_39_MTIME ] || \
1333 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1335 cancel_lru_locks osc
1336 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1339 run_test 39b "11063 problem 1 =================================="
1342 local client1=${CLIENT1:-`hostname`}
1343 local client2=${CLIENT2:-`hostname`}
1345 echo hello > $DIR1/$tfile
1347 local mtime1=`stat -c %Y $DIR1/$tfile`
1348 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1349 [ "$mtime1" = "$mtime2" ] || \
1350 error "create: different mtime on clients: $mtime1, $mtime2"
1353 $TRUNCATE $DIR1/$tfile 1
1355 for (( i=0; i < 2; i++ )) ; do
1356 local mtime3=`stat -c %Y $DIR1/$tfile`
1357 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1359 [ "$mtime3" = "$mtime4" ] || \
1360 error "different mtime on clients: $mtime3, $mtime4"
1361 [ "$mtime3" -gt $mtime2 ] || \
1362 error "truncate did not update mtime: $mtime2, $mtime3"
1364 cancel_lru_locks osc
1365 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1368 run_test 39c "check truncate mtime update ======================"
1370 test_39d() { # LU-7310
1372 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1374 local mtime1=$(stat -c %Y $DIR2/$tfile)
1375 [ "$mtime1" = $TEST_39_MTIME ] ||
1376 error "mtime: $mtime1, should be $TEST_39_MTIME"
1379 # define OBD_FAIL_OSC_NO_GRANT 0x411
1380 $LCTL set_param fail_loc=0x411
1382 local d1=$(date +%s)
1383 echo hello >> $DIR1/$tfile
1384 local d2=$(date +%s)
1386 $LCTL set_param fail_loc=0
1388 cancel_lru_locks $OSC
1390 local mtime2=$(stat -c %Y $DIR2/$tfile)
1391 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1392 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1394 run_test 39d "sync write should update mtime"
1396 # check that pid exists hence second operation wasn't blocked by first one
1397 # if it is so then there is no conflict, return 0
1398 # else second operation is conflicting with first one, return 1
1399 check_pdo_conflict() {
1402 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1403 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1413 # test 40: check non-blocking operations
1415 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1417 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1419 mkdir $DIR1/$tfile &
1422 touch $DIR2/$tfile-2
1423 check_pdo_conflict $PID1 || error "create is blocked"
1424 mkdir $DIR2/$tfile-3
1425 check_pdo_conflict $PID1 || error "mkdir is blocked"
1426 link $DIR2/$tfile-2 $DIR2/$tfile-4
1427 check_pdo_conflict $PID1 || error "link is blocked"
1428 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1429 check_pdo_conflict $PID1 || error "rename is blocked"
1430 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1431 check_pdo_conflict $PID1 || error "getattr is blocked"
1432 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1433 rmdir $DIR2/$tfile-3
1434 check_pdo_conflict $PID1 || error "unlink is blocked"
1436 # all operations above shouldn't wait the first one
1437 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1442 run_test 40a "pdirops: create vs others =============="
1445 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1446 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1447 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1448 touch $DIR1/$tfile &
1452 touch $DIR2/$tfile-2
1453 check_pdo_conflict $PID1 || error "create is blocked"
1454 mkdir $DIR2/$tfile-3
1455 check_pdo_conflict $PID1 || error "mkdir is blocked"
1456 link $DIR2/$tfile-2 $DIR2/$tfile-4
1457 check_pdo_conflict $PID1 || error "link is blocked"
1458 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1459 check_pdo_conflict $PID1 || error "rename is blocked"
1460 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1461 check_pdo_conflict $PID1 || error "getattr is blocked"
1462 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1463 rmdir $DIR2/$tfile-3
1464 check_pdo_conflict $PID1 || error "unlink is blocked"
1465 # all operations above shouldn't wait the first one
1467 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1472 run_test 40b "pdirops: open|create and others =============="
1475 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1477 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1478 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1479 link $DIR1/$tfile $DIR1/$tfile-0 &
1483 touch $DIR2/$tfile-2
1484 check_pdo_conflict $PID1 || error "create is blocked"
1485 mkdir $DIR2/$tfile-3
1486 check_pdo_conflict $PID1 || error "mkdir is blocked"
1487 link $DIR2/$tfile-2 $DIR2/$tfile-4
1488 check_pdo_conflict $PID1 || error "link is blocked"
1489 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1490 check_pdo_conflict $PID1 || error "rename is blocked"
1491 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1492 check_pdo_conflict $PID1 || error "getattr is blocked"
1493 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1494 rmdir $DIR2/$tfile-3
1495 check_pdo_conflict $PID1 || error "unlink is blocked"
1497 # all operations above shouldn't wait the first one
1498 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1503 run_test 40c "pdirops: link and others =============="
1506 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1508 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1509 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1514 touch $DIR2/$tfile-2
1515 check_pdo_conflict $PID1 || error "create is blocked"
1516 mkdir $DIR2/$tfile-3
1517 check_pdo_conflict $PID1 || error "mkdir is blocked"
1518 link $DIR2/$tfile-2 $DIR2/$tfile-4
1519 check_pdo_conflict $PID1 || error "link is blocked"
1520 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1521 check_pdo_conflict $PID1 || error "rename is blocked"
1522 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1523 check_pdo_conflict $PID1 || error "getattr is blocked"
1524 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1525 rmdir $DIR2/$tfile-3
1526 check_pdo_conflict $PID1 || error "unlink is blocked"
1528 # all operations above shouldn't wait the first one
1529 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1533 run_test 40d "pdirops: unlink and others =============="
1536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1538 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1539 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1540 mv $DIR1/$tfile $DIR1/$tfile-0 &
1544 touch $DIR2/$tfile-2
1545 check_pdo_conflict $PID1 || error "create is blocked"
1546 mkdir $DIR2/$tfile-3
1547 check_pdo_conflict $PID1 || error "mkdir is blocked"
1548 link $DIR2/$tfile-2 $DIR2/$tfile-4
1549 check_pdo_conflict $PID1 || error "link is blocked"
1550 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1551 check_pdo_conflict $PID1 || error "getattr is blocked"
1552 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1553 rmdir $DIR2/$tfile-3
1554 check_pdo_conflict $PID1 || error "unlink is blocked"
1556 # all operations above shouldn't wait the first one
1557 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1562 run_test 40e "pdirops: rename and others =============="
1564 # test 41: create blocking operations
1566 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1567 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1568 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1571 mkdir $DIR2/$tfile && error "mkdir must fail"
1572 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1576 run_test 41a "pdirops: create vs mkdir =============="
1579 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1580 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1581 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1584 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1585 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1589 run_test 41b "pdirops: create vs create =============="
1592 touch $DIR1/$tfile-2
1593 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1594 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1595 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1598 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1599 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1603 run_test 41c "pdirops: create vs link =============="
1606 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1607 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1608 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1611 rm $DIR2/$tfile || error "unlink must succeed"
1612 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1616 run_test 41d "pdirops: create vs unlink =============="
1619 touch $DIR1/$tfile-2
1620 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1621 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1622 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1625 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1626 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1630 run_test 41e "pdirops: create and rename (tgt) =============="
1633 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1634 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1635 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1638 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1639 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1643 run_test 41f "pdirops: create and rename (src) =============="
1646 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1647 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1648 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1651 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1652 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1656 run_test 41g "pdirops: create vs getattr =============="
1659 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1660 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1661 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1664 ls -lia $DIR2/ > /dev/null
1665 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1669 run_test 41h "pdirops: create vs readdir =============="
1671 # test 42: unlink and blocking operations
1673 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1674 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1675 mkdir $DIR1/$tfile &
1678 mkdir $DIR2/$tfile && error "mkdir must fail"
1679 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1683 run_test 42a "pdirops: mkdir vs mkdir =============="
1686 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1687 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1688 mkdir $DIR1/$tfile &
1691 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1692 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1696 run_test 42b "pdirops: mkdir vs create =============="
1699 touch $DIR1/$tfile-2
1700 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1701 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1702 mkdir $DIR1/$tfile &
1705 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1706 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1710 run_test 42c "pdirops: mkdir vs link =============="
1713 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1714 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1715 mkdir $DIR1/$tfile &
1718 rmdir $DIR2/$tfile || error "unlink must succeed"
1719 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1723 run_test 42d "pdirops: mkdir vs unlink =============="
1726 touch $DIR1/$tfile-2
1727 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1728 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1729 mkdir $DIR1/$tfile &
1732 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1733 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1737 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1740 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1741 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1742 mkdir $DIR1/$tfile &
1745 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1746 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1750 run_test 42f "pdirops: mkdir and rename (src) =============="
1753 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1754 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1755 mkdir $DIR1/$tfile &
1758 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1763 run_test 42g "pdirops: mkdir vs getattr =============="
1766 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1767 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1768 mkdir $DIR1/$tfile &
1771 ls -lia $DIR2/ > /dev/null
1772 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1776 run_test 42h "pdirops: mkdir vs readdir =============="
1778 # test 43: unlink and blocking operations
1781 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1782 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1786 mkdir $DIR2/$tfile || error "mkdir must succeed"
1787 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1791 run_test 43a "pdirops: unlink vs mkdir =============="
1795 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1796 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1800 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1801 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1805 run_test 43b "pdirops: unlink vs create =============="
1809 touch $DIR1/$tfile-2
1810 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1811 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1815 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1816 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1820 run_test 43c "pdirops: unlink vs link =============="
1824 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1825 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1829 rm $DIR2/$tfile && error "unlink must fail"
1830 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1834 run_test 43d "pdirops: unlink vs unlink =============="
1838 touch $DIR1/$tfile-2
1839 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1840 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1844 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1845 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1849 run_test 43e "pdirops: unlink and rename (tgt) =============="
1853 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1854 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1858 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1859 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1863 run_test 43f "pdirops: unlink and rename (src) =============="
1867 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1868 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1872 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1873 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1877 run_test 43g "pdirops: unlink vs getattr =============="
1881 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1882 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1886 ls -lia $DIR2/ > /dev/null
1887 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1891 run_test 43h "pdirops: unlink vs readdir =============="
1894 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1896 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1897 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1901 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1902 check_pdo_conflict $PID1 &&
1903 { wait $PID1; error "remote mkdir isn't blocked"; }
1907 run_test 43i "pdirops: unlink vs remote mkdir"
1909 # test 44: rename tgt and blocking operations
1911 touch $DIR1/$tfile-2
1912 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1913 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1914 mv $DIR1/$tfile-2 $DIR1/$tfile &
1917 mkdir $DIR2/$tfile && error "mkdir must fail"
1918 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1922 run_test 44a "pdirops: rename tgt vs mkdir =============="
1925 touch $DIR1/$tfile-2
1926 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1927 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1928 mv $DIR1/$tfile-2 $DIR1/$tfile &
1931 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1932 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1936 run_test 44b "pdirops: rename tgt vs create =============="
1939 touch $DIR1/$tfile-2
1940 touch $DIR1/$tfile-3
1941 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1942 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1943 mv $DIR1/$tfile-2 $DIR1/$tfile &
1946 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1947 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1951 run_test 44c "pdirops: rename tgt vs link =============="
1954 touch $DIR1/$tfile-2
1955 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1956 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1957 mv $DIR1/$tfile-2 $DIR1/$tfile &
1960 rm $DIR2/$tfile || error "unlink must succeed"
1961 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1965 run_test 44d "pdirops: rename tgt vs unlink =============="
1969 touch $DIR1/$tfile-2
1970 touch $DIR1/$tfile-3
1971 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1972 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1973 mv $DIR1/$tfile-2 $DIR1/$tfile &
1976 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1977 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1981 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1984 touch $DIR1/$tfile-2
1985 touch $DIR1/$tfile-3
1986 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1987 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1988 mv $DIR1/$tfile-2 $DIR1/$tfile &
1991 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1992 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1996 run_test 44f "pdirops: rename tgt and rename (src) =============="
1999 touch $DIR1/$tfile-2
2000 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2001 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2002 mv $DIR1/$tfile-2 $DIR1/$tfile &
2005 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2006 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2010 run_test 44g "pdirops: rename tgt vs getattr =============="
2013 touch $DIR1/$tfile-2
2014 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2015 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2016 mv $DIR1/$tfile-2 $DIR1/$tfile &
2019 ls -lia $DIR2/ > /dev/null
2020 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2024 run_test 44h "pdirops: rename tgt vs readdir =============="
2026 # test 44: rename tgt and blocking operations
2028 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2029 touch $DIR1/$tfile-2
2030 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2031 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2032 mv $DIR1/$tfile-2 $DIR1/$tfile &
2035 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2036 check_pdo_conflict $PID1 && { wait $PID1;
2037 error "remote mkdir isn't blocked"; }
2041 run_test 44i "pdirops: rename tgt vs remote mkdir"
2043 # test 45: rename src and blocking operations
2046 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2047 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2048 mv $DIR1/$tfile $DIR1/$tfile-2 &
2051 mkdir $DIR2/$tfile || error "mkdir must succeed"
2052 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2056 run_test 45a "pdirops: rename src vs mkdir =============="
2060 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2061 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2062 mv $DIR1/$tfile $DIR1/$tfile-2 &
2065 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2066 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2070 run_test 45b "pdirops: rename src vs create =============="
2074 touch $DIR1/$tfile-3
2075 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2076 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2077 mv $DIR1/$tfile $DIR1/$tfile-2 &
2080 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2081 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2085 run_test 45c "pdirops: rename src vs link =============="
2089 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2090 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2091 mv $DIR1/$tfile $DIR1/$tfile-2 &
2094 rm $DIR2/$tfile && error "unlink must fail"
2095 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2099 run_test 45d "pdirops: rename src vs unlink =============="
2103 touch $DIR1/$tfile-3
2104 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2105 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2106 mv $DIR1/$tfile $DIR1/$tfile-2 &
2109 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2110 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2114 run_test 45e "pdirops: rename src and rename (tgt) =============="
2118 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2119 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2120 mv $DIR1/$tfile $DIR1/$tfile-2 &
2123 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2124 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2128 run_test 45f "pdirops: rename src and rename (src) =============="
2132 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2133 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2134 mv $DIR1/$tfile $DIR1/$tfile-2 &
2137 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2138 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2142 run_test 45g "pdirops: rename src vs getattr =============="
2146 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2147 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2148 mv $DIR1/$tfile $DIR1/$tfile-2 &
2151 ls -lia $DIR2/ > /dev/null
2152 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2156 run_test 45h "pdirops: unlink vs readdir =============="
2159 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2161 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2162 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2163 mv $DIR1/$tfile $DIR1/$tfile-2 &
2166 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2167 check_pdo_conflict $PID1 && { wait $PID1;
2168 error "create remote dir isn't blocked"; }
2172 run_test 45i "pdirops: rename src vs remote mkdir"
2174 # test 46: link and blocking operations
2176 touch $DIR1/$tfile-2
2177 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2178 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2179 link $DIR1/$tfile-2 $DIR1/$tfile &
2182 mkdir $DIR2/$tfile && error "mkdir must fail"
2183 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2187 run_test 46a "pdirops: link vs mkdir =============="
2190 touch $DIR1/$tfile-2
2191 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2192 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2193 link $DIR1/$tfile-2 $DIR1/$tfile &
2196 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2197 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2201 run_test 46b "pdirops: link vs create =============="
2204 touch $DIR1/$tfile-2
2205 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2206 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2207 link $DIR1/$tfile-2 $DIR1/$tfile &
2210 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2211 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2215 run_test 46c "pdirops: link vs link =============="
2218 touch $DIR1/$tfile-2
2219 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2220 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2221 link $DIR1/$tfile-2 $DIR1/$tfile &
2224 rm $DIR2/$tfile || error "unlink must succeed"
2225 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2229 run_test 46d "pdirops: link vs unlink =============="
2232 touch $DIR1/$tfile-2
2233 touch $DIR1/$tfile-3
2234 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2235 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2236 link $DIR1/$tfile-2 $DIR1/$tfile &
2239 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2240 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2244 run_test 46e "pdirops: link and rename (tgt) =============="
2247 touch $DIR1/$tfile-2
2248 touch $DIR1/$tfile-3
2249 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2250 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2251 link $DIR1/$tfile-2 $DIR1/$tfile &
2254 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2255 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2259 run_test 46f "pdirops: link and rename (src) =============="
2262 touch $DIR1/$tfile-2
2263 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2264 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2265 link $DIR1/$tfile-2 $DIR1/$tfile &
2268 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2269 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2273 run_test 46g "pdirops: link vs getattr =============="
2276 touch $DIR1/$tfile-2
2277 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2278 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2279 link $DIR1/$tfile-2 $DIR1/$tfile &
2282 ls -lia $DIR2/ > /dev/null
2283 check_pdo_conflict $PID1 && { wait $PID1;
2284 error "readdir isn't blocked"; }
2288 run_test 46h "pdirops: link vs readdir =============="
2291 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2292 touch $DIR1/$tfile-2
2293 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2294 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2295 link $DIR1/$tfile-2 $DIR1/$tfile &
2298 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2299 check_pdo_conflict $PID1 && { wait $PID1;
2300 error "remote mkdir isn't blocked"; }
2304 run_test 46i "pdirops: link vs remote mkdir"
2306 # test 47: remote mkdir and blocking operations
2308 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2309 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2310 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2311 $LFS mkdir -i 1 $DIR1/$tfile &
2314 mkdir $DIR2/$tfile && error "mkdir must fail"
2315 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2319 run_test 47a "pdirops: remote mkdir vs mkdir"
2322 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2323 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2324 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2325 $LFS mkdir -i 1 $DIR1/$tfile &
2328 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2329 check_pdo_conflict $PID1 && { wait $PID1;
2330 error "create isn't blocked"; }
2334 run_test 47b "pdirops: remote mkdir vs create"
2337 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2338 touch $DIR1/$tfile-2
2339 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2340 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2341 $LFS mkdir -i 1 $DIR1/$tfile &
2344 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2345 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2349 run_test 47c "pdirops: remote mkdir vs link"
2352 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2353 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2354 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2355 $LFS mkdir -i 1 $DIR1/$tfile &
2358 rmdir $DIR2/$tfile || error "unlink must succeed"
2359 check_pdo_conflict $PID1 && { wait $PID1;
2360 error "unlink isn't blocked"; }
2364 run_test 47d "pdirops: remote mkdir vs unlink"
2367 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2368 touch $DIR1/$tfile-2
2369 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2370 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2371 $LFS mkdir -i 1 $DIR1/$tfile &
2374 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2375 check_pdo_conflict $PID1 && { wait $PID1;
2376 error "rename isn't blocked"; }
2380 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2383 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2384 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2385 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2386 $LFS mkdir -i 1 $DIR1/$tfile &
2389 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2390 check_pdo_conflict $PID1 && { wait $PID1;
2391 error "rename isn't blocked"; }
2395 run_test 47f "pdirops: remote mkdir and rename (src)"
2398 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2399 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2400 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2401 $LFS mkdir -i 1 $DIR1/$tfile &
2404 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2405 check_pdo_conflict $PID1 && { wait $PID1;
2406 error "getattr isn't blocked"; }
2410 run_test 47g "pdirops: remote mkdir vs getattr"
2414 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2415 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2416 do_facet client "lctl set_param fail_loc=0x410"
2417 $TRUNCATE $DIR2/$tfile $trunc_size
2418 do_facet client "lctl set_param fail_loc=0x0"
2420 size=`stat -c %s $DIR2/$tfile`
2421 [ $size -eq $trunc_size ] || error "wrong size"
2423 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2427 local origfile=/etc/hosts
2429 filesize=$(stat -c %s $origfile)
2431 # create an empty file
2432 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2433 # cache layout lock on both mount point
2434 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2435 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2437 # open and sleep 2 seconds then read
2438 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2442 # create the layout of testing file
2443 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2444 error "dd $DIR1/$tfile failed"
2446 # MULTIOP proc should be able to read enough bytes and exit
2447 for ((i = 0; i < 6; i++)); do
2449 kill -0 $pid || break
2451 kill -0 $pid 2> /dev/null && error "multiop is still there"
2452 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2456 run_test 51a "layout lock: refresh layout should work"
2459 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2460 { skip "Need MDS version at least 2.3.59"; return 0; }
2462 local tmpfile=`mktemp`
2464 # create an empty file
2465 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2467 # delay glimpse so that layout has changed when glimpse finish
2468 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2469 $LCTL set_param fail_loc=0x1404
2470 stat -c %s $DIR2/$tfile |tee $tmpfile &
2474 # create layout of testing file
2475 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2476 error "dd $DIR1/$tfile failed"
2479 local fsize=$(cat $tmpfile)
2481 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2483 rm -f $DIR1/$tfile $tmpfile
2485 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2488 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2490 # set default layout to have 1 stripe
2492 $LFS setstripe -c 1 $DIR1/$tdir
2494 # create a file with empty layout
2495 $MCREATE $DIR1/$tdir/$tfile ||
2496 error "$MCREATE $DIR1/$tdir/$tfile failed"
2498 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2499 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2501 # change the layout of testing file
2502 echo "Setting layout to have $OSTCOUNT stripes ..."
2503 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2507 # write something to the file, it should be blocked on fetching layout
2508 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2509 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2512 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2513 # count to succeed with only 3/4 of the number of stripes (rounded up),
2514 # so creating striped files does not fail if an OST is offline or full
2515 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2516 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2520 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2523 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2524 cancel_lru_locks mdc
2526 # open should grant LAYOUT lock, mmap and read will install pages
2527 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2531 # rss before revoking
2532 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2533 echo "Before revoking layout lock: $br KB mapped"
2535 # delete the file will revoke layout lock
2538 # rss after revoking
2539 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2544 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2546 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2550 echo "==> rename vs getattr vs setxattr should not deadlock"
2551 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2553 do_facet mds1 $LCTL set_param fail_loc=$1
2555 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2563 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2564 wait $PID1 || error "(3) mv failed"
2565 wait $PID2 || error "(4) stat failed"
2572 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2573 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2575 do_facet mds1 $LCTL set_param fail_loc=$1
2577 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2585 $MULTIOP $DIR2/d1/d2 Oc &
2589 stat $DIR/d1 || error "(2) stat failed"
2591 wait $PID1 || error "(3) mv failed"
2592 wait $PID2 || error "(4) stat failed"
2593 wait $PID3 && error "(5) multiop failed"
2599 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2600 save_lustre_params client "llite.*.xattr_cache" > $p
2601 lctl set_param llite.*.xattr_cache 1 ||
2602 { skip "xattr cache is not supported"; return 0; }
2604 #define OBD_FAIL_MDS_RENAME 0x153
2605 #define OBD_FAIL_MDS_RENAME2 0x154
2606 test_54_part1 0x80000153 || error 10
2607 test_54_part1 0x80000154 || error 11
2608 test_54_part2 0x80000153 || error 12
2609 test_54_part2 0x80000154 || error 13
2611 restore_lustre_params < $p
2614 run_test 54 "rename locking"
2617 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2619 #define OBD_FAIL_MDS_RENAME4 0x156
2620 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2622 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2627 wait $PID1 && error "(2) mv succeeded"
2631 run_test 55a "rename vs unlink target dir"
2635 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2637 #define OBD_FAIL_MDS_RENAME4 0x156
2638 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2640 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2645 wait $PID1 && error "(2) mv succeeded"
2649 run_test 55b "rename vs unlink source dir"
2653 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2655 #define OBD_FAIL_MDS_RENAME4 0x156
2656 do_facet mds1 $LCTL set_param fail_loc=0x156
2658 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2662 # while rename is sleeping, open and remove d3
2663 $MULTIOP $DIR2/d3 D_c &
2669 # while rename is sleeping 2nd time, close d3
2671 wait $PID2 || error "(3) multiop failed"
2673 wait $PID1 && error "(2) mv succeeded"
2677 run_test 55c "rename vs unlink orphan target dir"
2683 #define OBD_FAIL_MDS_RENAME3 0x155
2684 do_facet mds1 $LCTL set_param fail_loc=0x155
2685 mv $DIR/f1 $DIR/$tdir &
2689 # while rename is sleeping, create $tdir, but as a directory
2690 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2692 # link in reverse locking order
2693 ln $DIR2/f1 $DIR2/$tdir/
2695 wait $PID1 && error "(2) mv succeeded"
2698 run_test 55d "rename file vs link"
2701 local MDSVER=$(lustre_build_version $SINGLEMDS)
2702 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2703 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2706 test_mkdir $DIR1/$tdir
2707 file1=$DIR1/$tdir/file
2708 file2=$DIR2/$tdir/file
2710 echo orig > $file2 || error "Could not create $file2"
2711 version=$($LFS data_version $file1)
2714 echo append >> $file2 || error "Could not append to $file2"
2715 version2=$($LFS data_version $file1)
2716 [ "$version" != "$version2" ] ||
2717 error "append did not change data version: $version"
2720 echo overwrite > $file2 || error "Could not overwrite $file2"
2721 version3=$($LFS data_version $file1)
2722 [ "$version2" != "$version3" ] ||
2723 error "overwrite did not change data version: $version2"
2725 # Truncate before EOF
2726 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2727 version4=$($LFS data_version $file1)
2728 [ "$version3" != "$version4" ] ||
2729 error "truncate did not change data version: $version3"
2731 # Truncate after EOF
2732 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2733 version5=$($LFS data_version $file1)
2734 [ "$version4" != "$version5" ] ||
2735 error "truncate did not change data version: $version4"
2737 # Chmod do not change version
2738 chmod 400 $file2 || error "Could not chmod 400 $file2"
2739 version6=$($LFS data_version $file1)
2740 [ "$version5" == "$version6" ] ||
2741 error "chmod should not change data version: $version5 != $version6"
2743 # Chown do not change version
2744 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2745 version7=$($LFS data_version $file1)
2746 [ "$version5" == "$version7" ] ||
2747 error "chown should not change data version: $version5 != $version7"
2749 run_test 60 "Verify data_version behaviour"
2752 local test_dir=$tdir/test_dir
2754 mkdir -p $DIR1/$tdir
2755 if [ $MDSCOUNT -ge 2 ]; then
2757 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2758 error "Create remote directory failed"
2760 mkdir -p $DIR1/$test_dir
2762 cd $DIR2/$test_dir || error "cd directory failed"
2763 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2765 cd $DIR2/$tdir || error "exit directory"
2767 run_test 70a "cd directory && rm directory"
2769 test_70b() { # LU-2781
2771 mkdir -p $DIR1/$tdir
2773 touch $DIR1/$tdir/file
2774 for ((i = 0; i < 32; i++)); do
2775 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2777 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2779 touch $DIR1/$tdir/file
2780 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2781 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2782 rm -rf $DIR1/$tdir/test_dir ||
2783 error "cannot remove directory after rm_entry"
2784 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2786 run_test 70b "remove files after calling rm_entry"
2789 local server_version=$(lustre_version_code $SINGLEMDS)
2791 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2792 skip "Need MDS version at least 2.1.6" && return
2794 # Patch not applied to 2.2 and 2.3 branches
2795 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2796 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2797 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2800 checkfiemap --test ||
2801 { skip "checkfiemap not runnable: $?" && return; }
2802 # write data this way: hole - data - hole - data
2803 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2804 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2806 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2807 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2808 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2810 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2812 checkfiemap $DIR2/$tfile 81920 ||
2813 error "data is not flushed from client"
2814 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2817 # common case of "create file, copy file" on a single node
2818 # should not flush data from ost
2819 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2820 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2822 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2824 checkfiemap $DIR1/$tfile 81920 ||
2826 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2828 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2830 run_test 71a "correct file map just after write operation is finished"
2833 local server_version=$(lustre_version_code $SINGLEMDS)
2835 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2836 skip "Need MDS version at least 2.1.6" && return
2838 # Patch not applied to 2.2 and 2.3 branches
2839 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2840 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2841 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2843 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2845 checkfiemap --test ||
2846 { skip "error $?: checkfiemap failed" && return; }
2848 mkdir -p $DIR1/$tdir
2850 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2851 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2852 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2854 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2855 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2857 run_test 71b "check fiemap support for stripecount > 1"
2860 local p="$TMP/sanityN-$TESTNAME.parameters"
2863 save_lustre_params client "llite.*.xattr_cache" > $p
2864 lctl set_param llite.*.xattr_cache 1 ||
2865 { skip "xattr cache is not supported"; return 0; }
2868 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2869 error "setfattr1 failed"
2870 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2871 error "getfattr1 failed"
2872 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2873 error "setfattr2 failed"
2874 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2875 error "getfattr2 failed"
2877 # check that trusted.link is consistent
2878 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2879 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2880 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2881 echo "$tlink1 $tlink2"
2882 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2886 restore_lustre_params < $p
2889 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2892 local p="$TMP/sanityN-$TESTNAME.parameters"
2893 save_lustre_params client "llite.*.xattr_cache" > $p
2894 lctl set_param llite.*.xattr_cache 1 ||
2895 { skip "xattr cache is not supported"; return 0; }
2898 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2899 error "setfattr1 failed"
2900 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2901 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2902 clear_stats llite.*.stats
2903 # PR lock should be cached by now on both clients
2904 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2905 # 2 hits for getfattr(0)+getfattr(size)
2906 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2907 error "not cached in $DIR1"
2908 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2909 # 4 hits for more getfattr(0)+getfattr(size)
2910 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2911 error "not cached in $DIR2"
2914 restore_lustre_params < $p
2917 run_test 73 "getxattr should not cause xattr lock cancellation"
2920 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2921 skip "Need MDS version at least 2.4.93" && return
2923 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2924 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2925 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2927 run_test 74 "flock deadlock: different mounts =============="
2931 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2932 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2933 cancel_lru_locks osc
2935 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2938 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2939 $LCTL set_param fail_loc=0x31d
2940 stat -c %s $DIR1/$tfile &
2945 # For bad lock error handler we should ASSERT and got kernel panic here
2947 $LCTL set_param fail_loc=0
2949 run_test 75 "osc: upcall after unuse lock==================="
2952 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2953 skip "Need MDS version at least 2.5.53" && return
2955 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2956 local fcount=$((MDSCOUNT * 256))
2961 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2967 test_mkdir $DIR/$tdir
2969 # drop all open locks and close any cached "open" files on the client
2970 cancel_lru_locks mdc
2972 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2973 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2974 local already=${#fid_list[@]}
2975 for (( i = 0; i < $already; i++ )) ; do
2976 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2979 echo -n "opening files: "
2980 ulimit -n $((fcount + 50))
2981 for ((i = 0; i < $fcount; i++)); do
2982 touch $DIR/$tdir/f_$i
2983 local fd=$(free_fd ${fd_list[i]})
2984 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
2989 (( $i % 32 == 0 )) && echo -n "."
2993 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2995 # Possible errors in openfiles FID list.
2996 # 1. Missing FIDs. Check 1
2997 # 2. Extra FIDs. Check 1
2998 # 3. Duplicated FID. Check 2
2999 # 4. Invalid FIDs. Check 2
3000 # 5. Valid FID, points to some other file. Check 3
3003 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3004 error "${#fid_list[@]} != $fcount (+$already old) open files"
3006 echo -n "closing files: "
3007 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3008 local close_cmd="exec ${fd_list[fd]}<&-"
3010 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3012 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3013 echo "skip old open file $filename"
3015 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3019 rm --interactive=no $filename
3021 error "Nonexisting fid ${fid_list[fid]} listed."
3022 (( $fd % 32 == 0 )) && echo -n "."
3027 ls_op=$(ls $DIR2/$tdir | wc -l)
3029 error "Some openfiles are missing in lproc output"
3033 run_test 76 "Verify MDT open_files listing"
3037 local dir=$DIR/$tdir
3040 mkdir $dir || error "mkdir $dir failed"
3041 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3044 do_nodes $CLIENTS $myRUNAS \
3045 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3046 error "dd at 0 on client failed (1)"
3048 for ((i = 0; i < $n; i++)); do
3049 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3050 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3051 error "dd at ${i}MB on client failed (2)" &
3054 do_nodes $CLIENTS sync;
3055 cancel_lru_locks osc
3057 for ((i = 0; i < $n; i++)); do
3058 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3059 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3060 error "dd at ${i}MB on client failed (3)" &
3063 cancel_lru_locks osc
3065 for ((i = 0; i < $n; i++)); do
3069 rm -rf $dir || error "rm -rf $dir failed"
3072 test_77a() { #LU-3266
3073 oss=$(comma_list $(osts_nodes))
3074 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
3079 run_test 77a "check FIFO NRS policy"
3081 test_77b() { #LU-3266
3082 oss=$(comma_list $(osts_nodes))
3084 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3085 ost.OSS.*.nrs_crrn_quantum=1
3087 echo "policy: crr-n, crrn_quantum 1"
3090 do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
3092 echo "policy: crr-n, crrn_quantum 64"
3096 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3099 run_test 77b "check CRR-N NRS policy"
3104 oss=$(comma_list $(osts_nodes))
3106 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3107 ost.OSS.*.nrs_"$policy"_quantum=1 \
3108 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3109 ost.OSS.*.nrs_"$policy"_supported="reads"
3111 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
3114 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
3115 ost.OSS.*.nrs_${policy}_quantum=64
3117 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
3120 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3121 ost.OSS.*.nrs_${policy}_offset_type="logical"
3122 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3126 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3130 test_77c() { #LU-3266
3134 run_test 77c "check ORR NRS policy"
3136 test_77d() { #LU-3266
3140 run_test 77d "check TRR nrs policy"
3147 do_facet $facet lctl set_param \
3148 ost.OSS.ost_io.nrs_tbf_rule="$*"
3150 error "failed to run operate '$*' on TBF rules"
3153 cleanup_tbf_verify()
3157 echo "cleanup_tbf $DIR/$tdir"
3160 wait_delete_completed
3165 local dir=$DIR/$tdir
3166 local client1=${CLIENT1:-$(hostname)}
3169 mkdir $dir || error "mkdir $dir failed"
3170 $LFS setstripe -c 1 $dir || error "setstripe to $dir failed"
3173 trap cleanup_tbf_verify EXIT
3174 echo "Limited write rate: $1, read rate: $2"
3175 echo "Verify the write rate is under TBF control"
3176 local runtime=$(do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3177 bs=1M count=100 oflag=direct 2>&1 | awk '/bytes/ {print $6}')
3178 local rate=$(bc <<< "scale=6; 100 / $runtime")
3179 echo "Write runtime is $runtime s, speed is $rate IOPS"
3181 # verify the write rate does not exceed 110% of TBF limited rate
3182 [ $(bc <<< "$rate < 1.1 * $1") -eq 1 ] ||
3183 error "The write rate ($rate) exceeds 110% of preset rate ($1)"
3185 cancel_lru_locks osc
3187 echo "Verify the read rate is under TBF control"
3188 runtime=$(do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3189 bs=1M count=100 iflag=direct 2>&1 | awk '/bytes/ {print $6}')
3190 rate=$(bc <<< "scale=6; 100 / $runtime")
3191 echo "Read runtime is $runtime s, speed is $rate IOPS"
3193 # verify the read rate does not exceed 110% of TBF limited rate
3194 [ $(bc <<< "$rate < 1.1 * $2") -eq 1 ] ||
3195 error "The read rate ($rate) exceeds 110% of preset rate ($2)"
3197 cancel_lru_locks osc
3198 cleanup_tbf_verify || error "rm -rf $dir failed"
3202 local server_version=$(lustre_version_code ost1)
3203 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3204 { skip "Need server version newer than 2.7.57"; return 0; }
3206 oss=$(comma_list $(osts_nodes))
3208 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3209 [ $? -ne 0 ] && error "failed to set TBF policy"
3213 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3218 # Only operate rules on ost1 since OSTs might run on the same OSS
3220 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3221 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3222 local client_nids=$(nids_list $address "\\")
3223 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3224 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3228 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3229 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3230 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3234 tbf_rule_operate ost1 "stop\ localhost"
3235 tbf_rule_operate ost1 "stop\ clients"
3236 tbf_rule_operate ost1 "stop\ others"
3239 # Cleanup the TBF policy
3240 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3241 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3245 run_test 77e "check TBF NID nrs policy"
3248 local server_version=$(lustre_version_code ost1)
3249 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3250 { skip "Need server version newer than 2.7.57"; return 0; }
3252 oss=$(comma_list $(osts_nodes))
3254 # Configure jobid_var
3255 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3256 if [ $saved_jobid_var != procname_uid ]; then
3257 set_conf_param_and_check client \
3258 "$LCTL get_param -n jobid_var" \
3259 "$FSNAME.sys.jobid_var" procname_uid
3262 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3263 [ $? -ne 0 ] && error "failed to set TBF policy"
3267 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3272 # Only operate rules on ost1 since OSTs might run on the same OSS
3274 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3275 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3276 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3277 nrs_write_read "$RUNAS"
3280 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3281 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3282 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3283 nrs_write_read "$RUNAS"
3286 tbf_rule_operate ost1 "stop\ runas"
3287 tbf_rule_operate ost1 "stop\ iozone_runas"
3288 tbf_rule_operate ost1 "stop\ dd_runas"
3289 nrs_write_read "$RUNAS"
3291 # Cleanup the TBF policy
3292 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3293 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3294 nrs_write_read "$RUNAS"
3296 local current_jobid_var=$($LCTL get_param -n jobid_var)
3297 if [ $saved_jobid_var != $current_jobid_var ]; then
3298 set_conf_param_and_check client \
3299 "$LCTL get_param -n jobid_var" \
3300 "$FSNAME.sys.jobid_var" $saved_jobid_var
3304 run_test 77f "check TBF JobID nrs policy"
3307 local server_version=$(lustre_version_code ost1)
3308 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3309 { skip "Need server version newer than 2.7.57"; return 0; }
3311 oss=$(comma_list $(osts_nodes))
3313 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3314 [ $? -ne 0 ] && error "failed to set TBF policy"
3316 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3317 [ $? -ne 0 ] && error "failed to set TBF policy"
3321 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3326 # Add a rule that only valid for Jobid TBF. If direct change between
3327 # TBF types is not supported, this operation will fail.
3328 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3330 # Cleanup the TBF policy
3331 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3332 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3335 run_test 77g "Change TBF type directly"
3338 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3339 { skip "Need OST version at least 2.8.55"; return 0; }
3341 local old_policy=$(do_facet ost1 \
3342 lctl get_param ost.OSS.ost_io.nrs_policies)
3345 do_facet ost1 lctl set_param \
3346 ost.OSS.ost_io.nrs_policies="abc"
3347 [ $? -eq 0 ] && error "should return error"
3349 do_facet ost1 lctl set_param \
3350 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3351 [ $? -eq 0 ] && error "should return error"
3353 do_facet ost1 lctl set_param \
3354 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3355 [ $? -eq 0 ] && error "should return error"
3357 do_facet ost1 lctl set_param \
3358 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3359 [ $? -eq 0 ] && error "should return error"
3361 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3362 [ $? -eq 0 ] || error "shouldn't LBUG"
3364 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3368 run_test 77h "Wrong policy name should report error, not LBUG"
3374 local error_message=$3
3376 for rule in $expected; do
3377 rule_number=$((rule_number + 1))
3379 local stop_line=$(($rule_number + 3))
3380 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3382 local output=$(do_facet $facet lctl get_param \
3383 ost.OSS.ost_io.nrs_tbf_rule |
3387 if [ "$output" != "$expected" ]; then
3388 error "$error_message, expected '$expected', got '$output'"
3393 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3394 { skip "Need OST version at least 2.8.55"; return 0; }
3396 for i in $(seq 1 $OSTCOUNT)
3398 do_facet ost"$i" lctl set_param \
3399 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3401 error "failed to set TBF policy"
3404 tbf_rule_check ost1 "default" "error before inserting any rule"
3406 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3407 tbf_rule_check ost1 "before default" \
3408 "error when inserting rule 'before'"
3410 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3411 tbf_rule_check ost1 "before after default" \
3412 "error when inserting rule 'after'"
3414 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3415 tbf_rule_check ost1 "before target after default" \
3416 "error when inserting rule 'target'"
3418 echo "Move before itself"
3419 tbf_rule_operate ost1 "change\ target\ rank=target"
3420 tbf_rule_check ost1 "before target after default" \
3421 "error when moving before itself"
3423 echo "Move to higher rank"
3424 tbf_rule_operate ost1 "change\ target\ rank=before"
3425 tbf_rule_check ost1 "target before after default" \
3426 "error when moving to higher rank"
3428 echo "Move to lower rank"
3429 tbf_rule_operate ost1 "change\ target\ rank=after"
3430 tbf_rule_check ost1 "before target after default" \
3431 "error when moving to lower rank"
3433 echo "Move before default"
3434 tbf_rule_operate ost1 "change\ target\ rank=default"
3435 tbf_rule_check ost1 "before after target default" \
3436 error "error when moving before default"
3438 # Cleanup the TBF policy
3439 do_nodes $(comma_list $(osts_nodes)) \
3440 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3443 run_test 77i "Change rank of TBF rule"
3448 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.60) ]; then
3453 do_nodes $(comma_list $(osts_nodes)) \
3454 lctl set_param jobid_var=procname_uid \
3455 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3456 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3457 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3458 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3463 do_nodes $(comma_list $(osts_nodes)) \
3464 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3465 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3466 ost.OSS.ost_io.nrs_policies="fifo"
3468 # sleep 3 seconds to wait the tbf policy stop completely,
3469 # or the next test case is possible get -EAGAIN when
3470 # setting the tbf policy
3473 run_test 77j "check TBF-OPCode NRS policy"
3476 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3477 { skip "Need OST version at least 2.9.53"; return 0; }
3479 do_nodes $(comma_list $(osts_nodes)) \
3480 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3481 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3482 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3484 nrs_write_read "$RUNAS"
3485 tbf_verify 20 10 "$RUNAS"
3487 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3488 local client_nids=$(nids_list $address "\\")
3489 do_nodes $(comma_list $(osts_nodes)) \
3490 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3491 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3492 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3493 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3498 do_nodes $(comma_list $(osts_nodes)) \
3499 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3500 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3501 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3503 nrs_write_read "$RUNAS"
3504 tbf_verify 20 20 "$RUNAS"
3506 do_nodes $(comma_list $(osts_nodes)) \
3507 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3508 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3509 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3511 nrs_write_read "$RUNAS"
3512 # with parameter "RUNAS", it will match the latest rule
3513 # "ext_b" first, so the limited write rate is 10.
3514 tbf_verify 10 10 "$RUNAS"
3517 do_nodes $(comma_list $(osts_nodes)) \
3518 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3519 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3520 ost.OSS.ost_io.nrs_policies="fifo"
3524 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3527 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3528 skip "Need OST version at least 2.9.54"
3532 local dir=$DIR/$tdir
3534 mkdir $dir || error "mkdir $dir failed"
3535 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3538 local nodes=$(comma_list $(osts_nodes))
3539 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3540 ost.OSS.ost_io.nrs_delay_min=4 \
3541 ost.OSS.ost_io.nrs_delay_max=4 \
3542 ost.OSS.ost_io.nrs_delay_pct=100
3543 [ $? -ne 0 ] && error "Failed to set delay policy"
3545 local start=$SECONDS
3546 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3547 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3548 oflag=direct conv=fdatasync ||
3549 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3550 error "dd on client failed (1)"; }
3551 local elapsed=$((SECONDS - start))
3553 # NRS delay doesn't do sub-second timing, so a request enqueued at
3554 # 0.9 seconds can be dequeued at 4.0
3555 [ $elapsed -lt 3 ] &&
3556 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3557 error "Single 1M write should take at least 3 seconds"; }
3560 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3561 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3562 oflag=direct conv=fdatasync ||
3563 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3564 error "dd on client failed (2)"; }
3565 elapsed=$((SECONDS - start))
3567 [ $elapsed -lt 30 ] &&
3568 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3569 error "Ten 1M writes should take at least 30 seconds"; }
3571 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3572 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3576 run_test 77l "check NRS Delay slows write RPC processing"
3578 test_78() { #LU-6673
3579 local server_version=$(lustre_version_code ost1)
3580 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3581 { skip "Need server version newer than 2.7.57"; return 0; }
3585 oss=$(comma_list $(osts_nodes))
3586 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3587 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3589 # Valid return codes are:
3590 # 0: Tuning succeeded
3591 # ENODEV: Policy is still stopped
3592 # EAGAIN: Policy is being initialized
3593 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3594 error "Expected set_param to return 0|ENODEV|EAGAIN"
3596 # Cleanup the ORR policy
3597 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3598 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3601 run_test 78 "Enable policy and specify tunings right away"
3604 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3605 test_mkdir $DIR/$tdir
3607 # Prevent interference from layout intent RPCs due to
3608 # asynchronous writeback. These will be tested in 130c below.
3609 do_nodes ${CLIENTS:-$HOSTNAME} sync
3611 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3612 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3614 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3615 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3616 local facet=mds$((mdtidx + 1))
3618 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3619 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3623 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3624 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3629 run_test 79 "xattr: intent error"
3632 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3639 mkdir -p $DIR1/$tdir/dir
3640 createmany -o $DIR1/$tdir/dir/f 10 ||
3641 error "create files under remote dir failed $i"
3643 cp /etc/passwd $DIR1/$tdir/$tfile
3645 #migrate open file should fails
3646 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3648 # give multiop a chance to open
3651 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3652 error "migrate open files should failed with open files"
3656 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3657 error "migrate remote dir error"
3659 echo "Finish migration, then checking.."
3660 for file in $(find $DIR1/$tdir); do
3661 mdt_index=$($LFS getstripe -M $file)
3662 [ $mdt_index == $MDTIDX ] ||
3663 error "$file is not on MDT${MDTIDX}"
3666 diff /etc/passwd $DIR1/$tdir/$tfile ||
3667 error "file different after migration"
3669 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3671 run_test 80a "migrate directory when some children is being opened"
3675 kill -9 $migrate_pid
3679 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3680 local migrate_dir1=$DIR1/$tdir/migrate_dir
3681 local migrate_dir2=$DIR2/$tdir/migrate_dir
3682 local migrate_run=$LUSTRE/tests/migrate.sh
3690 trap cleanup_80b EXIT
3691 #prepare migrate directory
3692 mkdir -p $migrate_dir1
3693 for F in {1,2,3,4,5}; do
3694 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3695 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3698 #migrate the directories among MDTs
3701 mdt_idx=$((RANDOM % MDSCOUNT))
3702 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3704 [ $rc -ne 0 -o $rc -ne 16 ] || break
3709 echo "start migration thread $migrate_pid"
3710 #Access the files at the same time
3711 start_time=$(date +%s)
3712 echo "accessing the migrating directory for 5 minutes..."
3714 ls $migrate_dir2 > /dev/null || {
3715 echo "read dir fails"
3718 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3719 echo "access file1 fails"
3723 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3724 echo "access file2/3 fails"
3728 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3729 echo "access file4 fails"
3733 stat $migrate_dir2/file5 > /dev/null || {
3734 echo "stat file5 fails"
3738 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3739 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3740 echo "touch file failed with $rc1"
3744 if [ -e $migrate_dir2/source_file ]; then
3745 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3746 &>/dev/null || rc1=$?
3747 if [ -e $migrate_dir2/link_file ]; then
3748 rm -rf $migrate_dir2/link_file
3751 mrename $migrate_dir2/source_file \
3752 $migrate_dir2/target_file &>/dev/null || rc1=$?
3753 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3754 echo "rename failed with $rc1"
3758 if [ -e $migrate_dir2/target_file ]; then
3759 rm -rf $migrate_dir2/target_file &>/dev/null ||
3762 rm -rf $migrate_dir2/source_file &>/dev/null ||
3765 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3766 echo "unlink failed with $rc1"
3771 end_time=$(date +%s)
3772 duration=$((end_time - start_time))
3773 if [ $((duration % 10)) -eq 0 ]; then
3774 if [ $show_time -eq 1 ]; then
3775 echo "...$duration seconds"
3782 kill -0 $migrate_pid || {
3783 echo "migration stopped 1"
3787 [ $duration -ge 300 ] && break
3790 #check migration are still there
3791 kill -0 $migrate_pid || error "migration stopped 2"
3794 run_test 80b "Accessing directory during migration"
3797 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3801 mkdir -p $DIR1/$tdir
3803 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3804 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3807 touch d0/0 || error "create 0 failed"
3808 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3809 stat d0/0 && error "stat mv filed succeed"
3810 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3811 stat d0/0 || error "stat failed"
3813 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3815 if [ $t -ne 3 ]; then
3816 ls -ai $DIR1/$tdir/d0
3817 error "expect 3 get $t"
3822 run_test 81 "rename and stat under striped directory"
3825 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3826 { skip "Need MDS version at least 2.6.92"; return 0; }
3828 # Client 1 creates a file.
3829 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3831 # Client 2 opens the file.
3832 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3834 # Client 1 makes the file an orphan.
3835 rm $DIR1/$tfile || error "rm"
3836 # Client 2 sets EA "user.multiop".
3838 wait $pid2 || error "multiop 2"
3839 # Client 1 gets EA "user.multiop". This used to fail because the EA
3840 # cache refill would get "trusted.link" from mdd_xattr_list() but
3841 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3844 wait $pid1 || error "multiop 1"
3846 run_test 82 "fsetxattr and fgetxattr on orphan files"
3849 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3856 $LFS mkdir -i1 -c2 $tdir
3861 echo "start pid $pid1 to create/unlink striped directory"
3863 # Access the directory at the same time
3867 stat $tdir > /dev/null 2>&1
3871 echo "start pid $pid2 to stat striped directory"
3879 run_test 83 "access striped directory while it is being created/unlinked"
3882 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3887 [ "$SLOW" = "yes" ] && duration=600
3888 # Open/Create under striped directory
3892 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3893 touch $tdir/f{0..3} > /dev/null 2>&1
3897 echo "start pid $pid1 to open/create under striped directory"
3899 # unlink the striped directory at the same time
3903 rm -rf $tdir > /dev/null 2>&1
3907 echo "start pid $pid2 to unlink striped directory"
3916 run_test 90 "open/create and unlink striped directory"
3919 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3924 [ "$SLOW" = "yes" ] && duration=600
3925 # chmod striped directory
3929 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3930 chmod go+w $tdir > /dev/null 2>&1
3934 echo "start pid $pid1 to chmod striped directory"
3936 # unlink the striped directory at the same time
3940 rm -rf $tdir > /dev/null 2>&1
3944 echo "start pid $pid2 to unlink striped directory"
3953 run_test 91 "chmod and unlink striped directory"
3956 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3959 local cmd="exec $fd<$DIR1/$tdir"
3960 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3963 trap "eval $cmd" EXIT
3964 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3965 rmdir ../$tdir || error "rmdir ../$tdir fails"
3967 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3968 $LCTL set_param fail_loc=0x1408
3969 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3970 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3971 error "create remote dir succeeds"
3972 $LCTL set_param fail_loc=0
3976 run_test 92 "create remote directory under orphan directory"
3983 mkdir -p $DIR1/$tfile-1/
3984 mkdir -p $DIR2/$tfile-2/
3985 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
3986 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
3987 do_facet $SINGLEMDS lctl set_param -n \
3988 'lod.lustre-MDT*/qos_threshold_rr' 100
3989 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
3990 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
3992 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
3995 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
3999 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4000 do_facet $SINGLEMDS "lctl set_param -n \
4001 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4003 $GETSTRIPE $DIR1/$tfile-1/file1
4004 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4005 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4006 $GETSTRIPE $DIR2/$tfile-2/file2
4007 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4008 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4009 echo "rc1=$rc1 and rc2=$rc2 "
4010 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4011 error "object allocate on same ost detected"
4013 run_test 93 "alloc_rr should not allocate on same ost"
4017 skip "Reserved for glimpse-ahead" && return
4020 $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4022 lctl set_param -n mdc.*.stats=clear
4023 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4025 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4026 # first stat from server should return size data and save glimpse
4027 local reads=$(lctl get_param -n mdc.*.stats | \
4028 awk '/ldlm_glimpse/ {print $2}')
4029 [ -z $reads ] || error "Unexpected $reads glimpse RPCs"
4030 # second stat to check size is NOT cached on client without IO lock
4031 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4033 local reads=$(lctl get_param -n mdc.*.stats | \
4034 awk '/ldlm_glimpse/ {print $2}')
4035 [ "1" == "$reads" ] || error "Expect 1 glimpse RPCs but got $reads"
4038 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4043 $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4045 lctl set_param -n mdc.*.stats=clear
4046 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4047 cancel_lru_locks mdc
4048 # first stat data from server should have size
4049 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4050 # second stat to check size is cached on client
4051 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4053 local reads=$(lctl get_param -n mdc.*.stats | \
4054 awk '/ldlm_glimpse/ {print $2}')
4055 # both stats should cause no glimpse requests
4056 [ -z $reads ] || error "Unexpected $reads glimpse RPCs"
4059 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4064 $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4066 lctl set_param -n mdc.*.stats=clear
4067 lctl set_param -n osc.*.stats=clear
4068 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4070 # check that size is merged from MDT and OST correctly
4071 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4072 error "Wrong size from stat #1"
4074 local reads=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4075 [ $reads -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4079 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4084 $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4087 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4088 lctl set_param -n mdc.*.stats=clear
4089 $TRUNCATE $DIR2/$tdir/dom 4096
4091 # check that reported size is valid after file grows to OST and
4092 # is truncated back to MDT stripe size
4093 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4094 error "Wrong size from stat #1"
4096 local reads=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4097 [ $reads -eq 0 ] && error "Expect OST glimpse but got none"
4101 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4105 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4106 lctl set_param -n mdc.*.stats=clear
4108 $CHECKSTAT -t file $DIR1/$tfile
4110 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4111 # must discard pages
4112 rm $DIR2/$tfile || error "Unlink fails"
4113 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4114 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4116 run_test 101a "Discard DoM data on unlink"
4119 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4120 touch $DIR1/${tfile}_2
4121 lctl set_param -n mdc.*.stats=clear
4123 $CHECKSTAT -t file $DIR1/$tfile
4125 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4126 # must discard pages
4127 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4128 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4129 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4131 run_test 101b "Discard DoM data on rename"
4134 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4135 lctl set_param -n mdc.*.stats=clear
4137 $CHECKSTAT -t file $DIR1/$tfile
4139 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4141 $MULTIOP $DIR1/$tfile O_c &
4144 rm $DIR2/$tfile > /dev/null || error "Unlink fails"
4145 kill -USR1 $MULTIOP_PID || return 2
4146 wait $MULTIOP_PID || return 3
4147 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4148 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4150 run_test 101c "Discard DoM data on close-unlink"
4152 log "cleanup: ======================================================"
4154 # kill and wait in each test only guarentee script finish, but command in script
4155 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4156 # otherwise umount below will fail
4157 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4162 check_and_cleanup_lustre