6 # bug number for skipped test: 9977/LU-7105
7 ALWAYS_EXCEPT=" 28 $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 ||
88 error "Either not file type or perms not 0777"
90 run_test 2a "check cached attribute updates on 2 mtpt's ========"
96 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
97 error "Either not file type or perms not 0777"
99 run_test 2b "check cached attribute updates on 2 mtpt's ========"
101 # NEED TO SAVE ROOT DIR MODE
104 $CHECKSTAT -t dir -p 0777 $DIR2 ||
105 error "Either not dir type or perms not 0777"
107 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
111 $CHECKSTAT -t dir -p 0755 $DIR2 ||
112 error "Either not file type or perms not 0775"
114 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
121 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
124 run_test 2e "check chmod on root is propagated to others"
127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
129 local remote_dir=$tdir/remote_dir
132 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
133 error "Create remote directory failed"
135 touch $DIR1/$remote_dir/$tfile ||
136 error "Create file under remote directory failed"
137 chmod 777 $DIR1/$remote_dir/$tfile ||
138 error "Chmod file under remote directory failed"
140 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
141 error "Check attr of file under remote directory failed"
143 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
144 error "Chown file under remote directory failed"
146 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
147 error "Check owner of file under remote directory failed"
149 cd $DIR2/$remote_dir || error "enter remote dir"
150 rm -rf $DIR1/$remote_dir/$tfile ||
151 error "Unlink remote directory failed"
153 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
154 error "unlink file still exists!"
156 cd $DIR2/$tdir || error "exit remote dir"
157 rm -rf $DIR1/$tdir || error "unlink directory failed"
159 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
162 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
164 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
166 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
167 echo "$DIR1/$tfile has $block1 blocks"
168 echo "$DIR2/$tfile has $block2 blocks"
169 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
171 run_test 2g "check blocks update on sync write"
174 local target="this/is/good"
175 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
176 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
177 error "link $DIR2/$tfile not as expected"
179 run_test 3 "symlink on one mtpt, readlink on another ==========="
182 multifstat $DIR1/f4 $DIR2/f4
184 run_test 4 "fstat validation on multiple mount points =========="
188 $TRUNCATE $DIR2/f5 100
189 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
190 error "Either not file type or size not equal to 100 bytes"
193 run_test 5 "create a file on one mount, truncate it on the other"
196 openunlink $DIR1/$tfile $DIR2/$tfile || \
197 error "openunlink $DIR1/$tfile $DIR2/$tfile"
199 run_test 6 "remove of open file on other node =================="
203 opendirunlink $DIR1/$dir $DIR2/$dir || \
204 error "opendirunlink $DIR1/$dir $DIR2/$dir"
206 run_test 7 "remove of open directory on other node ============="
209 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
210 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
212 run_test 8 "remove of open special file on other node =========="
218 for C in a b c d e f g h i j k l; do
219 dir=`eval echo \\$DIR$MTPT`
220 echo -n $C >> $dir/f9
221 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
223 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
224 error "`od -a $DIR1/f9` != abcdefghijkl"
226 run_test 9 "append of file with sub-page size on multiple mounts"
233 for C in a b c d e f g h i j k l; do
234 dir=`eval echo \\$DIR$MTPT`
235 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
236 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
237 OFFSET=`expr $OFFSET + 1`
239 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
240 error "`od -a $DIR1/f10` != abcdefghijkl"
242 run_test 10a "write of file with sub-page size on multiple mounts "
246 yes "R" | head -c 4000 >$TMP/f10b-seed
247 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
249 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
251 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
253 # create a test file locally to compare
254 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
255 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
256 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
257 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
259 run_test 10b "write of file with sub-page size on multiple mounts "
263 multiop_bg_pause $DIR1/d11/f O_c || return 1
265 cp -p /bin/ls $DIR1/d11/f
269 wait $MULTIPID || error "wait for PID $MULTIPID failed"
270 [ $RC -eq 0 ] && error || true
272 run_test 11 "execution of file opened for write should return error ===="
275 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
277 run_test 12 "test lock ordering (link, stat, unlink)"
279 test_13() { # bug 2451 - directory coherency
281 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
283 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
285 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
286 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
287 # need to run it twice
288 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
290 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
291 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
293 run_test 13 "test directory page revocation"
296 test_mkdir $DIR1/$tdir
297 cp -p /bin/ls $DIR1/$tdir/$tfile
298 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
301 $DIR2/$tdir/$tfile && error || true
303 wait $MULTIPID || return 2
305 run_test 14aa "execution of file open for write returns -ETXTBSY"
308 test_mkdir $DIR1/$tdir
309 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
310 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
313 $MULTIOP $DIR2/$tdir/multiop Oc && error "expected error, got success"
314 kill -USR1 $MULTIOP_PID || return 2
315 wait $MULTIOP_PID || return 3
316 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
318 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
320 test_14b() { # bug 3192, 7040
321 test_mkdir $DIR1/$tdir
322 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
323 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
326 $TRUNCATE $DIR2/$tdir/multiop 0 && kill -9 $MULTIOP_PID && \
327 error "expected truncate error, got success"
328 kill -USR1 $MULTIOP_PID || return 2
329 wait $MULTIOP_PID || return 3
330 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
331 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
333 run_test 14b "truncate of executing file returns -ETXTBSY ======"
335 test_14c() { # bug 3430, 7040
336 test_mkdir $DIR1/$tdir
337 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
338 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
341 cp /etc/hosts $DIR2/$tdir/multiop && error "expected error, got success"
342 kill -USR1 $MULTIOP_PID || return 2
343 wait $MULTIOP_PID || return 3
344 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
345 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
347 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
349 test_14d() { # bug 10921
350 test_mkdir $DIR1/$tdir
351 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
352 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
356 chmod 600 $DIR1/$tdir/multiop || error "chmod failed"
357 kill -USR1 $MULTIOP_PID || return 2
358 wait $MULTIOP_PID || return 3
359 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
360 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
362 run_test 14d "chmod of executing file is still possible ========"
364 test_15() { # bug 974 - ENOSPC
366 sh oos2.sh $MOUNT1 $MOUNT2
367 wait_delete_completed
368 grant_error=`dmesg | grep "> available"`
369 [ -z "$grant_error" ] || error "$grant_error"
371 run_test 15 "test out-of-space with multiple writers ==========="
374 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
375 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
376 # pass a 2500 operation dual-mount run within the time limit.
377 if [ "$(facet_fstype ost1)" = "zfs" ]; then
378 FSXNUM=$((COUNT / 5))
380 elif [ "$SLOW" = "yes" ]; then
381 FSXNUM=$((COUNT * 5))
389 local file1=$DIR1/$tfile
390 local file2=$DIR2/$tfile
392 # to allocate grant because it may run out due to test_15.
393 $LFS setstripe -c -1 $file1
394 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
395 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
398 $LFS setstripe -c -1 $file1 # b=10919
399 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
400 || error "fsx failed"
403 # O_DIRECT reads and writes must be aligned to the device block size.
404 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
405 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
407 run_test 16a "$FSXNUM iterations of dual-mount fsx"
409 # Consistency check for tiny writes, LU-9409
411 local file1=$DIR1/$tfile
412 local file2=$DIR2/$tfile
414 # to allocate grant because it may run out due to test_15.
415 lfs setstripe -c -1 $file1
416 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
417 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
420 lfs setstripe -c -1 $file1 # b=10919
421 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
422 # create a mix of tiny writes & normal writes
423 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
426 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
428 test_17() { # bug 3513, 3667
429 remote_ost_nodsh && skip "remote OST with nodsh" && return
431 lfs setstripe $DIR1/$tfile -i 0 -c 1
432 cp $SAMPLE_FILE $DIR1/$tfile
433 cancel_lru_locks osc > /dev/null
434 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
435 do_facet ost1 lctl set_param fail_loc=0x8000030a
436 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
437 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
439 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
441 run_test 17 "resource creation/LVB creation race ==============="
444 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
447 for idx in {a..z}; do
448 local ptr=EXCEPT_ALWAYS_18$idx
449 [ x${!ptr} = xtrue ] || continue
451 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
454 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
457 run_test 18 "mmap sanity check ================================="
459 test_19() { # bug3811
460 local node=$(facet_active_host ost1)
462 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
464 # check whether obdfilter is cache capable at all
465 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
466 echo "not cache-capable obdfilter"
470 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
472 set_osd_param $node '' readcache_max_filesize 4096
473 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
474 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
475 cp $TMP/$tfile $DIR1/$tfile
476 for i in `seq 1 20`; do
477 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
478 cancel_lru_locks $OSC > /dev/null
479 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
480 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
482 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
483 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
484 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
485 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
487 set_osd_param $node '' readcache_max_filesize $MAX
490 run_test 19 "test concurrent uncached read races ==============="
494 cancel_lru_locks $OSC
495 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
496 $MULTIOP $DIR1/f20 Ow8190c
497 $MULTIOP $DIR2/f20 Oz8194w8190c
498 $MULTIOP $DIR1/f20 Oz0r8190c
499 cancel_lru_locks $OSC
500 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
502 error $CNTD" page left in cache after lock cancel" || true
504 run_test 20 "test extra readahead page left in cache ===="
511 test_21() { # Bug 5907
512 test_mkdir $DIR1/$tdir
513 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
515 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
516 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
517 test -d $DIR1/$tdir || error "Mounted directory disappeared"
519 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
522 run_test 21 " Try to remove mountpoint on another dir ===="
524 test_23() { # Bug 5972
525 local at_diff=$(do_facet $SINGLEMDS \
526 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
527 echo "atime should be updated while another read" > $DIR1/$tfile
529 # clear the lock(mode: LCK_PW) gotten from creating operation
530 cancel_lru_locks $OSC
533 sleep $((at_diff + 1))
535 echo "starting reads"
536 multiop_bg_pause $DIR1/$tfile or20_c || return 1
537 # with SOM and opencache enabled, we need to close a file and cancel
538 # open lock to get atime propogated to MDS
539 kill -USR1 $! || return 2
542 time2=$(stat -c "%X" $DIR/$tfile)
543 echo "new atime is $time2"
545 [ $time2 -gt $time1 ] || error "atime was not updated"
546 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
549 run_test 23 " others should see updated atime while another read===="
553 lfs df || error "lfs df failed"
554 lfs df -ih || error "lfs df -ih failed"
555 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
556 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
557 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
558 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
560 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
561 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
562 lctl --device %osc deactivate
563 lfs df -i || error "lfs df -i with deactivated OSC failed"
564 lctl --device %osc activate
565 lfs df || error "lfs df with reactivated OSC failed"
567 run_test 24a "lfs df [-ih] [path] test ========================="
571 fsnum=$(lfs_df | grep -c "summary")
572 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
574 run_test 24b "lfs df should show both filesystems ==============="
577 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
579 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
582 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
583 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
585 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
586 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
587 error "setfacl $DIR2/$tdir #1"
588 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
589 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
590 error "setfacl $DIR2/$tdir #2"
591 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
592 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
593 error "setfacl $DIR2/$tdir #3"
594 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
595 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
596 error "setfacl $DIR2/$tdir #4"
597 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
601 run_test 25a "change ACL on one mountpoint be seen on another ==="
604 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
606 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
608 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
611 $LFS mkdir -i 1 $DIR1/$tdir
612 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
613 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
615 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
616 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
617 error "setfacl $DIR2/$tdir #1"
618 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
619 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
620 error "setfacl $DIR2/$tdir #2"
621 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
622 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
623 error "setfacl $DIR2/$tdir #3"
624 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
625 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
626 error "setfacl $DIR2/$tdir #4"
627 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
631 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
634 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
636 run_test 26a "allow mtime to get older"
641 echo "aaa" >> $DIR1/$tfile
643 chmod a+x $DIR2/$tfile
644 mt1=`stat -c %Y $DIR1/$tfile`
645 mt2=`stat -c %Y $DIR2/$tfile`
647 if [ x"$mt1" != x"$mt2" ]; then
648 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
651 run_test 26b "sync mtime between ost and mds"
654 cancel_lru_locks $OSC
656 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
661 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
666 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
668 lctl set_param -n ldlm.dump_namespaces ""
669 wait $DD1_PID $DD2_PID
670 [ $? -ne 0 ] && lctl dk $TMP/debug || true
672 run_test 27 "align non-overlapping extent locks from request ==="
674 test_28() { # bug 9977
675 ECHO_UUID="ECHO_osc1_UUID"
676 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
678 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
679 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
680 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
684 attach echo_client ECHO_osc1 $ECHO_UUID
688 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
689 $LCTL --device $tECHOID destroy "${tOBJID}:0"
697 # reading of 1st stripe should pass
698 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
699 # reading of 2nd stripe should fail (this stripe was destroyed)
700 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
702 # now, recreating test file
703 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
704 # reading of 1st stripe should pass
705 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
706 # reading of 2nd stripe should pass
707 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
710 run_test 28 "read/write/truncate file with lost stripes"
712 test_30() { #b=11110, LU-2523
713 test_mkdir $DIR1/$tdir
714 cp -f /bin/bash $DIR1/$tdir/bash
715 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
716 $DIR1/$tdir/bash -c 'sleep 2;
717 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
721 run_test 30 "recreate file race"
724 test_mkdir $DIR1/$tdir
725 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
726 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
727 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
728 lctl set_param fail_loc=0x314
729 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
730 awk 'BEGIN { FS="+" } /in/ {print $1}')
731 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
733 run_test 31a "voluntary cancel / blocking ast race=============="
736 remote_ost || { skip "local OST" && return 0; }
737 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
739 # make sure there is no local locks due to destroy
740 wait_mds_ost_sync || error "wait_mds_ost_sync()"
741 wait_delete_completed || error "wait_delete_completed()"
743 test_mkdir $DIR1/$tdir
744 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
745 cp /etc/hosts $DIR/$tdir/$tfile
746 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
747 lctl set_param fail_loc=0x314
748 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
749 do_facet ost1 lctl set_param fail_loc=0x316
751 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
752 lctl set_param fail_loc=0
753 do_facet ost1 lctl set_param fail_loc=0
754 # cleanup: reconnect the client back
757 run_test 31b "voluntary OST cancel / blocking ast race=============="
759 # enable/disable lockless truncate feature, depending on the arg 0/1
760 enable_lockless_truncate() {
761 lctl set_param -n $OSC.*.lockless_truncate $1
764 test_32a() { # bug 11270
765 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
767 save_lustre_params client "$OSC.*.lockless_truncate" > $p
768 cancel_lru_locks $OSC
769 enable_lockless_truncate 1
771 lfs setstripe -c -1 $DIR1/$tfile
772 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
774 clear_stats $OSC.*.${OSC}_stats
776 log "checking cached lockless truncate"
777 $TRUNCATE $DIR1/$tfile 8000000
778 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
779 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
780 error "cached truncate isn't lockless"
782 log "checking not cached lockless truncate"
783 $TRUNCATE $DIR2/$tfile 5000000
784 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
785 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
786 error "not cached truncate isn't lockless"
788 log "disabled lockless truncate"
789 enable_lockless_truncate 0
790 clear_stats $OSC.*.${OSC}_stats
791 $TRUNCATE $DIR2/$tfile 3000000
792 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
793 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
794 error "lockless truncate disabling failed"
796 # restore lockless_truncate default values
797 restore_lustre_params < $p
800 run_test 32a "lockless truncate"
802 test_32b() { # bug 11270
803 remote_ost_nodsh && skip "remote OST with nodsh" && return
806 local facets=$(get_facets OST)
807 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
809 save_lustre_params client "osc.*.contention_seconds" > $p
810 save_lustre_params $facets \
811 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
812 save_lustre_params $facets \
813 "ldlm.namespaces.filter-*.contended_locks" >> $p
814 save_lustre_params $facets \
815 "ldlm.namespaces.filter-*.contention_seconds" >> $p
816 clear_stats $OSC.*.${OSC}_stats
818 # agressive lockless i/o settings
819 do_nodes $(comma_list $(osts_nodes)) \
820 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
821 ldlm.namespaces.filter-*.contended_locks=0 \
822 ldlm.namespaces.filter-*.contention_seconds=60"
823 lctl set_param -n $OSC.*.contention_seconds=60
825 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
827 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
830 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
831 error "lockless i/o was not triggered"
832 # disable lockless i/o (it is disabled by default)
833 do_nodes $(comma_list $(osts_nodes)) \
834 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
835 ldlm.namespaces.filter-*.contended_locks=32 \
836 ldlm.namespaces.filter-*.contention_seconds=0"
837 # set contention_seconds to 0 at client too, otherwise Lustre still
838 # remembers lock contention
839 lctl set_param -n $OSC.*.contention_seconds=0
840 clear_stats $OSC.*.${OSC}_stats
842 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
844 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
847 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
848 error "lockless i/o works when disabled"
850 restore_lustre_params <$p
853 run_test 32b "lockless i/o"
857 local mdts=$(get_facets MDS)
862 for mds in ${mdts//,/ }; do
864 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
865 xargs readlink -f" ))
866 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
869 stat=$(( stat + val))
874 # commit on sharing tests
876 remote_mds_nodsh && skip "remote MDS with nodsh" && return
878 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
879 [ $CLIENTCOUNT -lt 2 ] &&
880 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
882 local nfiles=${TEST33_NFILES:-10000}
883 local param_file=$TMP/$tfile-params
884 local fstype=$(facet_fstype $SINGLEMDS)
886 save_lustre_params $(get_facets MDS) \
887 "mdt.*.commit_on_sharing" > $param_file
895 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
899 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
901 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
902 echo "=== START createmany old: $jbdold transaction"
903 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")
904 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
905 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
906 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
907 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
908 avgtime=$(( avgtime + elapsed ))
910 eval cos${COS}_jbd=$((avgjbd / 3))
911 eval cos${COS}_time=$((avgtime / 3))
914 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
915 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
916 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
917 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
919 restore_lustre_params < $param_file
923 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
925 # commit on sharing tests
927 remote_mds_nodsh && skip "remote MDS with nodsh" && return
929 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
930 [ $CLIENTCOUNT -ge 2 ] ||
931 { skip "Need two or more clients, have $CLIENTCOUNT" &&
933 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
935 local nfiles=${TEST33_NFILES:-10000}
936 local param_file=$TMP/$tfile-params
938 save_lustre_params $(get_facets MDS) \
939 "mdt.*.commit_on_sharing" > $param_file
948 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
952 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
953 $DIR1/$tdir-\\\$(hostname)-$i"
955 jbdold=$(print_jbd_stat)
956 echo "=== START createmany old: $jbdold transaction"
957 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
958 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
959 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
961 jbdnew=$(print_jbd_stat)
962 jbd=$(( jbdnew - jbdold ))
963 echo "=== END createmany new: $jbdnew transaction : \
964 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
965 avgjbd=$(( avgjbd + jbd ))
966 avgtime=$(( avgtime + elapsed ))
968 eval cos${COS}_jbd=$((avgjbd / 3))
969 eval cos${COS}_time=$((avgtime / 3))
972 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
973 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
974 [ "$cos0_jbd" != 0 ] &&
975 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
976 [ "$cos0_time" != 0 ] &&
977 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
979 restore_lustre_params < $param_file
983 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
986 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
987 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
988 skip "DNE CoS not supported" && return
993 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
994 $LFS mkdir -i 1 $DIR/$tdir/d1
995 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
997 local sync_count=$(do_facet mds1 \
998 "lctl get_param -n mdt.*MDT0000.sync_count")
999 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
1001 $LFS mkdir -i 1 $DIR/$tdir/d3
1002 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1003 # during sleep remote mkdir should have been committed and canceled
1004 # remote lock spontaneously, which shouldn't trigger sync
1007 local sync_count=$(do_facet mds1 \
1008 "lctl get_param -n mdt.*MDT0000.sync_count")
1009 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1011 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1014 local nodes=$(comma_list $(mdts_nodes))
1015 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1017 local async_commit_count=$(do_nodes $nodes \
1018 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1019 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
1026 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1027 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1028 skip "DNE CoS not supported" && return
1031 # remote directory create
1033 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1034 # remote directory unlink
1035 $LFS mkdir -i 1 $DIR/$tdir
1036 ops_do_cos "rmdir $DIR/$tdir"
1037 # striped directory create
1039 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1040 # striped directory setattr
1041 $LFS mkdir -c 2 $DIR/$tdir
1043 ops_do_cos "chmod 713 $DIR/$tdir"
1044 # striped directory unlink
1045 $LFS mkdir -c 2 $DIR/$tdir
1047 ops_do_cos "rmdir $DIR/$tdir"
1049 $LFS mkdir -c 2 $DIR/$tdir
1050 $LFS mkdir -i 0 $DIR/$tdir/d1
1051 $LFS mkdir -i 1 $DIR/$tdir/d2
1052 touch $DIR/$tdir/d1/tgt
1053 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1055 $LFS mkdir -c 2 $DIR/$tdir
1056 $LFS mkdir -i 0 $DIR/$tdir/d1
1057 $LFS mkdir -i 1 $DIR/$tdir/d2
1058 touch $DIR/$tdir/d1/src
1059 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1061 $LFS mkdir -i 0 $DIR/$tdir
1062 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1065 run_test 33d "DNE distributed operation should trigger COS"
1068 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1069 [ $CLIENTCOUNT -ge 2 ] ||
1070 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1072 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1073 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1074 skip "DNE CoS not supported" && return
1076 local client2=${CLIENT2:-$(hostname)}
1080 local nodes=$(comma_list $(mdts_nodes))
1081 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1083 $LFS mkdir -c 2 $DIR/$tdir
1084 mkdir $DIR/$tdir/subdir
1085 echo abc > $DIR/$tdir/$tfile
1086 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1087 do_node $client2 touch $DIR/$tdir/subdir
1089 local async_commit_count=$(do_nodes $nodes \
1090 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1091 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1095 run_test 33e "DNE local operation shouldn't trigger COS"
1097 # End commit on sharing tests
1099 get_ost_lock_timeouts() {
1100 local nodes=${1:-$(comma_list $(osts_nodes))}
1102 local locks=$(do_nodes $nodes \
1103 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1111 do_nodes $(comma_list $(osts_nodes)) \
1112 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1113 for i in $(seq $OSTCOUNT); do
1114 wait_osc_import_state client ost$i FULL
1119 remote_ost_nodsh && skip "remote OST with nodsh" && return
1123 trap cleanup_34 EXIT RETURN
1124 for OPER in notimeout timeout ; do
1125 rm $DIR1/$tfile 2>/dev/null
1126 lock_in=$(get_ost_lock_timeouts)
1127 if [ $OPER == "timeout" ] ; then
1128 for j in `seq $OSTCOUNT`; do
1129 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1130 do_facet ost$j lctl set_param fail_loc=0x511
1132 echo lock should expire
1134 for j in `seq $OSTCOUNT`; do
1135 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1136 do_facet ost$j lctl set_param fail_loc=0x512
1138 echo lock should not expire
1140 echo writing on client1
1141 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1143 echo reading on client2
1144 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1145 # wait for a lock timeout
1147 lock_out=$(get_ost_lock_timeouts)
1148 if [ $OPER == "timeout" ] ; then
1149 if [ $lock_in == $lock_out ]; then
1150 error "no lock timeout happened"
1155 if [ $lock_in != $lock_out ]; then
1156 error "lock timeout happened"
1164 run_test 34 "no lock timeout under IO"
1166 test_35() { # bug 17645
1169 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1170 awk '/generation/{print $2}')
1172 generation[count]=$g
1176 test_mkdir $MOUNT1/$tdir
1177 cancel_lru_locks mdc
1179 # Let's initiate -EINTR situation by setting fail_loc and take
1180 # write lock on same file from same client. This will not cause
1181 # bl_ast yet as lock is already in local cache.
1182 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1183 do_facet client "lctl set_param fail_loc=0x80000317"
1184 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1185 let timeout=timeout*3
1187 while test $nr -lt 10; do
1188 log "Race attempt $nr"
1189 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1190 awk '/ldlm_bl_callback/ { print $2 }')
1191 test "x$blk1" = "x" && blk1=0
1192 createmany -o $MOUNT2/$tdir/a 4000 &
1196 # Let's make conflict and bl_ast
1197 ls -la $MOUNT1/$tdir > /dev/null &
1200 log "Wait for $pid1 $pid2 for $timeout sec..."
1202 kill -9 $pid1 $pid2 > /dev/null 2>&1
1204 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1205 awk '/ldlm_bl_callback/ { print $2 }')
1206 test "x$blk2" = "x" && blk2=0
1207 test $blk2 -gt $blk1 && break
1208 rm -fr $MOUNT1/$tdir
1209 cancel_lru_locks mdc
1212 do_facet client "lctl set_param fail_loc=0x0"
1213 df -h $MOUNT1 $MOUNT2
1215 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1216 awk '/generation/{print $2}')
1218 if ! test "$g" -eq "${generation[count]}"; then
1219 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1221 for imp in $list; do
1222 if [ $c = $count ]; then
1227 imp=$(echo "$imp" | awk -F"." '{print $2}')
1228 error "Eviction happened on import $imp"
1233 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1235 test_36() { #bug 16417
1240 test_mkdir $DIR1/$tdir
1241 $LFS setstripe -c -1 $DIR1/$tdir
1244 let SIZE_B=SIZE*1024*1024
1245 sync; sleep 2; sync # wait for delete thread
1246 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1247 wait_destroy_complete || error "wait_destroy_complete failed"
1249 while [ $i -le 10 ]; do
1250 lctl mark "start test - cycle ($i)"
1251 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1252 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1253 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1254 sync # sync data from client cache
1255 sync_all_data # sync data from server cache (delayed allocation)
1257 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1258 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1260 rm -f $DIR1/$tdir/$tfile
1261 kill -USR1 $read_pid
1263 sync; sleep 2; sync # Ensure new statfs
1264 wait_delete_completed
1265 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1266 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1268 # this free space! not used
1269 (( $after_dd <= $after)) ||
1270 error "space leaked after_dd:$after_dd > after:$after"
1274 run_test 36 "handle ESTALE/open-unlink correctly"
1276 test_37() { # bug 18695
1277 test_mkdir $DIR1/$tdir
1278 multiop_bg_pause $DIR1/$tdir D_c || return 1
1280 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1281 createmany -m $DIR2/$tdir/f 10000
1282 # set mtime/atime backward
1283 touch -t 198001010000 $DIR2/$tdir
1284 kill -USR1 $MULTIPID
1285 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1286 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1289 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1291 # this should be set to past
1292 TEST_39_MTIME=`date -d "1 year ago" +%s`
1296 local client1=${CLIENT1:-`hostname`}
1297 local client2=${CLIENT2:-`hostname`}
1299 do_node $client1 "touch $DIR1/$tfile"
1301 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1302 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1303 [ "$mtime1" = $TEST_39_MTIME ] || \
1304 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1306 local d1=`do_node $client1 date +%s`
1307 do_node $client1 'echo hello >> '$DIR1/$tfile
1308 local d2=`do_node $client1 date +%s`
1310 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1311 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1312 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1314 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1316 for (( i=0; i < 2; i++ )) ; do
1317 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1318 [ "$mtime2" = "$mtime3" ] || \
1319 error "mtime ($mtime2) changed (to $mtime3) on rename"
1321 cancel_lru_locks osc
1322 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1325 run_test 39a "test from 11063 =================================="
1328 local client1=${CLIENT1:-`hostname`}
1329 local client2=${CLIENT2:-`hostname`}
1333 local mtime1=`stat -c %Y $DIR1/$tfile`
1334 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1337 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1339 for (( i=0; i < 2; i++ )) ; do
1340 local mtime3=`stat -c %Y $DIR1/$tfile`
1341 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1343 [ "$mtime3" = "$mtime4" ] || \
1344 error "different mtime on clients: $mtime3, $mtime4"
1345 [ "$mtime3" = $TEST_39_MTIME ] || \
1346 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1348 cancel_lru_locks osc
1349 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1352 run_test 39b "11063 problem 1 =================================="
1355 local client1=${CLIENT1:-`hostname`}
1356 local client2=${CLIENT2:-`hostname`}
1358 echo hello > $DIR1/$tfile
1360 local mtime1=`stat -c %Y $DIR1/$tfile`
1361 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1362 [ "$mtime1" = "$mtime2" ] || \
1363 error "create: different mtime on clients: $mtime1, $mtime2"
1366 $TRUNCATE $DIR1/$tfile 1
1368 for (( i=0; i < 2; i++ )) ; do
1369 local mtime3=`stat -c %Y $DIR1/$tfile`
1370 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1372 [ "$mtime3" = "$mtime4" ] || \
1373 error "different mtime on clients: $mtime3, $mtime4"
1374 [ "$mtime3" -gt $mtime2 ] || \
1375 error "truncate did not update mtime: $mtime2, $mtime3"
1377 cancel_lru_locks osc
1378 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1381 run_test 39c "check truncate mtime update ======================"
1383 test_39d() { # LU-7310
1385 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1387 local mtime1=$(stat -c %Y $DIR2/$tfile)
1388 [ "$mtime1" = $TEST_39_MTIME ] ||
1389 error "mtime: $mtime1, should be $TEST_39_MTIME"
1392 # define OBD_FAIL_OSC_NO_GRANT 0x411
1393 $LCTL set_param fail_loc=0x411
1395 local d1=$(date +%s)
1396 echo hello >> $DIR1/$tfile
1397 local d2=$(date +%s)
1399 $LCTL set_param fail_loc=0
1401 cancel_lru_locks $OSC
1403 local mtime2=$(stat -c %Y $DIR2/$tfile)
1404 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1405 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1407 run_test 39d "sync write should update mtime"
1409 # check that pid exists hence second operation wasn't blocked by first one
1410 # if it is so then there is no conflict, return 0
1411 # else second operation is conflicting with first one, return 1
1412 check_pdo_conflict() {
1415 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1416 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1426 # test 40: check non-blocking operations
1428 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1429 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1430 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1432 mkdir $DIR1/$tfile &
1435 touch $DIR2/$tfile-2
1436 check_pdo_conflict $PID1 || error "create is blocked"
1437 mkdir $DIR2/$tfile-3
1438 check_pdo_conflict $PID1 || error "mkdir is blocked"
1439 link $DIR2/$tfile-2 $DIR2/$tfile-4
1440 check_pdo_conflict $PID1 || error "link is blocked"
1441 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1442 check_pdo_conflict $PID1 || error "rename is blocked"
1443 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1444 check_pdo_conflict $PID1 || error "getattr is blocked"
1445 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1446 rmdir $DIR2/$tfile-3
1447 check_pdo_conflict $PID1 || error "unlink is blocked"
1449 # all operations above shouldn't wait the first one
1450 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1455 run_test 40a "pdirops: create vs others =============="
1458 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1459 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1460 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1461 touch $DIR1/$tfile &
1465 touch $DIR2/$tfile-2
1466 check_pdo_conflict $PID1 || error "create is blocked"
1467 mkdir $DIR2/$tfile-3
1468 check_pdo_conflict $PID1 || error "mkdir is blocked"
1469 link $DIR2/$tfile-2 $DIR2/$tfile-4
1470 check_pdo_conflict $PID1 || error "link is blocked"
1471 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1472 check_pdo_conflict $PID1 || error "rename is blocked"
1473 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1474 check_pdo_conflict $PID1 || error "getattr is blocked"
1475 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1476 rmdir $DIR2/$tfile-3
1477 check_pdo_conflict $PID1 || error "unlink is blocked"
1478 # all operations above shouldn't wait the first one
1480 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1485 run_test 40b "pdirops: open|create and others =============="
1488 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1490 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1491 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1492 link $DIR1/$tfile $DIR1/$tfile-0 &
1496 touch $DIR2/$tfile-2
1497 check_pdo_conflict $PID1 || error "create is blocked"
1498 mkdir $DIR2/$tfile-3
1499 check_pdo_conflict $PID1 || error "mkdir is blocked"
1500 link $DIR2/$tfile-2 $DIR2/$tfile-4
1501 check_pdo_conflict $PID1 || error "link is blocked"
1502 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1503 check_pdo_conflict $PID1 || error "rename is blocked"
1504 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1505 check_pdo_conflict $PID1 || error "getattr is blocked"
1506 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1507 rmdir $DIR2/$tfile-3
1508 check_pdo_conflict $PID1 || error "unlink is blocked"
1510 # all operations above shouldn't wait the first one
1511 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1516 run_test 40c "pdirops: link and others =============="
1519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1521 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1522 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1527 touch $DIR2/$tfile-2
1528 check_pdo_conflict $PID1 || error "create is blocked"
1529 mkdir $DIR2/$tfile-3
1530 check_pdo_conflict $PID1 || error "mkdir is blocked"
1531 link $DIR2/$tfile-2 $DIR2/$tfile-4
1532 check_pdo_conflict $PID1 || error "link is blocked"
1533 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1534 check_pdo_conflict $PID1 || error "rename is blocked"
1535 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1536 check_pdo_conflict $PID1 || error "getattr is blocked"
1537 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1538 rmdir $DIR2/$tfile-3
1539 check_pdo_conflict $PID1 || error "unlink is blocked"
1541 # all operations above shouldn't wait the first one
1542 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1546 run_test 40d "pdirops: unlink and others =============="
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1551 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1552 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1553 mv $DIR1/$tfile $DIR1/$tfile-0 &
1557 touch $DIR2/$tfile-2
1558 check_pdo_conflict $PID1 || error "create is blocked"
1559 mkdir $DIR2/$tfile-3
1560 check_pdo_conflict $PID1 || error "mkdir is blocked"
1561 link $DIR2/$tfile-2 $DIR2/$tfile-4
1562 check_pdo_conflict $PID1 || error "link is blocked"
1563 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1564 check_pdo_conflict $PID1 || error "getattr is blocked"
1565 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1566 rmdir $DIR2/$tfile-3
1567 check_pdo_conflict $PID1 || error "unlink is blocked"
1569 # all operations above shouldn't wait the first one
1570 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1575 run_test 40e "pdirops: rename and others =============="
1577 # test 41: create blocking operations
1579 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1580 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1581 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1584 mkdir $DIR2/$tfile && error "mkdir must fail"
1585 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1589 run_test 41a "pdirops: create vs mkdir =============="
1592 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1593 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1594 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1597 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1598 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1602 run_test 41b "pdirops: create vs create =============="
1605 touch $DIR1/$tfile-2
1606 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1607 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1608 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1611 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1612 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1616 run_test 41c "pdirops: create vs link =============="
1619 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1620 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1621 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1624 rm $DIR2/$tfile || error "unlink must succeed"
1625 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1629 run_test 41d "pdirops: create vs unlink =============="
1632 touch $DIR1/$tfile-2
1633 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1634 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1635 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1638 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1639 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1643 run_test 41e "pdirops: create and rename (tgt) =============="
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 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1652 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1656 run_test 41f "pdirops: create and rename (src) =============="
1659 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1660 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1661 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1664 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1665 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1669 run_test 41g "pdirops: create vs getattr =============="
1672 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1673 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1674 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1677 ls -lia $DIR2/ > /dev/null
1678 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1682 run_test 41h "pdirops: create vs readdir =============="
1684 # test 42: unlink and blocking operations
1686 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1687 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1688 mkdir $DIR1/$tfile &
1691 mkdir $DIR2/$tfile && error "mkdir must fail"
1692 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1696 run_test 42a "pdirops: mkdir vs mkdir =============="
1699 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1700 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1701 mkdir $DIR1/$tfile &
1704 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1705 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1709 run_test 42b "pdirops: mkdir vs create =============="
1712 touch $DIR1/$tfile-2
1713 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1714 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1715 mkdir $DIR1/$tfile &
1718 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1719 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1723 run_test 42c "pdirops: mkdir vs link =============="
1726 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1727 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1728 mkdir $DIR1/$tfile &
1731 rmdir $DIR2/$tfile || error "unlink must succeed"
1732 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1736 run_test 42d "pdirops: mkdir vs unlink =============="
1739 touch $DIR1/$tfile-2
1740 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1741 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1742 mkdir $DIR1/$tfile &
1745 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1746 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1750 run_test 42e "pdirops: mkdir and rename (tgt) =============="
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 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1763 run_test 42f "pdirops: mkdir and rename (src) =============="
1766 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1767 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1768 mkdir $DIR1/$tfile &
1771 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1772 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1776 run_test 42g "pdirops: mkdir vs getattr =============="
1779 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1780 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1781 mkdir $DIR1/$tfile &
1784 ls -lia $DIR2/ > /dev/null
1785 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1789 run_test 42h "pdirops: mkdir vs readdir =============="
1791 # test 43: unlink and blocking operations
1794 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1795 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1799 mkdir $DIR2/$tfile || error "mkdir must succeed"
1800 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1804 run_test 43a "pdirops: unlink vs mkdir =============="
1808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1809 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1813 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1818 run_test 43b "pdirops: unlink vs create =============="
1822 touch $DIR1/$tfile-2
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1828 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1833 run_test 43c "pdirops: unlink vs link =============="
1837 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1838 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1842 rm $DIR2/$tfile && error "unlink must fail"
1843 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1847 run_test 43d "pdirops: unlink vs unlink =============="
1851 touch $DIR1/$tfile-2
1852 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1853 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1857 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1858 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1862 run_test 43e "pdirops: unlink and rename (tgt) =============="
1866 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1867 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1871 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1872 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1876 run_test 43f "pdirops: unlink and rename (src) =============="
1880 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1881 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1885 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1886 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1890 run_test 43g "pdirops: unlink vs getattr =============="
1894 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1895 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1899 ls -lia $DIR2/ > /dev/null
1900 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1904 run_test 43h "pdirops: unlink vs readdir =============="
1907 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1909 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1910 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1914 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1915 check_pdo_conflict $PID1 &&
1916 { wait $PID1; error "remote mkdir isn't blocked"; }
1920 run_test 43i "pdirops: unlink vs remote mkdir"
1922 # test 44: rename tgt and blocking operations
1924 touch $DIR1/$tfile-2
1925 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1926 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1927 mv $DIR1/$tfile-2 $DIR1/$tfile &
1930 mkdir $DIR2/$tfile && error "mkdir must fail"
1931 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1935 run_test 44a "pdirops: rename tgt vs mkdir =============="
1938 touch $DIR1/$tfile-2
1939 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1940 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1941 mv $DIR1/$tfile-2 $DIR1/$tfile &
1944 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1945 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1949 run_test 44b "pdirops: rename tgt vs create =============="
1952 touch $DIR1/$tfile-2
1953 touch $DIR1/$tfile-3
1954 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1955 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1956 mv $DIR1/$tfile-2 $DIR1/$tfile &
1959 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1960 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1964 run_test 44c "pdirops: rename tgt vs link =============="
1967 touch $DIR1/$tfile-2
1968 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1969 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1970 mv $DIR1/$tfile-2 $DIR1/$tfile &
1973 rm $DIR2/$tfile || error "unlink must succeed"
1974 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1978 run_test 44d "pdirops: rename tgt vs unlink =============="
1982 touch $DIR1/$tfile-2
1983 touch $DIR1/$tfile-3
1984 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1985 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1986 mv $DIR1/$tfile-2 $DIR1/$tfile &
1989 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1990 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1994 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1997 touch $DIR1/$tfile-2
1998 touch $DIR1/$tfile-3
1999 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2000 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2001 mv $DIR1/$tfile-2 $DIR1/$tfile &
2004 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2005 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2009 run_test 44f "pdirops: rename tgt and rename (src) =============="
2012 touch $DIR1/$tfile-2
2013 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2014 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2015 mv $DIR1/$tfile-2 $DIR1/$tfile &
2018 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2019 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2023 run_test 44g "pdirops: rename tgt vs getattr =============="
2026 touch $DIR1/$tfile-2
2027 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2028 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2029 mv $DIR1/$tfile-2 $DIR1/$tfile &
2032 ls -lia $DIR2/ > /dev/null
2033 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2037 run_test 44h "pdirops: rename tgt vs readdir =============="
2039 # test 44: rename tgt and blocking operations
2041 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2042 touch $DIR1/$tfile-2
2043 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2044 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2045 mv $DIR1/$tfile-2 $DIR1/$tfile &
2048 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2049 check_pdo_conflict $PID1 && { wait $PID1;
2050 error "remote mkdir isn't blocked"; }
2054 run_test 44i "pdirops: rename tgt vs remote mkdir"
2056 # test 45: rename src and blocking operations
2059 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2060 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2061 mv $DIR1/$tfile $DIR1/$tfile-2 &
2064 mkdir $DIR2/$tfile || error "mkdir must succeed"
2065 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2069 run_test 45a "pdirops: rename src vs mkdir =============="
2073 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2074 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2075 mv $DIR1/$tfile $DIR1/$tfile-2 &
2078 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2079 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2083 run_test 45b "pdirops: rename src vs create =============="
2087 touch $DIR1/$tfile-3
2088 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2089 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2090 mv $DIR1/$tfile $DIR1/$tfile-2 &
2093 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2094 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2098 run_test 45c "pdirops: rename src vs link =============="
2102 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2103 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2104 mv $DIR1/$tfile $DIR1/$tfile-2 &
2107 rm $DIR2/$tfile && error "unlink must fail"
2108 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2112 run_test 45d "pdirops: rename src vs unlink =============="
2116 touch $DIR1/$tfile-3
2117 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2118 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2119 mv $DIR1/$tfile $DIR1/$tfile-2 &
2122 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2123 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2127 run_test 45e "pdirops: rename src and rename (tgt) =============="
2131 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2132 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2133 mv $DIR1/$tfile $DIR1/$tfile-2 &
2136 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2137 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2141 run_test 45f "pdirops: rename src and rename (src) =============="
2145 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2146 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2147 mv $DIR1/$tfile $DIR1/$tfile-2 &
2150 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2151 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2155 run_test 45g "pdirops: rename src vs getattr =============="
2159 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2160 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2161 mv $DIR1/$tfile $DIR1/$tfile-2 &
2164 ls -lia $DIR2/ > /dev/null
2165 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2169 run_test 45h "pdirops: unlink vs readdir =============="
2172 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2174 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2175 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2176 mv $DIR1/$tfile $DIR1/$tfile-2 &
2179 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2180 check_pdo_conflict $PID1 && { wait $PID1;
2181 error "create remote dir isn't blocked"; }
2185 run_test 45i "pdirops: rename src vs remote mkdir"
2187 # test 46: link and blocking operations
2189 touch $DIR1/$tfile-2
2190 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2191 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2192 link $DIR1/$tfile-2 $DIR1/$tfile &
2195 mkdir $DIR2/$tfile && error "mkdir must fail"
2196 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2200 run_test 46a "pdirops: link vs mkdir =============="
2203 touch $DIR1/$tfile-2
2204 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2205 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2206 link $DIR1/$tfile-2 $DIR1/$tfile &
2209 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2210 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2214 run_test 46b "pdirops: link vs create =============="
2217 touch $DIR1/$tfile-2
2218 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2219 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2220 link $DIR1/$tfile-2 $DIR1/$tfile &
2223 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2224 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2228 run_test 46c "pdirops: link vs link =============="
2231 touch $DIR1/$tfile-2
2232 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2233 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2234 link $DIR1/$tfile-2 $DIR1/$tfile &
2237 rm $DIR2/$tfile || error "unlink must succeed"
2238 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2242 run_test 46d "pdirops: link vs unlink =============="
2245 touch $DIR1/$tfile-2
2246 touch $DIR1/$tfile-3
2247 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2248 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2249 link $DIR1/$tfile-2 $DIR1/$tfile &
2252 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2253 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2257 run_test 46e "pdirops: link and rename (tgt) =============="
2260 touch $DIR1/$tfile-2
2261 touch $DIR1/$tfile-3
2262 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2263 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2264 link $DIR1/$tfile-2 $DIR1/$tfile &
2267 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2268 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2272 run_test 46f "pdirops: link and rename (src) =============="
2275 touch $DIR1/$tfile-2
2276 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2277 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2278 link $DIR1/$tfile-2 $DIR1/$tfile &
2281 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2282 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2286 run_test 46g "pdirops: link vs getattr =============="
2289 touch $DIR1/$tfile-2
2290 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2291 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2292 link $DIR1/$tfile-2 $DIR1/$tfile &
2295 ls -lia $DIR2/ > /dev/null
2296 check_pdo_conflict $PID1 && { wait $PID1;
2297 error "readdir isn't blocked"; }
2301 run_test 46h "pdirops: link vs readdir =============="
2304 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2305 touch $DIR1/$tfile-2
2306 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2307 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2308 link $DIR1/$tfile-2 $DIR1/$tfile &
2311 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2312 check_pdo_conflict $PID1 && { wait $PID1;
2313 error "remote mkdir isn't blocked"; }
2317 run_test 46i "pdirops: link vs remote mkdir"
2319 # test 47: remote mkdir and blocking operations
2321 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2322 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2323 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2324 $LFS mkdir -i 1 $DIR1/$tfile &
2327 mkdir $DIR2/$tfile && error "mkdir must fail"
2328 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2332 run_test 47a "pdirops: remote mkdir vs mkdir"
2335 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2336 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2337 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2338 $LFS mkdir -i 1 $DIR1/$tfile &
2341 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2342 check_pdo_conflict $PID1 && { wait $PID1;
2343 error "create isn't blocked"; }
2347 run_test 47b "pdirops: remote mkdir vs create"
2350 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2351 touch $DIR1/$tfile-2
2352 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2353 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2354 $LFS mkdir -i 1 $DIR1/$tfile &
2357 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2358 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2362 run_test 47c "pdirops: remote mkdir vs link"
2365 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2366 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2367 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2368 $LFS mkdir -i 1 $DIR1/$tfile &
2371 rmdir $DIR2/$tfile || error "unlink must succeed"
2372 check_pdo_conflict $PID1 && { wait $PID1;
2373 error "unlink isn't blocked"; }
2377 run_test 47d "pdirops: remote mkdir vs unlink"
2380 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2381 touch $DIR1/$tfile-2
2382 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2383 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2384 $LFS mkdir -i 1 $DIR1/$tfile &
2387 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2388 check_pdo_conflict $PID1 && { wait $PID1;
2389 error "rename isn't blocked"; }
2393 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2396 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2397 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2398 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2399 $LFS mkdir -i 1 $DIR1/$tfile &
2402 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2403 check_pdo_conflict $PID1 && { wait $PID1;
2404 error "rename isn't blocked"; }
2408 run_test 47f "pdirops: remote mkdir and rename (src)"
2411 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2412 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2413 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2414 $LFS mkdir -i 1 $DIR1/$tfile &
2417 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2418 check_pdo_conflict $PID1 && { wait $PID1;
2419 error "getattr isn't blocked"; }
2423 run_test 47g "pdirops: remote mkdir vs getattr"
2427 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2428 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2429 do_facet client "lctl set_param fail_loc=0x410"
2430 $TRUNCATE $DIR2/$tfile $trunc_size
2431 do_facet client "lctl set_param fail_loc=0x0"
2433 size=`stat -c %s $DIR2/$tfile`
2434 [ $size -eq $trunc_size ] || error "wrong size"
2436 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2440 local origfile=/etc/hosts
2442 filesize=$(stat -c %s $origfile)
2444 # create an empty file
2445 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2446 # cache layout lock on both mount point
2447 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2448 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2450 # open and sleep 2 seconds then read
2451 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2455 # create the layout of testing file
2456 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2457 error "dd $DIR1/$tfile failed"
2459 # MULTIOP proc should be able to read enough bytes and exit
2460 for ((i = 0; i < 6; i++)); do
2462 kill -0 $pid || break
2464 kill -0 $pid 2> /dev/null && error "multiop is still there"
2465 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2469 run_test 51a "layout lock: refresh layout should work"
2472 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2473 { skip "Need MDS version at least 2.3.59"; return 0; }
2475 local tmpfile=`mktemp`
2477 # create an empty file
2478 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2480 # delay glimpse so that layout has changed when glimpse finish
2481 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2482 $LCTL set_param fail_loc=0x1404
2483 stat -c %s $DIR2/$tfile |tee $tmpfile &
2487 # create layout of testing file
2488 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2489 error "dd $DIR1/$tfile failed"
2492 local fsize=$(cat $tmpfile)
2494 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2496 rm -f $DIR1/$tfile $tmpfile
2498 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2501 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2503 # set default layout to have 1 stripe
2505 $LFS setstripe -c 1 $DIR1/$tdir
2507 # create a file with empty layout
2508 $MCREATE $DIR1/$tdir/$tfile ||
2509 error "$MCREATE $DIR1/$tdir/$tfile failed"
2511 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2512 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2514 # change the layout of testing file
2515 echo "Setting layout to have $OSTCOUNT stripes ..."
2516 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2520 # write something to the file, it should be blocked on fetching layout
2521 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2522 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2525 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2526 # count to succeed with only 3/4 of the number of stripes (rounded up),
2527 # so creating striped files does not fail if an OST is offline or full
2528 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2529 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2533 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2536 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2537 cancel_lru_locks mdc
2539 # open should grant LAYOUT lock, mmap and read will install pages
2540 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2544 # rss before revoking
2545 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2546 echo "Before revoking layout lock: $br KB mapped"
2548 # cancel layout lock manually
2549 cancel_lru_locks mdc
2551 # rss after revoking
2552 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2555 wait $PID || error "wait PID $PID failed"
2557 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2559 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2563 echo "==> rename vs getattr vs setxattr should not deadlock"
2564 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2566 do_facet mds1 $LCTL set_param fail_loc=$1
2568 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2576 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2577 wait $PID1 || error "(3) mv failed"
2578 wait $PID2 || error "(4) stat failed"
2585 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2586 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2588 do_facet mds1 $LCTL set_param fail_loc=$1
2590 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2598 $MULTIOP $DIR2/d1/d2 Oc &
2602 stat $DIR/d1 || error "(2) stat failed"
2604 wait $PID1 || error "(3) mv failed"
2605 wait $PID2 || error "(4) stat failed"
2606 wait $PID3 && error "(5) multiop failed"
2612 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2613 save_lustre_params client "llite.*.xattr_cache" > $p
2614 lctl set_param llite.*.xattr_cache 1 ||
2615 { skip "xattr cache is not supported"; return 0; }
2617 #define OBD_FAIL_MDS_RENAME 0x153
2618 #define OBD_FAIL_MDS_RENAME2 0x154
2619 test_54_part1 0x80000153 || error 10
2620 test_54_part1 0x80000154 || error 11
2621 test_54_part2 0x80000153 || error 12
2622 test_54_part2 0x80000154 || error 13
2624 restore_lustre_params < $p
2627 run_test 54 "rename locking"
2630 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2632 #define OBD_FAIL_MDS_RENAME4 0x156
2633 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2635 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2640 wait $PID1 && error "(2) mv succeeded"
2644 run_test 55a "rename vs unlink target dir"
2648 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2650 #define OBD_FAIL_MDS_RENAME4 0x156
2651 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2653 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2658 wait $PID1 && error "(2) mv succeeded"
2662 run_test 55b "rename vs unlink source dir"
2666 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2668 #define OBD_FAIL_MDS_RENAME4 0x156
2669 do_facet mds1 $LCTL set_param fail_loc=0x156
2671 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2675 # while rename is sleeping, open and remove d3
2676 $MULTIOP $DIR2/d3 D_c &
2682 # while rename is sleeping 2nd time, close d3
2684 wait $PID2 || error "(3) multiop failed"
2686 wait $PID1 && error "(2) mv succeeded"
2690 run_test 55c "rename vs unlink orphan target dir"
2696 #define OBD_FAIL_MDS_RENAME3 0x155
2697 do_facet mds1 $LCTL set_param fail_loc=0x155
2698 mv $DIR/f1 $DIR/$tdir &
2702 # while rename is sleeping, create $tdir, but as a directory
2703 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2705 # link in reverse locking order
2706 ln $DIR2/f1 $DIR2/$tdir/
2708 wait $PID1 && error "(2) mv succeeded"
2711 run_test 55d "rename file vs link"
2714 local MDSVER=$(lustre_build_version $SINGLEMDS)
2715 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2716 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2719 test_mkdir $DIR1/$tdir
2720 file1=$DIR1/$tdir/file
2721 file2=$DIR2/$tdir/file
2723 echo orig > $file2 || error "Could not create $file2"
2724 version=$($LFS data_version $file1)
2727 echo append >> $file2 || error "Could not append to $file2"
2728 version2=$($LFS data_version $file1)
2729 [ "$version" != "$version2" ] ||
2730 error "append did not change data version: $version"
2733 echo overwrite > $file2 || error "Could not overwrite $file2"
2734 version3=$($LFS data_version $file1)
2735 [ "$version2" != "$version3" ] ||
2736 error "overwrite did not change data version: $version2"
2738 # Truncate before EOF
2739 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2740 version4=$($LFS data_version $file1)
2741 [ "$version3" != "$version4" ] ||
2742 error "truncate did not change data version: $version3"
2744 # Truncate after EOF
2745 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2746 version5=$($LFS data_version $file1)
2747 [ "$version4" != "$version5" ] ||
2748 error "truncate did not change data version: $version4"
2750 # Chmod do not change version
2751 chmod 400 $file2 || error "Could not chmod 400 $file2"
2752 version6=$($LFS data_version $file1)
2753 [ "$version5" == "$version6" ] ||
2754 error "chmod should not change data version: $version5 != $version6"
2756 # Chown do not change version
2757 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2758 version7=$($LFS data_version $file1)
2759 [ "$version5" == "$version7" ] ||
2760 error "chown should not change data version: $version5 != $version7"
2762 run_test 60 "Verify data_version behaviour"
2765 local test_dir=$tdir/test_dir
2767 mkdir -p $DIR1/$tdir
2768 if [ $MDSCOUNT -ge 2 ]; then
2770 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2771 error "Create remote directory failed"
2773 mkdir -p $DIR1/$test_dir
2775 cd $DIR2/$test_dir || error "cd directory failed"
2776 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2778 cd $DIR2/$tdir || error "exit directory"
2780 run_test 70a "cd directory && rm directory"
2782 test_70b() { # LU-2781
2784 mkdir -p $DIR1/$tdir
2786 touch $DIR1/$tdir/file
2787 for ((i = 0; i < 32; i++)); do
2788 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2790 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2792 touch $DIR1/$tdir/file
2793 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2794 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2795 rm -rf $DIR1/$tdir/test_dir ||
2796 error "cannot remove directory after rm_entry"
2797 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2799 run_test 70b "remove files after calling rm_entry"
2802 local server_version=$(lustre_version_code $SINGLEMDS)
2804 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2805 skip "Need MDS version at least 2.1.6" && return
2807 # Patch not applied to 2.2 and 2.3 branches
2808 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2809 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2810 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2813 checkfiemap --test ||
2814 { skip "checkfiemap not runnable: $?" && return; }
2815 # write data this way: hole - data - hole - data
2816 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2817 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2819 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2820 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2821 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2823 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2825 checkfiemap $DIR2/$tfile 81920 ||
2826 error "data is not flushed from client"
2827 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2830 # common case of "create file, copy file" on a single node
2831 # should not flush data from ost
2832 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2833 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2835 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2837 checkfiemap $DIR1/$tfile 81920 ||
2839 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2841 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2843 run_test 71a "correct file map just after write operation is finished"
2846 local server_version=$(lustre_version_code $SINGLEMDS)
2848 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2849 skip "Need MDS version at least 2.1.6" && return
2851 # Patch not applied to 2.2 and 2.3 branches
2852 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2853 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2854 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2856 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2858 checkfiemap --test ||
2859 { skip "error $?: checkfiemap failed" && return; }
2861 mkdir -p $DIR1/$tdir
2863 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2864 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2865 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2867 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2868 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2870 run_test 71b "check fiemap support for stripecount > 1"
2873 local p="$TMP/sanityN-$TESTNAME.parameters"
2876 save_lustre_params client "llite.*.xattr_cache" > $p
2877 lctl set_param llite.*.xattr_cache 1 ||
2878 { skip "xattr cache is not supported"; return 0; }
2881 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2882 error "setfattr1 failed"
2883 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2884 error "getfattr1 failed"
2885 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2886 error "setfattr2 failed"
2887 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2888 error "getfattr2 failed"
2890 # check that trusted.link is consistent
2891 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2892 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2893 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2894 echo "$tlink1 $tlink2"
2895 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2899 restore_lustre_params < $p
2902 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2905 local p="$TMP/sanityN-$TESTNAME.parameters"
2906 save_lustre_params client "llite.*.xattr_cache" > $p
2907 lctl set_param llite.*.xattr_cache 1 ||
2908 { skip "xattr cache is not supported"; return 0; }
2911 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2912 error "setfattr1 failed"
2913 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2914 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2915 clear_stats llite.*.stats
2916 # PR lock should be cached by now on both clients
2917 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2918 # 2 hits for getfattr(0)+getfattr(size)
2919 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2920 error "not cached in $DIR1"
2921 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2922 # 4 hits for more getfattr(0)+getfattr(size)
2923 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2924 error "not cached in $DIR2"
2927 restore_lustre_params < $p
2930 run_test 73 "getxattr should not cause xattr lock cancellation"
2933 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2934 skip "Need MDS version at least 2.4.93" && return
2936 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2937 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2938 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2940 run_test 74 "flock deadlock: different mounts =============="
2944 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2945 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2946 cancel_lru_locks osc
2948 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2951 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2952 $LCTL set_param fail_loc=0x31d
2953 stat -c %s $DIR1/$tfile &
2958 # For bad lock error handler we should ASSERT and got kernel panic here
2960 $LCTL set_param fail_loc=0
2962 run_test 75 "osc: upcall after unuse lock==================="
2965 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2966 skip "Need MDS version at least 2.5.53" && return
2968 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2969 local fcount=$((MDSCOUNT * 256))
2974 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2980 test_mkdir $DIR/$tdir
2982 # drop all open locks and close any cached "open" files on the client
2983 cancel_lru_locks mdc
2985 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2986 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2987 local already=${#fid_list[@]}
2988 for (( i = 0; i < $already; i++ )) ; do
2989 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2992 echo -n "opening files: "
2993 ulimit -n $((fcount + 50))
2994 for ((i = 0; i < $fcount; i++)); do
2995 touch $DIR/$tdir/f_$i
2996 local fd=$(free_fd ${fd_list[i]})
2997 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3002 (( $i % 32 == 0 )) && echo -n "."
3006 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3008 # Possible errors in openfiles FID list.
3009 # 1. Missing FIDs. Check 1
3010 # 2. Extra FIDs. Check 1
3011 # 3. Duplicated FID. Check 2
3012 # 4. Invalid FIDs. Check 2
3013 # 5. Valid FID, points to some other file. Check 3
3016 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3017 error "${#fid_list[@]} != $fcount (+$already old) open files"
3019 echo -n "closing files: "
3020 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3021 local close_cmd="exec ${fd_list[fd]}<&-"
3023 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3025 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3026 echo "skip old open file $filename"
3028 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3032 rm --interactive=no $filename
3034 error "Nonexisting fid ${fid_list[fid]} listed."
3035 (( $fd % 32 == 0 )) && echo -n "."
3040 ls_op=$(ls $DIR2/$tdir | wc -l)
3042 error "Some openfiles are missing in lproc output"
3046 run_test 76 "Verify MDT open_files listing"
3050 local dir=$DIR/$tdir
3053 mkdir $dir || error "mkdir $dir failed"
3054 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3057 do_nodes $CLIENTS $myRUNAS \
3058 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3059 error "dd at 0 on client failed (1)"
3061 for ((i = 0; i < $n; i++)); do
3062 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3063 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3064 error "dd at ${i}MB on client failed (2)" &
3067 do_nodes $CLIENTS sync;
3068 cancel_lru_locks osc
3070 for ((i = 0; i < $n; i++)); do
3071 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3072 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3073 error "dd at ${i}MB on client failed (3)" &
3076 cancel_lru_locks osc
3078 for ((i = 0; i < $n; i++)); do
3082 rm -rf $dir || error "rm -rf $dir failed"
3085 test_77a() { #LU-3266
3088 oss=$(comma_list $(osts_nodes))
3089 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3091 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3092 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3097 run_test 77a "check FIFO NRS policy"
3099 test_77b() { #LU-3266
3102 oss=$(comma_list $(osts_nodes))
3104 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3105 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3106 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3107 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3109 echo "policy: crr-n, crrn_quantum 1"
3112 do_nodes $oss lctl set_param \
3113 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3114 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3116 echo "policy: crr-n, crrn_quantum 64"
3120 do_nodes $oss lctl set_param \
3121 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3122 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3125 run_test 77b "check CRR-N NRS policy"
3130 oss=$(comma_list $(osts_nodes))
3132 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3133 ost.OSS.*.nrs_"$policy"_quantum=1 \
3134 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3135 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3137 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3138 "physical, ${policy}_supported reads"
3141 do_nodes $oss lctl set_param \
3142 ost.OSS.*.nrs_${policy}_supported="writes" \
3143 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3145 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3146 "physical, ${policy}_supported writes"
3149 do_nodes $oss lctl set_param \
3150 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3151 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3152 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3153 "logical, ${policy}_supported reads_and_writes"
3157 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3162 test_77c() { #LU-3266
3164 orr_trr "orr" || rc=$?
3165 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3166 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3169 run_test 77c "check ORR NRS policy"
3171 test_77d() { #LU-3266
3173 orr_trr "trr" || rc=$?
3174 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3175 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3178 run_test 77d "check TRR nrs policy"
3185 do_facet $facet lctl set_param \
3186 ost.OSS.ost_io.nrs_tbf_rule="$*"
3188 error "failed to run operate '$*' on TBF rules"
3191 cleanup_tbf_verify()
3195 echo "cleanup_tbf $DIR/$tdir"
3198 wait_delete_completed
3203 local dir=$DIR/$tdir
3204 local client1=${CLIENT1:-$(hostname)}
3207 local np=$(check_cpt_number ost1)
3208 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3209 echo "cpu_npartitions on ost1 is $np"
3211 mkdir $dir || error "mkdir $dir failed"
3212 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3215 trap cleanup_tbf_verify EXIT
3216 echo "Limited write rate: $1, read rate: $2"
3217 echo "Verify the write rate is under TBF control"
3218 local start=$SECONDS
3219 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3220 bs=1M count=100 oflag=direct 2>&1
3221 local runtime=$((SECONDS - start + 1))
3222 local rate=$(bc <<< "scale=6; 100 / $runtime")
3223 echo "Write runtime is $runtime s, speed is $rate IOPS"
3225 # verify the write rate does not exceed TBF rate limit
3226 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3227 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3229 cancel_lru_locks osc
3231 echo "Verify the read rate is under TBF control"
3233 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3234 bs=1M count=100 iflag=direct 2>&1
3235 runtime=$((SECONDS - start + 1))
3236 rate=$(bc <<< "scale=6; 100 / $runtime")
3237 echo "Read runtime is $runtime s, speed is $rate IOPS"
3239 # verify the read rate does not exceed TBF rate limit
3240 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3241 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3243 cancel_lru_locks osc
3244 cleanup_tbf_verify || error "rm -rf $dir failed"
3250 oss=$(comma_list $(osts_nodes))
3252 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3254 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3255 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3259 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3264 # Only operate rules on ost1 since OSTs might run on the same OSS
3266 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3267 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3268 local client_nids=$(nids_list $address "\\")
3269 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3270 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3274 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3275 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3276 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3280 tbf_rule_operate ost1 "stop\ localhost"
3281 tbf_rule_operate ost1 "stop\ clients"
3282 tbf_rule_operate ost1 "stop\ others"
3285 # Cleanup the TBF policy
3286 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3287 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3291 run_test 77e "check TBF NID nrs policy"
3296 oss=$(comma_list $(osts_nodes))
3298 do_nodes $oss $LCTL set_param \
3299 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3300 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3301 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3303 # Configure jobid_var
3304 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3306 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3307 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3308 if [ $saved_jobid_var != procname_uid ]; then
3309 set_conf_param_and_check client \
3310 "$LCTL get_param -n jobid_var" \
3311 "$FSNAME.sys.jobid_var" procname_uid
3316 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3321 # Only operate rules on ost1 since OSTs might run on the same OSS
3323 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3324 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3325 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3326 nrs_write_read "$RUNAS"
3329 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3330 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3331 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3332 nrs_write_read "$RUNAS"
3335 tbf_rule_operate ost1 "stop\ runas"
3336 tbf_rule_operate ost1 "stop\ iozone_runas"
3337 tbf_rule_operate ost1 "stop\ dd_runas"
3338 nrs_write_read "$RUNAS"
3340 # Cleanup the TBF policy
3341 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3342 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3343 nrs_write_read "$RUNAS"
3345 local current_jobid_var=$($LCTL get_param -n jobid_var)
3346 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3347 if [ $saved_jobid_var != $current_jobid_var ]; then
3348 set_conf_param_and_check client \
3349 "$LCTL get_param -n jobid_var" \
3350 "$FSNAME.sys.jobid_var" $saved_jobid_var
3354 run_test 77f "check TBF JobID nrs policy"
3359 oss=$(comma_list $(osts_nodes))
3361 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3363 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3364 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3366 do_nodes $oss lctl set_param \
3367 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3368 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3372 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3377 # Add a rule that only valid for Jobid TBF. If direct change between
3378 # TBF types is not supported, this operation will fail.
3379 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3381 # Cleanup the TBF policy
3382 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3383 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3386 run_test 77g "Change TBF type directly"
3389 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3390 { skip "Need OST version at least 2.8.55"; return 0; }
3392 local old_policy=$(do_facet ost1 \
3393 lctl get_param ost.OSS.ost_io.nrs_policies)
3396 do_facet ost1 lctl set_param \
3397 ost.OSS.ost_io.nrs_policies="abc"
3398 [ $? -eq 0 ] && error "should return error"
3400 do_facet ost1 lctl set_param \
3401 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3402 [ $? -eq 0 ] && error "should return error"
3404 do_facet ost1 lctl set_param \
3405 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3406 [ $? -eq 0 ] && error "should return error"
3408 do_facet ost1 lctl set_param \
3409 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3410 [ $? -eq 0 ] && error "should return error"
3412 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3413 [ $? -eq 0 ] || error "shouldn't LBUG"
3415 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3419 run_test 77h "Wrong policy name should report error, not LBUG"
3425 local error_message=$3
3427 for rule in $expected; do
3428 rule_number=$((rule_number + 1))
3430 local stop_line=$(($rule_number + 3))
3431 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3433 local output=$(do_facet $facet lctl get_param \
3434 ost.OSS.ost_io.nrs_tbf_rule |
3438 if [ "$output" != "$expected" ]; then
3439 error "$error_message, expected '$expected', got '$output'"
3444 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3445 { skip "Need OST version at least 2.8.55"; return 0; }
3447 for i in $(seq 1 $OSTCOUNT)
3449 do_facet ost"$i" lctl set_param \
3450 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3452 error "failed to set TBF policy"
3455 tbf_rule_check ost1 "default" "error before inserting any rule"
3457 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3458 tbf_rule_check ost1 "before default" \
3459 "error when inserting rule 'before'"
3461 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3462 tbf_rule_check ost1 "before after default" \
3463 "error when inserting rule 'after'"
3465 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3466 tbf_rule_check ost1 "before target after default" \
3467 "error when inserting rule 'target'"
3469 echo "Move before itself"
3470 tbf_rule_operate ost1 "change\ target\ rank=target"
3471 tbf_rule_check ost1 "before target after default" \
3472 "error when moving before itself"
3474 echo "Move to higher rank"
3475 tbf_rule_operate ost1 "change\ target\ rank=before"
3476 tbf_rule_check ost1 "target before after default" \
3477 "error when moving to higher rank"
3479 echo "Move to lower rank"
3480 tbf_rule_operate ost1 "change\ target\ rank=after"
3481 tbf_rule_check ost1 "before target after default" \
3482 "error when moving to lower rank"
3484 echo "Move before default"
3485 tbf_rule_operate ost1 "change\ target\ rank=default"
3486 tbf_rule_check ost1 "before after target default" \
3487 error "error when moving before default"
3489 # Cleanup the TBF policy
3490 do_nodes $(comma_list $(osts_nodes)) \
3491 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3494 run_test 77i "Change rank of TBF rule"
3499 local ost_version=$(lustre_version_code ost1)
3501 [ $ost_version -ge $(version_code 2.9.53) ] ||
3502 { skip "Need OST version at least 2.9.53"; return 0; }
3503 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3508 do_nodes $(comma_list $(osts_nodes)) \
3509 lctl set_param jobid_var=procname_uid \
3510 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3511 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3512 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3513 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3518 do_nodes $(comma_list $(osts_nodes)) \
3519 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3520 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3521 ost.OSS.ost_io.nrs_policies="fifo"
3523 # sleep 3 seconds to wait the tbf policy stop completely,
3524 # or the next test case is possible get -EAGAIN when
3525 # setting the tbf policy
3528 run_test 77j "check TBF-OPCode NRS policy"
3531 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3532 { skip "Need OST version at least 2.9.53"; return 0; }
3534 do_nodes $(comma_list $(osts_nodes)) \
3535 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3536 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3537 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3539 nrs_write_read "$RUNAS"
3540 tbf_verify 20 10 "$RUNAS"
3542 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3543 local client_nids=$(nids_list $address "\\")
3544 do_nodes $(comma_list $(osts_nodes)) \
3545 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3546 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3547 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3548 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3553 do_nodes $(comma_list $(osts_nodes)) \
3554 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3555 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3556 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3558 nrs_write_read "$RUNAS"
3559 tbf_verify 20 20 "$RUNAS"
3561 do_nodes $(comma_list $(osts_nodes)) \
3562 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3563 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3564 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3566 nrs_write_read "$RUNAS"
3567 # with parameter "RUNAS", it will match the latest rule
3568 # "ext_b" first, so the limited write rate is 10.
3569 tbf_verify 10 10 "$RUNAS"
3572 do_nodes $(comma_list $(osts_nodes)) \
3573 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3574 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3575 ost.OSS.ost_io.nrs_policies="fifo"
3579 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3582 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3583 { skip "Need OST version at least 2.10.56"; return 0; }
3585 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3586 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3588 local output=$(do_facet ost1 lctl get_param \
3589 ost.OSS.ost_io.nrs_policies | \
3590 awk '/name: tbf/ {print;exit}' | \
3591 awk -F ': ' '{print $2}')
3593 if [ "$output" != "tbf" ]; then
3594 error "The generic TBF output is '$output', not 'tbf'"
3597 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3599 run_test 77l "check the output of NRS policies for generic TBF"
3602 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3603 skip "Need OST version at least 2.9.54"
3607 local dir=$DIR/$tdir
3609 mkdir $dir || error "mkdir $dir failed"
3610 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3613 local nodes=$(comma_list $(osts_nodes))
3614 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3615 ost.OSS.ost_io.nrs_delay_min=4 \
3616 ost.OSS.ost_io.nrs_delay_max=4 \
3617 ost.OSS.ost_io.nrs_delay_pct=100
3618 [ $? -ne 0 ] && error "Failed to set delay policy"
3620 local start=$SECONDS
3621 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3622 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3623 oflag=direct conv=fdatasync ||
3624 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3625 error "dd on client failed (1)"; }
3626 local elapsed=$((SECONDS - start))
3628 # NRS delay doesn't do sub-second timing, so a request enqueued at
3629 # 0.9 seconds can be dequeued at 4.0
3630 [ $elapsed -lt 3 ] &&
3631 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3632 error "Single 1M write should take at least 3 seconds"; }
3635 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3636 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3637 oflag=direct conv=fdatasync ||
3638 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3639 error "dd on client failed (2)"; }
3640 elapsed=$((SECONDS - start))
3642 [ $elapsed -lt 30 ] &&
3643 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3644 error "Ten 1M writes should take at least 30 seconds"; }
3646 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3647 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3651 run_test 77m "check NRS Delay slows write RPC processing"
3653 test_78() { #LU-6673
3656 oss=$(comma_list $(osts_nodes))
3657 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3658 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3660 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3661 # Valid return codes are:
3662 # 0: Tuning succeeded
3663 # ENODEV: Policy is still stopped
3664 # EAGAIN: Policy is being initialized
3665 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3666 error "Expected set_param to return 0|ENODEV|EAGAIN"
3668 # Cleanup the ORR policy
3669 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3670 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3673 run_test 78 "Enable policy and specify tunings right away"
3676 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3677 test_mkdir $DIR/$tdir
3679 # Prevent interference from layout intent RPCs due to
3680 # asynchronous writeback. These will be tested in 130c below.
3681 do_nodes ${CLIENTS:-$HOSTNAME} sync
3683 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3684 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3686 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3687 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3688 local facet=mds$((mdtidx + 1))
3690 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3691 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3695 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3696 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3701 run_test 79 "xattr: intent error"
3704 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3711 mkdir -p $DIR1/$tdir/dir
3712 createmany -o $DIR1/$tdir/dir/f 10 ||
3713 error "create files under remote dir failed $i"
3715 cp /etc/passwd $DIR1/$tdir/$tfile
3717 #migrate open file should fails
3718 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3720 # give multiop a chance to open
3723 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3724 error "migrate open files should failed with open files"
3728 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3729 error "migrate remote dir error"
3731 echo "Finish migration, then checking.."
3732 for file in $(find $DIR1/$tdir); do
3733 mdt_index=$($LFS getstripe -M $file)
3734 [ $mdt_index == $MDTIDX ] ||
3735 error "$file is not on MDT${MDTIDX}"
3738 diff /etc/passwd $DIR1/$tdir/$tfile ||
3739 error "file different after migration"
3741 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3743 run_test 80a "migrate directory when some children is being opened"
3747 kill -9 $migrate_pid
3751 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3752 local migrate_dir1=$DIR1/$tdir/migrate_dir
3753 local migrate_dir2=$DIR2/$tdir/migrate_dir
3754 local migrate_run=$LUSTRE/tests/migrate.sh
3762 trap cleanup_80b EXIT
3763 #prepare migrate directory
3764 mkdir -p $migrate_dir1
3765 for F in {1,2,3,4,5}; do
3766 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3767 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3770 #migrate the directories among MDTs
3773 mdt_idx=$((RANDOM % MDSCOUNT))
3774 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3776 [ $rc -ne 0 -o $rc -ne 16 ] || break
3781 echo "start migration thread $migrate_pid"
3782 #Access the files at the same time
3783 start_time=$(date +%s)
3784 echo "accessing the migrating directory for 5 minutes..."
3786 ls $migrate_dir2 > /dev/null || {
3787 echo "read dir fails"
3790 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3791 echo "access file1 fails"
3795 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3796 echo "access file2/3 fails"
3800 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3801 echo "access file4 fails"
3805 stat $migrate_dir2/file5 > /dev/null || {
3806 echo "stat file5 fails"
3810 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3811 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3812 echo "touch file failed with $rc1"
3816 if [ -e $migrate_dir2/source_file ]; then
3817 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3818 &>/dev/null || rc1=$?
3819 if [ -e $migrate_dir2/link_file ]; then
3820 rm -rf $migrate_dir2/link_file
3823 mrename $migrate_dir2/source_file \
3824 $migrate_dir2/target_file &>/dev/null || rc1=$?
3825 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3826 echo "rename failed with $rc1"
3830 if [ -e $migrate_dir2/target_file ]; then
3831 rm -rf $migrate_dir2/target_file &>/dev/null ||
3834 rm -rf $migrate_dir2/source_file &>/dev/null ||
3837 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3838 echo "unlink failed with $rc1"
3843 end_time=$(date +%s)
3844 duration=$((end_time - start_time))
3845 if [ $((duration % 10)) -eq 0 ]; then
3846 if [ $show_time -eq 1 ]; then
3847 echo "...$duration seconds"
3854 kill -0 $migrate_pid || {
3855 echo "migration stopped 1"
3859 [ $duration -ge 300 ] && break
3862 #check migration are still there
3863 kill -0 $migrate_pid || error "migration stopped 2"
3866 run_test 80b "Accessing directory during migration"
3869 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3873 mkdir -p $DIR1/$tdir
3875 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3876 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3879 touch d0/0 || error "create 0 failed"
3880 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3881 stat d0/0 && error "stat mv filed succeed"
3882 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3883 stat d0/0 || error "stat failed"
3885 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3887 if [ $t -ne 3 ]; then
3888 ls -ai $DIR1/$tdir/d0
3889 error "expect 3 get $t"
3894 run_test 81 "rename and stat under striped directory"
3897 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3898 { skip "Need MDS version at least 2.6.92"; return 0; }
3900 # Client 1 creates a file.
3901 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3903 # Client 2 opens the file.
3904 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3906 # Client 1 makes the file an orphan.
3907 rm $DIR1/$tfile || error "rm"
3908 # Client 2 sets EA "user.multiop".
3910 wait $pid2 || error "multiop 2"
3911 # Client 1 gets EA "user.multiop". This used to fail because the EA
3912 # cache refill would get "trusted.link" from mdd_xattr_list() but
3913 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3916 wait $pid1 || error "multiop 1"
3918 run_test 82 "fsetxattr and fgetxattr on orphan files"
3921 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3928 $LFS mkdir -i1 -c2 $tdir
3933 echo "start pid $pid1 to create/unlink striped directory"
3935 # Access the directory at the same time
3939 stat $tdir > /dev/null 2>&1
3943 echo "start pid $pid2 to stat striped directory"
3951 run_test 83 "access striped directory while it is being created/unlinked"
3954 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3959 [ "$SLOW" = "yes" ] && duration=600
3960 # Open/Create under striped directory
3964 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3965 touch $tdir/f{0..3} > /dev/null 2>&1
3969 echo "start pid $pid1 to open/create under striped directory"
3971 # unlink the striped directory at the same time
3975 rm -rf $tdir > /dev/null 2>&1
3979 echo "start pid $pid2 to unlink striped directory"
3988 run_test 90 "open/create and unlink striped directory"
3991 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3996 [ "$SLOW" = "yes" ] && duration=600
3997 # chmod striped directory
4001 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4002 chmod go+w $tdir > /dev/null 2>&1
4006 echo "start pid $pid1 to chmod striped directory"
4008 # unlink the striped directory at the same time
4012 rm -rf $tdir > /dev/null 2>&1
4016 echo "start pid $pid2 to unlink striped directory"
4025 run_test 91 "chmod and unlink striped directory"
4028 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4031 local cmd="exec $fd<$DIR1/$tdir"
4032 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4035 trap "eval $cmd" EXIT
4036 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4037 rmdir ../$tdir || error "rmdir ../$tdir fails"
4039 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4040 $LCTL set_param fail_loc=0x1408
4041 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4042 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4043 error "create remote dir succeeds"
4044 $LCTL set_param fail_loc=0
4048 run_test 92 "create remote directory under orphan directory"
4055 mkdir -p $DIR1/$tfile-1/
4056 mkdir -p $DIR2/$tfile-2/
4057 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4058 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4059 do_facet $SINGLEMDS lctl set_param -n \
4060 'lod.lustre-MDT*/qos_threshold_rr' 100
4061 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4062 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4064 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4067 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4071 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4072 do_facet $SINGLEMDS "lctl set_param -n \
4073 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4075 $GETSTRIPE $DIR1/$tfile-1/file1
4076 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4077 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4078 $GETSTRIPE $DIR2/$tfile-2/file2
4079 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4080 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4081 echo "rc1=$rc1 and rc2=$rc2 "
4082 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4083 error "object allocate on same ost detected"
4085 run_test 93 "alloc_rr should not allocate on same ost"
4089 skip "Reserved for glimpse-ahead" && return
4090 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4091 skip "Need MDS version at least 2.10.55" && return
4095 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4097 lctl set_param -n mdc.*.stats=clear
4098 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4100 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4101 # first stat from server should return size data and save glimpse
4102 local gls=$(lctl get_param -n mdc.*.stats | \
4103 awk '/ldlm_glimpse/ {print $2}')
4104 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4105 # second stat to check size is NOT cached on client without IO lock
4106 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4108 local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l)
4109 [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls"
4112 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4115 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4116 skip "Need MDS version at least 2.10.55" && return
4120 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4122 lctl set_param -n mdc.*.stats=clear
4123 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4124 cancel_lru_locks mdc
4125 # first stat data from server should have size
4126 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4127 # second stat to check size is cached on client
4128 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4130 local gls=$(lctl get_param -n mdc.*.stats |
4131 awk '/ldlm_glimpse/ {print $2}')
4132 # both stats should cause no glimpse requests
4133 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4136 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4139 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4140 skip "Need MDS version at least 2.10.55" && return
4144 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4146 lctl set_param -n mdc.*.stats=clear
4147 lctl set_param -n osc.*.stats=clear
4148 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4150 # check that size is merged from MDT and OST correctly
4151 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4152 error "Wrong size from stat #1"
4154 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4155 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4159 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4162 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4163 skip "Need MDS version at least 2.10.55" && return
4167 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4170 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4171 lctl set_param -n mdc.*.stats=clear
4172 $TRUNCATE $DIR2/$tdir/dom 4096
4174 # check that reported size is valid after file grows to OST and
4175 # is truncated back to MDT stripe size
4176 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4177 error "Wrong size from stat #1"
4179 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4180 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4184 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4187 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4188 skip "Need MDS version at least 2.10.55" && return
4190 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4192 $CHECKSTAT -t file $DIR1/$tfile
4194 OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
4195 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
4199 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4200 error_noexit "Write fails"
4201 # must discard pages
4202 lctl set_param -n mdc.*.stats=clear
4203 rm $DIR2/$tfile || error_noexit "Unlink fails"
4204 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4205 echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
4207 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4209 run_test 101a "Discard DoM data on unlink"
4212 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4213 skip "Need MDS version at least 2.10.55" && return
4215 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4216 touch $DIR1/${tfile}_2
4218 $CHECKSTAT -t file $DIR1/$tfile
4220 OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
4221 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
4225 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4226 error_noexit "Write fails"
4227 # must discard pages
4228 lctl set_param -n mdc.*.stats=clear
4229 mv $DIR2/${tfile}_2 $DIR2/$tfile || error_noexit "Rename fails"
4230 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4231 echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
4232 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4234 run_test 101b "Discard DoM data on rename"
4237 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4238 skip "Need MDS version at least 2.10.55" && return
4240 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4242 $CHECKSTAT -t file $DIR1/$tfile
4244 OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
4245 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
4249 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4250 error_noexit "Write fails"
4251 $MULTIOP $DIR1/$tfile O_c &
4254 lctl set_param -n mdc.*.stats=clear
4255 rm $DIR2/$tfile > /dev/null || error_noexit "Unlink fails"
4256 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID ||
4257 error_noexit "multiop failure"
4258 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4259 echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
4260 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4262 run_test 101c "Discard DoM data on close-unlink"
4264 log "cleanup: ======================================================"
4266 # kill and wait in each test only guarentee script finish, but command in script
4267 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4268 # otherwise umount below will fail
4269 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4274 check_and_cleanup_lustre