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_30() { #b=11110, LU-2523
687 test_mkdir $DIR1/$tdir
688 cp -f /bin/bash $DIR1/$tdir/bash
689 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
690 $DIR1/$tdir/bash -c 'sleep 2;
691 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
695 run_test 30 "recreate file race"
698 test_mkdir $DIR1/$tdir
699 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
700 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
701 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
702 lctl set_param fail_loc=0x314
703 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
704 awk 'BEGIN { FS="+" } /in/ {print $1}')
705 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
707 run_test 31a "voluntary cancel / blocking ast race=============="
710 remote_ost || { skip "local OST" && return 0; }
711 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
713 # make sure there is no local locks due to destroy
714 wait_mds_ost_sync || error "wait_mds_ost_sync()"
715 wait_delete_completed || error "wait_delete_completed()"
717 test_mkdir $DIR1/$tdir
718 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
719 cp /etc/hosts $DIR/$tdir/$tfile
720 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
721 lctl set_param fail_loc=0x314
722 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
723 do_facet ost1 lctl set_param fail_loc=0x316
725 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
726 lctl set_param fail_loc=0
727 do_facet ost1 lctl set_param fail_loc=0
728 # cleanup: reconnect the client back
731 run_test 31b "voluntary OST cancel / blocking ast race=============="
733 # enable/disable lockless truncate feature, depending on the arg 0/1
734 enable_lockless_truncate() {
735 lctl set_param -n $OSC.*.lockless_truncate $1
738 test_32a() { # bug 11270
739 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
741 save_lustre_params client "$OSC.*.lockless_truncate" > $p
742 cancel_lru_locks $OSC
743 enable_lockless_truncate 1
745 lfs setstripe -c -1 $DIR1/$tfile
746 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
748 clear_stats $OSC.*.${OSC}_stats
750 log "checking cached lockless truncate"
751 $TRUNCATE $DIR1/$tfile 8000000
752 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
753 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
754 error "cached truncate isn't lockless"
756 log "checking not cached lockless truncate"
757 $TRUNCATE $DIR2/$tfile 5000000
758 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
759 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
760 error "not cached truncate isn't lockless"
762 log "disabled lockless truncate"
763 enable_lockless_truncate 0
764 clear_stats $OSC.*.${OSC}_stats
765 $TRUNCATE $DIR2/$tfile 3000000
766 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
767 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
768 error "lockless truncate disabling failed"
770 # restore lockless_truncate default values
771 restore_lustre_params < $p
774 run_test 32a "lockless truncate"
776 test_32b() { # bug 11270
777 remote_ost_nodsh && skip "remote OST with nodsh" && return
780 local facets=$(get_facets OST)
781 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
783 save_lustre_params client "osc.*.contention_seconds" > $p
784 save_lustre_params $facets \
785 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
786 save_lustre_params $facets \
787 "ldlm.namespaces.filter-*.contended_locks" >> $p
788 save_lustre_params $facets \
789 "ldlm.namespaces.filter-*.contention_seconds" >> $p
790 clear_stats $OSC.*.${OSC}_stats
792 # agressive lockless i/o settings
793 do_nodes $(comma_list $(osts_nodes)) \
794 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
795 ldlm.namespaces.filter-*.contended_locks=0 \
796 ldlm.namespaces.filter-*.contention_seconds=60"
797 lctl set_param -n $OSC.*.contention_seconds=60
799 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
801 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
804 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
805 error "lockless i/o was not triggered"
806 # disable lockless i/o (it is disabled by default)
807 do_nodes $(comma_list $(osts_nodes)) \
808 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
809 ldlm.namespaces.filter-*.contended_locks=32 \
810 ldlm.namespaces.filter-*.contention_seconds=0"
811 # set contention_seconds to 0 at client too, otherwise Lustre still
812 # remembers lock contention
813 lctl set_param -n $OSC.*.contention_seconds=0
814 clear_stats $OSC.*.${OSC}_stats
816 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
818 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
821 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
822 error "lockless i/o works when disabled"
824 restore_lustre_params <$p
827 run_test 32b "lockless i/o"
831 local mdts=$(get_facets MDS)
836 for mds in ${mdts//,/ }; do
838 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
839 xargs readlink -f" ))
840 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
843 stat=$(( stat + val))
848 # commit on sharing tests
850 remote_mds_nodsh && skip "remote MDS with nodsh" && return
852 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
853 [ $CLIENTCOUNT -lt 2 ] &&
854 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
856 local nfiles=${TEST33_NFILES:-10000}
857 local param_file=$TMP/$tfile-params
858 local fstype=$(facet_fstype $SINGLEMDS)
860 save_lustre_params $(get_facets MDS) \
861 "mdt.*.commit_on_sharing" > $param_file
869 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
873 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
875 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
876 echo "=== START createmany old: $jbdold transaction"
877 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")
878 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
879 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
880 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
881 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
882 avgtime=$(( avgtime + elapsed ))
884 eval cos${COS}_jbd=$((avgjbd / 3))
885 eval cos${COS}_time=$((avgtime / 3))
888 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
889 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
890 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
891 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
893 restore_lustre_params < $param_file
897 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
899 # commit on sharing tests
901 remote_mds_nodsh && skip "remote MDS with nodsh" && return
903 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
904 [ $CLIENTCOUNT -ge 2 ] ||
905 { skip "Need two or more clients, have $CLIENTCOUNT" &&
907 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
909 local nfiles=${TEST33_NFILES:-10000}
910 local param_file=$TMP/$tfile-params
912 save_lustre_params $(get_facets MDS) \
913 "mdt.*.commit_on_sharing" > $param_file
922 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
926 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
927 $DIR1/$tdir-\\\$(hostname)-$i"
929 jbdold=$(print_jbd_stat)
930 echo "=== START createmany old: $jbdold transaction"
931 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
932 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
933 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
935 jbdnew=$(print_jbd_stat)
936 jbd=$(( jbdnew - jbdold ))
937 echo "=== END createmany new: $jbdnew transaction : \
938 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
939 avgjbd=$(( avgjbd + jbd ))
940 avgtime=$(( avgtime + elapsed ))
942 eval cos${COS}_jbd=$((avgjbd / 3))
943 eval cos${COS}_time=$((avgtime / 3))
946 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
947 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
948 [ "$cos0_jbd" != 0 ] &&
949 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
950 [ "$cos0_time" != 0 ] &&
951 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
953 restore_lustre_params < $param_file
957 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
960 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
961 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
962 skip "DNE CoS not supported" && return
967 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
968 $LFS mkdir -i 1 $DIR/$tdir/d1
969 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
971 local sync_count=$(do_facet mds1 \
972 "lctl get_param -n mdt.*MDT0000.sync_count")
973 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
975 $LFS mkdir -i 1 $DIR/$tdir/d3
976 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
977 # during sleep remote mkdir should have been committed and canceled
978 # remote lock spontaneously, which shouldn't trigger sync
981 local sync_count=$(do_facet mds1 \
982 "lctl get_param -n mdt.*MDT0000.sync_count")
983 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
985 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
988 local nodes=$(comma_list $(mdts_nodes))
989 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
991 local async_commit_count=$(do_nodes $nodes \
992 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
993 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
1000 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1001 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1002 skip "DNE CoS not supported" && return
1005 # remote directory create
1007 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1008 # remote directory unlink
1009 $LFS mkdir -i 1 $DIR/$tdir
1010 ops_do_cos "rmdir $DIR/$tdir"
1011 # striped directory create
1013 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1014 # striped directory setattr
1015 $LFS mkdir -c 2 $DIR/$tdir
1017 ops_do_cos "chmod 713 $DIR/$tdir"
1018 # striped directory unlink
1019 $LFS mkdir -c 2 $DIR/$tdir
1021 ops_do_cos "rmdir $DIR/$tdir"
1023 $LFS mkdir -c 2 $DIR/$tdir
1024 $LFS mkdir -i 0 $DIR/$tdir/d1
1025 $LFS mkdir -i 1 $DIR/$tdir/d2
1026 touch $DIR/$tdir/d1/tgt
1027 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1029 $LFS mkdir -c 2 $DIR/$tdir
1030 $LFS mkdir -i 0 $DIR/$tdir/d1
1031 $LFS mkdir -i 1 $DIR/$tdir/d2
1032 touch $DIR/$tdir/d1/src
1033 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1035 $LFS mkdir -i 0 $DIR/$tdir
1036 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1039 run_test 33d "DNE distributed operation should trigger COS"
1042 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1043 [ $CLIENTCOUNT -ge 2 ] ||
1044 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1046 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1047 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1048 skip "DNE CoS not supported" && return
1050 local client2=${CLIENT2:-$(hostname)}
1054 local nodes=$(comma_list $(mdts_nodes))
1055 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1057 $LFS mkdir -c 2 $DIR/$tdir
1058 mkdir $DIR/$tdir/subdir
1059 echo abc > $DIR/$tdir/$tfile
1060 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1061 do_node $client2 touch $DIR/$tdir/subdir
1063 local async_commit_count=$(do_nodes $nodes \
1064 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1065 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1069 run_test 33e "DNE local operation shouldn't trigger COS"
1071 # End commit on sharing tests
1073 get_ost_lock_timeouts() {
1074 local nodes=${1:-$(comma_list $(osts_nodes))}
1076 local locks=$(do_nodes $nodes \
1077 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1085 do_nodes $(comma_list $(osts_nodes)) \
1086 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1087 for i in $(seq $OSTCOUNT); do
1088 wait_osc_import_state client ost$i FULL
1093 remote_ost_nodsh && skip "remote OST with nodsh" && return
1097 trap cleanup_34 EXIT RETURN
1098 for OPER in notimeout timeout ; do
1099 rm $DIR1/$tfile 2>/dev/null
1100 lock_in=$(get_ost_lock_timeouts)
1101 if [ $OPER == "timeout" ] ; then
1102 for j in `seq $OSTCOUNT`; do
1103 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1104 do_facet ost$j lctl set_param fail_loc=0x511
1106 echo lock should expire
1108 for j in `seq $OSTCOUNT`; do
1109 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1110 do_facet ost$j lctl set_param fail_loc=0x512
1112 echo lock should not expire
1114 echo writing on client1
1115 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1117 echo reading on client2
1118 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1119 # wait for a lock timeout
1121 lock_out=$(get_ost_lock_timeouts)
1122 if [ $OPER == "timeout" ] ; then
1123 if [ $lock_in == $lock_out ]; then
1124 error "no lock timeout happened"
1129 if [ $lock_in != $lock_out ]; then
1130 error "lock timeout happened"
1138 run_test 34 "no lock timeout under IO"
1140 test_35() { # bug 17645
1143 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1144 awk '/generation/{print $2}')
1146 generation[count]=$g
1150 test_mkdir $MOUNT1/$tdir
1151 cancel_lru_locks mdc
1153 # Let's initiate -EINTR situation by setting fail_loc and take
1154 # write lock on same file from same client. This will not cause
1155 # bl_ast yet as lock is already in local cache.
1156 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1157 do_facet client "lctl set_param fail_loc=0x80000317"
1158 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1159 let timeout=timeout*3
1161 while test $nr -lt 10; do
1162 log "Race attempt $nr"
1163 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1164 awk '/ldlm_bl_callback/ { print $2 }')
1165 test "x$blk1" = "x" && blk1=0
1166 createmany -o $MOUNT2/$tdir/a 4000 &
1170 # Let's make conflict and bl_ast
1171 ls -la $MOUNT1/$tdir > /dev/null &
1174 log "Wait for $pid1 $pid2 for $timeout sec..."
1176 kill -9 $pid1 $pid2 > /dev/null 2>&1
1178 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1179 awk '/ldlm_bl_callback/ { print $2 }')
1180 test "x$blk2" = "x" && blk2=0
1181 test $blk2 -gt $blk1 && break
1182 rm -fr $MOUNT1/$tdir
1183 cancel_lru_locks mdc
1186 do_facet client "lctl set_param fail_loc=0x0"
1187 df -h $MOUNT1 $MOUNT2
1189 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1190 awk '/generation/{print $2}')
1192 if ! test "$g" -eq "${generation[count]}"; then
1193 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1195 for imp in $list; do
1196 if [ $c = $count ]; then
1201 imp=$(echo "$imp" | awk -F"." '{print $2}')
1202 error "Eviction happened on import $imp"
1207 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1209 test_36() { #bug 16417
1214 test_mkdir $DIR1/$tdir
1215 $LFS setstripe -c -1 $DIR1/$tdir
1218 let SIZE_B=SIZE*1024*1024
1219 sync; sleep 2; sync # wait for delete thread
1220 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1221 wait_destroy_complete || error "wait_destroy_complete failed"
1223 while [ $i -le 10 ]; do
1224 lctl mark "start test - cycle ($i)"
1225 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1226 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1227 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1228 sync # sync data from client cache
1229 sync_all_data # sync data from server cache (delayed allocation)
1231 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1232 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1234 rm -f $DIR1/$tdir/$tfile
1235 kill -USR1 $read_pid
1237 sync; sleep 2; sync # Ensure new statfs
1238 wait_delete_completed
1239 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1240 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1242 # this free space! not used
1243 (( $after_dd <= $after)) ||
1244 error "space leaked after_dd:$after_dd > after:$after"
1248 run_test 36 "handle ESTALE/open-unlink correctly"
1250 test_37() { # bug 18695
1251 test_mkdir $DIR1/$tdir
1252 multiop_bg_pause $DIR1/$tdir D_c || return 1
1254 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1255 createmany -m $DIR2/$tdir/f 10000
1256 # set mtime/atime backward
1257 touch -t 198001010000 $DIR2/$tdir
1258 kill -USR1 $MULTIPID
1259 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1260 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1263 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1265 # this should be set to past
1266 TEST_39_MTIME=`date -d "1 year ago" +%s`
1270 local client1=${CLIENT1:-`hostname`}
1271 local client2=${CLIENT2:-`hostname`}
1273 do_node $client1 "touch $DIR1/$tfile"
1275 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1276 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1277 [ "$mtime1" = $TEST_39_MTIME ] || \
1278 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1280 local d1=`do_node $client1 date +%s`
1281 do_node $client1 'echo hello >> '$DIR1/$tfile
1282 local d2=`do_node $client1 date +%s`
1284 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1285 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1286 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1288 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1290 for (( i=0; i < 2; i++ )) ; do
1291 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1292 [ "$mtime2" = "$mtime3" ] || \
1293 error "mtime ($mtime2) changed (to $mtime3) on rename"
1295 cancel_lru_locks osc
1296 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1299 run_test 39a "test from 11063 =================================="
1302 local client1=${CLIENT1:-`hostname`}
1303 local client2=${CLIENT2:-`hostname`}
1307 local mtime1=`stat -c %Y $DIR1/$tfile`
1308 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1311 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1313 for (( i=0; i < 2; i++ )) ; do
1314 local mtime3=`stat -c %Y $DIR1/$tfile`
1315 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1317 [ "$mtime3" = "$mtime4" ] || \
1318 error "different mtime on clients: $mtime3, $mtime4"
1319 [ "$mtime3" = $TEST_39_MTIME ] || \
1320 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1322 cancel_lru_locks osc
1323 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1326 run_test 39b "11063 problem 1 =================================="
1329 local client1=${CLIENT1:-`hostname`}
1330 local client2=${CLIENT2:-`hostname`}
1332 echo hello > $DIR1/$tfile
1334 local mtime1=`stat -c %Y $DIR1/$tfile`
1335 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1336 [ "$mtime1" = "$mtime2" ] || \
1337 error "create: different mtime on clients: $mtime1, $mtime2"
1340 $TRUNCATE $DIR1/$tfile 1
1342 for (( i=0; i < 2; i++ )) ; do
1343 local mtime3=`stat -c %Y $DIR1/$tfile`
1344 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1346 [ "$mtime3" = "$mtime4" ] || \
1347 error "different mtime on clients: $mtime3, $mtime4"
1348 [ "$mtime3" -gt $mtime2 ] || \
1349 error "truncate did not update mtime: $mtime2, $mtime3"
1351 cancel_lru_locks osc
1352 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1355 run_test 39c "check truncate mtime update ======================"
1357 test_39d() { # LU-7310
1359 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1361 local mtime1=$(stat -c %Y $DIR2/$tfile)
1362 [ "$mtime1" = $TEST_39_MTIME ] ||
1363 error "mtime: $mtime1, should be $TEST_39_MTIME"
1366 # define OBD_FAIL_OSC_NO_GRANT 0x411
1367 $LCTL set_param fail_loc=0x411
1369 local d1=$(date +%s)
1370 echo hello >> $DIR1/$tfile
1371 local d2=$(date +%s)
1373 $LCTL set_param fail_loc=0
1375 cancel_lru_locks $OSC
1377 local mtime2=$(stat -c %Y $DIR2/$tfile)
1378 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1379 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1381 run_test 39d "sync write should update mtime"
1383 # check that pid exists hence second operation wasn't blocked by first one
1384 # if it is so then there is no conflict, return 0
1385 # else second operation is conflicting with first one, return 1
1386 check_pdo_conflict() {
1389 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1390 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1400 # test 40: check non-blocking operations
1402 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1403 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1404 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1406 mkdir $DIR1/$tfile &
1409 touch $DIR2/$tfile-2
1410 check_pdo_conflict $PID1 || error "create is blocked"
1411 mkdir $DIR2/$tfile-3
1412 check_pdo_conflict $PID1 || error "mkdir is blocked"
1413 link $DIR2/$tfile-2 $DIR2/$tfile-4
1414 check_pdo_conflict $PID1 || error "link is blocked"
1415 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1416 check_pdo_conflict $PID1 || error "rename is blocked"
1417 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1418 check_pdo_conflict $PID1 || error "getattr is blocked"
1419 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1420 rmdir $DIR2/$tfile-3
1421 check_pdo_conflict $PID1 || error "unlink is blocked"
1423 # all operations above shouldn't wait the first one
1424 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1429 run_test 40a "pdirops: create vs others =============="
1432 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1433 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1434 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1435 touch $DIR1/$tfile &
1439 touch $DIR2/$tfile-2
1440 check_pdo_conflict $PID1 || error "create is blocked"
1441 mkdir $DIR2/$tfile-3
1442 check_pdo_conflict $PID1 || error "mkdir is blocked"
1443 link $DIR2/$tfile-2 $DIR2/$tfile-4
1444 check_pdo_conflict $PID1 || error "link is blocked"
1445 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1446 check_pdo_conflict $PID1 || error "rename is blocked"
1447 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1448 check_pdo_conflict $PID1 || error "getattr is blocked"
1449 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1450 rmdir $DIR2/$tfile-3
1451 check_pdo_conflict $PID1 || error "unlink is blocked"
1452 # all operations above shouldn't wait the first one
1454 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1459 run_test 40b "pdirops: open|create and others =============="
1462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1464 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1465 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1466 link $DIR1/$tfile $DIR1/$tfile-0 &
1470 touch $DIR2/$tfile-2
1471 check_pdo_conflict $PID1 || error "create is blocked"
1472 mkdir $DIR2/$tfile-3
1473 check_pdo_conflict $PID1 || error "mkdir is blocked"
1474 link $DIR2/$tfile-2 $DIR2/$tfile-4
1475 check_pdo_conflict $PID1 || error "link is blocked"
1476 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1477 check_pdo_conflict $PID1 || error "rename is blocked"
1478 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1479 check_pdo_conflict $PID1 || error "getattr is blocked"
1480 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1481 rmdir $DIR2/$tfile-3
1482 check_pdo_conflict $PID1 || error "unlink is blocked"
1484 # all operations above shouldn't wait the first one
1485 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1490 run_test 40c "pdirops: link and others =============="
1493 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1495 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1496 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1501 touch $DIR2/$tfile-2
1502 check_pdo_conflict $PID1 || error "create is blocked"
1503 mkdir $DIR2/$tfile-3
1504 check_pdo_conflict $PID1 || error "mkdir is blocked"
1505 link $DIR2/$tfile-2 $DIR2/$tfile-4
1506 check_pdo_conflict $PID1 || error "link is blocked"
1507 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1508 check_pdo_conflict $PID1 || error "rename is blocked"
1509 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1510 check_pdo_conflict $PID1 || error "getattr is blocked"
1511 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1512 rmdir $DIR2/$tfile-3
1513 check_pdo_conflict $PID1 || error "unlink is blocked"
1515 # all operations above shouldn't wait the first one
1516 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1520 run_test 40d "pdirops: unlink and others =============="
1523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1526 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1527 mv $DIR1/$tfile $DIR1/$tfile-0 &
1531 touch $DIR2/$tfile-2
1532 check_pdo_conflict $PID1 || error "create is blocked"
1533 mkdir $DIR2/$tfile-3
1534 check_pdo_conflict $PID1 || error "mkdir is blocked"
1535 link $DIR2/$tfile-2 $DIR2/$tfile-4
1536 check_pdo_conflict $PID1 || error "link is blocked"
1537 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1538 check_pdo_conflict $PID1 || error "getattr is blocked"
1539 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1540 rmdir $DIR2/$tfile-3
1541 check_pdo_conflict $PID1 || error "unlink is blocked"
1543 # all operations above shouldn't wait the first one
1544 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1549 run_test 40e "pdirops: rename and others =============="
1551 # test 41: create blocking operations
1553 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1554 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1555 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1558 mkdir $DIR2/$tfile && error "mkdir must fail"
1559 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1563 run_test 41a "pdirops: create vs mkdir =============="
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 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1572 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1576 run_test 41b "pdirops: create vs create =============="
1579 touch $DIR1/$tfile-2
1580 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1581 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1582 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1585 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1586 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1590 run_test 41c "pdirops: create vs link =============="
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 rm $DIR2/$tfile || error "unlink must succeed"
1599 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1603 run_test 41d "pdirops: create vs unlink =============="
1606 touch $DIR1/$tfile-2
1607 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1608 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1609 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1612 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1613 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1617 run_test 41e "pdirops: create and rename (tgt) =============="
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 $DIR2/$tfile-2 || error "rename must succeed"
1626 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1630 run_test 41f "pdirops: create and rename (src) =============="
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 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1639 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1643 run_test 41g "pdirops: create vs getattr =============="
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 ls -lia $DIR2/ > /dev/null
1652 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1656 run_test 41h "pdirops: create vs readdir =============="
1658 # test 42: unlink and blocking operations
1660 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1661 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1662 mkdir $DIR1/$tfile &
1665 mkdir $DIR2/$tfile && error "mkdir must fail"
1666 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1670 run_test 42a "pdirops: mkdir vs mkdir =============="
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 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1679 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1683 run_test 42b "pdirops: mkdir vs create =============="
1686 touch $DIR1/$tfile-2
1687 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1688 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1689 mkdir $DIR1/$tfile &
1692 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1693 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1697 run_test 42c "pdirops: mkdir vs link =============="
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 rmdir $DIR2/$tfile || error "unlink must succeed"
1706 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1710 run_test 42d "pdirops: mkdir vs unlink =============="
1713 touch $DIR1/$tfile-2
1714 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1715 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1716 mkdir $DIR1/$tfile &
1719 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1720 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1724 run_test 42e "pdirops: mkdir and rename (tgt) =============="
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 $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1733 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1737 run_test 42f "pdirops: mkdir and rename (src) =============="
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 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1746 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1750 run_test 42g "pdirops: mkdir vs getattr =============="
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 ls -lia $DIR2/ > /dev/null
1759 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1763 run_test 42h "pdirops: mkdir vs readdir =============="
1765 # test 43: unlink and blocking operations
1768 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1769 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1773 mkdir $DIR2/$tfile || error "mkdir must succeed"
1774 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1778 run_test 43a "pdirops: unlink vs mkdir =============="
1782 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1783 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1787 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1788 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1792 run_test 43b "pdirops: unlink vs create =============="
1796 touch $DIR1/$tfile-2
1797 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1798 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1802 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1803 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1807 run_test 43c "pdirops: unlink vs link =============="
1811 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1812 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1816 rm $DIR2/$tfile && error "unlink must fail"
1817 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1821 run_test 43d "pdirops: unlink vs unlink =============="
1825 touch $DIR1/$tfile-2
1826 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1827 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1831 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1832 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1836 run_test 43e "pdirops: unlink and rename (tgt) =============="
1840 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1841 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1845 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1846 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1850 run_test 43f "pdirops: unlink and rename (src) =============="
1854 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1855 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1859 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1860 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1864 run_test 43g "pdirops: unlink vs getattr =============="
1868 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1869 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1873 ls -lia $DIR2/ > /dev/null
1874 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1878 run_test 43h "pdirops: unlink vs readdir =============="
1881 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1883 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1884 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1888 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1889 check_pdo_conflict $PID1 &&
1890 { wait $PID1; error "remote mkdir isn't blocked"; }
1894 run_test 43i "pdirops: unlink vs remote mkdir"
1896 # test 44: rename tgt and blocking operations
1898 touch $DIR1/$tfile-2
1899 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1900 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1901 mv $DIR1/$tfile-2 $DIR1/$tfile &
1904 mkdir $DIR2/$tfile && error "mkdir must fail"
1905 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1909 run_test 44a "pdirops: rename tgt vs mkdir =============="
1912 touch $DIR1/$tfile-2
1913 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1914 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1915 mv $DIR1/$tfile-2 $DIR1/$tfile &
1918 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1919 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1923 run_test 44b "pdirops: rename tgt vs create =============="
1926 touch $DIR1/$tfile-2
1927 touch $DIR1/$tfile-3
1928 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1929 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1930 mv $DIR1/$tfile-2 $DIR1/$tfile &
1933 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1934 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1938 run_test 44c "pdirops: rename tgt vs link =============="
1941 touch $DIR1/$tfile-2
1942 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1943 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1944 mv $DIR1/$tfile-2 $DIR1/$tfile &
1947 rm $DIR2/$tfile || error "unlink must succeed"
1948 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1952 run_test 44d "pdirops: rename tgt vs unlink =============="
1956 touch $DIR1/$tfile-2
1957 touch $DIR1/$tfile-3
1958 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1959 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1960 mv $DIR1/$tfile-2 $DIR1/$tfile &
1963 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1964 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1968 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1971 touch $DIR1/$tfile-2
1972 touch $DIR1/$tfile-3
1973 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1974 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1975 mv $DIR1/$tfile-2 $DIR1/$tfile &
1978 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1979 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1983 run_test 44f "pdirops: rename tgt and rename (src) =============="
1986 touch $DIR1/$tfile-2
1987 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1988 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1989 mv $DIR1/$tfile-2 $DIR1/$tfile &
1992 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1993 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1997 run_test 44g "pdirops: rename tgt vs getattr =============="
2000 touch $DIR1/$tfile-2
2001 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2002 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2003 mv $DIR1/$tfile-2 $DIR1/$tfile &
2006 ls -lia $DIR2/ > /dev/null
2007 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2011 run_test 44h "pdirops: rename tgt vs readdir =============="
2013 # test 44: rename tgt and blocking operations
2015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2016 touch $DIR1/$tfile-2
2017 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2018 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2019 mv $DIR1/$tfile-2 $DIR1/$tfile &
2022 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2023 check_pdo_conflict $PID1 && { wait $PID1;
2024 error "remote mkdir isn't blocked"; }
2028 run_test 44i "pdirops: rename tgt vs remote mkdir"
2030 # test 45: rename src and blocking operations
2033 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2034 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2035 mv $DIR1/$tfile $DIR1/$tfile-2 &
2038 mkdir $DIR2/$tfile || error "mkdir must succeed"
2039 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2043 run_test 45a "pdirops: rename src vs mkdir =============="
2047 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2048 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2049 mv $DIR1/$tfile $DIR1/$tfile-2 &
2052 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2053 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2057 run_test 45b "pdirops: rename src vs create =============="
2061 touch $DIR1/$tfile-3
2062 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2063 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2064 mv $DIR1/$tfile $DIR1/$tfile-2 &
2067 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2068 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2072 run_test 45c "pdirops: rename src vs link =============="
2076 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2077 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2078 mv $DIR1/$tfile $DIR1/$tfile-2 &
2081 rm $DIR2/$tfile && error "unlink must fail"
2082 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2086 run_test 45d "pdirops: rename src vs unlink =============="
2090 touch $DIR1/$tfile-3
2091 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2092 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2093 mv $DIR1/$tfile $DIR1/$tfile-2 &
2096 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2097 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2101 run_test 45e "pdirops: rename src and rename (tgt) =============="
2105 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2106 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2107 mv $DIR1/$tfile $DIR1/$tfile-2 &
2110 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2111 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2115 run_test 45f "pdirops: rename src and rename (src) =============="
2119 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2120 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2121 mv $DIR1/$tfile $DIR1/$tfile-2 &
2124 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2125 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2129 run_test 45g "pdirops: rename src vs getattr =============="
2133 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2134 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2135 mv $DIR1/$tfile $DIR1/$tfile-2 &
2138 ls -lia $DIR2/ > /dev/null
2139 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2143 run_test 45h "pdirops: unlink vs readdir =============="
2146 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2148 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2149 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2150 mv $DIR1/$tfile $DIR1/$tfile-2 &
2153 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2154 check_pdo_conflict $PID1 && { wait $PID1;
2155 error "create remote dir isn't blocked"; }
2159 run_test 45i "pdirops: rename src vs remote mkdir"
2161 # test 46: link and blocking operations
2163 touch $DIR1/$tfile-2
2164 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2165 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2166 link $DIR1/$tfile-2 $DIR1/$tfile &
2169 mkdir $DIR2/$tfile && error "mkdir must fail"
2170 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2174 run_test 46a "pdirops: link vs mkdir =============="
2177 touch $DIR1/$tfile-2
2178 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2179 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2180 link $DIR1/$tfile-2 $DIR1/$tfile &
2183 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2184 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2188 run_test 46b "pdirops: link vs create =============="
2191 touch $DIR1/$tfile-2
2192 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2193 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2194 link $DIR1/$tfile-2 $DIR1/$tfile &
2197 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2198 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2202 run_test 46c "pdirops: link vs link =============="
2205 touch $DIR1/$tfile-2
2206 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2207 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2208 link $DIR1/$tfile-2 $DIR1/$tfile &
2211 rm $DIR2/$tfile || error "unlink must succeed"
2212 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2216 run_test 46d "pdirops: link vs unlink =============="
2219 touch $DIR1/$tfile-2
2220 touch $DIR1/$tfile-3
2221 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2222 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2223 link $DIR1/$tfile-2 $DIR1/$tfile &
2226 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2227 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2231 run_test 46e "pdirops: link and rename (tgt) =============="
2234 touch $DIR1/$tfile-2
2235 touch $DIR1/$tfile-3
2236 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2237 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2238 link $DIR1/$tfile-2 $DIR1/$tfile &
2241 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2242 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2246 run_test 46f "pdirops: link and rename (src) =============="
2249 touch $DIR1/$tfile-2
2250 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2251 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2252 link $DIR1/$tfile-2 $DIR1/$tfile &
2255 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2256 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2260 run_test 46g "pdirops: link vs getattr =============="
2263 touch $DIR1/$tfile-2
2264 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2265 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2266 link $DIR1/$tfile-2 $DIR1/$tfile &
2269 ls -lia $DIR2/ > /dev/null
2270 check_pdo_conflict $PID1 && { wait $PID1;
2271 error "readdir isn't blocked"; }
2275 run_test 46h "pdirops: link vs readdir =============="
2278 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2279 touch $DIR1/$tfile-2
2280 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2281 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2282 link $DIR1/$tfile-2 $DIR1/$tfile &
2285 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2286 check_pdo_conflict $PID1 && { wait $PID1;
2287 error "remote mkdir isn't blocked"; }
2291 run_test 46i "pdirops: link vs remote mkdir"
2293 # test 47: remote mkdir and blocking operations
2295 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2296 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2297 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2298 $LFS mkdir -i 1 $DIR1/$tfile &
2301 mkdir $DIR2/$tfile && error "mkdir must fail"
2302 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2306 run_test 47a "pdirops: remote mkdir vs mkdir"
2309 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2310 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2311 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2312 $LFS mkdir -i 1 $DIR1/$tfile &
2315 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2316 check_pdo_conflict $PID1 && { wait $PID1;
2317 error "create isn't blocked"; }
2321 run_test 47b "pdirops: remote mkdir vs create"
2324 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2325 touch $DIR1/$tfile-2
2326 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2327 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2328 $LFS mkdir -i 1 $DIR1/$tfile &
2331 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2332 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2336 run_test 47c "pdirops: remote mkdir vs link"
2339 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2340 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2341 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2342 $LFS mkdir -i 1 $DIR1/$tfile &
2345 rmdir $DIR2/$tfile || error "unlink must succeed"
2346 check_pdo_conflict $PID1 && { wait $PID1;
2347 error "unlink isn't blocked"; }
2351 run_test 47d "pdirops: remote mkdir vs unlink"
2354 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2355 touch $DIR1/$tfile-2
2356 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2357 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2358 $LFS mkdir -i 1 $DIR1/$tfile &
2361 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2362 check_pdo_conflict $PID1 && { wait $PID1;
2363 error "rename isn't blocked"; }
2367 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2370 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2371 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2372 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2373 $LFS mkdir -i 1 $DIR1/$tfile &
2376 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2377 check_pdo_conflict $PID1 && { wait $PID1;
2378 error "rename isn't blocked"; }
2382 run_test 47f "pdirops: remote mkdir and rename (src)"
2385 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2386 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2387 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2388 $LFS mkdir -i 1 $DIR1/$tfile &
2391 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2392 check_pdo_conflict $PID1 && { wait $PID1;
2393 error "getattr isn't blocked"; }
2397 run_test 47g "pdirops: remote mkdir vs getattr"
2401 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2402 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2403 do_facet client "lctl set_param fail_loc=0x410"
2404 $TRUNCATE $DIR2/$tfile $trunc_size
2405 do_facet client "lctl set_param fail_loc=0x0"
2407 size=`stat -c %s $DIR2/$tfile`
2408 [ $size -eq $trunc_size ] || error "wrong size"
2410 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2414 local origfile=/etc/hosts
2416 filesize=$(stat -c %s $origfile)
2418 # create an empty file
2419 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2420 # cache layout lock on both mount point
2421 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2422 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2424 # open and sleep 2 seconds then read
2425 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2429 # create the layout of testing file
2430 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2431 error "dd $DIR1/$tfile failed"
2433 # MULTIOP proc should be able to read enough bytes and exit
2434 for ((i = 0; i < 6; i++)); do
2436 kill -0 $pid || break
2438 kill -0 $pid 2> /dev/null && error "multiop is still there"
2439 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2443 run_test 51a "layout lock: refresh layout should work"
2446 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2447 { skip "Need MDS version at least 2.3.59"; return 0; }
2449 local tmpfile=`mktemp`
2451 # create an empty file
2452 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2454 # delay glimpse so that layout has changed when glimpse finish
2455 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2456 $LCTL set_param fail_loc=0x1404
2457 stat -c %s $DIR2/$tfile |tee $tmpfile &
2461 # create layout of testing file
2462 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2463 error "dd $DIR1/$tfile failed"
2466 local fsize=$(cat $tmpfile)
2468 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2470 rm -f $DIR1/$tfile $tmpfile
2472 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2475 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2477 # set default layout to have 1 stripe
2479 $LFS setstripe -c 1 $DIR1/$tdir
2481 # create a file with empty layout
2482 $MCREATE $DIR1/$tdir/$tfile ||
2483 error "$MCREATE $DIR1/$tdir/$tfile failed"
2485 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2486 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2488 # change the layout of testing file
2489 echo "Setting layout to have $OSTCOUNT stripes ..."
2490 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2494 # write something to the file, it should be blocked on fetching layout
2495 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2496 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2499 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2500 # count to succeed with only 3/4 of the number of stripes (rounded up),
2501 # so creating striped files does not fail if an OST is offline or full
2502 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2503 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2507 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2510 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2511 cancel_lru_locks mdc
2513 # open should grant LAYOUT lock, mmap and read will install pages
2514 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2518 # rss before revoking
2519 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2520 echo "Before revoking layout lock: $br KB mapped"
2522 # delete the file will revoke layout lock
2525 # rss after revoking
2526 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2531 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2533 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2537 echo "==> rename vs getattr vs setxattr should not deadlock"
2538 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2540 do_facet mds1 $LCTL set_param fail_loc=$1
2542 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2550 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2551 wait $PID1 || error "(3) mv failed"
2552 wait $PID2 || error "(4) stat failed"
2559 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2560 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2562 do_facet mds1 $LCTL set_param fail_loc=$1
2564 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2572 $MULTIOP $DIR2/d1/d2 Oc &
2576 stat $DIR/d1 || error "(2) stat failed"
2578 wait $PID1 || error "(3) mv failed"
2579 wait $PID2 || error "(4) stat failed"
2580 wait $PID3 && error "(5) multiop failed"
2586 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2587 save_lustre_params client "llite.*.xattr_cache" > $p
2588 lctl set_param llite.*.xattr_cache 1 ||
2589 { skip "xattr cache is not supported"; return 0; }
2591 #define OBD_FAIL_MDS_RENAME 0x153
2592 #define OBD_FAIL_MDS_RENAME2 0x154
2593 test_54_part1 0x80000153 || error 10
2594 test_54_part1 0x80000154 || error 11
2595 test_54_part2 0x80000153 || error 12
2596 test_54_part2 0x80000154 || error 13
2598 restore_lustre_params < $p
2601 run_test 54 "rename locking"
2604 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2606 #define OBD_FAIL_MDS_RENAME4 0x156
2607 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2609 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2614 wait $PID1 && error "(2) mv succeeded"
2618 run_test 55a "rename vs unlink target dir"
2622 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2624 #define OBD_FAIL_MDS_RENAME4 0x156
2625 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2627 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2632 wait $PID1 && error "(2) mv succeeded"
2636 run_test 55b "rename vs unlink source dir"
2640 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2642 #define OBD_FAIL_MDS_RENAME4 0x156
2643 do_facet mds1 $LCTL set_param fail_loc=0x156
2645 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2649 # while rename is sleeping, open and remove d3
2650 $MULTIOP $DIR2/d3 D_c &
2656 # while rename is sleeping 2nd time, close d3
2658 wait $PID2 || error "(3) multiop failed"
2660 wait $PID1 && error "(2) mv succeeded"
2664 run_test 55c "rename vs unlink orphan target dir"
2670 #define OBD_FAIL_MDS_RENAME3 0x155
2671 do_facet mds1 $LCTL set_param fail_loc=0x155
2672 mv $DIR/f1 $DIR/$tdir &
2676 # while rename is sleeping, create $tdir, but as a directory
2677 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2679 # link in reverse locking order
2680 ln $DIR2/f1 $DIR2/$tdir/
2682 wait $PID1 && error "(2) mv succeeded"
2685 run_test 55d "rename file vs link"
2688 local MDSVER=$(lustre_build_version $SINGLEMDS)
2689 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2690 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2693 test_mkdir $DIR1/$tdir
2694 file1=$DIR1/$tdir/file
2695 file2=$DIR2/$tdir/file
2697 echo orig > $file2 || error "Could not create $file2"
2698 version=$($LFS data_version $file1)
2701 echo append >> $file2 || error "Could not append to $file2"
2702 version2=$($LFS data_version $file1)
2703 [ "$version" != "$version2" ] ||
2704 error "append did not change data version: $version"
2707 echo overwrite > $file2 || error "Could not overwrite $file2"
2708 version3=$($LFS data_version $file1)
2709 [ "$version2" != "$version3" ] ||
2710 error "overwrite did not change data version: $version2"
2712 # Truncate before EOF
2713 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2714 version4=$($LFS data_version $file1)
2715 [ "$version3" != "$version4" ] ||
2716 error "truncate did not change data version: $version3"
2718 # Truncate after EOF
2719 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2720 version5=$($LFS data_version $file1)
2721 [ "$version4" != "$version5" ] ||
2722 error "truncate did not change data version: $version4"
2724 # Chmod do not change version
2725 chmod 400 $file2 || error "Could not chmod 400 $file2"
2726 version6=$($LFS data_version $file1)
2727 [ "$version5" == "$version6" ] ||
2728 error "chmod should not change data version: $version5 != $version6"
2730 # Chown do not change version
2731 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2732 version7=$($LFS data_version $file1)
2733 [ "$version5" == "$version7" ] ||
2734 error "chown should not change data version: $version5 != $version7"
2736 run_test 60 "Verify data_version behaviour"
2739 local test_dir=$tdir/test_dir
2741 mkdir -p $DIR1/$tdir
2742 if [ $MDSCOUNT -ge 2 ]; then
2744 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2745 error "Create remote directory failed"
2747 mkdir -p $DIR1/$test_dir
2749 cd $DIR2/$test_dir || error "cd directory failed"
2750 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2752 cd $DIR2/$tdir || error "exit directory"
2754 run_test 70a "cd directory && rm directory"
2756 test_70b() { # LU-2781
2758 mkdir -p $DIR1/$tdir
2760 touch $DIR1/$tdir/file
2761 for ((i = 0; i < 32; i++)); do
2762 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2764 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2766 touch $DIR1/$tdir/file
2767 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2768 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2769 rm -rf $DIR1/$tdir/test_dir ||
2770 error "cannot remove directory after rm_entry"
2771 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2773 run_test 70b "remove files after calling rm_entry"
2776 local server_version=$(lustre_version_code $SINGLEMDS)
2778 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2779 skip "Need MDS version at least 2.1.6" && return
2781 # Patch not applied to 2.2 and 2.3 branches
2782 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2783 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2784 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2787 checkfiemap --test ||
2788 { skip "checkfiemap not runnable: $?" && return; }
2789 # write data this way: hole - data - hole - data
2790 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2791 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2793 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2794 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2795 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2797 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2799 checkfiemap $DIR2/$tfile 81920 ||
2800 error "data is not flushed from client"
2801 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2804 # common case of "create file, copy file" on a single node
2805 # should not flush data from ost
2806 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2807 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2809 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2811 checkfiemap $DIR1/$tfile 81920 ||
2813 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2815 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2817 run_test 71a "correct file map just after write operation is finished"
2820 local server_version=$(lustre_version_code $SINGLEMDS)
2822 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2823 skip "Need MDS version at least 2.1.6" && return
2825 # Patch not applied to 2.2 and 2.3 branches
2826 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2827 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2828 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2830 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2832 checkfiemap --test ||
2833 { skip "error $?: checkfiemap failed" && return; }
2835 mkdir -p $DIR1/$tdir
2837 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2838 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2839 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2841 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2842 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2844 run_test 71b "check fiemap support for stripecount > 1"
2847 local p="$TMP/sanityN-$TESTNAME.parameters"
2850 save_lustre_params client "llite.*.xattr_cache" > $p
2851 lctl set_param llite.*.xattr_cache 1 ||
2852 { skip "xattr cache is not supported"; return 0; }
2855 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2856 error "setfattr1 failed"
2857 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2858 error "getfattr1 failed"
2859 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2860 error "setfattr2 failed"
2861 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2862 error "getfattr2 failed"
2864 # check that trusted.link is consistent
2865 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2866 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2867 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2868 echo "$tlink1 $tlink2"
2869 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2873 restore_lustre_params < $p
2876 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2879 local p="$TMP/sanityN-$TESTNAME.parameters"
2880 save_lustre_params client "llite.*.xattr_cache" > $p
2881 lctl set_param llite.*.xattr_cache 1 ||
2882 { skip "xattr cache is not supported"; return 0; }
2885 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2886 error "setfattr1 failed"
2887 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2888 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2889 clear_stats llite.*.stats
2890 # PR lock should be cached by now on both clients
2891 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2892 # 2 hits for getfattr(0)+getfattr(size)
2893 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2894 error "not cached in $DIR1"
2895 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2896 # 4 hits for more getfattr(0)+getfattr(size)
2897 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2898 error "not cached in $DIR2"
2901 restore_lustre_params < $p
2904 run_test 73 "getxattr should not cause xattr lock cancellation"
2907 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2908 skip "Need MDS version at least 2.4.93" && return
2910 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2911 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2912 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2914 run_test 74 "flock deadlock: different mounts =============="
2918 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2919 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2920 cancel_lru_locks osc
2922 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2925 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2926 $LCTL set_param fail_loc=0x31d
2927 stat -c %s $DIR1/$tfile &
2932 # For bad lock error handler we should ASSERT and got kernel panic here
2934 $LCTL set_param fail_loc=0
2936 run_test 75 "osc: upcall after unuse lock==================="
2939 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2940 skip "Need MDS version at least 2.5.53" && return
2942 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2943 local fcount=$((MDSCOUNT * 256))
2948 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2954 test_mkdir $DIR/$tdir
2956 # drop all open locks and close any cached "open" files on the client
2957 cancel_lru_locks mdc
2959 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2960 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2961 local already=${#fid_list[@]}
2962 for (( i = 0; i < $already; i++ )) ; do
2963 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2966 echo -n "opening files: "
2967 ulimit -n $((fcount + 50))
2968 for ((i = 0; i < $fcount; i++)); do
2969 touch $DIR/$tdir/f_$i
2970 local fd=$(free_fd ${fd_list[i]})
2971 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
2976 (( $i % 32 == 0 )) && echo -n "."
2980 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2982 # Possible errors in openfiles FID list.
2983 # 1. Missing FIDs. Check 1
2984 # 2. Extra FIDs. Check 1
2985 # 3. Duplicated FID. Check 2
2986 # 4. Invalid FIDs. Check 2
2987 # 5. Valid FID, points to some other file. Check 3
2990 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
2991 error "${#fid_list[@]} != $fcount (+$already old) open files"
2993 echo -n "closing files: "
2994 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
2995 local close_cmd="exec ${fd_list[fd]}<&-"
2997 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
2999 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3000 echo "skip old open file $filename"
3002 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3006 rm --interactive=no $filename
3008 error "Nonexisting fid ${fid_list[fid]} listed."
3009 (( $fd % 32 == 0 )) && echo -n "."
3014 ls_op=$(ls $DIR2/$tdir | wc -l)
3016 error "Some openfiles are missing in lproc output"
3020 run_test 76 "Verify MDT open_files listing"
3024 local dir=$DIR/$tdir
3027 mkdir $dir || error "mkdir $dir failed"
3028 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3031 do_nodes $CLIENTS $myRUNAS \
3032 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3033 error "dd at 0 on client failed (1)"
3035 for ((i = 0; i < $n; i++)); do
3036 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3037 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3038 error "dd at ${i}MB on client failed (2)" &
3041 do_nodes $CLIENTS sync;
3042 cancel_lru_locks osc
3044 for ((i = 0; i < $n; i++)); do
3045 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3046 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3047 error "dd at ${i}MB on client failed (3)" &
3050 cancel_lru_locks osc
3052 for ((i = 0; i < $n; i++)); do
3056 rm -rf $dir || error "rm -rf $dir failed"
3059 test_77a() { #LU-3266
3060 oss=$(comma_list $(osts_nodes))
3061 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
3066 run_test 77a "check FIFO NRS policy"
3068 test_77b() { #LU-3266
3069 oss=$(comma_list $(osts_nodes))
3071 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3072 ost.OSS.*.nrs_crrn_quantum=1
3074 echo "policy: crr-n, crrn_quantum 1"
3077 do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
3079 echo "policy: crr-n, crrn_quantum 64"
3083 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3086 run_test 77b "check CRR-N NRS policy"
3091 oss=$(comma_list $(osts_nodes))
3093 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3094 ost.OSS.*.nrs_"$policy"_quantum=1 \
3095 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3096 ost.OSS.*.nrs_"$policy"_supported="reads"
3098 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
3101 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
3102 ost.OSS.*.nrs_${policy}_quantum=64
3104 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
3107 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3108 ost.OSS.*.nrs_${policy}_offset_type="logical"
3109 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3113 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3117 test_77c() { #LU-3266
3121 run_test 77c "check ORR NRS policy"
3123 test_77d() { #LU-3266
3127 run_test 77d "check TRR nrs policy"
3134 do_facet $facet lctl set_param \
3135 ost.OSS.ost_io.nrs_tbf_rule="$*"
3137 error "failed to run operate '$*' on TBF rules"
3140 cleanup_tbf_verify()
3144 echo "cleanup_tbf $DIR/$tdir"
3147 wait_delete_completed
3152 local dir=$DIR/$tdir
3153 local client1=${CLIENT1:-$(hostname)}
3156 local np=$(check_cpt_number ost1)
3157 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3158 echo "cpu_npartitions on ost1 is $np"
3160 mkdir $dir || error "mkdir $dir failed"
3161 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3164 trap cleanup_tbf_verify EXIT
3165 echo "Limited write rate: $1, read rate: $2"
3166 echo "Verify the write rate is under TBF control"
3167 local start=$SECONDS
3168 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3169 bs=1M count=100 oflag=direct 2>&1
3170 local runtime=$((SECONDS - start + 1))
3171 local rate=$(bc <<< "scale=6; 100 / $runtime")
3172 echo "Write runtime is $runtime s, speed is $rate IOPS"
3174 # verify the write rate does not exceed TBF rate limit
3175 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3176 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3178 cancel_lru_locks osc
3180 echo "Verify the read rate is under TBF control"
3182 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3183 bs=1M count=100 iflag=direct 2>&1
3184 runtime=$((SECONDS - start + 1))
3185 rate=$(bc <<< "scale=6; 100 / $runtime")
3186 echo "Read runtime is $runtime s, speed is $rate IOPS"
3188 # verify the read rate does not exceed TBF rate limit
3189 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3190 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3192 cancel_lru_locks osc
3193 cleanup_tbf_verify || error "rm -rf $dir failed"
3197 local server_version=$(lustre_version_code ost1)
3198 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3199 { skip "Need server version newer than 2.7.57"; return 0; }
3201 oss=$(comma_list $(osts_nodes))
3203 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3204 [ $? -ne 0 ] && error "failed to set TBF policy"
3208 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3213 # Only operate rules on ost1 since OSTs might run on the same OSS
3215 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3216 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3217 local client_nids=$(nids_list $address "\\")
3218 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3219 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3223 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3224 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3225 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3229 tbf_rule_operate ost1 "stop\ localhost"
3230 tbf_rule_operate ost1 "stop\ clients"
3231 tbf_rule_operate ost1 "stop\ others"
3234 # Cleanup the TBF policy
3235 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3236 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3240 run_test 77e "check TBF NID nrs policy"
3243 local server_version=$(lustre_version_code ost1)
3244 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3245 { skip "Need server version newer than 2.7.57"; return 0; }
3247 oss=$(comma_list $(osts_nodes))
3249 # Configure jobid_var
3250 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3251 if [ $saved_jobid_var != procname_uid ]; then
3252 set_conf_param_and_check client \
3253 "$LCTL get_param -n jobid_var" \
3254 "$FSNAME.sys.jobid_var" procname_uid
3257 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3258 [ $? -ne 0 ] && error "failed to set TBF policy"
3262 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3267 # Only operate rules on ost1 since OSTs might run on the same OSS
3269 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3270 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3271 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3272 nrs_write_read "$RUNAS"
3275 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3276 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3277 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3278 nrs_write_read "$RUNAS"
3281 tbf_rule_operate ost1 "stop\ runas"
3282 tbf_rule_operate ost1 "stop\ iozone_runas"
3283 tbf_rule_operate ost1 "stop\ dd_runas"
3284 nrs_write_read "$RUNAS"
3286 # Cleanup the TBF policy
3287 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3288 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3289 nrs_write_read "$RUNAS"
3291 local current_jobid_var=$($LCTL get_param -n jobid_var)
3292 if [ $saved_jobid_var != $current_jobid_var ]; then
3293 set_conf_param_and_check client \
3294 "$LCTL get_param -n jobid_var" \
3295 "$FSNAME.sys.jobid_var" $saved_jobid_var
3299 run_test 77f "check TBF JobID nrs policy"
3302 local server_version=$(lustre_version_code ost1)
3303 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3304 { skip "Need server version newer than 2.7.57"; return 0; }
3306 oss=$(comma_list $(osts_nodes))
3308 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3309 [ $? -ne 0 ] && error "failed to set TBF policy"
3311 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3312 [ $? -ne 0 ] && error "failed to set TBF policy"
3316 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3321 # Add a rule that only valid for Jobid TBF. If direct change between
3322 # TBF types is not supported, this operation will fail.
3323 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3325 # Cleanup the TBF policy
3326 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3327 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3330 run_test 77g "Change TBF type directly"
3333 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3334 { skip "Need OST version at least 2.8.55"; return 0; }
3336 local old_policy=$(do_facet ost1 \
3337 lctl get_param ost.OSS.ost_io.nrs_policies)
3340 do_facet ost1 lctl set_param \
3341 ost.OSS.ost_io.nrs_policies="abc"
3342 [ $? -eq 0 ] && error "should return error"
3344 do_facet ost1 lctl set_param \
3345 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3346 [ $? -eq 0 ] && error "should return error"
3348 do_facet ost1 lctl set_param \
3349 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3350 [ $? -eq 0 ] && error "should return error"
3352 do_facet ost1 lctl set_param \
3353 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3354 [ $? -eq 0 ] && error "should return error"
3356 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3357 [ $? -eq 0 ] || error "shouldn't LBUG"
3359 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3363 run_test 77h "Wrong policy name should report error, not LBUG"
3369 local error_message=$3
3371 for rule in $expected; do
3372 rule_number=$((rule_number + 1))
3374 local stop_line=$(($rule_number + 3))
3375 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3377 local output=$(do_facet $facet lctl get_param \
3378 ost.OSS.ost_io.nrs_tbf_rule |
3382 if [ "$output" != "$expected" ]; then
3383 error "$error_message, expected '$expected', got '$output'"
3388 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3389 { skip "Need OST version at least 2.8.55"; return 0; }
3391 for i in $(seq 1 $OSTCOUNT)
3393 do_facet ost"$i" lctl set_param \
3394 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3396 error "failed to set TBF policy"
3399 tbf_rule_check ost1 "default" "error before inserting any rule"
3401 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3402 tbf_rule_check ost1 "before default" \
3403 "error when inserting rule 'before'"
3405 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3406 tbf_rule_check ost1 "before after default" \
3407 "error when inserting rule 'after'"
3409 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3410 tbf_rule_check ost1 "before target after default" \
3411 "error when inserting rule 'target'"
3413 echo "Move before itself"
3414 tbf_rule_operate ost1 "change\ target\ rank=target"
3415 tbf_rule_check ost1 "before target after default" \
3416 "error when moving before itself"
3418 echo "Move to higher rank"
3419 tbf_rule_operate ost1 "change\ target\ rank=before"
3420 tbf_rule_check ost1 "target before after default" \
3421 "error when moving to higher rank"
3423 echo "Move to lower rank"
3424 tbf_rule_operate ost1 "change\ target\ rank=after"
3425 tbf_rule_check ost1 "before target after default" \
3426 "error when moving to lower rank"
3428 echo "Move before default"
3429 tbf_rule_operate ost1 "change\ target\ rank=default"
3430 tbf_rule_check ost1 "before after target default" \
3431 error "error when moving before default"
3433 # Cleanup the TBF policy
3434 do_nodes $(comma_list $(osts_nodes)) \
3435 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3438 run_test 77i "Change rank of TBF rule"
3443 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.60) ]; then
3448 do_nodes $(comma_list $(osts_nodes)) \
3449 lctl set_param jobid_var=procname_uid \
3450 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3451 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3452 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3453 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3458 do_nodes $(comma_list $(osts_nodes)) \
3459 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3460 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3461 ost.OSS.ost_io.nrs_policies="fifo"
3463 # sleep 3 seconds to wait the tbf policy stop completely,
3464 # or the next test case is possible get -EAGAIN when
3465 # setting the tbf policy
3468 run_test 77j "check TBF-OPCode NRS policy"
3471 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3472 { skip "Need OST version at least 2.9.53"; return 0; }
3474 do_nodes $(comma_list $(osts_nodes)) \
3475 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3476 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3477 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3479 nrs_write_read "$RUNAS"
3480 tbf_verify 20 10 "$RUNAS"
3482 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3483 local client_nids=$(nids_list $address "\\")
3484 do_nodes $(comma_list $(osts_nodes)) \
3485 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3486 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3487 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3488 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3493 do_nodes $(comma_list $(osts_nodes)) \
3494 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3495 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3496 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3498 nrs_write_read "$RUNAS"
3499 tbf_verify 20 20 "$RUNAS"
3501 do_nodes $(comma_list $(osts_nodes)) \
3502 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3503 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3504 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3506 nrs_write_read "$RUNAS"
3507 # with parameter "RUNAS", it will match the latest rule
3508 # "ext_b" first, so the limited write rate is 10.
3509 tbf_verify 10 10 "$RUNAS"
3512 do_nodes $(comma_list $(osts_nodes)) \
3513 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3514 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3515 ost.OSS.ost_io.nrs_policies="fifo"
3519 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3522 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3523 skip "Need OST version at least 2.9.54"
3527 local dir=$DIR/$tdir
3529 mkdir $dir || error "mkdir $dir failed"
3530 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3533 local nodes=$(comma_list $(osts_nodes))
3534 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3535 ost.OSS.ost_io.nrs_delay_min=4 \
3536 ost.OSS.ost_io.nrs_delay_max=4 \
3537 ost.OSS.ost_io.nrs_delay_pct=100
3538 [ $? -ne 0 ] && error "Failed to set delay policy"
3540 local start=$SECONDS
3541 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3542 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3543 oflag=direct conv=fdatasync ||
3544 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3545 error "dd on client failed (1)"; }
3546 local elapsed=$((SECONDS - start))
3548 # NRS delay doesn't do sub-second timing, so a request enqueued at
3549 # 0.9 seconds can be dequeued at 4.0
3550 [ $elapsed -lt 3 ] &&
3551 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3552 error "Single 1M write should take at least 3 seconds"; }
3555 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3556 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3557 oflag=direct conv=fdatasync ||
3558 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3559 error "dd on client failed (2)"; }
3560 elapsed=$((SECONDS - start))
3562 [ $elapsed -lt 30 ] &&
3563 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3564 error "Ten 1M writes should take at least 30 seconds"; }
3566 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3567 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3571 run_test 77l "check NRS Delay slows write RPC processing"
3573 test_78() { #LU-6673
3574 local server_version=$(lustre_version_code ost1)
3575 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3576 { skip "Need server version newer than 2.7.57"; return 0; }
3580 oss=$(comma_list $(osts_nodes))
3581 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3582 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3584 # Valid return codes are:
3585 # 0: Tuning succeeded
3586 # ENODEV: Policy is still stopped
3587 # EAGAIN: Policy is being initialized
3588 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3589 error "Expected set_param to return 0|ENODEV|EAGAIN"
3591 # Cleanup the ORR policy
3592 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3593 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3596 run_test 78 "Enable policy and specify tunings right away"
3599 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3600 test_mkdir $DIR/$tdir
3602 # Prevent interference from layout intent RPCs due to
3603 # asynchronous writeback. These will be tested in 130c below.
3604 do_nodes ${CLIENTS:-$HOSTNAME} sync
3606 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3607 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3609 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3610 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3611 local facet=mds$((mdtidx + 1))
3613 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3614 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3618 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3619 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3624 run_test 79 "xattr: intent error"
3627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3634 mkdir -p $DIR1/$tdir/dir
3635 createmany -o $DIR1/$tdir/dir/f 10 ||
3636 error "create files under remote dir failed $i"
3638 cp /etc/passwd $DIR1/$tdir/$tfile
3640 #migrate open file should fails
3641 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3643 # give multiop a chance to open
3646 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3647 error "migrate open files should failed with open files"
3651 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3652 error "migrate remote dir error"
3654 echo "Finish migration, then checking.."
3655 for file in $(find $DIR1/$tdir); do
3656 mdt_index=$($LFS getstripe -M $file)
3657 [ $mdt_index == $MDTIDX ] ||
3658 error "$file is not on MDT${MDTIDX}"
3661 diff /etc/passwd $DIR1/$tdir/$tfile ||
3662 error "file different after migration"
3664 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3666 run_test 80a "migrate directory when some children is being opened"
3670 kill -9 $migrate_pid
3674 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3675 local migrate_dir1=$DIR1/$tdir/migrate_dir
3676 local migrate_dir2=$DIR2/$tdir/migrate_dir
3677 local migrate_run=$LUSTRE/tests/migrate.sh
3685 trap cleanup_80b EXIT
3686 #prepare migrate directory
3687 mkdir -p $migrate_dir1
3688 for F in {1,2,3,4,5}; do
3689 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3690 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3693 #migrate the directories among MDTs
3696 mdt_idx=$((RANDOM % MDSCOUNT))
3697 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3699 [ $rc -ne 0 -o $rc -ne 16 ] || break
3704 echo "start migration thread $migrate_pid"
3705 #Access the files at the same time
3706 start_time=$(date +%s)
3707 echo "accessing the migrating directory for 5 minutes..."
3709 ls $migrate_dir2 > /dev/null || {
3710 echo "read dir fails"
3713 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3714 echo "access file1 fails"
3718 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3719 echo "access file2/3 fails"
3723 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3724 echo "access file4 fails"
3728 stat $migrate_dir2/file5 > /dev/null || {
3729 echo "stat file5 fails"
3733 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3734 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3735 echo "touch file failed with $rc1"
3739 if [ -e $migrate_dir2/source_file ]; then
3740 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3741 &>/dev/null || rc1=$?
3742 if [ -e $migrate_dir2/link_file ]; then
3743 rm -rf $migrate_dir2/link_file
3746 mrename $migrate_dir2/source_file \
3747 $migrate_dir2/target_file &>/dev/null || rc1=$?
3748 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3749 echo "rename failed with $rc1"
3753 if [ -e $migrate_dir2/target_file ]; then
3754 rm -rf $migrate_dir2/target_file &>/dev/null ||
3757 rm -rf $migrate_dir2/source_file &>/dev/null ||
3760 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3761 echo "unlink failed with $rc1"
3766 end_time=$(date +%s)
3767 duration=$((end_time - start_time))
3768 if [ $((duration % 10)) -eq 0 ]; then
3769 if [ $show_time -eq 1 ]; then
3770 echo "...$duration seconds"
3777 kill -0 $migrate_pid || {
3778 echo "migration stopped 1"
3782 [ $duration -ge 300 ] && break
3785 #check migration are still there
3786 kill -0 $migrate_pid || error "migration stopped 2"
3789 run_test 80b "Accessing directory during migration"
3792 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3796 mkdir -p $DIR1/$tdir
3798 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3799 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3802 touch d0/0 || error "create 0 failed"
3803 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3804 stat d0/0 && error "stat mv filed succeed"
3805 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3806 stat d0/0 || error "stat failed"
3808 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3810 if [ $t -ne 3 ]; then
3811 ls -ai $DIR1/$tdir/d0
3812 error "expect 3 get $t"
3817 run_test 81 "rename and stat under striped directory"
3820 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3821 { skip "Need MDS version at least 2.6.92"; return 0; }
3823 # Client 1 creates a file.
3824 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3826 # Client 2 opens the file.
3827 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3829 # Client 1 makes the file an orphan.
3830 rm $DIR1/$tfile || error "rm"
3831 # Client 2 sets EA "user.multiop".
3833 wait $pid2 || error "multiop 2"
3834 # Client 1 gets EA "user.multiop". This used to fail because the EA
3835 # cache refill would get "trusted.link" from mdd_xattr_list() but
3836 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3839 wait $pid1 || error "multiop 1"
3841 run_test 82 "fsetxattr and fgetxattr on orphan files"
3844 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3851 $LFS mkdir -i1 -c2 $tdir
3856 echo "start pid $pid1 to create/unlink striped directory"
3858 # Access the directory at the same time
3862 stat $tdir > /dev/null 2>&1
3866 echo "start pid $pid2 to stat striped directory"
3874 run_test 83 "access striped directory while it is being created/unlinked"
3877 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3882 [ "$SLOW" = "yes" ] && duration=600
3883 # Open/Create under striped directory
3887 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3888 touch $tdir/f{0..3} > /dev/null 2>&1
3892 echo "start pid $pid1 to open/create under striped directory"
3894 # unlink the striped directory at the same time
3898 rm -rf $tdir > /dev/null 2>&1
3902 echo "start pid $pid2 to unlink striped directory"
3911 run_test 90 "open/create and unlink striped directory"
3914 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3919 [ "$SLOW" = "yes" ] && duration=600
3920 # chmod striped directory
3924 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3925 chmod go+w $tdir > /dev/null 2>&1
3929 echo "start pid $pid1 to chmod striped directory"
3931 # unlink the striped directory at the same time
3935 rm -rf $tdir > /dev/null 2>&1
3939 echo "start pid $pid2 to unlink striped directory"
3948 run_test 91 "chmod and unlink striped directory"
3951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3954 local cmd="exec $fd<$DIR1/$tdir"
3955 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3958 trap "eval $cmd" EXIT
3959 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3960 rmdir ../$tdir || error "rmdir ../$tdir fails"
3962 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3963 $LCTL set_param fail_loc=0x1408
3964 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3965 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3966 error "create remote dir succeeds"
3967 $LCTL set_param fail_loc=0
3971 run_test 92 "create remote directory under orphan directory"
3978 mkdir -p $DIR1/$tfile-1/
3979 mkdir -p $DIR2/$tfile-2/
3980 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
3981 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
3982 do_facet $SINGLEMDS lctl set_param -n \
3983 'lod.lustre-MDT*/qos_threshold_rr' 100
3984 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
3985 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
3987 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
3990 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
3994 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
3995 do_facet $SINGLEMDS "lctl set_param -n \
3996 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
3998 $GETSTRIPE $DIR1/$tfile-1/file1
3999 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4000 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4001 $GETSTRIPE $DIR2/$tfile-2/file2
4002 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4003 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4004 echo "rc1=$rc1 and rc2=$rc2 "
4005 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4006 error "object allocate on same ost detected"
4008 run_test 93 "alloc_rr should not allocate on same ost"
4012 skip "Reserved for glimpse-ahead" && return
4015 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4017 lctl set_param -n mdc.*.stats=clear
4018 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4020 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4021 # first stat from server should return size data and save glimpse
4022 local gls=$(lctl get_param -n mdc.*.stats | \
4023 awk '/ldlm_glimpse/ {print $2}')
4024 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4025 # second stat to check size is NOT cached on client without IO lock
4026 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4028 local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l)
4029 [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls"
4032 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4037 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4039 lctl set_param -n mdc.*.stats=clear
4040 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4041 cancel_lru_locks mdc
4042 # first stat data from server should have size
4043 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4044 # second stat to check size is cached on client
4045 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4047 local gls=$(lctl get_param -n mdc.*.stats |
4048 awk '/ldlm_glimpse/ {print $2}')
4049 # both stats should cause no glimpse requests
4050 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4053 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4058 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4060 lctl set_param -n mdc.*.stats=clear
4061 lctl set_param -n osc.*.stats=clear
4062 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4064 # check that size is merged from MDT and OST correctly
4065 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4066 error "Wrong size from stat #1"
4068 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4069 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4073 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4078 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4081 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4082 lctl set_param -n mdc.*.stats=clear
4083 $TRUNCATE $DIR2/$tdir/dom 4096
4085 # check that reported size is valid after file grows to OST and
4086 # is truncated back to MDT stripe size
4087 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4088 error "Wrong size from stat #1"
4090 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4091 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4095 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4099 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4100 lctl set_param -n mdc.*.stats=clear
4102 $CHECKSTAT -t file $DIR1/$tfile
4104 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4105 # must discard pages
4106 rm $DIR2/$tfile || error "Unlink fails"
4107 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4108 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4110 run_test 101a "Discard DoM data on unlink"
4113 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4114 touch $DIR1/${tfile}_2
4115 lctl set_param -n mdc.*.stats=clear
4117 $CHECKSTAT -t file $DIR1/$tfile
4119 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4120 # must discard pages
4121 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4122 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4123 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4125 run_test 101b "Discard DoM data on rename"
4128 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4129 lctl set_param -n mdc.*.stats=clear
4131 $CHECKSTAT -t file $DIR1/$tfile
4133 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4135 $MULTIOP $DIR1/$tfile O_c &
4138 rm $DIR2/$tfile > /dev/null || error "Unlink fails"
4139 kill -USR1 $MULTIOP_PID || return 2
4140 wait $MULTIOP_PID || return 3
4141 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4142 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4144 run_test 101c "Discard DoM data on close-unlink"
4146 log "cleanup: ======================================================"
4148 # kill and wait in each test only guarentee script finish, but command in script
4149 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4150 # otherwise umount below will fail
4151 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4156 check_and_cleanup_lustre