6 # bug number for skipped test: 9977/LU-7105
8 ALWAYS_EXCEPT=" 28 $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"
448 local file1=$DIR1/$tfile
449 local file2=$DIR2/$tfile
450 local stripe_size=$(do_facet $SINGLEMDS \
451 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
453 [ $(facet_fstype ost1) != ldiskfs ] && skip "dio on ldiskfs only"
455 # to allocate grant because it may run out due to test_15.
456 $LFS setstripe -c -1 $file1
457 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
458 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
460 wait_delete_completed
462 local list=$(comma_list $(osts_nodes))
463 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
464 skip "not cache-capable obdfilter"
467 set_osd_param $list '' read_cache_enable 0
468 set_osd_param $list '' writethrough_cache_enable 0
470 $LFS setstripe -c -1 $file1 # b=10919
471 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
472 || error "fsx failed"
475 set_osd_param $list '' read_cache_enable 1
476 set_osd_param $list '' writethrough_cache_enable 1
480 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
483 test_17() { # bug 3513, 3667
484 remote_ost_nodsh && skip "remote OST with nodsh" && return
486 lfs setstripe $DIR1/$tfile -i 0 -c 1
487 cp $SAMPLE_FILE $DIR1/$tfile
488 cancel_lru_locks osc > /dev/null
489 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
490 do_facet ost1 lctl set_param fail_loc=0x8000030a
491 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
492 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
494 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
496 run_test 17 "resource creation/LVB creation race ==============="
499 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
502 for idx in {a..z}; do
503 local ptr=EXCEPT_ALWAYS_18$idx
504 [ x${!ptr} = xtrue ] || continue
506 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
509 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
512 run_test 18 "mmap sanity check ================================="
514 test_19() { # bug3811
515 local node=$(facet_active_host ost1)
517 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
519 # check whether obdfilter is cache capable at all
520 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
521 echo "not cache-capable obdfilter"
525 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
527 set_osd_param $node '' readcache_max_filesize 4096
528 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
529 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
530 cp $TMP/$tfile $DIR1/$tfile
531 for i in `seq 1 20`; do
532 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
533 cancel_lru_locks $OSC > /dev/null
534 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
535 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
537 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
538 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
539 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
540 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
542 set_osd_param $node '' readcache_max_filesize $MAX
545 run_test 19 "test concurrent uncached read races ==============="
549 cancel_lru_locks $OSC
550 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
551 $MULTIOP $DIR1/f20 Ow8190c
552 $MULTIOP $DIR2/f20 Oz8194w8190c
553 $MULTIOP $DIR1/f20 Oz0r8190c
554 cancel_lru_locks $OSC
555 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
557 error $CNTD" page left in cache after lock cancel" || true
559 run_test 20 "test extra readahead page left in cache ===="
566 test_21() { # Bug 5907
567 test_mkdir $DIR1/$tdir
568 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
570 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
571 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
572 test -d $DIR1/$tdir || error "Mounted directory disappeared"
574 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
577 run_test 21 " Try to remove mountpoint on another dir ===="
579 test_23() { # Bug 5972
580 local at_diff=$(do_facet $SINGLEMDS \
581 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
582 echo "atime should be updated while another read" > $DIR1/$tfile
584 # clear the lock(mode: LCK_PW) gotten from creating operation
585 cancel_lru_locks $OSC
588 sleep $((at_diff + 1))
590 echo "starting reads"
591 multiop_bg_pause $DIR1/$tfile or20_c || return 1
592 # with SOM and opencache enabled, we need to close a file and cancel
593 # open lock to get atime propogated to MDS
594 kill -USR1 $! || return 2
597 time2=$(stat -c "%X" $DIR/$tfile)
598 echo "new atime is $time2"
600 [ $time2 -gt $time1 ] || error "atime was not updated"
601 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
604 run_test 23 " others should see updated atime while another read===="
608 lfs df || error "lfs df failed"
609 lfs df -ih || error "lfs df -ih failed"
610 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
611 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
612 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
613 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
615 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
616 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
617 lctl --device %osc deactivate
618 lfs df -i || error "lfs df -i with deactivated OSC failed"
619 lctl --device %osc activate
620 lfs df || error "lfs df with reactivated OSC failed"
622 run_test 24a "lfs df [-ih] [path] test ========================="
626 fsnum=$(lfs_df | grep -c "summary")
627 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
629 run_test 24b "lfs df should show both filesystems ==============="
632 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
634 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
637 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
638 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
640 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
641 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
642 error "setfacl $DIR2/$tdir #1"
643 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
644 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
645 error "setfacl $DIR2/$tdir #2"
646 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
647 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
648 error "setfacl $DIR2/$tdir #3"
649 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
650 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
651 error "setfacl $DIR2/$tdir #4"
652 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
656 run_test 25a "change ACL on one mountpoint be seen on another ==="
659 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
661 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
663 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
666 $LFS mkdir -i 1 $DIR1/$tdir
667 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
668 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
670 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
671 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
672 error "setfacl $DIR2/$tdir #1"
673 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
674 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
675 error "setfacl $DIR2/$tdir #2"
676 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
677 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
678 error "setfacl $DIR2/$tdir #3"
679 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
680 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
681 error "setfacl $DIR2/$tdir #4"
682 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
686 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
689 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
691 run_test 26a "allow mtime to get older"
696 echo "aaa" >> $DIR1/$tfile
698 chmod a+x $DIR2/$tfile
699 mt1=`stat -c %Y $DIR1/$tfile`
700 mt2=`stat -c %Y $DIR2/$tfile`
702 if [ x"$mt1" != x"$mt2" ]; then
703 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
706 run_test 26b "sync mtime between ost and mds"
709 cancel_lru_locks $OSC
711 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
716 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
721 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
723 lctl set_param -n ldlm.dump_namespaces ""
724 wait $DD1_PID $DD2_PID
725 [ $? -ne 0 ] && lctl dk $TMP/debug || true
727 run_test 27 "align non-overlapping extent locks from request ==="
729 test_28() { # bug 9977
730 ECHO_UUID="ECHO_osc1_UUID"
731 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
733 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
734 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
735 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
739 attach echo_client ECHO_osc1 $ECHO_UUID
743 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
744 $LCTL --device $tECHOID destroy "${tOBJID}:0"
752 # reading of 1st stripe should pass
753 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
754 # reading of 2nd stripe should fail (this stripe was destroyed)
755 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
757 # now, recreating test file
758 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
759 # reading of 1st stripe should pass
760 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
761 # reading of 2nd stripe should pass
762 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
765 run_test 28 "read/write/truncate file with lost stripes"
767 test_30() { #b=11110, LU-2523
768 test_mkdir $DIR1/$tdir
769 cp -f /bin/bash $DIR1/$tdir/bash
770 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
771 $DIR1/$tdir/bash -c 'sleep 2;
772 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
776 run_test 30 "recreate file race"
779 test_mkdir $DIR1/$tdir
780 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
781 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
782 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
783 lctl set_param fail_loc=0x314
784 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
785 awk 'BEGIN { FS="+" } /in/ {print $1}')
786 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
788 run_test 31a "voluntary cancel / blocking ast race=============="
791 remote_ost || { skip "local OST" && return 0; }
792 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
794 # make sure there is no local locks due to destroy
795 wait_mds_ost_sync || error "wait_mds_ost_sync()"
796 wait_delete_completed || error "wait_delete_completed()"
798 test_mkdir $DIR1/$tdir
799 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
800 cp /etc/hosts $DIR/$tdir/$tfile
801 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
802 lctl set_param fail_loc=0x314
803 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
804 do_facet ost1 lctl set_param fail_loc=0x316
806 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
807 lctl set_param fail_loc=0
808 do_facet ost1 lctl set_param fail_loc=0
809 # cleanup: reconnect the client back
812 run_test 31b "voluntary OST cancel / blocking ast race=============="
814 # enable/disable lockless truncate feature, depending on the arg 0/1
815 enable_lockless_truncate() {
816 lctl set_param -n $OSC.*.lockless_truncate $1
819 test_32a() { # bug 11270
820 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
821 local stripe_size=$(do_facet $SINGLEMDS \
822 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
824 save_lustre_params client "$OSC.*.lockless_truncate" > $p
825 cancel_lru_locks $OSC
826 enable_lockless_truncate 1
828 lfs setstripe -c -1 $DIR1/$tfile
829 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
831 clear_stats $OSC.*.${OSC}_stats
833 log "checking cached lockless truncate"
834 $TRUNCATE $DIR1/$tfile 8000000
835 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
836 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
837 error "cached truncate isn't lockless"
839 log "checking not cached lockless truncate"
840 $TRUNCATE $DIR2/$tfile 5000000
841 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
842 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
843 error "not cached truncate isn't lockless"
845 log "disabled lockless truncate"
846 enable_lockless_truncate 0
847 clear_stats $OSC.*.${OSC}_stats
848 $TRUNCATE $DIR2/$tfile 3000000
849 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
850 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
851 error "lockless truncate disabling failed"
853 # restore lockless_truncate default values
854 restore_lustre_params < $p
857 run_test 32a "lockless truncate"
859 test_32b() { # bug 11270
860 remote_ost_nodsh && skip "remote OST with nodsh" && return
863 local facets=$(get_facets OST)
864 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
866 save_lustre_params client "osc.*.contention_seconds" > $p
867 save_lustre_params $facets \
868 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
869 save_lustre_params $facets \
870 "ldlm.namespaces.filter-*.contended_locks" >> $p
871 save_lustre_params $facets \
872 "ldlm.namespaces.filter-*.contention_seconds" >> $p
873 clear_stats $OSC.*.${OSC}_stats
875 # agressive lockless i/o settings
876 do_nodes $(comma_list $(osts_nodes)) \
877 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
878 ldlm.namespaces.filter-*.contended_locks=0 \
879 ldlm.namespaces.filter-*.contention_seconds=60"
880 lctl set_param -n $OSC.*.contention_seconds=60
882 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
884 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
887 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
888 error "lockless i/o was not triggered"
889 # disable lockless i/o (it is disabled by default)
890 do_nodes $(comma_list $(osts_nodes)) \
891 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
892 ldlm.namespaces.filter-*.contended_locks=32 \
893 ldlm.namespaces.filter-*.contention_seconds=0"
894 # set contention_seconds to 0 at client too, otherwise Lustre still
895 # remembers lock contention
896 lctl set_param -n $OSC.*.contention_seconds=0
897 clear_stats $OSC.*.${OSC}_stats
899 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
901 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
904 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
905 error "lockless i/o works when disabled"
907 restore_lustre_params <$p
910 run_test 32b "lockless i/o"
914 local mdts=$(get_facets MDS)
919 for mds in ${mdts//,/ }; do
921 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
922 xargs readlink -f" ))
923 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
926 stat=$(( stat + val))
931 # commit on sharing tests
933 remote_mds_nodsh && skip "remote MDS with nodsh" && return
935 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
936 [ $CLIENTCOUNT -lt 2 ] &&
937 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
939 local nfiles=${TEST33_NFILES:-10000}
940 local param_file=$TMP/$tfile-params
941 local fstype=$(facet_fstype $SINGLEMDS)
943 save_lustre_params $(get_facets MDS) \
944 "mdt.*.commit_on_sharing" > $param_file
952 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
956 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
958 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
959 echo "=== START createmany old: $jbdold transaction"
960 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")
961 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
962 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
963 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
964 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
965 avgtime=$(( avgtime + elapsed ))
967 eval cos${COS}_jbd=$((avgjbd / 3))
968 eval cos${COS}_time=$((avgtime / 3))
971 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
972 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
973 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
974 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
976 restore_lustre_params < $param_file
980 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
982 # commit on sharing tests
984 remote_mds_nodsh && skip "remote MDS with nodsh" && return
986 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
987 [ $CLIENTCOUNT -ge 2 ] ||
988 { skip "Need two or more clients, have $CLIENTCOUNT" &&
990 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
992 local nfiles=${TEST33_NFILES:-10000}
993 local param_file=$TMP/$tfile-params
995 save_lustre_params $(get_facets MDS) \
996 "mdt.*.commit_on_sharing" > $param_file
1005 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1009 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1010 $DIR1/$tdir-\\\$(hostname)-$i"
1012 jbdold=$(print_jbd_stat)
1013 echo "=== START createmany old: $jbdold transaction"
1014 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1015 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1016 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1018 jbdnew=$(print_jbd_stat)
1019 jbd=$(( jbdnew - jbdold ))
1020 echo "=== END createmany new: $jbdnew transaction : \
1021 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1022 avgjbd=$(( avgjbd + jbd ))
1023 avgtime=$(( avgtime + elapsed ))
1025 eval cos${COS}_jbd=$((avgjbd / 3))
1026 eval cos${COS}_time=$((avgtime / 3))
1029 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1030 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1031 [ "$cos0_jbd" != 0 ] &&
1032 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1033 [ "$cos0_time" != 0 ] &&
1034 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1036 restore_lustre_params < $param_file
1040 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1043 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1044 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1045 skip "DNE CoS not supported" && return
1051 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1052 # do twice in case transaction is committed before unlock, see LU-8200
1054 # remote dir is created on MDT1, which enqueued lock of $tdir on
1056 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1057 mkdir $DIR/$tdir/local.$i
1059 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1060 echo "sync_count $sync_count"
1061 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1064 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1065 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1066 # during sleep remote mkdir should have been committed and canceled
1067 # remote lock spontaneously, which shouldn't trigger sync
1069 mkdir $DIR/$tdir/local.3
1070 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1071 echo "sync_count $sync_count"
1072 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1074 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1076 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1080 local nodes=$(comma_list $(mdts_nodes))
1084 # trigger CoS twice in case transaction commit before unlock
1087 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1089 commit_nr=$(do_nodes $nodes \
1090 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1091 total=$((total + commit_nr));
1096 echo "CoS count $total"
1097 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1102 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1103 skip "DNE CoS not supported" && return
1105 # remote directory create
1106 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1107 # remote directory unlink
1108 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1109 # striped directory create
1110 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1111 # striped directory setattr
1112 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1113 "chmod 713 $DIR/$tdir"
1114 # striped directory unlink
1115 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1118 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1119 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1120 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1121 touch $DIR/$tdir/d1/tgt" \
1122 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1124 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1125 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1126 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1127 touch $DIR/$tdir/d1/src" \
1128 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1130 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1131 "$LFS migrate -m 1 $DIR/$tdir"
1135 run_test 33d "DNE distributed operation should trigger COS"
1138 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1139 [ $CLIENTCOUNT -ge 2 ] ||
1140 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1142 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1143 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1144 skip "DNE CoS not supported" && return
1146 local client2=${CLIENT2:-$(hostname)}
1150 local nodes=$(comma_list $(mdts_nodes))
1151 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1153 $LFS mkdir -c 2 $DIR/$tdir
1154 mkdir $DIR/$tdir/subdir
1155 echo abc > $DIR/$tdir/$tfile
1156 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1157 do_node $client2 touch $DIR/$tdir/subdir
1159 local async_commit_count=$(do_nodes $nodes \
1160 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1161 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1165 run_test 33e "DNE local operation shouldn't trigger COS"
1167 # End commit on sharing tests
1169 get_ost_lock_timeouts() {
1170 local nodes=${1:-$(comma_list $(osts_nodes))}
1172 local locks=$(do_nodes $nodes \
1173 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1181 do_nodes $(comma_list $(osts_nodes)) \
1182 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1183 for i in $(seq $OSTCOUNT); do
1184 wait_osc_import_ready client ost$i
1189 remote_ost_nodsh && skip "remote OST with nodsh" && return
1193 trap cleanup_34 EXIT RETURN
1194 for OPER in notimeout timeout ; do
1195 rm $DIR1/$tfile 2>/dev/null
1196 lock_in=$(get_ost_lock_timeouts)
1197 if [ $OPER == "timeout" ] ; then
1198 for j in `seq $OSTCOUNT`; do
1199 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1200 do_facet ost$j lctl set_param fail_loc=0x511
1202 echo lock should expire
1204 for j in `seq $OSTCOUNT`; do
1205 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1206 do_facet ost$j lctl set_param fail_loc=0x512
1208 echo lock should not expire
1210 echo writing on client1
1211 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1213 echo reading on client2
1214 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1215 # wait for a lock timeout
1217 lock_out=$(get_ost_lock_timeouts)
1218 if [ $OPER == "timeout" ] ; then
1219 if [ $lock_in == $lock_out ]; then
1220 error "no lock timeout happened"
1225 if [ $lock_in != $lock_out ]; then
1226 error "lock timeout happened"
1234 run_test 34 "no lock timeout under IO"
1236 test_35() { # bug 17645
1239 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1240 awk '/generation/{print $2}')
1242 generation[count]=$g
1246 test_mkdir $MOUNT1/$tdir
1247 cancel_lru_locks mdc
1249 # Let's initiate -EINTR situation by setting fail_loc and take
1250 # write lock on same file from same client. This will not cause
1251 # bl_ast yet as lock is already in local cache.
1252 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1253 do_facet client "lctl set_param fail_loc=0x80000317"
1254 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1255 let timeout=timeout*3
1257 while test $nr -lt 10; do
1258 log "Race attempt $nr"
1259 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1260 awk '/ldlm_bl_callback/ { print $2 }')
1261 test "x$blk1" = "x" && blk1=0
1262 createmany -o $MOUNT2/$tdir/a 4000 &
1266 # Let's make conflict and bl_ast
1267 ls -la $MOUNT1/$tdir > /dev/null &
1270 log "Wait for $pid1 $pid2 for $timeout sec..."
1272 kill -9 $pid1 $pid2 > /dev/null 2>&1
1274 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1275 awk '/ldlm_bl_callback/ { print $2 }')
1276 test "x$blk2" = "x" && blk2=0
1277 test $blk2 -gt $blk1 && break
1278 rm -fr $MOUNT1/$tdir
1279 cancel_lru_locks mdc
1282 do_facet client "lctl set_param fail_loc=0x0"
1283 df -h $MOUNT1 $MOUNT2
1285 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1286 awk '/generation/{print $2}')
1288 if ! test "$g" -eq "${generation[count]}"; then
1289 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1291 for imp in $list; do
1292 if [ $c = $count ]; then
1297 imp=$(echo "$imp" | awk -F"." '{print $2}')
1298 error "Eviction happened on import $imp"
1303 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1305 test_36() { #bug 16417
1310 test_mkdir $DIR1/$tdir
1311 $LFS setstripe -c -1 $DIR1/$tdir
1314 let SIZE_B=SIZE*1024*1024
1315 sync; sleep 2; sync # wait for delete thread
1316 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1317 wait_destroy_complete || error "wait_destroy_complete failed"
1319 while [ $i -le 10 ]; do
1320 lctl mark "start test - cycle ($i)"
1321 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1322 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1323 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1324 sync # sync data from client cache
1325 sync_all_data # sync data from server cache (delayed allocation)
1327 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1328 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1330 rm -f $DIR1/$tdir/$tfile
1331 kill -USR1 $read_pid
1333 sync; sleep 2; sync # Ensure new statfs
1334 wait_delete_completed
1335 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1336 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1338 # this free space! not used
1339 (( $after_dd <= $after)) ||
1340 error "space leaked after_dd:$after_dd > after:$after"
1344 run_test 36 "handle ESTALE/open-unlink correctly"
1346 test_37() { # bug 18695
1347 test_mkdir $DIR1/$tdir
1348 multiop_bg_pause $DIR1/$tdir D_c || return 1
1350 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1351 createmany -m $DIR2/$tdir/f 10000
1352 # set mtime/atime backward
1353 touch -t 198001010000 $DIR2/$tdir
1354 kill -USR1 $MULTIPID
1355 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1356 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1359 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1361 # this should be set to past
1362 TEST_39_MTIME=`date -d "1 year ago" +%s`
1366 local client1=${CLIENT1:-`hostname`}
1367 local client2=${CLIENT2:-`hostname`}
1369 do_node $client1 "touch $DIR1/$tfile"
1371 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1372 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1373 [ "$mtime1" = $TEST_39_MTIME ] || \
1374 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1376 local d1=`do_node $client1 date +%s`
1377 do_node $client1 'echo hello >> '$DIR1/$tfile
1378 local d2=`do_node $client1 date +%s`
1380 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1381 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1382 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1384 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1386 for (( i=0; i < 2; i++ )) ; do
1387 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1388 [ "$mtime2" = "$mtime3" ] || \
1389 error "mtime ($mtime2) changed (to $mtime3) on rename"
1391 cancel_lru_locks osc
1392 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1395 run_test 39a "test from 11063 =================================="
1398 local client1=${CLIENT1:-`hostname`}
1399 local client2=${CLIENT2:-`hostname`}
1403 local mtime1=`stat -c %Y $DIR1/$tfile`
1404 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1407 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1409 for (( i=0; i < 2; i++ )) ; do
1410 local mtime3=`stat -c %Y $DIR1/$tfile`
1411 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1413 [ "$mtime3" = "$mtime4" ] || \
1414 error "different mtime on clients: $mtime3, $mtime4"
1415 [ "$mtime3" = $TEST_39_MTIME ] || \
1416 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1418 cancel_lru_locks osc
1419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1422 run_test 39b "11063 problem 1 =================================="
1425 local client1=${CLIENT1:-`hostname`}
1426 local client2=${CLIENT2:-`hostname`}
1428 echo hello > $DIR1/$tfile
1430 local mtime1=`stat -c %Y $DIR1/$tfile`
1431 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1432 [ "$mtime1" = "$mtime2" ] || \
1433 error "create: different mtime on clients: $mtime1, $mtime2"
1436 $TRUNCATE $DIR1/$tfile 1
1438 for (( i=0; i < 2; i++ )) ; do
1439 local mtime3=`stat -c %Y $DIR1/$tfile`
1440 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1442 [ "$mtime3" = "$mtime4" ] || \
1443 error "different mtime on clients: $mtime3, $mtime4"
1444 [ "$mtime3" -gt $mtime2 ] || \
1445 error "truncate did not update mtime: $mtime2, $mtime3"
1447 cancel_lru_locks osc
1448 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1451 run_test 39c "check truncate mtime update ======================"
1453 test_39d() { # LU-7310
1455 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1457 local mtime1=$(stat -c %Y $DIR2/$tfile)
1458 [ "$mtime1" = $TEST_39_MTIME ] ||
1459 error "mtime: $mtime1, should be $TEST_39_MTIME"
1462 # define OBD_FAIL_OSC_NO_GRANT 0x411
1463 $LCTL set_param fail_loc=0x411
1465 local d1=$(date +%s)
1466 echo hello >> $DIR1/$tfile
1467 local d2=$(date +%s)
1469 $LCTL set_param fail_loc=0
1471 cancel_lru_locks $OSC
1473 local mtime2=$(stat -c %Y $DIR2/$tfile)
1474 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1475 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1477 run_test 39d "sync write should update mtime"
1479 # check that pid exists hence second operation wasn't blocked by first one
1480 # if it is so then there is no conflict, return 0
1481 # else second operation is conflicting with first one, return 1
1482 check_pdo_conflict() {
1485 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1486 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1496 # test 40: check non-blocking operations
1498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1499 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1500 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1502 mkdir $DIR1/$tfile &
1505 touch $DIR2/$tfile-2
1506 check_pdo_conflict $PID1 || error "create is blocked"
1507 mkdir $DIR2/$tfile-3
1508 check_pdo_conflict $PID1 || error "mkdir is blocked"
1509 link $DIR2/$tfile-2 $DIR2/$tfile-4
1510 check_pdo_conflict $PID1 || error "link is blocked"
1511 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1512 check_pdo_conflict $PID1 || error "rename is blocked"
1513 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1514 check_pdo_conflict $PID1 || error "getattr is blocked"
1515 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1516 rmdir $DIR2/$tfile-3
1517 check_pdo_conflict $PID1 || error "unlink is blocked"
1519 # all operations above shouldn't wait the first one
1520 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1525 run_test 40a "pdirops: create vs others =============="
1528 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1529 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1530 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1531 touch $DIR1/$tfile &
1535 touch $DIR2/$tfile-2
1536 check_pdo_conflict $PID1 || error "create is blocked"
1537 mkdir $DIR2/$tfile-3
1538 check_pdo_conflict $PID1 || error "mkdir is blocked"
1539 link $DIR2/$tfile-2 $DIR2/$tfile-4
1540 check_pdo_conflict $PID1 || error "link is blocked"
1541 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1542 check_pdo_conflict $PID1 || error "rename is blocked"
1543 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1544 check_pdo_conflict $PID1 || error "getattr is blocked"
1545 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1546 rmdir $DIR2/$tfile-3
1547 check_pdo_conflict $PID1 || error "unlink is blocked"
1548 # all operations above shouldn't wait the first one
1550 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1555 run_test 40b "pdirops: open|create and others =============="
1558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1560 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1561 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1562 link $DIR1/$tfile $DIR1/$tfile-0 &
1566 touch $DIR2/$tfile-2
1567 check_pdo_conflict $PID1 || error "create is blocked"
1568 mkdir $DIR2/$tfile-3
1569 check_pdo_conflict $PID1 || error "mkdir is blocked"
1570 link $DIR2/$tfile-2 $DIR2/$tfile-4
1571 check_pdo_conflict $PID1 || error "link is blocked"
1572 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1573 check_pdo_conflict $PID1 || error "rename is blocked"
1574 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1575 check_pdo_conflict $PID1 || error "getattr is blocked"
1576 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1577 rmdir $DIR2/$tfile-3
1578 check_pdo_conflict $PID1 || error "unlink is blocked"
1580 # all operations above shouldn't wait the first one
1581 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1586 run_test 40c "pdirops: link and others =============="
1589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1591 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1592 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1597 touch $DIR2/$tfile-2
1598 check_pdo_conflict $PID1 || error "create is blocked"
1599 mkdir $DIR2/$tfile-3
1600 check_pdo_conflict $PID1 || error "mkdir is blocked"
1601 link $DIR2/$tfile-2 $DIR2/$tfile-4
1602 check_pdo_conflict $PID1 || error "link is blocked"
1603 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1604 check_pdo_conflict $PID1 || error "rename is blocked"
1605 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1606 check_pdo_conflict $PID1 || error "getattr is blocked"
1607 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1608 rmdir $DIR2/$tfile-3
1609 check_pdo_conflict $PID1 || error "unlink is blocked"
1611 # all operations above shouldn't wait the first one
1612 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1616 run_test 40d "pdirops: unlink and others =============="
1619 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1621 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1622 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1623 mv $DIR1/$tfile $DIR1/$tfile-0 &
1627 touch $DIR2/$tfile-2
1628 check_pdo_conflict $PID1 || error "create is blocked"
1629 mkdir $DIR2/$tfile-3
1630 check_pdo_conflict $PID1 || error "mkdir is blocked"
1631 link $DIR2/$tfile-2 $DIR2/$tfile-4
1632 check_pdo_conflict $PID1 || error "link is blocked"
1633 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1634 check_pdo_conflict $PID1 || error "getattr is blocked"
1635 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1636 rmdir $DIR2/$tfile-3
1637 check_pdo_conflict $PID1 || error "unlink is blocked"
1639 # all operations above shouldn't wait the first one
1640 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1645 run_test 40e "pdirops: rename and others =============="
1647 # test 41: create blocking operations
1649 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1650 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1651 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1654 mkdir $DIR2/$tfile && error "mkdir must fail"
1655 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1659 run_test 41a "pdirops: create vs mkdir =============="
1662 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1663 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1664 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1667 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1668 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1672 run_test 41b "pdirops: create vs create =============="
1675 touch $DIR1/$tfile-2
1676 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1677 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1678 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1681 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1682 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1686 run_test 41c "pdirops: create vs link =============="
1689 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1690 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1691 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1694 rm $DIR2/$tfile || error "unlink must succeed"
1695 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1699 run_test 41d "pdirops: create vs unlink =============="
1702 touch $DIR1/$tfile-2
1703 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1704 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1705 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1708 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1709 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1713 run_test 41e "pdirops: create and rename (tgt) =============="
1716 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1717 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1718 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1721 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1722 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1726 run_test 41f "pdirops: create and rename (src) =============="
1729 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1730 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1731 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1734 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1735 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1739 run_test 41g "pdirops: create vs getattr =============="
1742 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1743 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1744 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1747 ls -lia $DIR2/ > /dev/null
1748 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1752 run_test 41h "pdirops: create vs readdir =============="
1754 # test 42: unlink and blocking operations
1756 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1757 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1758 mkdir $DIR1/$tfile &
1761 mkdir $DIR2/$tfile && error "mkdir must fail"
1762 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1766 run_test 42a "pdirops: mkdir vs mkdir =============="
1769 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1770 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1771 mkdir $DIR1/$tfile &
1774 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1775 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1779 run_test 42b "pdirops: mkdir vs create =============="
1782 touch $DIR1/$tfile-2
1783 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1784 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1785 mkdir $DIR1/$tfile &
1788 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1789 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1793 run_test 42c "pdirops: mkdir vs link =============="
1796 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1797 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1798 mkdir $DIR1/$tfile &
1801 rmdir $DIR2/$tfile || error "unlink must succeed"
1802 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1806 run_test 42d "pdirops: mkdir vs unlink =============="
1809 touch $DIR1/$tfile-2
1810 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1811 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1812 mkdir $DIR1/$tfile &
1815 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1816 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1820 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1825 mkdir $DIR1/$tfile &
1828 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1833 run_test 42f "pdirops: mkdir and rename (src) =============="
1836 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1837 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1838 mkdir $DIR1/$tfile &
1841 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1842 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1846 run_test 42g "pdirops: mkdir vs getattr =============="
1849 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1850 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1851 mkdir $DIR1/$tfile &
1854 ls -lia $DIR2/ > /dev/null
1855 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1859 run_test 42h "pdirops: mkdir vs readdir =============="
1861 # test 43: unlink and blocking operations
1864 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1865 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1869 mkdir $DIR2/$tfile || error "mkdir must succeed"
1870 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1874 run_test 43a "pdirops: unlink vs mkdir =============="
1878 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1879 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1883 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1884 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1888 run_test 43b "pdirops: unlink vs create =============="
1892 touch $DIR1/$tfile-2
1893 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1894 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1898 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1899 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1903 run_test 43c "pdirops: unlink vs link =============="
1907 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1908 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1912 rm $DIR2/$tfile && error "unlink must fail"
1913 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1917 run_test 43d "pdirops: unlink vs unlink =============="
1921 touch $DIR1/$tfile-2
1922 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1923 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1927 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1928 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1932 run_test 43e "pdirops: unlink and rename (tgt) =============="
1936 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1937 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1941 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1942 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1946 run_test 43f "pdirops: unlink and rename (src) =============="
1950 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1951 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1955 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1956 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1960 run_test 43g "pdirops: unlink vs getattr =============="
1964 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1965 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1969 ls -lia $DIR2/ > /dev/null
1970 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1974 run_test 43h "pdirops: unlink vs readdir =============="
1977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1979 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1980 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1984 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1985 check_pdo_conflict $PID1 &&
1986 { wait $PID1; error "remote mkdir isn't blocked"; }
1990 run_test 43i "pdirops: unlink vs remote mkdir"
1992 # test 44: rename tgt and blocking operations
1994 touch $DIR1/$tfile-2
1995 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1996 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1997 mv $DIR1/$tfile-2 $DIR1/$tfile &
2000 mkdir $DIR2/$tfile && error "mkdir must fail"
2001 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2005 run_test 44a "pdirops: rename tgt vs mkdir =============="
2008 touch $DIR1/$tfile-2
2009 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2010 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2011 mv $DIR1/$tfile-2 $DIR1/$tfile &
2014 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2015 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2019 run_test 44b "pdirops: rename tgt vs create =============="
2022 touch $DIR1/$tfile-2
2023 touch $DIR1/$tfile-3
2024 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2025 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2026 mv $DIR1/$tfile-2 $DIR1/$tfile &
2029 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
2030 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2034 run_test 44c "pdirops: rename tgt vs link =============="
2037 touch $DIR1/$tfile-2
2038 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2039 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2040 mv $DIR1/$tfile-2 $DIR1/$tfile &
2043 rm $DIR2/$tfile || error "unlink must succeed"
2044 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2048 run_test 44d "pdirops: rename tgt vs unlink =============="
2052 touch $DIR1/$tfile-2
2053 touch $DIR1/$tfile-3
2054 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2055 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2056 mv $DIR1/$tfile-2 $DIR1/$tfile &
2059 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2060 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2064 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2067 touch $DIR1/$tfile-2
2068 touch $DIR1/$tfile-3
2069 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2070 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2071 mv $DIR1/$tfile-2 $DIR1/$tfile &
2074 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2075 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2079 run_test 44f "pdirops: rename tgt and rename (src) =============="
2082 touch $DIR1/$tfile-2
2083 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2084 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2085 mv $DIR1/$tfile-2 $DIR1/$tfile &
2088 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2089 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2093 run_test 44g "pdirops: rename tgt vs getattr =============="
2096 touch $DIR1/$tfile-2
2097 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2098 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2099 mv $DIR1/$tfile-2 $DIR1/$tfile &
2102 ls -lia $DIR2/ > /dev/null
2103 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2107 run_test 44h "pdirops: rename tgt vs readdir =============="
2109 # test 44: rename tgt and blocking operations
2111 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2112 touch $DIR1/$tfile-2
2113 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2114 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2115 mv $DIR1/$tfile-2 $DIR1/$tfile &
2118 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2119 check_pdo_conflict $PID1 && { wait $PID1;
2120 error "remote mkdir isn't blocked"; }
2124 run_test 44i "pdirops: rename tgt vs remote mkdir"
2126 # test 45: rename src and blocking operations
2129 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2130 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2131 mv $DIR1/$tfile $DIR1/$tfile-2 &
2134 mkdir $DIR2/$tfile || error "mkdir must succeed"
2135 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2139 run_test 45a "pdirops: rename src vs mkdir =============="
2143 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2144 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2145 mv $DIR1/$tfile $DIR1/$tfile-2 &
2148 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2149 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2153 run_test 45b "pdirops: rename src vs create =============="
2157 touch $DIR1/$tfile-3
2158 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2159 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2160 mv $DIR1/$tfile $DIR1/$tfile-2 &
2163 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2164 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2168 run_test 45c "pdirops: rename src vs link =============="
2172 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2173 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2174 mv $DIR1/$tfile $DIR1/$tfile-2 &
2177 rm $DIR2/$tfile && error "unlink must fail"
2178 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2182 run_test 45d "pdirops: rename src vs unlink =============="
2186 touch $DIR1/$tfile-3
2187 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2188 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2189 mv $DIR1/$tfile $DIR1/$tfile-2 &
2192 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2193 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2197 run_test 45e "pdirops: rename src and rename (tgt) =============="
2201 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2202 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2203 mv $DIR1/$tfile $DIR1/$tfile-2 &
2206 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2207 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2211 run_test 45f "pdirops: rename src and rename (src) =============="
2215 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2216 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2217 mv $DIR1/$tfile $DIR1/$tfile-2 &
2220 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2221 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2225 run_test 45g "pdirops: rename src vs getattr =============="
2229 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2230 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2231 mv $DIR1/$tfile $DIR1/$tfile-2 &
2234 ls -lia $DIR2/ > /dev/null
2235 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2239 run_test 45h "pdirops: unlink vs readdir =============="
2242 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2244 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2245 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2246 mv $DIR1/$tfile $DIR1/$tfile-2 &
2249 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2250 check_pdo_conflict $PID1 && { wait $PID1;
2251 error "create remote dir isn't blocked"; }
2255 run_test 45i "pdirops: rename src vs remote mkdir"
2257 # test 46: link and blocking operations
2259 touch $DIR1/$tfile-2
2260 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2261 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2262 link $DIR1/$tfile-2 $DIR1/$tfile &
2265 mkdir $DIR2/$tfile && error "mkdir must fail"
2266 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2270 run_test 46a "pdirops: link vs mkdir =============="
2273 touch $DIR1/$tfile-2
2274 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2275 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2276 link $DIR1/$tfile-2 $DIR1/$tfile &
2279 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2280 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2284 run_test 46b "pdirops: link vs create =============="
2287 touch $DIR1/$tfile-2
2288 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2289 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2290 link $DIR1/$tfile-2 $DIR1/$tfile &
2293 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2294 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2298 run_test 46c "pdirops: link vs link =============="
2301 touch $DIR1/$tfile-2
2302 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2303 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2304 link $DIR1/$tfile-2 $DIR1/$tfile &
2307 rm $DIR2/$tfile || error "unlink must succeed"
2308 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2312 run_test 46d "pdirops: link vs unlink =============="
2315 touch $DIR1/$tfile-2
2316 touch $DIR1/$tfile-3
2317 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2318 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2319 link $DIR1/$tfile-2 $DIR1/$tfile &
2322 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2323 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2327 run_test 46e "pdirops: link and rename (tgt) =============="
2330 touch $DIR1/$tfile-2
2331 touch $DIR1/$tfile-3
2332 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2333 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2334 link $DIR1/$tfile-2 $DIR1/$tfile &
2337 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2338 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2342 run_test 46f "pdirops: link and rename (src) =============="
2345 touch $DIR1/$tfile-2
2346 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2347 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2348 link $DIR1/$tfile-2 $DIR1/$tfile &
2351 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2352 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2356 run_test 46g "pdirops: link vs getattr =============="
2359 touch $DIR1/$tfile-2
2360 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2361 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2362 link $DIR1/$tfile-2 $DIR1/$tfile &
2365 ls -lia $DIR2/ > /dev/null
2366 check_pdo_conflict $PID1 && { wait $PID1;
2367 error "readdir isn't blocked"; }
2371 run_test 46h "pdirops: link vs readdir =============="
2374 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2375 touch $DIR1/$tfile-2
2376 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2377 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2378 link $DIR1/$tfile-2 $DIR1/$tfile &
2381 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2382 check_pdo_conflict $PID1 && { wait $PID1;
2383 error "remote mkdir isn't blocked"; }
2387 run_test 46i "pdirops: link vs remote mkdir"
2389 # test 47: remote mkdir and blocking operations
2391 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2392 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2393 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2394 $LFS mkdir -i 1 $DIR1/$tfile &
2397 mkdir $DIR2/$tfile && error "mkdir must fail"
2398 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2402 run_test 47a "pdirops: remote mkdir vs mkdir"
2405 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2406 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2407 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2408 $LFS mkdir -i 1 $DIR1/$tfile &
2411 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2412 check_pdo_conflict $PID1 && { wait $PID1;
2413 error "create isn't blocked"; }
2417 run_test 47b "pdirops: remote mkdir vs create"
2420 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2421 touch $DIR1/$tfile-2
2422 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2423 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2424 $LFS mkdir -i 1 $DIR1/$tfile &
2427 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2428 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2432 run_test 47c "pdirops: remote mkdir vs link"
2435 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2436 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2437 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2438 $LFS mkdir -i 1 $DIR1/$tfile &
2441 rmdir $DIR2/$tfile || error "unlink must succeed"
2442 check_pdo_conflict $PID1 && { wait $PID1;
2443 error "unlink isn't blocked"; }
2447 run_test 47d "pdirops: remote mkdir vs unlink"
2450 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2451 touch $DIR1/$tfile-2
2452 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2453 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2454 $LFS mkdir -i 1 $DIR1/$tfile &
2457 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2458 check_pdo_conflict $PID1 && { wait $PID1;
2459 error "rename isn't blocked"; }
2463 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2466 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2467 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2468 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2469 $LFS mkdir -i 1 $DIR1/$tfile &
2472 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2473 check_pdo_conflict $PID1 && { wait $PID1;
2474 error "rename isn't blocked"; }
2478 run_test 47f "pdirops: remote mkdir and rename (src)"
2481 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2482 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2483 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2484 $LFS mkdir -i 1 $DIR1/$tfile &
2487 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2488 check_pdo_conflict $PID1 && { wait $PID1;
2489 error "getattr isn't blocked"; }
2493 run_test 47g "pdirops: remote mkdir vs getattr"
2497 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2498 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2499 do_facet client "lctl set_param fail_loc=0x410"
2500 $TRUNCATE $DIR2/$tfile $trunc_size
2501 do_facet client "lctl set_param fail_loc=0x0"
2503 size=`stat -c %s $DIR2/$tfile`
2504 [ $size -eq $trunc_size ] || error "wrong size"
2506 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2510 local origfile=/etc/hosts
2512 filesize=$(stat -c %s $origfile)
2514 # create an empty file
2515 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2516 # cache layout lock on both mount point
2517 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2518 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2520 # open and sleep 2 seconds then read
2521 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2525 # create the layout of testing file
2526 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2527 error "dd $DIR1/$tfile failed"
2529 # MULTIOP proc should be able to read enough bytes and exit
2530 for ((i = 0; i < 6; i++)); do
2532 kill -0 $pid || break
2534 kill -0 $pid 2> /dev/null && error "multiop is still there"
2535 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2539 run_test 51a "layout lock: refresh layout should work"
2542 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2543 { skip "Need MDS version at least 2.3.59"; return 0; }
2545 local tmpfile=`mktemp`
2547 # create an empty file
2548 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2550 # delay glimpse so that layout has changed when glimpse finish
2551 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2552 $LCTL set_param fail_loc=0x1404
2553 stat -c %s $DIR2/$tfile |tee $tmpfile &
2557 # create layout of testing file
2558 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2559 error "dd $DIR1/$tfile failed"
2562 local fsize=$(cat $tmpfile)
2564 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2566 rm -f $DIR1/$tfile $tmpfile
2568 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2571 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2573 # set default layout to have 1 stripe
2575 $LFS setstripe -c 1 $DIR1/$tdir
2577 # create a file with empty layout
2578 $MCREATE $DIR1/$tdir/$tfile ||
2579 error "$MCREATE $DIR1/$tdir/$tfile failed"
2581 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2582 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2584 # change the layout of testing file
2585 echo "Setting layout to have $OSTCOUNT stripes ..."
2586 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2590 # write something to the file, it should be blocked on fetching layout
2591 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2592 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2595 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2596 # count to succeed with only 3/4 of the number of stripes (rounded up),
2597 # so creating striped files does not fail if an OST is offline or full
2598 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2599 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2603 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2606 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2607 cancel_lru_locks mdc
2609 # open should grant LAYOUT lock, mmap and read will install pages
2610 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2614 # rss before revoking
2615 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2616 echo "Before revoking layout lock: $br KB mapped"
2618 # cancel layout lock manually
2619 cancel_lru_locks mdc
2621 # rss after revoking
2622 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2625 wait $PID || error "wait PID $PID failed"
2627 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2629 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2633 echo "==> rename vs getattr vs setxattr should not deadlock"
2634 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2636 do_facet mds1 $LCTL set_param fail_loc=$1
2638 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2646 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2647 wait $PID1 || error "(3) mv failed"
2648 wait $PID2 || error "(4) stat failed"
2655 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2656 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2658 do_facet mds1 $LCTL set_param fail_loc=$1
2660 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2668 $MULTIOP $DIR2/d1/d2 Oc &
2672 stat $DIR/d1 || error "(2) stat failed"
2674 wait $PID1 || error "(3) mv failed"
2675 wait $PID2 || error "(4) stat failed"
2676 wait $PID3 && error "(5) multiop failed"
2682 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2683 save_lustre_params client "llite.*.xattr_cache" > $p
2684 lctl set_param llite.*.xattr_cache 1 ||
2685 { skip "xattr cache is not supported"; return 0; }
2687 #define OBD_FAIL_MDS_RENAME 0x153
2688 #define OBD_FAIL_MDS_RENAME2 0x154
2689 test_54_part1 0x80000153 || error 10
2690 test_54_part1 0x80000154 || error 11
2691 test_54_part2 0x80000153 || error 12
2692 test_54_part2 0x80000154 || error 13
2694 restore_lustre_params < $p
2697 run_test 54 "rename locking"
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=0x80000156
2705 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2710 wait $PID1 && error "(2) mv succeeded"
2714 run_test 55a "rename vs unlink target dir"
2718 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2720 #define OBD_FAIL_MDS_RENAME4 0x156
2721 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2723 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2728 wait $PID1 && error "(2) mv succeeded"
2732 run_test 55b "rename vs unlink source dir"
2736 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2738 #define OBD_FAIL_MDS_RENAME4 0x156
2739 do_facet mds1 $LCTL set_param fail_loc=0x156
2741 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2745 # while rename is sleeping, open and remove d3
2746 $MULTIOP $DIR2/d3 D_c &
2752 # while rename is sleeping 2nd time, close d3
2754 wait $PID2 || error "(3) multiop failed"
2756 wait $PID1 && error "(2) mv succeeded"
2760 run_test 55c "rename vs unlink orphan target dir"
2766 #define OBD_FAIL_MDS_RENAME3 0x155
2767 do_facet mds1 $LCTL set_param fail_loc=0x155
2768 mv $DIR/f1 $DIR/$tdir &
2772 # while rename is sleeping, create $tdir, but as a directory
2773 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2775 # link in reverse locking order
2776 ln $DIR2/f1 $DIR2/$tdir/
2778 wait $PID1 && error "(2) mv succeeded"
2781 run_test 55d "rename file vs link"
2784 local MDSVER=$(lustre_build_version $SINGLEMDS)
2785 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2786 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2789 test_mkdir $DIR1/$tdir
2790 file1=$DIR1/$tdir/file
2791 file2=$DIR2/$tdir/file
2793 echo orig > $file2 || error "Could not create $file2"
2794 version=$($LFS data_version $file1)
2797 echo append >> $file2 || error "Could not append to $file2"
2798 version2=$($LFS data_version $file1)
2799 [ "$version" != "$version2" ] ||
2800 error "append did not change data version: $version"
2803 echo overwrite > $file2 || error "Could not overwrite $file2"
2804 version3=$($LFS data_version $file1)
2805 [ "$version2" != "$version3" ] ||
2806 error "overwrite did not change data version: $version2"
2808 # Truncate before EOF
2809 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2810 version4=$($LFS data_version $file1)
2811 [ "$version3" != "$version4" ] ||
2812 error "truncate did not change data version: $version3"
2814 # Truncate after EOF
2815 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2816 version5=$($LFS data_version $file1)
2817 [ "$version4" != "$version5" ] ||
2818 error "truncate did not change data version: $version4"
2820 # Chmod do not change version
2821 chmod 400 $file2 || error "Could not chmod 400 $file2"
2822 version6=$($LFS data_version $file1)
2823 [ "$version5" == "$version6" ] ||
2824 error "chmod should not change data version: $version5 != $version6"
2826 # Chown do not change version
2827 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2828 version7=$($LFS data_version $file1)
2829 [ "$version5" == "$version7" ] ||
2830 error "chown should not change data version: $version5 != $version7"
2832 run_test 60 "Verify data_version behaviour"
2835 local test_dir=$tdir/test_dir
2837 mkdir -p $DIR1/$tdir
2838 if [ $MDSCOUNT -ge 2 ]; then
2840 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2841 error "Create remote directory failed"
2843 mkdir -p $DIR1/$test_dir
2845 cd $DIR2/$test_dir || error "cd directory failed"
2846 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2848 cd $DIR2/$tdir || error "exit directory"
2850 run_test 70a "cd directory && rm directory"
2852 test_70b() { # LU-2781
2854 mkdir -p $DIR1/$tdir
2856 touch $DIR1/$tdir/file
2857 for ((i = 0; i < 32; i++)); do
2858 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2860 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2862 touch $DIR1/$tdir/file
2863 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2864 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2865 rm -rf $DIR1/$tdir/test_dir ||
2866 error "cannot remove directory after rm_entry"
2867 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2869 run_test 70b "remove files after calling rm_entry"
2872 local server_version=$(lustre_version_code $SINGLEMDS)
2874 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2875 skip "Need MDS version at least 2.1.6" && return
2877 # Patch not applied to 2.2 and 2.3 branches
2878 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2879 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2880 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2883 checkfiemap --test ||
2884 { skip "checkfiemap not runnable: $?" && return; }
2885 # write data this way: hole - data - hole - data
2886 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2887 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2889 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2890 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2891 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2893 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2895 checkfiemap $DIR2/$tfile 81920 ||
2896 error "data is not flushed from client"
2897 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2900 # common case of "create file, copy file" on a single node
2901 # should not flush data from ost
2902 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2903 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2905 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2907 checkfiemap $DIR1/$tfile 81920 ||
2909 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2911 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2913 run_test 71a "correct file map just after write operation is finished"
2916 local server_version=$(lustre_version_code $SINGLEMDS)
2918 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2919 skip "Need MDS version at least 2.1.6" && return
2921 # Patch not applied to 2.2 and 2.3 branches
2922 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2923 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2924 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2926 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2928 checkfiemap --test ||
2929 { skip "error $?: checkfiemap failed" && return; }
2931 mkdir -p $DIR1/$tdir
2933 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2934 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2935 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2937 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2938 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2940 run_test 71b "check fiemap support for stripecount > 1"
2943 local p="$TMP/sanityN-$TESTNAME.parameters"
2946 save_lustre_params client "llite.*.xattr_cache" > $p
2947 lctl set_param llite.*.xattr_cache 1 ||
2948 { skip "xattr cache is not supported"; return 0; }
2951 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2952 error "setfattr1 failed"
2953 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2954 error "getfattr1 failed"
2955 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2956 error "setfattr2 failed"
2957 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2958 error "getfattr2 failed"
2960 # check that trusted.link is consistent
2961 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2962 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2963 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2964 echo "$tlink1 $tlink2"
2965 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2969 restore_lustre_params < $p
2972 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2975 local p="$TMP/sanityN-$TESTNAME.parameters"
2976 save_lustre_params client "llite.*.xattr_cache" > $p
2977 lctl set_param llite.*.xattr_cache 1 ||
2978 { skip "xattr cache is not supported"; return 0; }
2981 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2982 error "setfattr1 failed"
2983 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2984 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2985 clear_stats llite.*.stats
2986 # PR lock should be cached by now on both clients
2987 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2988 # 2 hits for getfattr(0)+getfattr(size)
2989 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2990 error "not cached in $DIR1"
2991 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2992 # 4 hits for more getfattr(0)+getfattr(size)
2993 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2994 error "not cached in $DIR2"
2997 restore_lustre_params < $p
3000 run_test 73 "getxattr should not cause xattr lock cancellation"
3003 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3004 skip "Need MDS version at least 2.4.93" && return
3006 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3007 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3008 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3010 run_test 74 "flock deadlock: different mounts =============="
3014 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3015 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3016 cancel_lru_locks osc
3018 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3021 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3022 $LCTL set_param fail_loc=0x31d
3023 stat -c %s $DIR1/$tfile &
3028 # For bad lock error handler we should ASSERT and got kernel panic here
3030 $LCTL set_param fail_loc=0
3032 run_test 75 "osc: upcall after unuse lock==================="
3035 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3036 skip "Need MDS version at least 2.5.53" && return
3038 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3039 local fcount=$((MDSCOUNT * 256))
3044 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3050 test_mkdir $DIR/$tdir
3052 # drop all open locks and close any cached "open" files on the client
3053 cancel_lru_locks mdc
3055 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3056 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3057 local already=${#fid_list[@]}
3058 for (( i = 0; i < $already; i++ )) ; do
3059 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3062 echo -n "opening files: "
3063 ulimit -n $((fcount + 50))
3064 for ((i = 0; i < $fcount; i++)); do
3065 touch $DIR/$tdir/f_$i
3066 local fd=$(free_fd ${fd_list[i]})
3067 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3072 (( $i % 32 == 0 )) && echo -n "."
3076 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3078 # Possible errors in openfiles FID list.
3079 # 1. Missing FIDs. Check 1
3080 # 2. Extra FIDs. Check 1
3081 # 3. Duplicated FID. Check 2
3082 # 4. Invalid FIDs. Check 2
3083 # 5. Valid FID, points to some other file. Check 3
3086 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3087 error "${#fid_list[@]} != $fcount (+$already old) open files"
3089 echo -n "closing files: "
3090 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3091 local close_cmd="exec ${fd_list[fd]}<&-"
3093 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3095 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3096 echo "skip old open file $filename"
3098 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3102 rm --interactive=no $filename
3104 error "Nonexisting fid ${fid_list[fid]} listed."
3105 (( $fd % 32 == 0 )) && echo -n "."
3110 ls_op=$(ls $DIR2/$tdir | wc -l)
3112 error "Some openfiles are missing in lproc output"
3116 run_test 76 "Verify MDT open_files listing"
3120 local dir=$DIR/$tdir
3123 mkdir $dir || error "mkdir $dir failed"
3124 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3127 do_nodes $CLIENTS $myRUNAS \
3128 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3129 error "dd at 0 on client failed (1)"
3131 for ((i = 0; i < $n; i++)); do
3132 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3133 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3134 error "dd at ${i}MB on client failed (2)" &
3137 do_nodes $CLIENTS sync;
3138 cancel_lru_locks osc
3140 for ((i = 0; i < $n; i++)); do
3141 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3142 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3143 error "dd at ${i}MB on client failed (3)" &
3146 cancel_lru_locks osc
3148 for ((i = 0; i < $n; i++)); do
3152 rm -rf $dir || error "rm -rf $dir failed"
3155 test_77a() { #LU-3266
3158 oss=$(comma_list $(osts_nodes))
3159 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3161 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3162 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3167 run_test 77a "check FIFO NRS policy"
3169 test_77b() { #LU-3266
3172 oss=$(comma_list $(osts_nodes))
3174 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3175 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3176 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3177 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3179 echo "policy: crr-n, crrn_quantum 1"
3182 do_nodes $oss lctl set_param \
3183 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3184 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3186 echo "policy: crr-n, crrn_quantum 64"
3190 do_nodes $oss lctl set_param \
3191 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3192 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3195 run_test 77b "check CRR-N NRS policy"
3200 oss=$(comma_list $(osts_nodes))
3202 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3203 ost.OSS.*.nrs_"$policy"_quantum=1 \
3204 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3205 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3207 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3208 "physical, ${policy}_supported reads"
3211 do_nodes $oss lctl set_param \
3212 ost.OSS.*.nrs_${policy}_supported="writes" \
3213 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3215 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3216 "physical, ${policy}_supported writes"
3219 do_nodes $oss lctl set_param \
3220 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3221 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3222 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3223 "logical, ${policy}_supported reads_and_writes"
3227 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3232 test_77c() { #LU-3266
3234 orr_trr "orr" || rc=$?
3235 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3236 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3239 run_test 77c "check ORR NRS policy"
3241 test_77d() { #LU-3266
3243 orr_trr "trr" || rc=$?
3244 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3245 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3248 run_test 77d "check TRR nrs policy"
3255 do_facet $facet lctl set_param \
3256 ost.OSS.ost_io.nrs_tbf_rule="$*"
3258 error "failed to run operate '$*' on TBF rules"
3261 cleanup_tbf_verify()
3265 echo "cleanup_tbf $DIR/$tdir"
3268 wait_delete_completed
3273 local dir=$DIR/$tdir
3274 local client1=${CLIENT1:-$(hostname)}
3277 local np=$(check_cpt_number ost1)
3278 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3279 echo "cpu_npartitions on ost1 is $np"
3281 mkdir $dir || error "mkdir $dir failed"
3282 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3285 trap cleanup_tbf_verify EXIT
3286 echo "Limited write rate: $1, read rate: $2"
3287 echo "Verify the write rate is under TBF control"
3288 local start=$SECONDS
3289 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3290 bs=1M count=100 oflag=direct 2>&1
3291 local runtime=$((SECONDS - start + 1))
3292 local rate=$(bc <<< "scale=6; 100 / $runtime")
3293 echo "Write runtime is $runtime s, speed is $rate IOPS"
3295 # verify the write rate does not exceed TBF rate limit
3296 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3297 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3299 cancel_lru_locks osc
3301 echo "Verify the read rate is under TBF control"
3303 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3304 bs=1M count=100 iflag=direct 2>&1
3305 runtime=$((SECONDS - start + 1))
3306 rate=$(bc <<< "scale=6; 100 / $runtime")
3307 echo "Read runtime is $runtime s, speed is $rate IOPS"
3309 # verify the read rate does not exceed TBF rate limit
3310 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3311 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3313 cancel_lru_locks osc
3314 cleanup_tbf_verify || error "rm -rf $dir failed"
3320 oss=$(comma_list $(osts_nodes))
3322 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3324 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3325 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3329 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3334 # Only operate rules on ost1 since OSTs might run on the same OSS
3336 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3337 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3338 local client_nids=$(nids_list $address "\\")
3339 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3340 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3344 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3345 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3346 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3350 tbf_rule_operate ost1 "stop\ localhost"
3351 tbf_rule_operate ost1 "stop\ clients"
3352 tbf_rule_operate ost1 "stop\ others"
3355 # Cleanup the TBF policy
3356 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3357 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3361 run_test 77e "check TBF NID nrs policy"
3366 oss=$(comma_list $(osts_nodes))
3368 do_nodes $oss $LCTL set_param \
3369 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3370 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3371 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3373 # Configure jobid_var
3374 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3376 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3377 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3378 if [ $saved_jobid_var != procname_uid ]; then
3379 set_persistent_param_and_check client \
3380 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3385 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3390 # Only operate rules on ost1 since OSTs might run on the same OSS
3392 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3393 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3394 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3395 nrs_write_read "$RUNAS"
3398 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3399 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3400 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3401 nrs_write_read "$RUNAS"
3404 tbf_rule_operate ost1 "stop\ runas"
3405 tbf_rule_operate ost1 "stop\ iozone_runas"
3406 tbf_rule_operate ost1 "stop\ dd_runas"
3407 nrs_write_read "$RUNAS"
3409 # Cleanup the TBF policy
3410 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3411 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3412 nrs_write_read "$RUNAS"
3414 local current_jobid_var=$($LCTL get_param -n jobid_var)
3415 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3416 if [ $saved_jobid_var != $current_jobid_var ]; then
3417 set_persistent_param_and_check client \
3418 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3422 run_test 77f "check TBF JobID nrs policy"
3427 oss=$(comma_list $(osts_nodes))
3429 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3431 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3432 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3434 do_nodes $oss lctl set_param \
3435 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3436 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3440 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3445 # Add a rule that only valid for Jobid TBF. If direct change between
3446 # TBF types is not supported, this operation will fail.
3447 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3449 # Cleanup the TBF policy
3450 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3451 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3454 run_test 77g "Change TBF type directly"
3457 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3458 { skip "Need OST version at least 2.8.55"; return 0; }
3460 local old_policy=$(do_facet ost1 \
3461 lctl get_param ost.OSS.ost_io.nrs_policies)
3464 do_facet ost1 lctl set_param \
3465 ost.OSS.ost_io.nrs_policies="abc"
3466 [ $? -eq 0 ] && error "should return error"
3468 do_facet ost1 lctl set_param \
3469 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3470 [ $? -eq 0 ] && error "should return error"
3472 do_facet ost1 lctl set_param \
3473 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3474 [ $? -eq 0 ] && error "should return error"
3476 do_facet ost1 lctl set_param \
3477 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3478 [ $? -eq 0 ] && error "should return error"
3480 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3481 [ $? -eq 0 ] || error "shouldn't LBUG"
3483 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3487 run_test 77h "Wrong policy name should report error, not LBUG"
3493 local error_message=$3
3495 for rule in $expected; do
3496 rule_number=$((rule_number + 1))
3498 local stop_line=$(($rule_number + 3))
3499 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3501 local output=$(do_facet $facet lctl get_param \
3502 ost.OSS.ost_io.nrs_tbf_rule |
3506 if [ "$output" != "$expected" ]; then
3507 error "$error_message, expected '$expected', got '$output'"
3512 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3513 { skip "Need OST version at least 2.8.55"; return 0; }
3515 for i in $(seq 1 $OSTCOUNT)
3517 do_facet ost"$i" lctl set_param \
3518 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3520 error "failed to set TBF policy"
3523 tbf_rule_check ost1 "default" "error before inserting any rule"
3525 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3526 tbf_rule_check ost1 "before default" \
3527 "error when inserting rule 'before'"
3529 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3530 tbf_rule_check ost1 "before after default" \
3531 "error when inserting rule 'after'"
3533 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3534 tbf_rule_check ost1 "before target after default" \
3535 "error when inserting rule 'target'"
3537 echo "Move before itself"
3538 tbf_rule_operate ost1 "change\ target\ rank=target"
3539 tbf_rule_check ost1 "before target after default" \
3540 "error when moving before itself"
3542 echo "Move to higher rank"
3543 tbf_rule_operate ost1 "change\ target\ rank=before"
3544 tbf_rule_check ost1 "target before after default" \
3545 "error when moving to higher rank"
3547 echo "Move to lower rank"
3548 tbf_rule_operate ost1 "change\ target\ rank=after"
3549 tbf_rule_check ost1 "before target after default" \
3550 "error when moving to lower rank"
3552 echo "Move before default"
3553 tbf_rule_operate ost1 "change\ target\ rank=default"
3554 tbf_rule_check ost1 "before after target default" \
3555 error "error when moving before default"
3557 # Cleanup the TBF policy
3558 do_nodes $(comma_list $(osts_nodes)) \
3559 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3562 run_test 77i "Change rank of TBF rule"
3567 local ost_version=$(lustre_version_code ost1)
3569 [ $ost_version -ge $(version_code 2.9.53) ] ||
3570 { skip "Need OST version at least 2.9.53"; return 0; }
3571 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3576 do_nodes $(comma_list $(osts_nodes)) \
3577 lctl set_param jobid_var=procname_uid \
3578 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3579 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3580 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3581 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3586 do_nodes $(comma_list $(osts_nodes)) \
3587 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3588 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3589 ost.OSS.ost_io.nrs_policies="fifo"
3591 # sleep 3 seconds to wait the tbf policy stop completely,
3592 # or the next test case is possible get -EAGAIN when
3593 # setting the tbf policy
3596 run_test 77j "check TBF-OPCode NRS policy"
3599 local idstr="${1}id"
3600 local policy="${idstr}={$2}"
3601 local rate="rate=$3"
3603 do_nodes $(comma_list $(osts_nodes)) \
3604 lctl set_param jobid_var=procname_uid \
3605 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3606 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3607 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3609 nrs_write_read "runas $4"
3610 tbf_verify $3 $3 "runas $4"
3612 do_nodes $(comma_list $(osts_nodes)) \
3613 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3614 ost.OSS.ost_io.nrs_policies="fifo"
3616 # sleep 3 seconds to wait the tbf policy stop completely,
3617 # or the next test case is possible get -eagain when
3618 # setting the tbf policy
3623 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3624 skip "Need OST version at least 2.11.50"
3627 test_id "u" "500" "5" "-u 500"
3628 test_id "g" "500" "5" "-u 500 -g 500"
3630 run_test 77ja "check TBF-UID/GID NRS policy"
3638 for rule in $rule_lists; do
3639 do_nodes $(comma_list $(osts_nodes)) \
3640 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3643 do_nodes $(comma_list $(osts_nodes)) \
3644 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3650 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3651 { skip "Need OST version at least 2.9.53"; return 0; }
3653 do_nodes $(comma_list $(osts_nodes)) \
3654 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3655 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3656 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3658 nrs_write_read "$RUNAS"
3659 tbf_verify 20 10 "$RUNAS"
3661 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3662 local client_nids=$(nids_list $address "\\")
3663 do_nodes $(comma_list $(osts_nodes)) \
3664 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3665 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3666 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3667 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3672 do_nodes $(comma_list $(osts_nodes)) \
3673 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3674 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3675 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3677 nrs_write_read "$RUNAS"
3678 tbf_verify 20 20 "$RUNAS"
3680 do_nodes $(comma_list $(osts_nodes)) \
3681 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3682 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3683 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3685 nrs_write_read "$RUNAS"
3686 # with parameter "RUNAS", it will match the latest rule
3687 # "ext_b" first, so the limited write rate is 10.
3688 tbf_verify 10 10 "$RUNAS"
3691 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3693 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3694 { skip "Need OST version at least 2.10.58"; return 0; }
3696 do_nodes $(comma_list $(osts_nodes)) \
3697 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3698 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3699 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3700 nrs_write_read "runas -u 500 -g 1000"
3701 tbf_verify 5 5 "runas -u 500 -g 1000"
3703 do_nodes $(comma_list $(osts_nodes)) \
3704 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3705 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3706 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3708 nrs_write_read "runas -u 500"
3709 tbf_verify 20 10 "runas -u 500"
3711 do_nodes $(comma_list $(osts_nodes)) \
3712 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3713 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3714 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3715 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3716 nrs_write_read "runas -u 500"
3717 tbf_verify 10 10 "runas -u 500"
3718 tbf_verify 20 10 "runas -u 500"
3719 cleanup_77k "ext_a ext_b" "fifo"
3721 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3724 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3725 { skip "Need OST version at least 2.10.56"; return 0; }
3727 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3728 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3730 local output=$(do_facet ost1 lctl get_param \
3731 ost.OSS.ost_io.nrs_policies | \
3732 awk '/name: tbf/ {print;exit}' | \
3733 awk -F ': ' '{print $2}')
3735 if [ "$output" != "tbf" ]; then
3736 error "The generic TBF output is '$output', not 'tbf'"
3739 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3741 run_test 77l "check the output of NRS policies for generic TBF"
3744 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3745 skip "Need OST version at least 2.9.54"
3749 local dir=$DIR/$tdir
3751 mkdir $dir || error "mkdir $dir failed"
3752 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3755 local nodes=$(comma_list $(osts_nodes))
3756 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3757 ost.OSS.ost_io.nrs_delay_min=4 \
3758 ost.OSS.ost_io.nrs_delay_max=4 \
3759 ost.OSS.ost_io.nrs_delay_pct=100
3760 [ $? -ne 0 ] && error "Failed to set delay policy"
3762 local start=$SECONDS
3763 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3764 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3765 oflag=direct conv=fdatasync ||
3766 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3767 error "dd on client failed (1)"; }
3768 local elapsed=$((SECONDS - start))
3770 # NRS delay doesn't do sub-second timing, so a request enqueued at
3771 # 0.9 seconds can be dequeued at 4.0
3772 [ $elapsed -lt 3 ] &&
3773 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3774 error "Single 1M write should take at least 3 seconds"; }
3777 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3778 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3779 oflag=direct conv=fdatasync ||
3780 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3781 error "dd on client failed (2)"; }
3782 elapsed=$((SECONDS - start))
3784 [ $elapsed -lt 30 ] &&
3785 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3786 error "Ten 1M writes should take at least 30 seconds"; }
3788 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3789 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3793 run_test 77m "check NRS Delay slows write RPC processing"
3795 test_77n() { #LU-10802
3796 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3797 skip "Need OST version at least 2.10.58"
3801 # Configure jobid_var
3802 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3803 if [ $saved_jobid_var != procname_uid ]; then
3804 set_persistent_param_and_check client \
3805 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3808 do_nodes $(comma_list $(osts_nodes)) \
3809 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
3810 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3811 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
3814 tbf_verify 20 20 "$RUNAS"
3816 do_nodes $(comma_list $(osts_nodes)) \
3817 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3818 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
3823 do_nodes $(comma_list $(osts_nodes)) \
3824 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3825 ost.OSS.ost_io.nrs_policies="fifo"
3829 local current_jobid_var=$($LCTL get_param -n jobid_var)
3830 if [ $saved_jobid_var != $current_jobid_var ]; then
3831 set_persistent_param_and_check client \
3832 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3835 run_test 77n "check wildcard support for TBF JobID NRS policy"
3837 test_78() { #LU-6673
3840 oss=$(comma_list $(osts_nodes))
3841 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3842 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3844 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3845 # Valid return codes are:
3846 # 0: Tuning succeeded
3847 # ENODEV: Policy is still stopped
3848 # EAGAIN: Policy is being initialized
3849 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3850 error "Expected set_param to return 0|ENODEV|EAGAIN"
3852 # Cleanup the ORR policy
3853 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3854 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3857 run_test 78 "Enable policy and specify tunings right away"
3860 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3861 test_mkdir $DIR/$tdir
3863 # Prevent interference from layout intent RPCs due to
3864 # asynchronous writeback. These will be tested in 130c below.
3865 do_nodes ${CLIENTS:-$HOSTNAME} sync
3867 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3868 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3870 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3871 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
3872 local facet=mds$((mdtidx + 1))
3874 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3875 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3879 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3880 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3885 run_test 79 "xattr: intent error"
3888 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3895 mkdir -p $DIR1/$tdir/dir
3896 createmany -o $DIR1/$tdir/dir/f 10 ||
3897 error "create files under remote dir failed $i"
3899 cp /etc/passwd $DIR1/$tdir/$tfile
3901 #migrate open file should fails
3902 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3904 # give multiop a chance to open
3907 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3908 error "migrate open files should failed with open files"
3912 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3913 error "migrate remote dir error"
3915 echo "Finish migration, then checking.."
3916 for file in $(find $DIR1/$tdir); do
3917 mdt_index=$($LFS getstripe -m $file)
3918 [ $mdt_index == $MDTIDX ] ||
3919 error "$file is not on MDT${MDTIDX}"
3922 diff /etc/passwd $DIR1/$tdir/$tfile ||
3923 error "file different after migration"
3925 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3927 run_test 80a "migrate directory when some children is being opened"
3931 kill -9 $migrate_pid
3935 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3936 local migrate_dir1=$DIR1/$tdir/migrate_dir
3937 local migrate_dir2=$DIR2/$tdir/migrate_dir
3938 local migrate_run=$LUSTRE/tests/migrate.sh
3946 trap cleanup_80b EXIT
3947 #prepare migrate directory
3948 mkdir -p $migrate_dir1
3949 for F in {1,2,3,4,5}; do
3950 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3951 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3954 #migrate the directories among MDTs
3957 mdt_idx=$((RANDOM % MDSCOUNT))
3958 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3960 [ $rc -ne 0 -o $rc -ne 16 ] || break
3965 echo "start migration thread $migrate_pid"
3966 #Access the files at the same time
3967 start_time=$(date +%s)
3968 echo "accessing the migrating directory for 5 minutes..."
3970 ls $migrate_dir2 > /dev/null || {
3971 echo "read dir fails"
3974 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3975 echo "access file1 fails"
3979 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3980 echo "access file2/3 fails"
3984 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3985 echo "access file4 fails"
3989 stat $migrate_dir2/file5 > /dev/null || {
3990 echo "stat file5 fails"
3994 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3995 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3996 echo "touch file failed with $rc1"
4000 if [ -e $migrate_dir2/source_file ]; then
4001 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4002 &>/dev/null || rc1=$?
4003 if [ -e $migrate_dir2/link_file ]; then
4004 rm -rf $migrate_dir2/link_file
4007 mrename $migrate_dir2/source_file \
4008 $migrate_dir2/target_file &>/dev/null || rc1=$?
4009 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4010 echo "rename failed with $rc1"
4014 if [ -e $migrate_dir2/target_file ]; then
4015 rm -rf $migrate_dir2/target_file &>/dev/null ||
4018 rm -rf $migrate_dir2/source_file &>/dev/null ||
4021 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4022 echo "unlink failed with $rc1"
4027 end_time=$(date +%s)
4028 duration=$((end_time - start_time))
4029 if [ $((duration % 10)) -eq 0 ]; then
4030 if [ $show_time -eq 1 ]; then
4031 echo "...$duration seconds"
4038 kill -0 $migrate_pid || {
4039 echo "migration stopped 1"
4043 [ $duration -ge 300 ] && break
4046 #check migration are still there
4047 kill -0 $migrate_pid || error "migration stopped 2"
4050 run_test 80b "Accessing directory during migration"
4053 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4057 mkdir -p $DIR1/$tdir
4059 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4060 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4063 touch d0/0 || error "create 0 failed"
4064 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4065 stat d0/0 && error "stat mv filed succeed"
4066 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4067 stat d0/0 || error "stat failed"
4069 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4071 if [ $t -ne 3 ]; then
4072 ls -ai $DIR1/$tdir/d0
4073 error "expect 3 get $t"
4078 run_test 81a "rename and stat under striped directory"
4081 [ $MDSCOUNT -lt 2 ] &&
4082 skip "We need at least 2 MDTs for this test"
4089 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4090 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4099 for i in $(seq $total); do
4100 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4104 kill -9 $setattr_pid
4106 run_test 81b "rename under striped directory doesn't deadlock"
4109 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4110 { skip "Need MDS version at least 2.6.92"; return 0; }
4112 # Client 1 creates a file.
4113 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4115 # Client 2 opens the file.
4116 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4118 # Client 1 makes the file an orphan.
4119 rm $DIR1/$tfile || error "rm"
4120 # Client 2 sets EA "user.multiop".
4122 wait $pid2 || error "multiop 2"
4123 # Client 1 gets EA "user.multiop". This used to fail because the EA
4124 # cache refill would get "trusted.link" from mdd_xattr_list() but
4125 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4128 wait $pid1 || error "multiop 1"
4130 run_test 82 "fsetxattr and fgetxattr on orphan files"
4133 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4140 $LFS mkdir -i1 -c2 $tdir
4145 echo "start pid $pid1 to create/unlink striped directory"
4147 # Access the directory at the same time
4151 stat $tdir > /dev/null 2>&1
4155 echo "start pid $pid2 to stat striped directory"
4163 run_test 83 "access striped directory while it is being created/unlinked"
4166 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4171 [ "$SLOW" = "yes" ] && duration=600
4172 # Open/Create under striped directory
4176 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4177 touch $tdir/f{0..3} > /dev/null 2>&1
4181 echo "start pid $pid1 to open/create under striped directory"
4183 # unlink the striped directory at the same time
4187 rm -rf $tdir > /dev/null 2>&1
4191 echo "start pid $pid2 to unlink striped directory"
4200 run_test 90 "open/create and unlink striped directory"
4203 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4208 [ "$SLOW" = "yes" ] && duration=600
4209 # chmod striped directory
4213 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4214 chmod go+w $tdir > /dev/null 2>&1
4218 echo "start pid $pid1 to chmod striped directory"
4220 # unlink the striped directory at the same time
4224 rm -rf $tdir > /dev/null 2>&1
4228 echo "start pid $pid2 to unlink striped directory"
4237 run_test 91 "chmod and unlink striped directory"
4240 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4243 local cmd="exec $fd<$DIR1/$tdir"
4244 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4247 trap "eval $cmd" EXIT
4248 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4249 rmdir ../$tdir || error "rmdir ../$tdir fails"
4251 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4252 $LCTL set_param fail_loc=0x1408
4253 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4254 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4255 error "create remote dir succeeds"
4256 $LCTL set_param fail_loc=0
4260 run_test 92 "create remote directory under orphan directory"
4267 mkdir -p $DIR1/$tfile-1/
4268 mkdir -p $DIR2/$tfile-2/
4269 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4270 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4271 do_facet $SINGLEMDS lctl set_param -n \
4272 'lod.lustre-MDT*/qos_threshold_rr' 100
4273 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4274 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4276 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4279 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4283 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4284 do_facet $SINGLEMDS "lctl set_param -n \
4285 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4287 $GETSTRIPE $DIR1/$tfile-1/file1
4288 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4289 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4290 $GETSTRIPE $DIR2/$tfile-2/file2
4291 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4292 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4293 echo "rc1=$rc1 and rc2=$rc2 "
4294 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4295 error "object allocate on same ost detected"
4297 run_test 93 "alloc_rr should not allocate on same ost"
4301 skip "Reserved for glimpse-ahead" && return
4302 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4303 skip "Need MDS version at least 2.10.55" && return
4307 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4309 lctl set_param -n mdc.*.stats=clear
4310 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4312 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4313 # first stat from server should return size data and save glimpse
4314 local gls=$(lctl get_param -n mdc.*.stats | \
4315 awk '/ldlm_glimpse/ {print $2}')
4316 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4317 # second stat to check size is NOT cached on client without IO lock
4318 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4320 local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l)
4321 [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls"
4324 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4327 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4328 skip "Need MDS version at least 2.10.55" && return
4332 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4334 lctl set_param -n mdc.*.stats=clear
4335 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4336 cancel_lru_locks mdc
4337 # first stat data from server should have size
4338 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4339 # second stat to check size is cached on client
4340 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4342 local gls=$(lctl get_param -n mdc.*.stats |
4343 awk '/ldlm_glimpse/ {print $2}')
4344 # both stats should cause no glimpse requests
4345 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4348 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4351 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4352 skip "Need MDS version at least 2.10.55" && return
4356 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4358 lctl set_param -n mdc.*.stats=clear
4359 lctl set_param -n osc.*.stats=clear
4360 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4362 # check that size is merged from MDT and OST correctly
4363 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4364 error "Wrong size from stat #1"
4366 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4367 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4371 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4374 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4375 skip "Need MDS version at least 2.10.55" && return
4379 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4382 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4383 lctl set_param -n mdc.*.stats=clear
4384 $TRUNCATE $DIR2/$tdir/dom 4096
4386 # check that reported size is valid after file grows to OST and
4387 # is truncated back to MDT stripe size
4388 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4389 error "Wrong size from stat #1"
4391 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4392 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4396 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4399 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4400 skip "Need MDS version at least 2.10.55" && return
4402 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4404 $CHECKSTAT -t file $DIR1/$tfile
4406 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4407 sysctl -wq vm.dirty_writeback_centisecs=0
4409 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4412 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4413 error_noexit "Write fails"
4414 # must discard pages
4415 lctl set_param -n mdc.*.stats=clear
4416 rm $DIR2/$tfile || error "Unlink fails"
4418 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4419 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4421 run_test 101a "Discard DoM data on unlink"
4424 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4425 skip "Need MDS version at least 2.10.55" && return
4427 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4428 touch $DIR1/${tfile}_2
4430 $CHECKSTAT -t file $DIR1/$tfile
4432 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4433 sysctl -wq vm.dirty_writeback_centisecs=0
4435 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4438 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4439 # must discard pages
4440 lctl set_param -n mdc.*.stats=clear
4441 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4443 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4444 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4446 run_test 101b "Discard DoM data on rename"
4449 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4450 skip "Need MDS version at least 2.10.55" && return
4452 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4454 $CHECKSTAT -t file $DIR1/$tfile
4456 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4457 sysctl -wq vm.dirty_writeback_centisecs=0
4459 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4462 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4463 $MULTIOP $DIR1/$tfile O_c &
4466 lctl set_param -n mdc.*.stats=clear
4467 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4468 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4470 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4471 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4473 run_test 101c "Discard DoM data on close-unlink"
4475 log "cleanup: ======================================================"
4477 # kill and wait in each test only guarentee script finish, but command in script
4478 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4479 # otherwise umount below will fail
4480 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4485 check_and_cleanup_lustre