6 # bug number for skipped test: 9977/LU-7105
8 ALWAYS_EXCEPT=" 28 33d 80a $SANITYN_EXCEPT"
9 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
12 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
15 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
16 OPENFILE=${OPENFILE:-openfile}
17 OPENUNLINK=${OPENUNLINK:-openunlink}
18 export MULTIOP=${MULTIOP:-multiop}
19 export TMP=${TMP:-/tmp}
20 MOUNT_2=${MOUNT_2:-"yes"}
21 CHECK_GRANT=${CHECK_GRANT:-"yes"}
22 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
26 export NAME=${NAME:-local}
28 LUSTRE=${LUSTRE:-`dirname $0`/..}
29 . $LUSTRE/tests/test-framework.sh
33 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
36 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
37 # bug number for skipped test:
38 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
39 # LU-2829 / LU-2887 - make allowances for ZFS slowness
40 TEST33_NFILES=${TEST33_NFILES:-1000}
43 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
50 check_and_setup_lustre
55 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
57 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
58 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
60 # $RUNAS_ID may get set incorrectly somewhere else
61 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
63 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
69 [ -f $DIR2/$tfile ] || error "Check create"
70 chmod 777 $DIR2/$tfile
71 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
72 error "Check attribute update for 0777"
74 chmod a-x $DIR2/$tfile
75 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
76 error "Check attribute update for 0666"
79 $CHECKSTAT -a $DIR1/$tfile ||
80 error "Check unlink - removes file on other mountpoint"
82 run_test 1 "Check attribute updates on 2 mount points"
88 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
89 error "Either not file type or perms not 0777"
91 run_test 2a "check cached attribute updates on 2 mtpt's ========"
97 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
98 error "Either not file type or perms not 0777"
100 run_test 2b "check cached attribute updates on 2 mtpt's ========"
102 # NEED TO SAVE ROOT DIR MODE
105 $CHECKSTAT -t dir -p 0777 $DIR2 ||
106 error "Either not dir type or perms not 0777"
108 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
112 $CHECKSTAT -t dir -p 0755 $DIR2 ||
113 error "Either not file type or perms not 0775"
115 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
122 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
125 run_test 2e "check chmod on root is propagated to others"
128 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
130 local remote_dir=$tdir/remote_dir
133 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
134 error "Create remote directory failed"
136 touch $DIR1/$remote_dir/$tfile ||
137 error "Create file under remote directory failed"
138 chmod 777 $DIR1/$remote_dir/$tfile ||
139 error "Chmod file under remote directory failed"
141 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
142 error "Check attr of file under remote directory failed"
144 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
145 error "Chown file under remote directory failed"
147 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
148 error "Check owner of file under remote directory failed"
150 cd $DIR2/$remote_dir || error "enter remote dir"
151 rm -rf $DIR1/$remote_dir/$tfile ||
152 error "Unlink remote directory failed"
154 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
155 error "unlink file still exists!"
157 cd $DIR2/$tdir || error "exit remote dir"
158 rm -rf $DIR1/$tdir || error "unlink directory failed"
160 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
163 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
165 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
167 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
168 echo "$DIR1/$tfile has $block1 blocks"
169 echo "$DIR2/$tfile has $block2 blocks"
170 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
172 run_test 2g "check blocks update on sync write"
175 local target="this/is/good"
176 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
177 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
178 error "link $DIR2/$tfile not as expected"
180 run_test 3 "symlink on one mtpt, readlink on another ==========="
183 multifstat $DIR1/f4 $DIR2/f4
185 run_test 4 "fstat validation on multiple mount points =========="
189 $TRUNCATE $DIR2/f5 100
190 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
191 error "Either not file type or size not equal to 100 bytes"
194 run_test 5 "create a file on one mount, truncate it on the other"
197 openunlink $DIR1/$tfile $DIR2/$tfile || \
198 error "openunlink $DIR1/$tfile $DIR2/$tfile"
200 run_test 6 "remove of open file on other node =================="
204 opendirunlink $DIR1/$dir $DIR2/$dir || \
205 error "opendirunlink $DIR1/$dir $DIR2/$dir"
207 run_test 7 "remove of open directory on other node ============="
210 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
211 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
213 run_test 8 "remove of open special file on other node =========="
219 for C in a b c d e f g h i j k l; do
220 dir=`eval echo \\$DIR$MTPT`
221 echo -n $C >> $dir/f9
222 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
224 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
225 error "`od -a $DIR1/f9` != abcdefghijkl"
227 run_test 9a "append of file with sub-page size on multiple mounts"
229 #LU-10681 - tiny writes & appending to sparse striped file
231 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
233 $LFS setstripe -c 2 -S 1M $DIR/$tfile
234 echo "foo" >> $DIR/$tfile
235 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
236 error "sparse dd $DIR2/$tfile failed"
237 echo "foo" >> $DIR/$tfile
239 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
240 echo "Data read (expecting 'foo')": $data
241 [ "$data" = "foo" ] || error "append to sparse striped file failed"
243 run_test 9b "append to striped sparse file"
250 for C in a b c d e f g h i j k l; do
251 dir=`eval echo \\$DIR$MTPT`
252 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
253 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
254 OFFSET=`expr $OFFSET + 1`
256 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
257 error "`od -a $DIR1/f10` != abcdefghijkl"
259 run_test 10a "write of file with sub-page size on multiple mounts "
263 yes "R" | head -c 4000 >$TMP/f10b-seed
264 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
266 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
268 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
270 # create a test file locally to compare
271 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
272 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
273 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
274 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
276 run_test 10b "write of file with sub-page size on multiple mounts "
280 multiop_bg_pause $DIR1/d11/f O_c || return 1
282 cp -p /bin/ls $DIR1/d11/f
286 wait $MULTIPID || error "wait for PID $MULTIPID failed"
287 [ $RC -eq 0 ] && error || true
289 run_test 11 "execution of file opened for write should return error ===="
292 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
294 run_test 12 "test lock ordering (link, stat, unlink)"
296 test_13() { # bug 2451 - directory coherency
298 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
300 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
302 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
303 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
304 # need to run it twice
305 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
307 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
308 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
310 run_test 13 "test directory page revocation"
313 test_mkdir $DIR1/$tdir
314 cp -p /bin/ls $DIR1/$tdir/$tfile
315 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
318 $DIR2/$tdir/$tfile && error || true
320 wait $MULTIPID || return 2
322 run_test 14aa "execution of file open for write returns -ETXTBSY"
325 test_mkdir $DIR1/$tdir
326 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
327 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
330 $MULTIOP $DIR2/$tdir/multiop Oc && error "expected error, got success"
331 kill -USR1 $MULTIOP_PID || return 2
332 wait $MULTIOP_PID || return 3
333 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
335 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
337 test_14b() { # bug 3192, 7040
338 test_mkdir $DIR1/$tdir
339 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
340 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
343 $TRUNCATE $DIR2/$tdir/multiop 0 && kill -9 $MULTIOP_PID && \
344 error "expected truncate error, got success"
345 kill -USR1 $MULTIOP_PID || return 2
346 wait $MULTIOP_PID || return 3
347 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
348 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
350 run_test 14b "truncate of executing file returns -ETXTBSY ======"
352 test_14c() { # bug 3430, 7040
353 test_mkdir $DIR1/$tdir
354 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
355 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
358 cp /etc/hosts $DIR2/$tdir/multiop && error "expected error, got success"
359 kill -USR1 $MULTIOP_PID || return 2
360 wait $MULTIOP_PID || return 3
361 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
362 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
364 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
366 test_14d() { # bug 10921
367 test_mkdir $DIR1/$tdir
368 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
369 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
373 chmod 600 $DIR1/$tdir/multiop || error "chmod failed"
374 kill -USR1 $MULTIOP_PID || return 2
375 wait $MULTIOP_PID || return 3
376 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
377 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
379 run_test 14d "chmod of executing file is still possible ========"
381 test_15() { # bug 974 - ENOSPC
383 sh oos2.sh $MOUNT1 $MOUNT2
384 wait_delete_completed
385 grant_error=`dmesg | grep "> available"`
386 [ -z "$grant_error" ] || error "$grant_error"
388 run_test 15 "test out-of-space with multiple writers ==========="
391 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
392 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
393 # pass a 2500 operation dual-mount run within the time limit.
394 if [ "$(facet_fstype ost1)" = "zfs" ]; then
395 FSXNUM=$((COUNT / 5))
397 elif [ "$SLOW" = "yes" ]; then
398 FSXNUM=$((COUNT * 5))
406 local file1=$DIR1/$tfile
407 local file2=$DIR2/$tfile
408 local stripe_size=$(do_facet $SINGLEMDS \
409 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
411 # to allocate grant because it may run out due to test_15.
412 $LFS setstripe -c -1 $file1
413 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
414 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
417 $LFS setstripe -c -1 $file1 # b=10919
418 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
419 || error "fsx failed"
422 # O_DIRECT reads and writes must be aligned to the device block size.
423 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
424 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
426 run_test 16a "$FSXNUM iterations of dual-mount fsx"
428 # Consistency check for tiny writes, LU-9409
430 local file1=$DIR1/$tfile
431 local file2=$DIR2/$tfile
433 # to allocate grant because it may run out due to test_15.
434 lfs setstripe -c -1 $file1
435 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
436 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
439 lfs setstripe -c -1 $file1 # b=10919
440 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
441 # create a mix of tiny writes & normal writes
442 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
445 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
447 test_17() { # bug 3513, 3667
448 remote_ost_nodsh && skip "remote OST with nodsh" && return
450 lfs setstripe $DIR1/$tfile -i 0 -c 1
451 cp $SAMPLE_FILE $DIR1/$tfile
452 cancel_lru_locks osc > /dev/null
453 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
454 do_facet ost1 lctl set_param fail_loc=0x8000030a
455 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
456 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
458 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
460 run_test 17 "resource creation/LVB creation race ==============="
463 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
466 for idx in {a..z}; do
467 local ptr=EXCEPT_ALWAYS_18$idx
468 [ x${!ptr} = xtrue ] || continue
470 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
473 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
476 run_test 18 "mmap sanity check ================================="
478 test_19() { # bug3811
479 local node=$(facet_active_host ost1)
481 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
483 # check whether obdfilter is cache capable at all
484 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
485 echo "not cache-capable obdfilter"
489 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
491 set_osd_param $node '' readcache_max_filesize 4096
492 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
493 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
494 cp $TMP/$tfile $DIR1/$tfile
495 for i in `seq 1 20`; do
496 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
497 cancel_lru_locks $OSC > /dev/null
498 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
499 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
501 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
502 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
503 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
504 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
506 set_osd_param $node '' readcache_max_filesize $MAX
509 run_test 19 "test concurrent uncached read races ==============="
513 cancel_lru_locks $OSC
514 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
515 $MULTIOP $DIR1/f20 Ow8190c
516 $MULTIOP $DIR2/f20 Oz8194w8190c
517 $MULTIOP $DIR1/f20 Oz0r8190c
518 cancel_lru_locks $OSC
519 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
521 error $CNTD" page left in cache after lock cancel" || true
523 run_test 20 "test extra readahead page left in cache ===="
530 test_21() { # Bug 5907
531 test_mkdir $DIR1/$tdir
532 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
534 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
535 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
536 test -d $DIR1/$tdir || error "Mounted directory disappeared"
538 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
541 run_test 21 " Try to remove mountpoint on another dir ===="
543 test_23() { # Bug 5972
544 local at_diff=$(do_facet $SINGLEMDS \
545 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
546 echo "atime should be updated while another read" > $DIR1/$tfile
548 # clear the lock(mode: LCK_PW) gotten from creating operation
549 cancel_lru_locks $OSC
552 sleep $((at_diff + 1))
554 echo "starting reads"
555 multiop_bg_pause $DIR1/$tfile or20_c || return 1
556 # with SOM and opencache enabled, we need to close a file and cancel
557 # open lock to get atime propogated to MDS
558 kill -USR1 $! || return 2
561 time2=$(stat -c "%X" $DIR/$tfile)
562 echo "new atime is $time2"
564 [ $time2 -gt $time1 ] || error "atime was not updated"
565 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
568 run_test 23 " others should see updated atime while another read===="
572 lfs df || error "lfs df failed"
573 lfs df -ih || error "lfs df -ih failed"
574 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
575 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
576 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
577 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
579 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
580 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
581 lctl --device %osc deactivate
582 lfs df -i || error "lfs df -i with deactivated OSC failed"
583 lctl --device %osc activate
584 lfs df || error "lfs df with reactivated OSC failed"
586 run_test 24a "lfs df [-ih] [path] test ========================="
590 fsnum=$(lfs_df | grep -c "summary")
591 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
593 run_test 24b "lfs df should show both filesystems ==============="
596 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
598 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
601 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
602 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
604 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
605 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
606 error "setfacl $DIR2/$tdir #1"
607 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
608 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
609 error "setfacl $DIR2/$tdir #2"
610 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
611 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
612 error "setfacl $DIR2/$tdir #3"
613 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
614 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
615 error "setfacl $DIR2/$tdir #4"
616 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
620 run_test 25a "change ACL on one mountpoint be seen on another ==="
623 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
625 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
630 $LFS mkdir -i 1 $DIR1/$tdir
631 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
632 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
634 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
635 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
636 error "setfacl $DIR2/$tdir #1"
637 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
638 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
639 error "setfacl $DIR2/$tdir #2"
640 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
641 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
642 error "setfacl $DIR2/$tdir #3"
643 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
644 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
645 error "setfacl $DIR2/$tdir #4"
646 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
650 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
653 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
655 run_test 26a "allow mtime to get older"
660 echo "aaa" >> $DIR1/$tfile
662 chmod a+x $DIR2/$tfile
663 mt1=`stat -c %Y $DIR1/$tfile`
664 mt2=`stat -c %Y $DIR2/$tfile`
666 if [ x"$mt1" != x"$mt2" ]; then
667 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
670 run_test 26b "sync mtime between ost and mds"
673 cancel_lru_locks $OSC
675 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
680 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
685 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
687 lctl set_param -n ldlm.dump_namespaces ""
688 wait $DD1_PID $DD2_PID
689 [ $? -ne 0 ] && lctl dk $TMP/debug || true
691 run_test 27 "align non-overlapping extent locks from request ==="
693 test_28() { # bug 9977
694 ECHO_UUID="ECHO_osc1_UUID"
695 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
697 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
698 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
699 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
703 attach echo_client ECHO_osc1 $ECHO_UUID
707 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
708 $LCTL --device $tECHOID destroy "${tOBJID}:0"
716 # reading of 1st stripe should pass
717 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
718 # reading of 2nd stripe should fail (this stripe was destroyed)
719 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
721 # now, recreating test file
722 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
723 # reading of 1st stripe should pass
724 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
725 # reading of 2nd stripe should pass
726 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
729 run_test 28 "read/write/truncate file with lost stripes"
731 test_30() { #b=11110, LU-2523
732 test_mkdir $DIR1/$tdir
733 cp -f /bin/bash $DIR1/$tdir/bash
734 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
735 $DIR1/$tdir/bash -c 'sleep 2;
736 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
740 run_test 30 "recreate file race"
743 test_mkdir $DIR1/$tdir
744 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
745 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
746 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
747 lctl set_param fail_loc=0x314
748 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
749 awk 'BEGIN { FS="+" } /in/ {print $1}')
750 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
752 run_test 31a "voluntary cancel / blocking ast race=============="
755 remote_ost || { skip "local OST" && return 0; }
756 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
758 # make sure there is no local locks due to destroy
759 wait_mds_ost_sync || error "wait_mds_ost_sync()"
760 wait_delete_completed || error "wait_delete_completed()"
762 test_mkdir $DIR1/$tdir
763 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
764 cp /etc/hosts $DIR/$tdir/$tfile
765 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
766 lctl set_param fail_loc=0x314
767 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
768 do_facet ost1 lctl set_param fail_loc=0x316
770 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
771 lctl set_param fail_loc=0
772 do_facet ost1 lctl set_param fail_loc=0
773 # cleanup: reconnect the client back
776 run_test 31b "voluntary OST cancel / blocking ast race=============="
778 # enable/disable lockless truncate feature, depending on the arg 0/1
779 enable_lockless_truncate() {
780 lctl set_param -n $OSC.*.lockless_truncate $1
783 test_32a() { # bug 11270
784 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
785 local stripe_size=$(do_facet $SINGLEMDS \
786 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
788 save_lustre_params client "$OSC.*.lockless_truncate" > $p
789 cancel_lru_locks $OSC
790 enable_lockless_truncate 1
792 lfs setstripe -c -1 $DIR1/$tfile
793 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
795 clear_stats $OSC.*.${OSC}_stats
797 log "checking cached lockless truncate"
798 $TRUNCATE $DIR1/$tfile 8000000
799 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
800 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
801 error "cached truncate isn't lockless"
803 log "checking not cached lockless truncate"
804 $TRUNCATE $DIR2/$tfile 5000000
805 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
806 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
807 error "not cached truncate isn't lockless"
809 log "disabled lockless truncate"
810 enable_lockless_truncate 0
811 clear_stats $OSC.*.${OSC}_stats
812 $TRUNCATE $DIR2/$tfile 3000000
813 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
814 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
815 error "lockless truncate disabling failed"
817 # restore lockless_truncate default values
818 restore_lustre_params < $p
821 run_test 32a "lockless truncate"
823 test_32b() { # bug 11270
824 remote_ost_nodsh && skip "remote OST with nodsh" && return
827 local facets=$(get_facets OST)
828 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
830 save_lustre_params client "osc.*.contention_seconds" > $p
831 save_lustre_params $facets \
832 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
833 save_lustre_params $facets \
834 "ldlm.namespaces.filter-*.contended_locks" >> $p
835 save_lustre_params $facets \
836 "ldlm.namespaces.filter-*.contention_seconds" >> $p
837 clear_stats $OSC.*.${OSC}_stats
839 # agressive lockless i/o settings
840 do_nodes $(comma_list $(osts_nodes)) \
841 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
842 ldlm.namespaces.filter-*.contended_locks=0 \
843 ldlm.namespaces.filter-*.contention_seconds=60"
844 lctl set_param -n $OSC.*.contention_seconds=60
846 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
848 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
851 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
852 error "lockless i/o was not triggered"
853 # disable lockless i/o (it is disabled by default)
854 do_nodes $(comma_list $(osts_nodes)) \
855 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
856 ldlm.namespaces.filter-*.contended_locks=32 \
857 ldlm.namespaces.filter-*.contention_seconds=0"
858 # set contention_seconds to 0 at client too, otherwise Lustre still
859 # remembers lock contention
860 lctl set_param -n $OSC.*.contention_seconds=0
861 clear_stats $OSC.*.${OSC}_stats
863 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
865 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
868 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
869 error "lockless i/o works when disabled"
871 restore_lustre_params <$p
874 run_test 32b "lockless i/o"
878 local mdts=$(get_facets MDS)
883 for mds in ${mdts//,/ }; do
885 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
886 xargs readlink -f" ))
887 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
890 stat=$(( stat + val))
895 # commit on sharing tests
897 remote_mds_nodsh && skip "remote MDS with nodsh" && return
899 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
900 [ $CLIENTCOUNT -lt 2 ] &&
901 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
903 local nfiles=${TEST33_NFILES:-10000}
904 local param_file=$TMP/$tfile-params
905 local fstype=$(facet_fstype $SINGLEMDS)
907 save_lustre_params $(get_facets MDS) \
908 "mdt.*.commit_on_sharing" > $param_file
916 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
920 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
922 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
923 echo "=== START createmany old: $jbdold transaction"
924 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")
925 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
926 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
927 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
928 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
929 avgtime=$(( avgtime + elapsed ))
931 eval cos${COS}_jbd=$((avgjbd / 3))
932 eval cos${COS}_time=$((avgtime / 3))
935 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
936 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
937 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
938 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
940 restore_lustre_params < $param_file
944 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
946 # commit on sharing tests
948 remote_mds_nodsh && skip "remote MDS with nodsh" && return
950 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
951 [ $CLIENTCOUNT -ge 2 ] ||
952 { skip "Need two or more clients, have $CLIENTCOUNT" &&
954 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
956 local nfiles=${TEST33_NFILES:-10000}
957 local param_file=$TMP/$tfile-params
959 save_lustre_params $(get_facets MDS) \
960 "mdt.*.commit_on_sharing" > $param_file
969 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
973 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
974 $DIR1/$tdir-\\\$(hostname)-$i"
976 jbdold=$(print_jbd_stat)
977 echo "=== START createmany old: $jbdold transaction"
978 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
979 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
980 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
982 jbdnew=$(print_jbd_stat)
983 jbd=$(( jbdnew - jbdold ))
984 echo "=== END createmany new: $jbdnew transaction : \
985 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
986 avgjbd=$(( avgjbd + jbd ))
987 avgtime=$(( avgtime + elapsed ))
989 eval cos${COS}_jbd=$((avgjbd / 3))
990 eval cos${COS}_time=$((avgtime / 3))
993 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
994 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
995 [ "$cos0_jbd" != 0 ] &&
996 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
997 [ "$cos0_time" != 0 ] &&
998 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1000 restore_lustre_params < $param_file
1004 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1007 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1008 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1009 skip "DNE CoS not supported" && return
1015 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1016 # do twice in case transaction is committed before unlock, see LU-8200
1018 # remote dir is created on MDT1, which enqueued lock of $tdir on
1020 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1021 mkdir $DIR/$tdir/local.$i
1023 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1024 echo "sync_count $sync_count"
1025 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1028 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1029 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1030 # during sleep remote mkdir should have been committed and canceled
1031 # remote lock spontaneously, which shouldn't trigger sync
1033 mkdir $DIR/$tdir/local.3
1034 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1035 echo "sync_count $sync_count"
1036 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1038 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1040 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1044 local nodes=$(comma_list $(mdts_nodes))
1048 # trigger CoS twice in case transaction commit before unlock
1051 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1053 commit_nr=$(do_nodes $nodes \
1054 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1055 total=$((total + commit_nr));
1060 echo "CoS count $total"
1061 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1065 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1066 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1067 skip "DNE CoS not supported" && return
1069 # remote directory create
1070 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1071 # remote directory unlink
1072 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1073 # striped directory create
1074 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1075 # striped directory setattr
1076 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1077 "chmod 713 $DIR/$tdir"
1078 # striped directory unlink
1079 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1082 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1083 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1084 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1085 touch $DIR/$tdir/d1/tgt" \
1086 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1088 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1089 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1090 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1091 touch $DIR/$tdir/d1/src" \
1092 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1094 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1095 "$LFS migrate -m 1 $DIR/$tdir"
1099 run_test 33d "DNE distributed operation should trigger COS"
1102 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1103 [ $CLIENTCOUNT -ge 2 ] ||
1104 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1106 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1107 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1108 skip "DNE CoS not supported" && return
1110 local client2=${CLIENT2:-$(hostname)}
1114 local nodes=$(comma_list $(mdts_nodes))
1115 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1117 $LFS mkdir -c 2 $DIR/$tdir
1118 mkdir $DIR/$tdir/subdir
1119 echo abc > $DIR/$tdir/$tfile
1120 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1121 do_node $client2 touch $DIR/$tdir/subdir
1123 local async_commit_count=$(do_nodes $nodes \
1124 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1125 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1129 run_test 33e "DNE local operation shouldn't trigger COS"
1131 # End commit on sharing tests
1133 get_ost_lock_timeouts() {
1134 local nodes=${1:-$(comma_list $(osts_nodes))}
1136 local locks=$(do_nodes $nodes \
1137 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1145 do_nodes $(comma_list $(osts_nodes)) \
1146 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1147 for i in $(seq $OSTCOUNT); do
1148 wait_osc_import_ready client ost$i
1153 remote_ost_nodsh && skip "remote OST with nodsh" && return
1157 trap cleanup_34 EXIT RETURN
1158 for OPER in notimeout timeout ; do
1159 rm $DIR1/$tfile 2>/dev/null
1160 lock_in=$(get_ost_lock_timeouts)
1161 if [ $OPER == "timeout" ] ; then
1162 for j in `seq $OSTCOUNT`; do
1163 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1164 do_facet ost$j lctl set_param fail_loc=0x511
1166 echo lock should expire
1168 for j in `seq $OSTCOUNT`; do
1169 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1170 do_facet ost$j lctl set_param fail_loc=0x512
1172 echo lock should not expire
1174 echo writing on client1
1175 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1177 echo reading on client2
1178 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1179 # wait for a lock timeout
1181 lock_out=$(get_ost_lock_timeouts)
1182 if [ $OPER == "timeout" ] ; then
1183 if [ $lock_in == $lock_out ]; then
1184 error "no lock timeout happened"
1189 if [ $lock_in != $lock_out ]; then
1190 error "lock timeout happened"
1198 run_test 34 "no lock timeout under IO"
1200 test_35() { # bug 17645
1203 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1204 awk '/generation/{print $2}')
1206 generation[count]=$g
1210 test_mkdir $MOUNT1/$tdir
1211 cancel_lru_locks mdc
1213 # Let's initiate -EINTR situation by setting fail_loc and take
1214 # write lock on same file from same client. This will not cause
1215 # bl_ast yet as lock is already in local cache.
1216 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1217 do_facet client "lctl set_param fail_loc=0x80000317"
1218 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1219 let timeout=timeout*3
1221 while test $nr -lt 10; do
1222 log "Race attempt $nr"
1223 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1224 awk '/ldlm_bl_callback/ { print $2 }')
1225 test "x$blk1" = "x" && blk1=0
1226 createmany -o $MOUNT2/$tdir/a 4000 &
1230 # Let's make conflict and bl_ast
1231 ls -la $MOUNT1/$tdir > /dev/null &
1234 log "Wait for $pid1 $pid2 for $timeout sec..."
1236 kill -9 $pid1 $pid2 > /dev/null 2>&1
1238 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1239 awk '/ldlm_bl_callback/ { print $2 }')
1240 test "x$blk2" = "x" && blk2=0
1241 test $blk2 -gt $blk1 && break
1242 rm -fr $MOUNT1/$tdir
1243 cancel_lru_locks mdc
1246 do_facet client "lctl set_param fail_loc=0x0"
1247 df -h $MOUNT1 $MOUNT2
1249 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1250 awk '/generation/{print $2}')
1252 if ! test "$g" -eq "${generation[count]}"; then
1253 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1255 for imp in $list; do
1256 if [ $c = $count ]; then
1261 imp=$(echo "$imp" | awk -F"." '{print $2}')
1262 error "Eviction happened on import $imp"
1267 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1269 test_36() { #bug 16417
1274 test_mkdir $DIR1/$tdir
1275 $LFS setstripe -c -1 $DIR1/$tdir
1278 let SIZE_B=SIZE*1024*1024
1279 sync; sleep 2; sync # wait for delete thread
1280 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1281 wait_destroy_complete || error "wait_destroy_complete failed"
1283 while [ $i -le 10 ]; do
1284 lctl mark "start test - cycle ($i)"
1285 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1286 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1287 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1288 sync # sync data from client cache
1289 sync_all_data # sync data from server cache (delayed allocation)
1291 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1292 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1294 rm -f $DIR1/$tdir/$tfile
1295 kill -USR1 $read_pid
1297 sync; sleep 2; sync # Ensure new statfs
1298 wait_delete_completed
1299 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1300 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1302 # this free space! not used
1303 (( $after_dd <= $after)) ||
1304 error "space leaked after_dd:$after_dd > after:$after"
1308 run_test 36 "handle ESTALE/open-unlink correctly"
1310 test_37() { # bug 18695
1311 test_mkdir $DIR1/$tdir
1312 multiop_bg_pause $DIR1/$tdir D_c || return 1
1314 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1315 createmany -m $DIR2/$tdir/f 10000
1316 # set mtime/atime backward
1317 touch -t 198001010000 $DIR2/$tdir
1318 kill -USR1 $MULTIPID
1319 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1320 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1323 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1325 # this should be set to past
1326 TEST_39_MTIME=`date -d "1 year ago" +%s`
1330 local client1=${CLIENT1:-`hostname`}
1331 local client2=${CLIENT2:-`hostname`}
1333 do_node $client1 "touch $DIR1/$tfile"
1335 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1336 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1337 [ "$mtime1" = $TEST_39_MTIME ] || \
1338 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1340 local d1=`do_node $client1 date +%s`
1341 do_node $client1 'echo hello >> '$DIR1/$tfile
1342 local d2=`do_node $client1 date +%s`
1344 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1345 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1346 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1348 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1350 for (( i=0; i < 2; i++ )) ; do
1351 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1352 [ "$mtime2" = "$mtime3" ] || \
1353 error "mtime ($mtime2) changed (to $mtime3) on rename"
1355 cancel_lru_locks osc
1356 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1359 run_test 39a "test from 11063 =================================="
1362 local client1=${CLIENT1:-`hostname`}
1363 local client2=${CLIENT2:-`hostname`}
1367 local mtime1=`stat -c %Y $DIR1/$tfile`
1368 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1371 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1373 for (( i=0; i < 2; i++ )) ; do
1374 local mtime3=`stat -c %Y $DIR1/$tfile`
1375 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1377 [ "$mtime3" = "$mtime4" ] || \
1378 error "different mtime on clients: $mtime3, $mtime4"
1379 [ "$mtime3" = $TEST_39_MTIME ] || \
1380 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1382 cancel_lru_locks osc
1383 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1386 run_test 39b "11063 problem 1 =================================="
1389 local client1=${CLIENT1:-`hostname`}
1390 local client2=${CLIENT2:-`hostname`}
1392 echo hello > $DIR1/$tfile
1394 local mtime1=`stat -c %Y $DIR1/$tfile`
1395 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1396 [ "$mtime1" = "$mtime2" ] || \
1397 error "create: different mtime on clients: $mtime1, $mtime2"
1400 $TRUNCATE $DIR1/$tfile 1
1402 for (( i=0; i < 2; i++ )) ; do
1403 local mtime3=`stat -c %Y $DIR1/$tfile`
1404 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1406 [ "$mtime3" = "$mtime4" ] || \
1407 error "different mtime on clients: $mtime3, $mtime4"
1408 [ "$mtime3" -gt $mtime2 ] || \
1409 error "truncate did not update mtime: $mtime2, $mtime3"
1411 cancel_lru_locks osc
1412 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1415 run_test 39c "check truncate mtime update ======================"
1417 test_39d() { # LU-7310
1419 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1421 local mtime1=$(stat -c %Y $DIR2/$tfile)
1422 [ "$mtime1" = $TEST_39_MTIME ] ||
1423 error "mtime: $mtime1, should be $TEST_39_MTIME"
1426 # define OBD_FAIL_OSC_NO_GRANT 0x411
1427 $LCTL set_param fail_loc=0x411
1429 local d1=$(date +%s)
1430 echo hello >> $DIR1/$tfile
1431 local d2=$(date +%s)
1433 $LCTL set_param fail_loc=0
1435 cancel_lru_locks $OSC
1437 local mtime2=$(stat -c %Y $DIR2/$tfile)
1438 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1439 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1441 run_test 39d "sync write should update mtime"
1443 # check that pid exists hence second operation wasn't blocked by first one
1444 # if it is so then there is no conflict, return 0
1445 # else second operation is conflicting with first one, return 1
1446 check_pdo_conflict() {
1449 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1450 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1460 # test 40: check non-blocking operations
1462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1463 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1464 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1466 mkdir $DIR1/$tfile &
1469 touch $DIR2/$tfile-2
1470 check_pdo_conflict $PID1 || error "create is blocked"
1471 mkdir $DIR2/$tfile-3
1472 check_pdo_conflict $PID1 || error "mkdir is blocked"
1473 link $DIR2/$tfile-2 $DIR2/$tfile-4
1474 check_pdo_conflict $PID1 || error "link is blocked"
1475 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1476 check_pdo_conflict $PID1 || error "rename is blocked"
1477 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1478 check_pdo_conflict $PID1 || error "getattr is blocked"
1479 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1480 rmdir $DIR2/$tfile-3
1481 check_pdo_conflict $PID1 || error "unlink is blocked"
1483 # all operations above shouldn't wait the first one
1484 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1489 run_test 40a "pdirops: create vs others =============="
1492 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1493 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1494 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1495 touch $DIR1/$tfile &
1499 touch $DIR2/$tfile-2
1500 check_pdo_conflict $PID1 || error "create is blocked"
1501 mkdir $DIR2/$tfile-3
1502 check_pdo_conflict $PID1 || error "mkdir is blocked"
1503 link $DIR2/$tfile-2 $DIR2/$tfile-4
1504 check_pdo_conflict $PID1 || error "link is blocked"
1505 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1506 check_pdo_conflict $PID1 || error "rename is blocked"
1507 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1508 check_pdo_conflict $PID1 || error "getattr is blocked"
1509 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1510 rmdir $DIR2/$tfile-3
1511 check_pdo_conflict $PID1 || error "unlink is blocked"
1512 # all operations above shouldn't wait the first one
1514 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1519 run_test 40b "pdirops: open|create and others =============="
1522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1524 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1525 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1526 link $DIR1/$tfile $DIR1/$tfile-0 &
1530 touch $DIR2/$tfile-2
1531 check_pdo_conflict $PID1 || error "create is blocked"
1532 mkdir $DIR2/$tfile-3
1533 check_pdo_conflict $PID1 || error "mkdir is blocked"
1534 link $DIR2/$tfile-2 $DIR2/$tfile-4
1535 check_pdo_conflict $PID1 || error "link is blocked"
1536 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1537 check_pdo_conflict $PID1 || error "rename is blocked"
1538 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1539 check_pdo_conflict $PID1 || error "getattr is blocked"
1540 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1541 rmdir $DIR2/$tfile-3
1542 check_pdo_conflict $PID1 || error "unlink is blocked"
1544 # all operations above shouldn't wait the first one
1545 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1550 run_test 40c "pdirops: link and others =============="
1553 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1555 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1556 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1561 touch $DIR2/$tfile-2
1562 check_pdo_conflict $PID1 || error "create is blocked"
1563 mkdir $DIR2/$tfile-3
1564 check_pdo_conflict $PID1 || error "mkdir is blocked"
1565 link $DIR2/$tfile-2 $DIR2/$tfile-4
1566 check_pdo_conflict $PID1 || error "link is blocked"
1567 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1568 check_pdo_conflict $PID1 || error "rename is blocked"
1569 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1570 check_pdo_conflict $PID1 || error "getattr is blocked"
1571 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1572 rmdir $DIR2/$tfile-3
1573 check_pdo_conflict $PID1 || error "unlink is blocked"
1575 # all operations above shouldn't wait the first one
1576 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1580 run_test 40d "pdirops: unlink and others =============="
1583 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1585 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1586 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1587 mv $DIR1/$tfile $DIR1/$tfile-0 &
1591 touch $DIR2/$tfile-2
1592 check_pdo_conflict $PID1 || error "create is blocked"
1593 mkdir $DIR2/$tfile-3
1594 check_pdo_conflict $PID1 || error "mkdir is blocked"
1595 link $DIR2/$tfile-2 $DIR2/$tfile-4
1596 check_pdo_conflict $PID1 || error "link is blocked"
1597 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1598 check_pdo_conflict $PID1 || error "getattr is blocked"
1599 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1600 rmdir $DIR2/$tfile-3
1601 check_pdo_conflict $PID1 || error "unlink is blocked"
1603 # all operations above shouldn't wait the first one
1604 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1609 run_test 40e "pdirops: rename and others =============="
1611 # test 41: create blocking operations
1613 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1614 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1615 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1618 mkdir $DIR2/$tfile && error "mkdir must fail"
1619 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1623 run_test 41a "pdirops: create vs mkdir =============="
1626 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1627 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1628 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1631 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1632 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1636 run_test 41b "pdirops: create vs create =============="
1639 touch $DIR1/$tfile-2
1640 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1641 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1642 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1645 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1646 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1650 run_test 41c "pdirops: create vs link =============="
1653 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1654 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1655 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1658 rm $DIR2/$tfile || error "unlink must succeed"
1659 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1663 run_test 41d "pdirops: create vs unlink =============="
1666 touch $DIR1/$tfile-2
1667 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1668 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1669 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1672 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1673 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1677 run_test 41e "pdirops: create and rename (tgt) =============="
1680 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1681 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1682 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1685 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1686 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1690 run_test 41f "pdirops: create and rename (src) =============="
1693 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1694 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1695 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1698 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1699 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1703 run_test 41g "pdirops: create vs getattr =============="
1706 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1707 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1708 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1711 ls -lia $DIR2/ > /dev/null
1712 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1716 run_test 41h "pdirops: create vs readdir =============="
1718 # test 42: unlink and blocking operations
1720 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1721 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1722 mkdir $DIR1/$tfile &
1725 mkdir $DIR2/$tfile && error "mkdir must fail"
1726 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1730 run_test 42a "pdirops: mkdir vs mkdir =============="
1733 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1734 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1735 mkdir $DIR1/$tfile &
1738 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1739 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1743 run_test 42b "pdirops: mkdir vs create =============="
1746 touch $DIR1/$tfile-2
1747 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1748 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1749 mkdir $DIR1/$tfile &
1752 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1753 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1757 run_test 42c "pdirops: mkdir vs link =============="
1760 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1761 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1762 mkdir $DIR1/$tfile &
1765 rmdir $DIR2/$tfile || error "unlink must succeed"
1766 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1770 run_test 42d "pdirops: mkdir vs unlink =============="
1773 touch $DIR1/$tfile-2
1774 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1775 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1776 mkdir $DIR1/$tfile &
1779 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1780 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1784 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1787 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1788 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1789 mkdir $DIR1/$tfile &
1792 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1793 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1797 run_test 42f "pdirops: mkdir and rename (src) =============="
1800 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1801 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1802 mkdir $DIR1/$tfile &
1805 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1806 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1810 run_test 42g "pdirops: mkdir vs getattr =============="
1813 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1814 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1815 mkdir $DIR1/$tfile &
1818 ls -lia $DIR2/ > /dev/null
1819 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1823 run_test 42h "pdirops: mkdir vs readdir =============="
1825 # test 43: unlink and blocking operations
1828 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1829 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1833 mkdir $DIR2/$tfile || error "mkdir must succeed"
1834 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1838 run_test 43a "pdirops: unlink vs mkdir =============="
1842 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1843 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1847 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1848 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1852 run_test 43b "pdirops: unlink vs create =============="
1856 touch $DIR1/$tfile-2
1857 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1858 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1862 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1863 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1867 run_test 43c "pdirops: unlink vs link =============="
1871 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1872 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1876 rm $DIR2/$tfile && error "unlink must fail"
1877 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1881 run_test 43d "pdirops: unlink vs unlink =============="
1885 touch $DIR1/$tfile-2
1886 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1887 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1891 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1892 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1896 run_test 43e "pdirops: unlink and rename (tgt) =============="
1900 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1901 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1905 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1906 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1910 run_test 43f "pdirops: unlink and rename (src) =============="
1914 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1915 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1919 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1920 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1924 run_test 43g "pdirops: unlink vs getattr =============="
1928 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1929 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1933 ls -lia $DIR2/ > /dev/null
1934 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1938 run_test 43h "pdirops: unlink vs readdir =============="
1941 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1943 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1944 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1948 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1949 check_pdo_conflict $PID1 &&
1950 { wait $PID1; error "remote mkdir isn't blocked"; }
1954 run_test 43i "pdirops: unlink vs remote mkdir"
1956 # test 44: rename tgt and blocking operations
1958 touch $DIR1/$tfile-2
1959 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1960 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1961 mv $DIR1/$tfile-2 $DIR1/$tfile &
1964 mkdir $DIR2/$tfile && error "mkdir must fail"
1965 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1969 run_test 44a "pdirops: rename tgt vs mkdir =============="
1972 touch $DIR1/$tfile-2
1973 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1974 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1975 mv $DIR1/$tfile-2 $DIR1/$tfile &
1978 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1979 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1983 run_test 44b "pdirops: rename tgt vs create =============="
1986 touch $DIR1/$tfile-2
1987 touch $DIR1/$tfile-3
1988 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1990 mv $DIR1/$tfile-2 $DIR1/$tfile &
1993 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1994 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1998 run_test 44c "pdirops: rename tgt vs link =============="
2001 touch $DIR1/$tfile-2
2002 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2003 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2004 mv $DIR1/$tfile-2 $DIR1/$tfile &
2007 rm $DIR2/$tfile || error "unlink must succeed"
2008 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2012 run_test 44d "pdirops: rename tgt vs unlink =============="
2016 touch $DIR1/$tfile-2
2017 touch $DIR1/$tfile-3
2018 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2019 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2020 mv $DIR1/$tfile-2 $DIR1/$tfile &
2023 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2024 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2028 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2031 touch $DIR1/$tfile-2
2032 touch $DIR1/$tfile-3
2033 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2034 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2035 mv $DIR1/$tfile-2 $DIR1/$tfile &
2038 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2039 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2043 run_test 44f "pdirops: rename tgt and rename (src) =============="
2046 touch $DIR1/$tfile-2
2047 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2048 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2049 mv $DIR1/$tfile-2 $DIR1/$tfile &
2052 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2053 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2057 run_test 44g "pdirops: rename tgt vs getattr =============="
2060 touch $DIR1/$tfile-2
2061 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2062 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2063 mv $DIR1/$tfile-2 $DIR1/$tfile &
2066 ls -lia $DIR2/ > /dev/null
2067 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2071 run_test 44h "pdirops: rename tgt vs readdir =============="
2073 # test 44: rename tgt and blocking operations
2075 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2076 touch $DIR1/$tfile-2
2077 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2078 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2079 mv $DIR1/$tfile-2 $DIR1/$tfile &
2082 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2083 check_pdo_conflict $PID1 && { wait $PID1;
2084 error "remote mkdir isn't blocked"; }
2088 run_test 44i "pdirops: rename tgt vs remote mkdir"
2090 # test 45: rename src and blocking operations
2093 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2094 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2095 mv $DIR1/$tfile $DIR1/$tfile-2 &
2098 mkdir $DIR2/$tfile || error "mkdir must succeed"
2099 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2103 run_test 45a "pdirops: rename src vs mkdir =============="
2107 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2108 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2109 mv $DIR1/$tfile $DIR1/$tfile-2 &
2112 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2113 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2117 run_test 45b "pdirops: rename src vs create =============="
2121 touch $DIR1/$tfile-3
2122 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2123 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2124 mv $DIR1/$tfile $DIR1/$tfile-2 &
2127 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2128 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2132 run_test 45c "pdirops: rename src vs link =============="
2136 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2137 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2138 mv $DIR1/$tfile $DIR1/$tfile-2 &
2141 rm $DIR2/$tfile && error "unlink must fail"
2142 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2146 run_test 45d "pdirops: rename src vs unlink =============="
2150 touch $DIR1/$tfile-3
2151 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2152 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2153 mv $DIR1/$tfile $DIR1/$tfile-2 &
2156 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2157 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2161 run_test 45e "pdirops: rename src and rename (tgt) =============="
2165 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2166 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2167 mv $DIR1/$tfile $DIR1/$tfile-2 &
2170 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2171 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2175 run_test 45f "pdirops: rename src and rename (src) =============="
2179 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2180 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2181 mv $DIR1/$tfile $DIR1/$tfile-2 &
2184 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2185 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2189 run_test 45g "pdirops: rename src vs getattr =============="
2193 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2194 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2195 mv $DIR1/$tfile $DIR1/$tfile-2 &
2198 ls -lia $DIR2/ > /dev/null
2199 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2203 run_test 45h "pdirops: unlink vs readdir =============="
2206 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2208 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2209 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2210 mv $DIR1/$tfile $DIR1/$tfile-2 &
2213 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2214 check_pdo_conflict $PID1 && { wait $PID1;
2215 error "create remote dir isn't blocked"; }
2219 run_test 45i "pdirops: rename src vs remote mkdir"
2221 # test 46: link and blocking operations
2223 touch $DIR1/$tfile-2
2224 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2225 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2226 link $DIR1/$tfile-2 $DIR1/$tfile &
2229 mkdir $DIR2/$tfile && error "mkdir must fail"
2230 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2234 run_test 46a "pdirops: link vs mkdir =============="
2237 touch $DIR1/$tfile-2
2238 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2239 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2240 link $DIR1/$tfile-2 $DIR1/$tfile &
2243 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2244 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2248 run_test 46b "pdirops: link vs create =============="
2251 touch $DIR1/$tfile-2
2252 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2253 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2254 link $DIR1/$tfile-2 $DIR1/$tfile &
2257 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2258 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2262 run_test 46c "pdirops: link vs link =============="
2265 touch $DIR1/$tfile-2
2266 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2267 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2268 link $DIR1/$tfile-2 $DIR1/$tfile &
2271 rm $DIR2/$tfile || error "unlink must succeed"
2272 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2276 run_test 46d "pdirops: link vs unlink =============="
2279 touch $DIR1/$tfile-2
2280 touch $DIR1/$tfile-3
2281 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2282 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2283 link $DIR1/$tfile-2 $DIR1/$tfile &
2286 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2287 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2291 run_test 46e "pdirops: link and rename (tgt) =============="
2294 touch $DIR1/$tfile-2
2295 touch $DIR1/$tfile-3
2296 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2297 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2298 link $DIR1/$tfile-2 $DIR1/$tfile &
2301 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2302 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2306 run_test 46f "pdirops: link and rename (src) =============="
2309 touch $DIR1/$tfile-2
2310 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2311 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2312 link $DIR1/$tfile-2 $DIR1/$tfile &
2315 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2316 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2320 run_test 46g "pdirops: link vs getattr =============="
2323 touch $DIR1/$tfile-2
2324 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2325 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2326 link $DIR1/$tfile-2 $DIR1/$tfile &
2329 ls -lia $DIR2/ > /dev/null
2330 check_pdo_conflict $PID1 && { wait $PID1;
2331 error "readdir isn't blocked"; }
2335 run_test 46h "pdirops: link vs readdir =============="
2338 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2339 touch $DIR1/$tfile-2
2340 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2341 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2342 link $DIR1/$tfile-2 $DIR1/$tfile &
2345 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2346 check_pdo_conflict $PID1 && { wait $PID1;
2347 error "remote mkdir isn't blocked"; }
2351 run_test 46i "pdirops: link vs remote mkdir"
2353 # test 47: remote mkdir and blocking operations
2355 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2356 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2357 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2358 $LFS mkdir -i 1 $DIR1/$tfile &
2361 mkdir $DIR2/$tfile && error "mkdir must fail"
2362 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2366 run_test 47a "pdirops: remote mkdir vs mkdir"
2369 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2370 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2371 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2372 $LFS mkdir -i 1 $DIR1/$tfile &
2375 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2376 check_pdo_conflict $PID1 && { wait $PID1;
2377 error "create isn't blocked"; }
2381 run_test 47b "pdirops: remote mkdir vs create"
2384 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2385 touch $DIR1/$tfile-2
2386 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2387 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2388 $LFS mkdir -i 1 $DIR1/$tfile &
2391 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2392 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2396 run_test 47c "pdirops: remote mkdir vs link"
2399 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2400 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2401 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2402 $LFS mkdir -i 1 $DIR1/$tfile &
2405 rmdir $DIR2/$tfile || error "unlink must succeed"
2406 check_pdo_conflict $PID1 && { wait $PID1;
2407 error "unlink isn't blocked"; }
2411 run_test 47d "pdirops: remote mkdir vs unlink"
2414 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2415 touch $DIR1/$tfile-2
2416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2417 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2418 $LFS mkdir -i 1 $DIR1/$tfile &
2421 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2422 check_pdo_conflict $PID1 && { wait $PID1;
2423 error "rename isn't blocked"; }
2427 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2430 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2431 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2432 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2433 $LFS mkdir -i 1 $DIR1/$tfile &
2436 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2437 check_pdo_conflict $PID1 && { wait $PID1;
2438 error "rename isn't blocked"; }
2442 run_test 47f "pdirops: remote mkdir and rename (src)"
2445 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2446 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2447 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2448 $LFS mkdir -i 1 $DIR1/$tfile &
2451 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2452 check_pdo_conflict $PID1 && { wait $PID1;
2453 error "getattr isn't blocked"; }
2457 run_test 47g "pdirops: remote mkdir vs getattr"
2461 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2462 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2463 do_facet client "lctl set_param fail_loc=0x410"
2464 $TRUNCATE $DIR2/$tfile $trunc_size
2465 do_facet client "lctl set_param fail_loc=0x0"
2467 size=`stat -c %s $DIR2/$tfile`
2468 [ $size -eq $trunc_size ] || error "wrong size"
2470 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2474 local origfile=/etc/hosts
2476 filesize=$(stat -c %s $origfile)
2478 # create an empty file
2479 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2480 # cache layout lock on both mount point
2481 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2482 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2484 # open and sleep 2 seconds then read
2485 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2489 # create the layout of testing file
2490 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2491 error "dd $DIR1/$tfile failed"
2493 # MULTIOP proc should be able to read enough bytes and exit
2494 for ((i = 0; i < 6; i++)); do
2496 kill -0 $pid || break
2498 kill -0 $pid 2> /dev/null && error "multiop is still there"
2499 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2503 run_test 51a "layout lock: refresh layout should work"
2506 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2507 { skip "Need MDS version at least 2.3.59"; return 0; }
2509 local tmpfile=`mktemp`
2511 # create an empty file
2512 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2514 # delay glimpse so that layout has changed when glimpse finish
2515 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2516 $LCTL set_param fail_loc=0x1404
2517 stat -c %s $DIR2/$tfile |tee $tmpfile &
2521 # create layout of testing file
2522 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2523 error "dd $DIR1/$tfile failed"
2526 local fsize=$(cat $tmpfile)
2528 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2530 rm -f $DIR1/$tfile $tmpfile
2532 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2535 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2537 # set default layout to have 1 stripe
2539 $LFS setstripe -c 1 $DIR1/$tdir
2541 # create a file with empty layout
2542 $MCREATE $DIR1/$tdir/$tfile ||
2543 error "$MCREATE $DIR1/$tdir/$tfile failed"
2545 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2546 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2548 # change the layout of testing file
2549 echo "Setting layout to have $OSTCOUNT stripes ..."
2550 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2554 # write something to the file, it should be blocked on fetching layout
2555 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2556 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2559 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2560 # count to succeed with only 3/4 of the number of stripes (rounded up),
2561 # so creating striped files does not fail if an OST is offline or full
2562 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2563 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2567 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2570 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2571 cancel_lru_locks mdc
2573 # open should grant LAYOUT lock, mmap and read will install pages
2574 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2578 # rss before revoking
2579 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2580 echo "Before revoking layout lock: $br KB mapped"
2582 # cancel layout lock manually
2583 cancel_lru_locks mdc
2585 # rss after revoking
2586 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2589 wait $PID || error "wait PID $PID failed"
2591 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2593 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2597 echo "==> rename vs getattr vs setxattr should not deadlock"
2598 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2600 do_facet mds1 $LCTL set_param fail_loc=$1
2602 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2610 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2611 wait $PID1 || error "(3) mv failed"
2612 wait $PID2 || error "(4) stat failed"
2619 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2620 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2622 do_facet mds1 $LCTL set_param fail_loc=$1
2624 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2632 $MULTIOP $DIR2/d1/d2 Oc &
2636 stat $DIR/d1 || error "(2) stat failed"
2638 wait $PID1 || error "(3) mv failed"
2639 wait $PID2 || error "(4) stat failed"
2640 wait $PID3 && error "(5) multiop failed"
2646 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2647 save_lustre_params client "llite.*.xattr_cache" > $p
2648 lctl set_param llite.*.xattr_cache 1 ||
2649 { skip "xattr cache is not supported"; return 0; }
2651 #define OBD_FAIL_MDS_RENAME 0x153
2652 #define OBD_FAIL_MDS_RENAME2 0x154
2653 test_54_part1 0x80000153 || error 10
2654 test_54_part1 0x80000154 || error 11
2655 test_54_part2 0x80000153 || error 12
2656 test_54_part2 0x80000154 || error 13
2658 restore_lustre_params < $p
2661 run_test 54 "rename locking"
2664 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2666 #define OBD_FAIL_MDS_RENAME4 0x156
2667 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2669 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2674 wait $PID1 && error "(2) mv succeeded"
2678 run_test 55a "rename vs unlink target dir"
2682 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2684 #define OBD_FAIL_MDS_RENAME4 0x156
2685 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2687 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2692 wait $PID1 && error "(2) mv succeeded"
2696 run_test 55b "rename vs unlink source dir"
2700 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2702 #define OBD_FAIL_MDS_RENAME4 0x156
2703 do_facet mds1 $LCTL set_param fail_loc=0x156
2705 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2709 # while rename is sleeping, open and remove d3
2710 $MULTIOP $DIR2/d3 D_c &
2716 # while rename is sleeping 2nd time, close d3
2718 wait $PID2 || error "(3) multiop failed"
2720 wait $PID1 && error "(2) mv succeeded"
2724 run_test 55c "rename vs unlink orphan target dir"
2730 #define OBD_FAIL_MDS_RENAME3 0x155
2731 do_facet mds1 $LCTL set_param fail_loc=0x155
2732 mv $DIR/f1 $DIR/$tdir &
2736 # while rename is sleeping, create $tdir, but as a directory
2737 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2739 # link in reverse locking order
2740 ln $DIR2/f1 $DIR2/$tdir/
2742 wait $PID1 && error "(2) mv succeeded"
2745 run_test 55d "rename file vs link"
2748 local MDSVER=$(lustre_build_version $SINGLEMDS)
2749 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2750 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2753 test_mkdir $DIR1/$tdir
2754 file1=$DIR1/$tdir/file
2755 file2=$DIR2/$tdir/file
2757 echo orig > $file2 || error "Could not create $file2"
2758 version=$($LFS data_version $file1)
2761 echo append >> $file2 || error "Could not append to $file2"
2762 version2=$($LFS data_version $file1)
2763 [ "$version" != "$version2" ] ||
2764 error "append did not change data version: $version"
2767 echo overwrite > $file2 || error "Could not overwrite $file2"
2768 version3=$($LFS data_version $file1)
2769 [ "$version2" != "$version3" ] ||
2770 error "overwrite did not change data version: $version2"
2772 # Truncate before EOF
2773 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2774 version4=$($LFS data_version $file1)
2775 [ "$version3" != "$version4" ] ||
2776 error "truncate did not change data version: $version3"
2778 # Truncate after EOF
2779 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2780 version5=$($LFS data_version $file1)
2781 [ "$version4" != "$version5" ] ||
2782 error "truncate did not change data version: $version4"
2784 # Chmod do not change version
2785 chmod 400 $file2 || error "Could not chmod 400 $file2"
2786 version6=$($LFS data_version $file1)
2787 [ "$version5" == "$version6" ] ||
2788 error "chmod should not change data version: $version5 != $version6"
2790 # Chown do not change version
2791 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2792 version7=$($LFS data_version $file1)
2793 [ "$version5" == "$version7" ] ||
2794 error "chown should not change data version: $version5 != $version7"
2796 run_test 60 "Verify data_version behaviour"
2799 local test_dir=$tdir/test_dir
2801 mkdir -p $DIR1/$tdir
2802 if [ $MDSCOUNT -ge 2 ]; then
2804 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2805 error "Create remote directory failed"
2807 mkdir -p $DIR1/$test_dir
2809 cd $DIR2/$test_dir || error "cd directory failed"
2810 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2812 cd $DIR2/$tdir || error "exit directory"
2814 run_test 70a "cd directory && rm directory"
2816 test_70b() { # LU-2781
2818 mkdir -p $DIR1/$tdir
2820 touch $DIR1/$tdir/file
2821 for ((i = 0; i < 32; i++)); do
2822 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2824 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2826 touch $DIR1/$tdir/file
2827 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2828 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2829 rm -rf $DIR1/$tdir/test_dir ||
2830 error "cannot remove directory after rm_entry"
2831 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2833 run_test 70b "remove files after calling rm_entry"
2836 local server_version=$(lustre_version_code $SINGLEMDS)
2838 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2839 skip "Need MDS version at least 2.1.6" && return
2841 # Patch not applied to 2.2 and 2.3 branches
2842 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2843 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2844 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2847 checkfiemap --test ||
2848 { skip "checkfiemap not runnable: $?" && return; }
2849 # write data this way: hole - data - hole - data
2850 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2851 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2853 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2854 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2855 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2857 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2859 checkfiemap $DIR2/$tfile 81920 ||
2860 error "data is not flushed from client"
2861 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2864 # common case of "create file, copy file" on a single node
2865 # should not flush data from ost
2866 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2867 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2869 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2871 checkfiemap $DIR1/$tfile 81920 ||
2873 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2875 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2877 run_test 71a "correct file map just after write operation is finished"
2880 local server_version=$(lustre_version_code $SINGLEMDS)
2882 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2883 skip "Need MDS version at least 2.1.6" && return
2885 # Patch not applied to 2.2 and 2.3 branches
2886 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2887 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2888 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2890 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2892 checkfiemap --test ||
2893 { skip "error $?: checkfiemap failed" && return; }
2895 mkdir -p $DIR1/$tdir
2897 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2898 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2899 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2901 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2902 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2904 run_test 71b "check fiemap support for stripecount > 1"
2907 local p="$TMP/sanityN-$TESTNAME.parameters"
2910 save_lustre_params client "llite.*.xattr_cache" > $p
2911 lctl set_param llite.*.xattr_cache 1 ||
2912 { skip "xattr cache is not supported"; return 0; }
2915 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2916 error "setfattr1 failed"
2917 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2918 error "getfattr1 failed"
2919 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2920 error "setfattr2 failed"
2921 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2922 error "getfattr2 failed"
2924 # check that trusted.link is consistent
2925 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2926 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2927 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2928 echo "$tlink1 $tlink2"
2929 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2933 restore_lustre_params < $p
2936 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2939 local p="$TMP/sanityN-$TESTNAME.parameters"
2940 save_lustre_params client "llite.*.xattr_cache" > $p
2941 lctl set_param llite.*.xattr_cache 1 ||
2942 { skip "xattr cache is not supported"; return 0; }
2945 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2946 error "setfattr1 failed"
2947 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2948 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2949 clear_stats llite.*.stats
2950 # PR lock should be cached by now on both clients
2951 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2952 # 2 hits for getfattr(0)+getfattr(size)
2953 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2954 error "not cached in $DIR1"
2955 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2956 # 4 hits for more getfattr(0)+getfattr(size)
2957 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2958 error "not cached in $DIR2"
2961 restore_lustre_params < $p
2964 run_test 73 "getxattr should not cause xattr lock cancellation"
2967 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2968 skip "Need MDS version at least 2.4.93" && return
2970 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2971 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2972 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2974 run_test 74 "flock deadlock: different mounts =============="
2978 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2979 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2980 cancel_lru_locks osc
2982 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2985 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2986 $LCTL set_param fail_loc=0x31d
2987 stat -c %s $DIR1/$tfile &
2992 # For bad lock error handler we should ASSERT and got kernel panic here
2994 $LCTL set_param fail_loc=0
2996 run_test 75 "osc: upcall after unuse lock==================="
2999 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3000 skip "Need MDS version at least 2.5.53" && return
3002 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3003 local fcount=$((MDSCOUNT * 256))
3008 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3014 test_mkdir $DIR/$tdir
3016 # drop all open locks and close any cached "open" files on the client
3017 cancel_lru_locks mdc
3019 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3020 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3021 local already=${#fid_list[@]}
3022 for (( i = 0; i < $already; i++ )) ; do
3023 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3026 echo -n "opening files: "
3027 ulimit -n $((fcount + 50))
3028 for ((i = 0; i < $fcount; i++)); do
3029 touch $DIR/$tdir/f_$i
3030 local fd=$(free_fd ${fd_list[i]})
3031 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3036 (( $i % 32 == 0 )) && echo -n "."
3040 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3042 # Possible errors in openfiles FID list.
3043 # 1. Missing FIDs. Check 1
3044 # 2. Extra FIDs. Check 1
3045 # 3. Duplicated FID. Check 2
3046 # 4. Invalid FIDs. Check 2
3047 # 5. Valid FID, points to some other file. Check 3
3050 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3051 error "${#fid_list[@]} != $fcount (+$already old) open files"
3053 echo -n "closing files: "
3054 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3055 local close_cmd="exec ${fd_list[fd]}<&-"
3057 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3059 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3060 echo "skip old open file $filename"
3062 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3066 rm --interactive=no $filename
3068 error "Nonexisting fid ${fid_list[fid]} listed."
3069 (( $fd % 32 == 0 )) && echo -n "."
3074 ls_op=$(ls $DIR2/$tdir | wc -l)
3076 error "Some openfiles are missing in lproc output"
3080 run_test 76 "Verify MDT open_files listing"
3084 local dir=$DIR/$tdir
3087 mkdir $dir || error "mkdir $dir failed"
3088 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3091 do_nodes $CLIENTS $myRUNAS \
3092 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3093 error "dd at 0 on client failed (1)"
3095 for ((i = 0; i < $n; i++)); do
3096 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3097 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3098 error "dd at ${i}MB on client failed (2)" &
3101 do_nodes $CLIENTS sync;
3102 cancel_lru_locks osc
3104 for ((i = 0; i < $n; i++)); do
3105 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3106 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3107 error "dd at ${i}MB on client failed (3)" &
3110 cancel_lru_locks osc
3112 for ((i = 0; i < $n; i++)); do
3116 rm -rf $dir || error "rm -rf $dir failed"
3119 test_77a() { #LU-3266
3122 oss=$(comma_list $(osts_nodes))
3123 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3125 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3126 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3131 run_test 77a "check FIFO NRS policy"
3133 test_77b() { #LU-3266
3136 oss=$(comma_list $(osts_nodes))
3138 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3139 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3140 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3141 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3143 echo "policy: crr-n, crrn_quantum 1"
3146 do_nodes $oss lctl set_param \
3147 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3148 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3150 echo "policy: crr-n, crrn_quantum 64"
3154 do_nodes $oss lctl set_param \
3155 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3156 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3159 run_test 77b "check CRR-N NRS policy"
3164 oss=$(comma_list $(osts_nodes))
3166 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3167 ost.OSS.*.nrs_"$policy"_quantum=1 \
3168 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3169 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3171 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3172 "physical, ${policy}_supported reads"
3175 do_nodes $oss lctl set_param \
3176 ost.OSS.*.nrs_${policy}_supported="writes" \
3177 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3179 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3180 "physical, ${policy}_supported writes"
3183 do_nodes $oss lctl set_param \
3184 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3185 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3186 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3187 "logical, ${policy}_supported reads_and_writes"
3191 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3196 test_77c() { #LU-3266
3198 orr_trr "orr" || rc=$?
3199 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3200 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3203 run_test 77c "check ORR NRS policy"
3205 test_77d() { #LU-3266
3207 orr_trr "trr" || rc=$?
3208 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3209 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3212 run_test 77d "check TRR nrs policy"
3219 do_facet $facet lctl set_param \
3220 ost.OSS.ost_io.nrs_tbf_rule="$*"
3222 error "failed to run operate '$*' on TBF rules"
3225 cleanup_tbf_verify()
3229 echo "cleanup_tbf $DIR/$tdir"
3232 wait_delete_completed
3237 local dir=$DIR/$tdir
3238 local client1=${CLIENT1:-$(hostname)}
3241 local np=$(check_cpt_number ost1)
3242 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3243 echo "cpu_npartitions on ost1 is $np"
3245 mkdir $dir || error "mkdir $dir failed"
3246 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3249 trap cleanup_tbf_verify EXIT
3250 echo "Limited write rate: $1, read rate: $2"
3251 echo "Verify the write rate is under TBF control"
3252 local start=$SECONDS
3253 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3254 bs=1M count=100 oflag=direct 2>&1
3255 local runtime=$((SECONDS - start + 1))
3256 local rate=$(bc <<< "scale=6; 100 / $runtime")
3257 echo "Write runtime is $runtime s, speed is $rate IOPS"
3259 # verify the write rate does not exceed TBF rate limit
3260 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3261 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3263 cancel_lru_locks osc
3265 echo "Verify the read rate is under TBF control"
3267 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3268 bs=1M count=100 iflag=direct 2>&1
3269 runtime=$((SECONDS - start + 1))
3270 rate=$(bc <<< "scale=6; 100 / $runtime")
3271 echo "Read runtime is $runtime s, speed is $rate IOPS"
3273 # verify the read rate does not exceed TBF rate limit
3274 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3275 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3277 cancel_lru_locks osc
3278 cleanup_tbf_verify || error "rm -rf $dir failed"
3284 oss=$(comma_list $(osts_nodes))
3286 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3288 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3289 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3293 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3298 # Only operate rules on ost1 since OSTs might run on the same OSS
3300 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3301 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3302 local client_nids=$(nids_list $address "\\")
3303 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3304 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3308 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3309 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3310 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3314 tbf_rule_operate ost1 "stop\ localhost"
3315 tbf_rule_operate ost1 "stop\ clients"
3316 tbf_rule_operate ost1 "stop\ others"
3319 # Cleanup the TBF policy
3320 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3321 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3325 run_test 77e "check TBF NID nrs policy"
3330 oss=$(comma_list $(osts_nodes))
3332 do_nodes $oss $LCTL set_param \
3333 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3334 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3335 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3337 # Configure jobid_var
3338 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3340 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3341 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3342 if [ $saved_jobid_var != procname_uid ]; then
3343 set_conf_param_and_check client \
3344 "$LCTL get_param -n jobid_var" \
3345 "$FSNAME.sys.jobid_var" procname_uid
3350 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3355 # Only operate rules on ost1 since OSTs might run on the same OSS
3357 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3358 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3359 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3360 nrs_write_read "$RUNAS"
3363 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3364 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3365 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3366 nrs_write_read "$RUNAS"
3369 tbf_rule_operate ost1 "stop\ runas"
3370 tbf_rule_operate ost1 "stop\ iozone_runas"
3371 tbf_rule_operate ost1 "stop\ dd_runas"
3372 nrs_write_read "$RUNAS"
3374 # Cleanup the TBF policy
3375 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3376 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3377 nrs_write_read "$RUNAS"
3379 local current_jobid_var=$($LCTL get_param -n jobid_var)
3380 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3381 if [ $saved_jobid_var != $current_jobid_var ]; then
3382 set_conf_param_and_check client \
3383 "$LCTL get_param -n jobid_var" \
3384 "$FSNAME.sys.jobid_var" $saved_jobid_var
3388 run_test 77f "check TBF JobID nrs policy"
3393 oss=$(comma_list $(osts_nodes))
3395 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3397 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3398 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3400 do_nodes $oss lctl set_param \
3401 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3402 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3406 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3411 # Add a rule that only valid for Jobid TBF. If direct change between
3412 # TBF types is not supported, this operation will fail.
3413 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3415 # Cleanup the TBF policy
3416 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3417 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3420 run_test 77g "Change TBF type directly"
3423 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3424 { skip "Need OST version at least 2.8.55"; return 0; }
3426 local old_policy=$(do_facet ost1 \
3427 lctl get_param ost.OSS.ost_io.nrs_policies)
3430 do_facet ost1 lctl set_param \
3431 ost.OSS.ost_io.nrs_policies="abc"
3432 [ $? -eq 0 ] && error "should return error"
3434 do_facet ost1 lctl set_param \
3435 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3436 [ $? -eq 0 ] && error "should return error"
3438 do_facet ost1 lctl set_param \
3439 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3440 [ $? -eq 0 ] && error "should return error"
3442 do_facet ost1 lctl set_param \
3443 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3444 [ $? -eq 0 ] && error "should return error"
3446 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3447 [ $? -eq 0 ] || error "shouldn't LBUG"
3449 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3453 run_test 77h "Wrong policy name should report error, not LBUG"
3459 local error_message=$3
3461 for rule in $expected; do
3462 rule_number=$((rule_number + 1))
3464 local stop_line=$(($rule_number + 3))
3465 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3467 local output=$(do_facet $facet lctl get_param \
3468 ost.OSS.ost_io.nrs_tbf_rule |
3472 if [ "$output" != "$expected" ]; then
3473 error "$error_message, expected '$expected', got '$output'"
3478 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3479 { skip "Need OST version at least 2.8.55"; return 0; }
3481 for i in $(seq 1 $OSTCOUNT)
3483 do_facet ost"$i" lctl set_param \
3484 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3486 error "failed to set TBF policy"
3489 tbf_rule_check ost1 "default" "error before inserting any rule"
3491 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3492 tbf_rule_check ost1 "before default" \
3493 "error when inserting rule 'before'"
3495 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3496 tbf_rule_check ost1 "before after default" \
3497 "error when inserting rule 'after'"
3499 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3500 tbf_rule_check ost1 "before target after default" \
3501 "error when inserting rule 'target'"
3503 echo "Move before itself"
3504 tbf_rule_operate ost1 "change\ target\ rank=target"
3505 tbf_rule_check ost1 "before target after default" \
3506 "error when moving before itself"
3508 echo "Move to higher rank"
3509 tbf_rule_operate ost1 "change\ target\ rank=before"
3510 tbf_rule_check ost1 "target before after default" \
3511 "error when moving to higher rank"
3513 echo "Move to lower rank"
3514 tbf_rule_operate ost1 "change\ target\ rank=after"
3515 tbf_rule_check ost1 "before target after default" \
3516 "error when moving to lower rank"
3518 echo "Move before default"
3519 tbf_rule_operate ost1 "change\ target\ rank=default"
3520 tbf_rule_check ost1 "before after target default" \
3521 error "error when moving before default"
3523 # Cleanup the TBF policy
3524 do_nodes $(comma_list $(osts_nodes)) \
3525 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3528 run_test 77i "Change rank of TBF rule"
3533 local ost_version=$(lustre_version_code ost1)
3535 [ $ost_version -ge $(version_code 2.9.53) ] ||
3536 { skip "Need OST version at least 2.9.53"; return 0; }
3537 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3542 do_nodes $(comma_list $(osts_nodes)) \
3543 lctl set_param jobid_var=procname_uid \
3544 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3545 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3546 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3547 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3552 do_nodes $(comma_list $(osts_nodes)) \
3553 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3554 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3555 ost.OSS.ost_io.nrs_policies="fifo"
3557 # sleep 3 seconds to wait the tbf policy stop completely,
3558 # or the next test case is possible get -EAGAIN when
3559 # setting the tbf policy
3562 run_test 77j "check TBF-OPCode NRS policy"
3565 local idstr="${1}id"
3566 local policy="${idstr}={$2}"
3567 local rate="rate=$3"
3569 do_nodes $(comma_list $(osts_nodes)) \
3570 lctl set_param jobid_var=procname_uid \
3571 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3572 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3573 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3575 nrs_write_read "runas $4"
3576 tbf_verify $3 $3 "runas $4"
3578 do_nodes $(comma_list $(osts_nodes)) \
3579 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3580 ost.OSS.ost_io.nrs_policies="fifo"
3582 # sleep 3 seconds to wait the tbf policy stop completely,
3583 # or the next test case is possible get -eagain when
3584 # setting the tbf policy
3589 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3590 skip "Need OST version at least 2.11.50"
3593 test_id "u" "500" "5" "-u 500"
3594 test_id "g" "500" "5" "-u 500 -g 500"
3596 run_test 77ja "check TBF-UID/GID NRS policy"
3604 for rule in $rule_lists; do
3605 do_nodes $(comma_list $(osts_nodes)) \
3606 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3609 do_nodes $(comma_list $(osts_nodes)) \
3610 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3616 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3617 { skip "Need OST version at least 2.9.53"; return 0; }
3619 do_nodes $(comma_list $(osts_nodes)) \
3620 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3621 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3622 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3624 nrs_write_read "$RUNAS"
3625 tbf_verify 20 10 "$RUNAS"
3627 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3628 local client_nids=$(nids_list $address "\\")
3629 do_nodes $(comma_list $(osts_nodes)) \
3630 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3631 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3632 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3633 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3638 do_nodes $(comma_list $(osts_nodes)) \
3639 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3640 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3641 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3643 nrs_write_read "$RUNAS"
3644 tbf_verify 20 20 "$RUNAS"
3646 do_nodes $(comma_list $(osts_nodes)) \
3647 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3648 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3649 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3651 nrs_write_read "$RUNAS"
3652 # with parameter "RUNAS", it will match the latest rule
3653 # "ext_b" first, so the limited write rate is 10.
3654 tbf_verify 10 10 "$RUNAS"
3657 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3659 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3660 { skip "Need OST version at least 2.10.58"; return 0; }
3662 do_nodes $(comma_list $(osts_nodes)) \
3663 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3664 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3665 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3666 nrs_write_read "runas -u 500 -g 1000"
3667 tbf_verify 5 5 "runas -u 500 -g 1000"
3669 do_nodes $(comma_list $(osts_nodes)) \
3670 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3671 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3672 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3674 nrs_write_read "runas -u 500"
3675 tbf_verify 20 10 "runas -u 500"
3677 do_nodes $(comma_list $(osts_nodes)) \
3678 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3679 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3680 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3681 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3682 nrs_write_read "runas -u 500"
3683 tbf_verify 10 10 "runas -u 500"
3684 tbf_verify 20 10 "runas -u 500"
3685 cleanup_77k "ext_a ext_b" "fifo"
3687 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3690 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3691 { skip "Need OST version at least 2.10.56"; return 0; }
3693 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3694 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3696 local output=$(do_facet ost1 lctl get_param \
3697 ost.OSS.ost_io.nrs_policies | \
3698 awk '/name: tbf/ {print;exit}' | \
3699 awk -F ': ' '{print $2}')
3701 if [ "$output" != "tbf" ]; then
3702 error "The generic TBF output is '$output', not 'tbf'"
3705 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3707 run_test 77l "check the output of NRS policies for generic TBF"
3710 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3711 skip "Need OST version at least 2.9.54"
3715 local dir=$DIR/$tdir
3717 mkdir $dir || error "mkdir $dir failed"
3718 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3721 local nodes=$(comma_list $(osts_nodes))
3722 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3723 ost.OSS.ost_io.nrs_delay_min=4 \
3724 ost.OSS.ost_io.nrs_delay_max=4 \
3725 ost.OSS.ost_io.nrs_delay_pct=100
3726 [ $? -ne 0 ] && error "Failed to set delay policy"
3728 local start=$SECONDS
3729 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3730 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3731 oflag=direct conv=fdatasync ||
3732 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3733 error "dd on client failed (1)"; }
3734 local elapsed=$((SECONDS - start))
3736 # NRS delay doesn't do sub-second timing, so a request enqueued at
3737 # 0.9 seconds can be dequeued at 4.0
3738 [ $elapsed -lt 3 ] &&
3739 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3740 error "Single 1M write should take at least 3 seconds"; }
3743 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3744 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3745 oflag=direct conv=fdatasync ||
3746 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3747 error "dd on client failed (2)"; }
3748 elapsed=$((SECONDS - start))
3750 [ $elapsed -lt 30 ] &&
3751 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3752 error "Ten 1M writes should take at least 30 seconds"; }
3754 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3755 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3759 run_test 77m "check NRS Delay slows write RPC processing"
3761 test_77n() { #LU-10802
3762 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3763 skip "Need OST version at least 2.10.58"
3767 # Configure jobid_var
3768 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3769 if [ $saved_jobid_var != procname_uid ]; then
3770 set_conf_param_and_check client \
3771 "$LCTL get_param -n jobid_var" \
3772 "$FSNAME.sys.jobid_var" procname_uid
3775 do_nodes $(comma_list $(osts_nodes)) \
3776 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
3777 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3778 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
3781 tbf_verify 20 20 "$RUNAS"
3783 do_nodes $(comma_list $(osts_nodes)) \
3784 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3785 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
3790 do_nodes $(comma_list $(osts_nodes)) \
3791 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3792 ost.OSS.ost_io.nrs_policies="fifo"
3796 local current_jobid_var=$($LCTL get_param -n jobid_var)
3797 if [ $saved_jobid_var != $current_jobid_var ]; then
3798 set_conf_param_and_check client \
3799 "$LCTL get_param -n jobid_var" \
3800 "$FSNAME.sys.jobid_var" $saved_jobid_var
3803 run_test 77n "check wildcard support for TBF JobID NRS policy"
3805 test_78() { #LU-6673
3808 oss=$(comma_list $(osts_nodes))
3809 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3810 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3812 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3813 # Valid return codes are:
3814 # 0: Tuning succeeded
3815 # ENODEV: Policy is still stopped
3816 # EAGAIN: Policy is being initialized
3817 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3818 error "Expected set_param to return 0|ENODEV|EAGAIN"
3820 # Cleanup the ORR policy
3821 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3822 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3825 run_test 78 "Enable policy and specify tunings right away"
3828 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3829 test_mkdir $DIR/$tdir
3831 # Prevent interference from layout intent RPCs due to
3832 # asynchronous writeback. These will be tested in 130c below.
3833 do_nodes ${CLIENTS:-$HOSTNAME} sync
3835 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3836 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3838 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3839 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
3840 local facet=mds$((mdtidx + 1))
3842 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3843 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3847 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3848 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3853 run_test 79 "xattr: intent error"
3856 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3863 mkdir -p $DIR1/$tdir/dir
3864 createmany -o $DIR1/$tdir/dir/f 10 ||
3865 error "create files under remote dir failed $i"
3867 cp /etc/passwd $DIR1/$tdir/$tfile
3869 #migrate open file should fails
3870 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3872 # give multiop a chance to open
3875 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3876 error "migrate open files should failed with open files"
3880 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3881 error "migrate remote dir error"
3883 echo "Finish migration, then checking.."
3884 for file in $(find $DIR1/$tdir); do
3885 mdt_index=$($LFS getstripe -m $file)
3886 [ $mdt_index == $MDTIDX ] ||
3887 error "$file is not on MDT${MDTIDX}"
3890 diff /etc/passwd $DIR1/$tdir/$tfile ||
3891 error "file different after migration"
3893 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3895 run_test 80a "migrate directory when some children is being opened"
3899 kill -9 $migrate_pid
3903 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3904 local migrate_dir1=$DIR1/$tdir/migrate_dir
3905 local migrate_dir2=$DIR2/$tdir/migrate_dir
3906 local migrate_run=$LUSTRE/tests/migrate.sh
3914 trap cleanup_80b EXIT
3915 #prepare migrate directory
3916 mkdir -p $migrate_dir1
3917 for F in {1,2,3,4,5}; do
3918 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3919 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3922 #migrate the directories among MDTs
3925 mdt_idx=$((RANDOM % MDSCOUNT))
3926 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3928 [ $rc -ne 0 -o $rc -ne 16 ] || break
3933 echo "start migration thread $migrate_pid"
3934 #Access the files at the same time
3935 start_time=$(date +%s)
3936 echo "accessing the migrating directory for 5 minutes..."
3938 ls $migrate_dir2 > /dev/null || {
3939 echo "read dir fails"
3942 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3943 echo "access file1 fails"
3947 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3948 echo "access file2/3 fails"
3952 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3953 echo "access file4 fails"
3957 stat $migrate_dir2/file5 > /dev/null || {
3958 echo "stat file5 fails"
3962 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3963 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3964 echo "touch file failed with $rc1"
3968 if [ -e $migrate_dir2/source_file ]; then
3969 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3970 &>/dev/null || rc1=$?
3971 if [ -e $migrate_dir2/link_file ]; then
3972 rm -rf $migrate_dir2/link_file
3975 mrename $migrate_dir2/source_file \
3976 $migrate_dir2/target_file &>/dev/null || rc1=$?
3977 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3978 echo "rename failed with $rc1"
3982 if [ -e $migrate_dir2/target_file ]; then
3983 rm -rf $migrate_dir2/target_file &>/dev/null ||
3986 rm -rf $migrate_dir2/source_file &>/dev/null ||
3989 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3990 echo "unlink failed with $rc1"
3995 end_time=$(date +%s)
3996 duration=$((end_time - start_time))
3997 if [ $((duration % 10)) -eq 0 ]; then
3998 if [ $show_time -eq 1 ]; then
3999 echo "...$duration seconds"
4006 kill -0 $migrate_pid || {
4007 echo "migration stopped 1"
4011 [ $duration -ge 300 ] && break
4014 #check migration are still there
4015 kill -0 $migrate_pid || error "migration stopped 2"
4018 run_test 80b "Accessing directory during migration"
4021 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4025 mkdir -p $DIR1/$tdir
4027 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4028 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4031 touch d0/0 || error "create 0 failed"
4032 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4033 stat d0/0 && error "stat mv filed succeed"
4034 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4035 stat d0/0 || error "stat failed"
4037 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4039 if [ $t -ne 3 ]; then
4040 ls -ai $DIR1/$tdir/d0
4041 error "expect 3 get $t"
4046 run_test 81a "rename and stat under striped directory"
4049 [ $MDSCOUNT -lt 2 ] &&
4050 skip "We need at least 2 MDTs for this test"
4057 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4058 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4067 for i in $(seq $total); do
4068 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4072 kill -9 $setattr_pid
4074 run_test 81b "rename under striped directory doesn't deadlock"
4077 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4078 { skip "Need MDS version at least 2.6.92"; return 0; }
4080 # Client 1 creates a file.
4081 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4083 # Client 2 opens the file.
4084 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4086 # Client 1 makes the file an orphan.
4087 rm $DIR1/$tfile || error "rm"
4088 # Client 2 sets EA "user.multiop".
4090 wait $pid2 || error "multiop 2"
4091 # Client 1 gets EA "user.multiop". This used to fail because the EA
4092 # cache refill would get "trusted.link" from mdd_xattr_list() but
4093 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4096 wait $pid1 || error "multiop 1"
4098 run_test 82 "fsetxattr and fgetxattr on orphan files"
4101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4108 $LFS mkdir -i1 -c2 $tdir
4113 echo "start pid $pid1 to create/unlink striped directory"
4115 # Access the directory at the same time
4119 stat $tdir > /dev/null 2>&1
4123 echo "start pid $pid2 to stat striped directory"
4131 run_test 83 "access striped directory while it is being created/unlinked"
4134 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4139 [ "$SLOW" = "yes" ] && duration=600
4140 # Open/Create under striped directory
4144 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4145 touch $tdir/f{0..3} > /dev/null 2>&1
4149 echo "start pid $pid1 to open/create under striped directory"
4151 # unlink the striped directory at the same time
4155 rm -rf $tdir > /dev/null 2>&1
4159 echo "start pid $pid2 to unlink striped directory"
4168 run_test 90 "open/create and unlink striped directory"
4171 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4176 [ "$SLOW" = "yes" ] && duration=600
4177 # chmod striped directory
4181 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4182 chmod go+w $tdir > /dev/null 2>&1
4186 echo "start pid $pid1 to chmod striped directory"
4188 # unlink the striped directory at the same time
4192 rm -rf $tdir > /dev/null 2>&1
4196 echo "start pid $pid2 to unlink striped directory"
4205 run_test 91 "chmod and unlink striped directory"
4208 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4211 local cmd="exec $fd<$DIR1/$tdir"
4212 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4215 trap "eval $cmd" EXIT
4216 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4217 rmdir ../$tdir || error "rmdir ../$tdir fails"
4219 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4220 $LCTL set_param fail_loc=0x1408
4221 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4222 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4223 error "create remote dir succeeds"
4224 $LCTL set_param fail_loc=0
4228 run_test 92 "create remote directory under orphan directory"
4235 mkdir -p $DIR1/$tfile-1/
4236 mkdir -p $DIR2/$tfile-2/
4237 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4238 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4239 do_facet $SINGLEMDS lctl set_param -n \
4240 'lod.lustre-MDT*/qos_threshold_rr' 100
4241 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4242 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4244 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4247 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4251 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4252 do_facet $SINGLEMDS "lctl set_param -n \
4253 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4255 $GETSTRIPE $DIR1/$tfile-1/file1
4256 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4257 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4258 $GETSTRIPE $DIR2/$tfile-2/file2
4259 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4260 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4261 echo "rc1=$rc1 and rc2=$rc2 "
4262 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4263 error "object allocate on same ost detected"
4265 run_test 93 "alloc_rr should not allocate on same ost"
4269 skip "Reserved for glimpse-ahead" && return
4270 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4271 skip "Need MDS version at least 2.10.55" && return
4275 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4277 lctl set_param -n mdc.*.stats=clear
4278 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4280 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4281 # first stat from server should return size data and save glimpse
4282 local gls=$(lctl get_param -n mdc.*.stats | \
4283 awk '/ldlm_glimpse/ {print $2}')
4284 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4285 # second stat to check size is NOT cached on client without IO lock
4286 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4288 local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l)
4289 [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls"
4292 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4295 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4296 skip "Need MDS version at least 2.10.55" && return
4300 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4302 lctl set_param -n mdc.*.stats=clear
4303 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4304 cancel_lru_locks mdc
4305 # first stat data from server should have size
4306 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4307 # second stat to check size is cached on client
4308 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4310 local gls=$(lctl get_param -n mdc.*.stats |
4311 awk '/ldlm_glimpse/ {print $2}')
4312 # both stats should cause no glimpse requests
4313 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4316 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4319 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4320 skip "Need MDS version at least 2.10.55" && return
4324 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4326 lctl set_param -n mdc.*.stats=clear
4327 lctl set_param -n osc.*.stats=clear
4328 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4330 # check that size is merged from MDT and OST correctly
4331 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4332 error "Wrong size from stat #1"
4334 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4335 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4339 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4342 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4343 skip "Need MDS version at least 2.10.55" && return
4347 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4350 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4351 lctl set_param -n mdc.*.stats=clear
4352 $TRUNCATE $DIR2/$tdir/dom 4096
4354 # check that reported size is valid after file grows to OST and
4355 # is truncated back to MDT stripe size
4356 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4357 error "Wrong size from stat #1"
4359 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4360 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4364 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4367 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4368 skip "Need MDS version at least 2.10.55" && return
4370 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4372 $CHECKSTAT -t file $DIR1/$tfile
4374 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4375 sysctl -wq vm.dirty_writeback_centisecs=0
4377 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4380 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4381 error_noexit "Write fails"
4382 # must discard pages
4383 lctl set_param -n mdc.*.stats=clear
4384 rm $DIR2/$tfile || error "Unlink fails"
4386 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4387 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4389 run_test 101a "Discard DoM data on unlink"
4392 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4393 skip "Need MDS version at least 2.10.55" && return
4395 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4396 touch $DIR1/${tfile}_2
4398 $CHECKSTAT -t file $DIR1/$tfile
4400 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4401 sysctl -wq vm.dirty_writeback_centisecs=0
4403 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4406 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4407 # must discard pages
4408 lctl set_param -n mdc.*.stats=clear
4409 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4411 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4412 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4414 run_test 101b "Discard DoM data on rename"
4417 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4418 skip "Need MDS version at least 2.10.55" && return
4420 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4422 $CHECKSTAT -t file $DIR1/$tfile
4424 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4425 sysctl -wq vm.dirty_writeback_centisecs=0
4427 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4430 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4431 $MULTIOP $DIR1/$tfile O_c &
4434 lctl set_param -n mdc.*.stats=clear
4435 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4436 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4438 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4439 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4441 run_test 101c "Discard DoM data on close-unlink"
4443 log "cleanup: ======================================================"
4445 # kill and wait in each test only guarentee script finish, but command in script
4446 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4447 # otherwise umount below will fail
4448 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4453 check_and_cleanup_lustre