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 get_osd_param $node '' read_cache_enable >/dev/null ||
521 skip "not cache-capable obdfilter"
523 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
524 set_osd_param $node '' readcache_max_filesize 4096
525 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
526 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
527 cp $TMP/$tfile $DIR1/$tfile
528 for i in `seq 1 20`; do
529 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
530 cancel_lru_locks $OSC > /dev/null
531 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
532 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
534 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
535 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
536 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
537 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
539 set_osd_param $node '' readcache_max_filesize $MAX
542 run_test 19 "test concurrent uncached read races ==============="
546 cancel_lru_locks $OSC
547 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
548 $MULTIOP $DIR1/f20 Ow8190c
549 $MULTIOP $DIR2/f20 Oz8194w8190c
550 $MULTIOP $DIR1/f20 Oz0r8190c
551 cancel_lru_locks $OSC
552 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
554 error $CNTD" page left in cache after lock cancel" || true
556 run_test 20 "test extra readahead page left in cache ===="
563 test_21() { # Bug 5907
564 test_mkdir $DIR1/$tdir
565 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
567 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
568 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
569 test -d $DIR1/$tdir || error "Mounted directory disappeared"
571 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
574 run_test 21 " Try to remove mountpoint on another dir ===="
576 test_23() { # Bug 5972
577 local at_diff=$(do_facet $SINGLEMDS \
578 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
579 echo "atime should be updated while another read" > $DIR1/$tfile
581 # clear the lock(mode: LCK_PW) gotten from creating operation
582 cancel_lru_locks $OSC
585 sleep $((at_diff + 1))
587 echo "starting reads"
588 multiop_bg_pause $DIR1/$tfile or20_c || return 1
589 # with SOM and opencache enabled, we need to close a file and cancel
590 # open lock to get atime propogated to MDS
591 kill -USR1 $! || return 2
594 time2=$(stat -c "%X" $DIR/$tfile)
595 echo "new atime is $time2"
597 [ $time2 -gt $time1 ] || error "atime was not updated"
598 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
601 run_test 23 " others should see updated atime while another read===="
605 lfs df || error "lfs df failed"
606 lfs df -ih || error "lfs df -ih failed"
607 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
608 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
609 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
610 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
612 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
613 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
614 lctl --device %osc deactivate
615 lfs df -i || error "lfs df -i with deactivated OSC failed"
616 lctl --device %osc activate
617 lfs df || error "lfs df with reactivated OSC failed"
619 run_test 24a "lfs df [-ih] [path] test ========================="
623 fsnum=$(lfs_df | grep -c "summary")
624 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
626 run_test 24b "lfs df should show both filesystems ==============="
629 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
631 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
634 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
635 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
637 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
638 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
639 error "setfacl $DIR2/$tdir #1"
640 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
641 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
642 error "setfacl $DIR2/$tdir #2"
643 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
644 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
645 error "setfacl $DIR2/$tdir #3"
646 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
647 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
648 error "setfacl $DIR2/$tdir #4"
649 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
653 run_test 25a "change ACL on one mountpoint be seen on another ==="
656 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
658 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
660 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
663 $LFS mkdir -i 1 $DIR1/$tdir
664 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
665 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
667 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
668 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
669 error "setfacl $DIR2/$tdir #1"
670 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
671 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
672 error "setfacl $DIR2/$tdir #2"
673 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
674 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
675 error "setfacl $DIR2/$tdir #3"
676 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
677 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
678 error "setfacl $DIR2/$tdir #4"
679 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
683 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
686 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
688 run_test 26a "allow mtime to get older"
693 echo "aaa" >> $DIR1/$tfile
695 chmod a+x $DIR2/$tfile
696 mt1=`stat -c %Y $DIR1/$tfile`
697 mt2=`stat -c %Y $DIR2/$tfile`
699 if [ x"$mt1" != x"$mt2" ]; then
700 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
703 run_test 26b "sync mtime between ost and mds"
706 cancel_lru_locks $OSC
708 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
713 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
718 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
720 lctl set_param -n ldlm.dump_namespaces ""
721 wait $DD1_PID $DD2_PID
722 [ $? -ne 0 ] && lctl dk $TMP/debug || true
724 run_test 27 "align non-overlapping extent locks from request ==="
726 test_28() { # bug 9977
727 ECHO_UUID="ECHO_osc1_UUID"
728 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
730 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
731 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
732 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
736 attach echo_client ECHO_osc1 $ECHO_UUID
740 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
741 $LCTL --device $tECHOID destroy "${tOBJID}:0"
749 # reading of 1st stripe should pass
750 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
751 # reading of 2nd stripe should fail (this stripe was destroyed)
752 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
754 # now, recreating test file
755 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
756 # reading of 1st stripe should pass
757 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
758 # reading of 2nd stripe should pass
759 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
762 run_test 28 "read/write/truncate file with lost stripes"
764 test_30() { #b=11110, LU-2523
765 test_mkdir $DIR1/$tdir
766 cp -f /bin/bash $DIR1/$tdir/bash
767 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
768 $DIR1/$tdir/bash -c 'sleep 2;
769 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
773 run_test 30 "recreate file race"
776 test_mkdir $DIR1/$tdir
777 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
778 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
779 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
780 lctl set_param fail_loc=0x314
781 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
782 awk 'BEGIN { FS="+" } /in/ {print $1}')
783 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
785 run_test 31a "voluntary cancel / blocking ast race=============="
788 remote_ost || { skip "local OST" && return 0; }
789 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
791 # make sure there is no local locks due to destroy
792 wait_mds_ost_sync || error "wait_mds_ost_sync()"
793 wait_delete_completed || error "wait_delete_completed()"
795 test_mkdir $DIR1/$tdir
796 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
797 cp /etc/hosts $DIR/$tdir/$tfile
798 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
799 lctl set_param fail_loc=0x314
800 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
801 do_facet ost1 lctl set_param fail_loc=0x316
803 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
804 lctl set_param fail_loc=0
805 do_facet ost1 lctl set_param fail_loc=0
806 # cleanup: reconnect the client back
809 run_test 31b "voluntary OST cancel / blocking ast race=============="
811 # enable/disable lockless truncate feature, depending on the arg 0/1
812 enable_lockless_truncate() {
813 lctl set_param -n $OSC.*.lockless_truncate $1
816 test_32a() { # bug 11270
817 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
818 local stripe_size=$(do_facet $SINGLEMDS \
819 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
821 save_lustre_params client "$OSC.*.lockless_truncate" > $p
822 cancel_lru_locks $OSC
823 enable_lockless_truncate 1
825 lfs setstripe -c -1 $DIR1/$tfile
826 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
828 clear_stats $OSC.*.${OSC}_stats
830 log "checking cached lockless truncate"
831 $TRUNCATE $DIR1/$tfile 8000000
832 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
833 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
834 error "cached truncate isn't lockless"
836 log "checking not cached lockless truncate"
837 $TRUNCATE $DIR2/$tfile 5000000
838 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
839 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
840 error "not cached truncate isn't lockless"
842 log "disabled lockless truncate"
843 enable_lockless_truncate 0
844 clear_stats $OSC.*.${OSC}_stats
845 $TRUNCATE $DIR2/$tfile 3000000
846 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
847 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
848 error "lockless truncate disabling failed"
850 # restore lockless_truncate default values
851 restore_lustre_params < $p
854 run_test 32a "lockless truncate"
856 test_32b() { # bug 11270
857 remote_ost_nodsh && skip "remote OST with nodsh" && return
860 local facets=$(get_facets OST)
861 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
863 save_lustre_params client "osc.*.contention_seconds" > $p
864 save_lustre_params $facets \
865 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
866 save_lustre_params $facets \
867 "ldlm.namespaces.filter-*.contended_locks" >> $p
868 save_lustre_params $facets \
869 "ldlm.namespaces.filter-*.contention_seconds" >> $p
870 clear_stats $OSC.*.${OSC}_stats
872 # agressive lockless i/o settings
873 do_nodes $(comma_list $(osts_nodes)) \
874 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
875 ldlm.namespaces.filter-*.contended_locks=0 \
876 ldlm.namespaces.filter-*.contention_seconds=60"
877 lctl set_param -n $OSC.*.contention_seconds=60
879 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
881 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
884 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
885 error "lockless i/o was not triggered"
886 # disable lockless i/o (it is disabled by default)
887 do_nodes $(comma_list $(osts_nodes)) \
888 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
889 ldlm.namespaces.filter-*.contended_locks=32 \
890 ldlm.namespaces.filter-*.contention_seconds=0"
891 # set contention_seconds to 0 at client too, otherwise Lustre still
892 # remembers lock contention
893 lctl set_param -n $OSC.*.contention_seconds=0
894 clear_stats $OSC.*.${OSC}_stats
896 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
898 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
901 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
902 error "lockless i/o works when disabled"
904 restore_lustre_params <$p
907 run_test 32b "lockless i/o"
911 local mdts=$(get_facets MDS)
916 for mds in ${mdts//,/ }; do
918 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
919 xargs readlink -f" ))
920 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
923 stat=$(( stat + val))
928 # commit on sharing tests
930 remote_mds_nodsh && skip "remote MDS with nodsh" && return
932 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
933 [ $CLIENTCOUNT -lt 2 ] &&
934 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
936 local nfiles=${TEST33_NFILES:-10000}
937 local param_file=$TMP/$tfile-params
938 local fstype=$(facet_fstype $SINGLEMDS)
940 save_lustre_params $(get_facets MDS) \
941 "mdt.*.commit_on_sharing" > $param_file
949 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
953 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
955 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
956 echo "=== START createmany old: $jbdold transaction"
957 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")
958 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
959 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
960 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
961 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
962 avgtime=$(( avgtime + elapsed ))
964 eval cos${COS}_jbd=$((avgjbd / 3))
965 eval cos${COS}_time=$((avgtime / 3))
968 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
969 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
970 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
971 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
973 restore_lustre_params < $param_file
977 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
979 # commit on sharing tests
981 remote_mds_nodsh && skip "remote MDS with nodsh" && return
983 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
984 [ $CLIENTCOUNT -ge 2 ] ||
985 { skip "Need two or more clients, have $CLIENTCOUNT" &&
987 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
989 local nfiles=${TEST33_NFILES:-10000}
990 local param_file=$TMP/$tfile-params
992 save_lustre_params $(get_facets MDS) \
993 "mdt.*.commit_on_sharing" > $param_file
1002 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1006 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1007 $DIR1/$tdir-\\\$(hostname)-$i"
1009 jbdold=$(print_jbd_stat)
1010 echo "=== START createmany old: $jbdold transaction"
1011 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1012 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1013 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1015 jbdnew=$(print_jbd_stat)
1016 jbd=$(( jbdnew - jbdold ))
1017 echo "=== END createmany new: $jbdnew transaction : \
1018 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1019 avgjbd=$(( avgjbd + jbd ))
1020 avgtime=$(( avgtime + elapsed ))
1022 eval cos${COS}_jbd=$((avgjbd / 3))
1023 eval cos${COS}_time=$((avgtime / 3))
1026 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1027 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1028 [ "$cos0_jbd" != 0 ] &&
1029 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1030 [ "$cos0_time" != 0 ] &&
1031 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1033 restore_lustre_params < $param_file
1037 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1040 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1041 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1042 skip "DNE CoS not supported" && return
1048 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1049 # do twice in case transaction is committed before unlock, see LU-8200
1051 # remote dir is created on MDT1, which enqueued lock of $tdir on
1053 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1054 mkdir $DIR/$tdir/local.$i
1056 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1057 echo "sync_count $sync_count"
1058 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1061 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1062 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1063 # during sleep remote mkdir should have been committed and canceled
1064 # remote lock spontaneously, which shouldn't trigger sync
1066 mkdir $DIR/$tdir/local.3
1067 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1068 echo "sync_count $sync_count"
1069 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1071 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1073 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1077 local nodes=$(comma_list $(mdts_nodes))
1081 # trigger CoS twice in case transaction commit before unlock
1084 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1086 commit_nr=$(do_nodes $nodes \
1087 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1088 total=$((total + commit_nr));
1093 echo "CoS count $total"
1094 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1098 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1099 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1100 skip "DNE CoS not supported" && return
1102 # remote directory create
1103 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1104 # remote directory unlink
1105 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1106 # striped directory create
1107 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1108 # striped directory setattr
1109 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1110 "chmod 713 $DIR/$tdir"
1111 # striped directory unlink
1112 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1115 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1116 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1117 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1118 touch $DIR/$tdir/d1/tgt" \
1119 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1121 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1122 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1123 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1124 touch $DIR/$tdir/d1/src" \
1125 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1127 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1128 "$LFS migrate -m 1 $DIR/$tdir"
1132 run_test 33d "DNE distributed operation should trigger COS"
1135 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1136 [ $CLIENTCOUNT -ge 2 ] ||
1137 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1139 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1140 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1141 skip "DNE CoS not supported" && return
1143 local client2=${CLIENT2:-$(hostname)}
1147 local nodes=$(comma_list $(mdts_nodes))
1148 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1150 $LFS mkdir -c 2 $DIR/$tdir
1151 mkdir $DIR/$tdir/subdir
1152 echo abc > $DIR/$tdir/$tfile
1153 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1154 do_node $client2 touch $DIR/$tdir/subdir
1156 local async_commit_count=$(do_nodes $nodes \
1157 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1158 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1162 run_test 33e "DNE local operation shouldn't trigger COS"
1164 # End commit on sharing tests
1166 get_ost_lock_timeouts() {
1167 local nodes=${1:-$(comma_list $(osts_nodes))}
1169 local locks=$(do_nodes $nodes \
1170 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1178 do_nodes $(comma_list $(osts_nodes)) \
1179 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1180 for i in $(seq $OSTCOUNT); do
1181 wait_osc_import_ready client ost$i
1186 remote_ost_nodsh && skip "remote OST with nodsh" && return
1190 trap cleanup_34 EXIT RETURN
1191 for OPER in notimeout timeout ; do
1192 rm $DIR1/$tfile 2>/dev/null
1193 lock_in=$(get_ost_lock_timeouts)
1194 if [ $OPER == "timeout" ] ; then
1195 for j in `seq $OSTCOUNT`; do
1196 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1197 do_facet ost$j lctl set_param fail_loc=0x511
1199 echo lock should expire
1201 for j in `seq $OSTCOUNT`; do
1202 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1203 do_facet ost$j lctl set_param fail_loc=0x512
1205 echo lock should not expire
1207 echo writing on client1
1208 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1210 echo reading on client2
1211 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1212 # wait for a lock timeout
1214 lock_out=$(get_ost_lock_timeouts)
1215 if [ $OPER == "timeout" ] ; then
1216 if [ $lock_in == $lock_out ]; then
1217 error "no lock timeout happened"
1222 if [ $lock_in != $lock_out ]; then
1223 error "lock timeout happened"
1231 run_test 34 "no lock timeout under IO"
1233 test_35() { # bug 17645
1236 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1237 awk '/generation/{print $2}')
1239 generation[count]=$g
1243 test_mkdir $MOUNT1/$tdir
1244 cancel_lru_locks mdc
1246 # Let's initiate -EINTR situation by setting fail_loc and take
1247 # write lock on same file from same client. This will not cause
1248 # bl_ast yet as lock is already in local cache.
1249 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1250 do_facet client "lctl set_param fail_loc=0x80000317"
1251 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1252 let timeout=timeout*3
1254 while test $nr -lt 10; do
1255 log "Race attempt $nr"
1256 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1257 awk '/ldlm_bl_callback/ { print $2 }')
1258 test "x$blk1" = "x" && blk1=0
1259 createmany -o $MOUNT2/$tdir/a 4000 &
1263 # Let's make conflict and bl_ast
1264 ls -la $MOUNT1/$tdir > /dev/null &
1267 log "Wait for $pid1 $pid2 for $timeout sec..."
1269 kill -9 $pid1 $pid2 > /dev/null 2>&1
1271 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1272 awk '/ldlm_bl_callback/ { print $2 }')
1273 test "x$blk2" = "x" && blk2=0
1274 test $blk2 -gt $blk1 && break
1275 rm -fr $MOUNT1/$tdir
1276 cancel_lru_locks mdc
1279 do_facet client "lctl set_param fail_loc=0x0"
1280 df -h $MOUNT1 $MOUNT2
1282 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1283 awk '/generation/{print $2}')
1285 if ! test "$g" -eq "${generation[count]}"; then
1286 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1288 for imp in $list; do
1289 if [ $c = $count ]; then
1294 imp=$(echo "$imp" | awk -F"." '{print $2}')
1295 error "Eviction happened on import $imp"
1300 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1302 test_36() { #bug 16417
1307 test_mkdir $DIR1/$tdir
1308 $LFS setstripe -c -1 $DIR1/$tdir
1311 let SIZE_B=SIZE*1024*1024
1312 sync; sleep 2; sync # wait for delete thread
1313 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1314 wait_destroy_complete || error "wait_destroy_complete failed"
1316 while [ $i -le 10 ]; do
1317 lctl mark "start test - cycle ($i)"
1318 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1319 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1320 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1321 sync # sync data from client cache
1322 sync_all_data # sync data from server cache (delayed allocation)
1324 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1325 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1327 rm -f $DIR1/$tdir/$tfile
1328 kill -USR1 $read_pid
1330 sync; sleep 2; sync # Ensure new statfs
1331 wait_delete_completed
1332 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1333 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1335 # this free space! not used
1336 (( $after_dd <= $after)) ||
1337 error "space leaked after_dd:$after_dd > after:$after"
1341 run_test 36 "handle ESTALE/open-unlink correctly"
1343 test_37() { # bug 18695
1344 test_mkdir $DIR1/$tdir
1345 multiop_bg_pause $DIR1/$tdir D_c || return 1
1347 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1348 createmany -m $DIR2/$tdir/f 10000
1349 # set mtime/atime backward
1350 touch -t 198001010000 $DIR2/$tdir
1351 kill -USR1 $MULTIPID
1352 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1353 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1356 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1358 # this should be set to past
1359 TEST_39_MTIME=`date -d "1 year ago" +%s`
1363 local client1=${CLIENT1:-`hostname`}
1364 local client2=${CLIENT2:-`hostname`}
1366 do_node $client1 "touch $DIR1/$tfile"
1368 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1369 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1370 [ "$mtime1" = $TEST_39_MTIME ] || \
1371 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1373 local d1=`do_node $client1 date +%s`
1374 do_node $client1 'echo hello >> '$DIR1/$tfile
1375 local d2=`do_node $client1 date +%s`
1377 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1378 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1379 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1381 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1383 for (( i=0; i < 2; i++ )) ; do
1384 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1385 [ "$mtime2" = "$mtime3" ] || \
1386 error "mtime ($mtime2) changed (to $mtime3) on rename"
1388 cancel_lru_locks osc
1389 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1392 run_test 39a "test from 11063 =================================="
1395 local client1=${CLIENT1:-`hostname`}
1396 local client2=${CLIENT2:-`hostname`}
1400 local mtime1=`stat -c %Y $DIR1/$tfile`
1401 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1404 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1406 for (( i=0; i < 2; i++ )) ; do
1407 local mtime3=`stat -c %Y $DIR1/$tfile`
1408 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1410 [ "$mtime3" = "$mtime4" ] || \
1411 error "different mtime on clients: $mtime3, $mtime4"
1412 [ "$mtime3" = $TEST_39_MTIME ] || \
1413 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1415 cancel_lru_locks osc
1416 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1419 run_test 39b "11063 problem 1 =================================="
1422 local client1=${CLIENT1:-`hostname`}
1423 local client2=${CLIENT2:-`hostname`}
1425 echo hello > $DIR1/$tfile
1427 local mtime1=`stat -c %Y $DIR1/$tfile`
1428 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1429 [ "$mtime1" = "$mtime2" ] || \
1430 error "create: different mtime on clients: $mtime1, $mtime2"
1433 $TRUNCATE $DIR1/$tfile 1
1435 for (( i=0; i < 2; i++ )) ; do
1436 local mtime3=`stat -c %Y $DIR1/$tfile`
1437 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1439 [ "$mtime3" = "$mtime4" ] || \
1440 error "different mtime on clients: $mtime3, $mtime4"
1441 [ "$mtime3" -gt $mtime2 ] || \
1442 error "truncate did not update mtime: $mtime2, $mtime3"
1444 cancel_lru_locks osc
1445 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1448 run_test 39c "check truncate mtime update ======================"
1450 test_39d() { # LU-7310
1452 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1454 local mtime1=$(stat -c %Y $DIR2/$tfile)
1455 [ "$mtime1" = $TEST_39_MTIME ] ||
1456 error "mtime: $mtime1, should be $TEST_39_MTIME"
1459 # define OBD_FAIL_OSC_NO_GRANT 0x411
1460 $LCTL set_param fail_loc=0x411
1462 local d1=$(date +%s)
1463 echo hello >> $DIR1/$tfile
1464 local d2=$(date +%s)
1466 $LCTL set_param fail_loc=0
1468 cancel_lru_locks $OSC
1470 local mtime2=$(stat -c %Y $DIR2/$tfile)
1471 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1472 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1474 run_test 39d "sync write should update mtime"
1476 # check that pid exists hence second operation wasn't blocked by first one
1477 # if it is so then there is no conflict, return 0
1478 # else second operation is conflicting with first one, return 1
1479 check_pdo_conflict() {
1482 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1483 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1493 # test 40: check non-blocking operations
1495 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1496 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1497 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1499 mkdir $DIR1/$tfile &
1502 touch $DIR2/$tfile-2
1503 check_pdo_conflict $PID1 || error "create is blocked"
1504 mkdir $DIR2/$tfile-3
1505 check_pdo_conflict $PID1 || error "mkdir is blocked"
1506 link $DIR2/$tfile-2 $DIR2/$tfile-4
1507 check_pdo_conflict $PID1 || error "link is blocked"
1508 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1509 check_pdo_conflict $PID1 || error "rename is blocked"
1510 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1511 check_pdo_conflict $PID1 || error "getattr is blocked"
1512 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1513 rmdir $DIR2/$tfile-3
1514 check_pdo_conflict $PID1 || error "unlink is blocked"
1516 # all operations above shouldn't wait the first one
1517 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1522 run_test 40a "pdirops: create vs others =============="
1525 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1526 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1527 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1528 touch $DIR1/$tfile &
1532 touch $DIR2/$tfile-2
1533 check_pdo_conflict $PID1 || error "create is blocked"
1534 mkdir $DIR2/$tfile-3
1535 check_pdo_conflict $PID1 || error "mkdir is blocked"
1536 link $DIR2/$tfile-2 $DIR2/$tfile-4
1537 check_pdo_conflict $PID1 || error "link is blocked"
1538 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1539 check_pdo_conflict $PID1 || error "rename is blocked"
1540 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1541 check_pdo_conflict $PID1 || error "getattr is blocked"
1542 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1543 rmdir $DIR2/$tfile-3
1544 check_pdo_conflict $PID1 || error "unlink is blocked"
1545 # all operations above shouldn't wait the first one
1547 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1552 run_test 40b "pdirops: open|create and others =============="
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1558 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1559 link $DIR1/$tfile $DIR1/$tfile-0 &
1563 touch $DIR2/$tfile-2
1564 check_pdo_conflict $PID1 || error "create is blocked"
1565 mkdir $DIR2/$tfile-3
1566 check_pdo_conflict $PID1 || error "mkdir is blocked"
1567 link $DIR2/$tfile-2 $DIR2/$tfile-4
1568 check_pdo_conflict $PID1 || error "link is blocked"
1569 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1570 check_pdo_conflict $PID1 || error "rename is blocked"
1571 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1572 check_pdo_conflict $PID1 || error "getattr is blocked"
1573 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1574 rmdir $DIR2/$tfile-3
1575 check_pdo_conflict $PID1 || error "unlink is blocked"
1577 # all operations above shouldn't wait the first one
1578 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1583 run_test 40c "pdirops: link and others =============="
1586 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1588 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1589 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1594 touch $DIR2/$tfile-2
1595 check_pdo_conflict $PID1 || error "create is blocked"
1596 mkdir $DIR2/$tfile-3
1597 check_pdo_conflict $PID1 || error "mkdir is blocked"
1598 link $DIR2/$tfile-2 $DIR2/$tfile-4
1599 check_pdo_conflict $PID1 || error "link is blocked"
1600 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1601 check_pdo_conflict $PID1 || error "rename is blocked"
1602 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1603 check_pdo_conflict $PID1 || error "getattr is blocked"
1604 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1605 rmdir $DIR2/$tfile-3
1606 check_pdo_conflict $PID1 || error "unlink is blocked"
1608 # all operations above shouldn't wait the first one
1609 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1613 run_test 40d "pdirops: unlink and others =============="
1616 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1618 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1619 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1620 mv $DIR1/$tfile $DIR1/$tfile-0 &
1624 touch $DIR2/$tfile-2
1625 check_pdo_conflict $PID1 || error "create is blocked"
1626 mkdir $DIR2/$tfile-3
1627 check_pdo_conflict $PID1 || error "mkdir is blocked"
1628 link $DIR2/$tfile-2 $DIR2/$tfile-4
1629 check_pdo_conflict $PID1 || error "link is blocked"
1630 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1631 check_pdo_conflict $PID1 || error "getattr is blocked"
1632 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1633 rmdir $DIR2/$tfile-3
1634 check_pdo_conflict $PID1 || error "unlink is blocked"
1636 # all operations above shouldn't wait the first one
1637 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1642 run_test 40e "pdirops: rename and others =============="
1644 # test 41: create blocking operations
1646 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1647 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1648 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1651 mkdir $DIR2/$tfile && error "mkdir must fail"
1652 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1656 run_test 41a "pdirops: create vs mkdir =============="
1659 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1660 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1661 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1664 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1665 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1669 run_test 41b "pdirops: create vs create =============="
1672 touch $DIR1/$tfile-2
1673 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1674 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1675 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1678 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1679 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1683 run_test 41c "pdirops: create vs link =============="
1686 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1687 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1688 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1691 rm $DIR2/$tfile || error "unlink must succeed"
1692 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1696 run_test 41d "pdirops: create vs unlink =============="
1699 touch $DIR1/$tfile-2
1700 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1701 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1702 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1705 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1706 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1710 run_test 41e "pdirops: create and rename (tgt) =============="
1713 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1714 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1715 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1718 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1719 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1723 run_test 41f "pdirops: create and rename (src) =============="
1726 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1727 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1728 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1731 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1732 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1736 run_test 41g "pdirops: create vs getattr =============="
1739 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1740 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1741 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1744 ls -lia $DIR2/ > /dev/null
1745 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1749 run_test 41h "pdirops: create vs readdir =============="
1751 # test 42: unlink and blocking operations
1753 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1754 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1755 mkdir $DIR1/$tfile &
1758 mkdir $DIR2/$tfile && error "mkdir must fail"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1763 run_test 42a "pdirops: mkdir vs mkdir =============="
1766 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1767 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1768 mkdir $DIR1/$tfile &
1771 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1772 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1776 run_test 42b "pdirops: mkdir vs create =============="
1779 touch $DIR1/$tfile-2
1780 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1781 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1782 mkdir $DIR1/$tfile &
1785 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1786 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1790 run_test 42c "pdirops: mkdir vs link =============="
1793 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1794 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1795 mkdir $DIR1/$tfile &
1798 rmdir $DIR2/$tfile || error "unlink must succeed"
1799 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1803 run_test 42d "pdirops: mkdir vs unlink =============="
1806 touch $DIR1/$tfile-2
1807 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1808 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1809 mkdir $DIR1/$tfile &
1812 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1813 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1817 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1820 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1821 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1822 mkdir $DIR1/$tfile &
1825 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1826 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1830 run_test 42f "pdirops: mkdir and rename (src) =============="
1833 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1834 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1835 mkdir $DIR1/$tfile &
1838 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1839 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1843 run_test 42g "pdirops: mkdir vs getattr =============="
1846 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1847 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1848 mkdir $DIR1/$tfile &
1851 ls -lia $DIR2/ > /dev/null
1852 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1856 run_test 42h "pdirops: mkdir vs readdir =============="
1858 # test 43: unlink and blocking operations
1861 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1862 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1866 mkdir $DIR2/$tfile || error "mkdir must succeed"
1867 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1871 run_test 43a "pdirops: unlink vs mkdir =============="
1875 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1876 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1880 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1881 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1885 run_test 43b "pdirops: unlink vs create =============="
1889 touch $DIR1/$tfile-2
1890 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1891 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1895 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1896 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1900 run_test 43c "pdirops: unlink vs link =============="
1904 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1905 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1909 rm $DIR2/$tfile && error "unlink must fail"
1910 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1914 run_test 43d "pdirops: unlink vs unlink =============="
1918 touch $DIR1/$tfile-2
1919 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1920 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1924 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1925 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1929 run_test 43e "pdirops: unlink and rename (tgt) =============="
1933 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1934 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1938 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1939 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1943 run_test 43f "pdirops: unlink and rename (src) =============="
1947 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1948 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1952 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1953 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1957 run_test 43g "pdirops: unlink vs getattr =============="
1961 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1962 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1966 ls -lia $DIR2/ > /dev/null
1967 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1971 run_test 43h "pdirops: unlink vs readdir =============="
1974 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1976 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1977 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1981 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1982 check_pdo_conflict $PID1 &&
1983 { wait $PID1; error "remote mkdir isn't blocked"; }
1987 run_test 43i "pdirops: unlink vs remote mkdir"
1989 # test 44: rename tgt and blocking operations
1991 touch $DIR1/$tfile-2
1992 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1993 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1994 mv $DIR1/$tfile-2 $DIR1/$tfile &
1997 mkdir $DIR2/$tfile && error "mkdir must fail"
1998 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2002 run_test 44a "pdirops: rename tgt vs mkdir =============="
2005 touch $DIR1/$tfile-2
2006 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2007 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2008 mv $DIR1/$tfile-2 $DIR1/$tfile &
2011 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2012 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2016 run_test 44b "pdirops: rename tgt vs create =============="
2019 touch $DIR1/$tfile-2
2020 touch $DIR1/$tfile-3
2021 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2022 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2023 mv $DIR1/$tfile-2 $DIR1/$tfile &
2026 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
2027 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2031 run_test 44c "pdirops: rename tgt vs link =============="
2034 touch $DIR1/$tfile-2
2035 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2036 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2037 mv $DIR1/$tfile-2 $DIR1/$tfile &
2040 rm $DIR2/$tfile || error "unlink must succeed"
2041 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2045 run_test 44d "pdirops: rename tgt vs unlink =============="
2049 touch $DIR1/$tfile-2
2050 touch $DIR1/$tfile-3
2051 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2052 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2053 mv $DIR1/$tfile-2 $DIR1/$tfile &
2056 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2057 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2061 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2064 touch $DIR1/$tfile-2
2065 touch $DIR1/$tfile-3
2066 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2067 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2068 mv $DIR1/$tfile-2 $DIR1/$tfile &
2071 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2072 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2076 run_test 44f "pdirops: rename tgt and rename (src) =============="
2079 touch $DIR1/$tfile-2
2080 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2081 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2082 mv $DIR1/$tfile-2 $DIR1/$tfile &
2085 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2086 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2090 run_test 44g "pdirops: rename tgt vs getattr =============="
2093 touch $DIR1/$tfile-2
2094 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2095 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2096 mv $DIR1/$tfile-2 $DIR1/$tfile &
2099 ls -lia $DIR2/ > /dev/null
2100 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2104 run_test 44h "pdirops: rename tgt vs readdir =============="
2106 # test 44: rename tgt and blocking operations
2108 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2109 touch $DIR1/$tfile-2
2110 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2111 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2112 mv $DIR1/$tfile-2 $DIR1/$tfile &
2115 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2116 check_pdo_conflict $PID1 && { wait $PID1;
2117 error "remote mkdir isn't blocked"; }
2121 run_test 44i "pdirops: rename tgt vs remote mkdir"
2123 # test 45: rename src and blocking operations
2126 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2127 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2128 mv $DIR1/$tfile $DIR1/$tfile-2 &
2131 mkdir $DIR2/$tfile || error "mkdir must succeed"
2132 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2136 run_test 45a "pdirops: rename src vs mkdir =============="
2140 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2141 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2142 mv $DIR1/$tfile $DIR1/$tfile-2 &
2145 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2146 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2150 run_test 45b "pdirops: rename src vs create =============="
2154 touch $DIR1/$tfile-3
2155 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2156 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2157 mv $DIR1/$tfile $DIR1/$tfile-2 &
2160 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2161 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2165 run_test 45c "pdirops: rename src vs link =============="
2169 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2170 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2171 mv $DIR1/$tfile $DIR1/$tfile-2 &
2174 rm $DIR2/$tfile && error "unlink must fail"
2175 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2179 run_test 45d "pdirops: rename src vs unlink =============="
2183 touch $DIR1/$tfile-3
2184 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2185 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2186 mv $DIR1/$tfile $DIR1/$tfile-2 &
2189 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2190 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2194 run_test 45e "pdirops: rename src and rename (tgt) =============="
2198 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2199 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2200 mv $DIR1/$tfile $DIR1/$tfile-2 &
2203 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2204 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2208 run_test 45f "pdirops: rename src and rename (src) =============="
2212 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2213 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2214 mv $DIR1/$tfile $DIR1/$tfile-2 &
2217 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2218 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2222 run_test 45g "pdirops: rename src vs getattr =============="
2226 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2227 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2228 mv $DIR1/$tfile $DIR1/$tfile-2 &
2231 ls -lia $DIR2/ > /dev/null
2232 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2236 run_test 45h "pdirops: unlink vs readdir =============="
2239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2241 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2242 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2243 mv $DIR1/$tfile $DIR1/$tfile-2 &
2246 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2247 check_pdo_conflict $PID1 && { wait $PID1;
2248 error "create remote dir isn't blocked"; }
2252 run_test 45i "pdirops: rename src vs remote mkdir"
2254 # test 46: link and blocking operations
2256 touch $DIR1/$tfile-2
2257 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2258 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2259 link $DIR1/$tfile-2 $DIR1/$tfile &
2262 mkdir $DIR2/$tfile && error "mkdir must fail"
2263 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2267 run_test 46a "pdirops: link vs mkdir =============="
2270 touch $DIR1/$tfile-2
2271 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2272 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2273 link $DIR1/$tfile-2 $DIR1/$tfile &
2276 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2277 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2281 run_test 46b "pdirops: link vs create =============="
2284 touch $DIR1/$tfile-2
2285 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2286 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2287 link $DIR1/$tfile-2 $DIR1/$tfile &
2290 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2291 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2295 run_test 46c "pdirops: link vs link =============="
2298 touch $DIR1/$tfile-2
2299 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2300 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2301 link $DIR1/$tfile-2 $DIR1/$tfile &
2304 rm $DIR2/$tfile || error "unlink must succeed"
2305 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2309 run_test 46d "pdirops: link vs unlink =============="
2312 touch $DIR1/$tfile-2
2313 touch $DIR1/$tfile-3
2314 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2315 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2316 link $DIR1/$tfile-2 $DIR1/$tfile &
2319 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2320 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2324 run_test 46e "pdirops: link and rename (tgt) =============="
2327 touch $DIR1/$tfile-2
2328 touch $DIR1/$tfile-3
2329 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2330 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2331 link $DIR1/$tfile-2 $DIR1/$tfile &
2334 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2335 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2339 run_test 46f "pdirops: link and rename (src) =============="
2342 touch $DIR1/$tfile-2
2343 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2344 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2345 link $DIR1/$tfile-2 $DIR1/$tfile &
2348 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2349 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2353 run_test 46g "pdirops: link vs getattr =============="
2356 touch $DIR1/$tfile-2
2357 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2358 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2359 link $DIR1/$tfile-2 $DIR1/$tfile &
2362 ls -lia $DIR2/ > /dev/null
2363 check_pdo_conflict $PID1 && { wait $PID1;
2364 error "readdir isn't blocked"; }
2368 run_test 46h "pdirops: link vs readdir =============="
2371 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2372 touch $DIR1/$tfile-2
2373 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2374 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2375 link $DIR1/$tfile-2 $DIR1/$tfile &
2378 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2379 check_pdo_conflict $PID1 && { wait $PID1;
2380 error "remote mkdir isn't blocked"; }
2384 run_test 46i "pdirops: link vs remote mkdir"
2386 # test 47: remote mkdir and blocking operations
2388 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2389 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2390 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2391 $LFS mkdir -i 1 $DIR1/$tfile &
2394 mkdir $DIR2/$tfile && error "mkdir must fail"
2395 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2399 run_test 47a "pdirops: remote mkdir vs mkdir"
2402 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2403 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2404 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2405 $LFS mkdir -i 1 $DIR1/$tfile &
2408 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2409 check_pdo_conflict $PID1 && { wait $PID1;
2410 error "create isn't blocked"; }
2414 run_test 47b "pdirops: remote mkdir vs create"
2417 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2418 touch $DIR1/$tfile-2
2419 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2420 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2421 $LFS mkdir -i 1 $DIR1/$tfile &
2424 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2425 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2429 run_test 47c "pdirops: remote mkdir vs link"
2432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2433 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2434 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2435 $LFS mkdir -i 1 $DIR1/$tfile &
2438 rmdir $DIR2/$tfile || error "unlink must succeed"
2439 check_pdo_conflict $PID1 && { wait $PID1;
2440 error "unlink isn't blocked"; }
2444 run_test 47d "pdirops: remote mkdir vs unlink"
2447 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2448 touch $DIR1/$tfile-2
2449 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2450 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2451 $LFS mkdir -i 1 $DIR1/$tfile &
2454 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2455 check_pdo_conflict $PID1 && { wait $PID1;
2456 error "rename isn't blocked"; }
2460 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2463 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2464 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2465 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2466 $LFS mkdir -i 1 $DIR1/$tfile &
2469 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2470 check_pdo_conflict $PID1 && { wait $PID1;
2471 error "rename isn't blocked"; }
2475 run_test 47f "pdirops: remote mkdir and rename (src)"
2478 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2481 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2482 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2483 $LFS mkdir -i 1 $DIR1/$tfile &
2486 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2487 check_pdo_conflict $PID1 && { wait $PID1;
2488 error "getattr isn't blocked"; }
2492 run_test 47g "pdirops: remote mkdir vs getattr"
2496 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2497 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2498 do_facet client "lctl set_param fail_loc=0x410"
2499 $TRUNCATE $DIR2/$tfile $trunc_size
2500 do_facet client "lctl set_param fail_loc=0x0"
2502 size=`stat -c %s $DIR2/$tfile`
2503 [ $size -eq $trunc_size ] || error "wrong size"
2505 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2509 local origfile=/etc/hosts
2511 filesize=$(stat -c %s $origfile)
2513 # create an empty file
2514 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2515 # cache layout lock on both mount point
2516 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2517 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2519 # open and sleep 2 seconds then read
2520 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2524 # create the layout of testing file
2525 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2526 error "dd $DIR1/$tfile failed"
2528 # MULTIOP proc should be able to read enough bytes and exit
2529 for ((i = 0; i < 6; i++)); do
2531 kill -0 $pid || break
2533 kill -0 $pid 2> /dev/null && error "multiop is still there"
2534 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2538 run_test 51a "layout lock: refresh layout should work"
2541 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2542 { skip "Need MDS version at least 2.3.59"; return 0; }
2544 local tmpfile=`mktemp`
2546 # create an empty file
2547 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2549 # delay glimpse so that layout has changed when glimpse finish
2550 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2551 $LCTL set_param fail_loc=0x1404
2552 stat -c %s $DIR2/$tfile |tee $tmpfile &
2556 # create layout of testing file
2557 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2558 error "dd $DIR1/$tfile failed"
2561 local fsize=$(cat $tmpfile)
2563 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2565 rm -f $DIR1/$tfile $tmpfile
2567 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2570 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2572 # set default layout to have 1 stripe
2574 $LFS setstripe -c 1 $DIR1/$tdir
2576 # create a file with empty layout
2577 $MCREATE $DIR1/$tdir/$tfile ||
2578 error "$MCREATE $DIR1/$tdir/$tfile failed"
2580 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2581 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2583 # change the layout of testing file
2584 echo "Setting layout to have $OSTCOUNT stripes ..."
2585 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2589 # write something to the file, it should be blocked on fetching layout
2590 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2591 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2594 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2595 # count to succeed with only 3/4 of the number of stripes (rounded up),
2596 # so creating striped files does not fail if an OST is offline or full
2597 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2598 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2602 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2605 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2606 cancel_lru_locks mdc
2608 # open should grant LAYOUT lock, mmap and read will install pages
2609 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2613 # rss before revoking
2614 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2615 echo "Before revoking layout lock: $br KB mapped"
2617 # cancel layout lock manually
2618 cancel_lru_locks mdc
2620 # rss after revoking
2621 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2624 wait $PID || error "wait PID $PID failed"
2626 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2628 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2632 echo "==> rename vs getattr vs setxattr should not deadlock"
2633 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2635 do_facet mds1 $LCTL set_param fail_loc=$1
2637 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2645 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2646 wait $PID1 || error "(3) mv failed"
2647 wait $PID2 || error "(4) stat failed"
2654 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2655 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2657 do_facet mds1 $LCTL set_param fail_loc=$1
2659 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2667 $MULTIOP $DIR2/d1/d2 Oc &
2671 stat $DIR/d1 || error "(2) stat failed"
2673 wait $PID1 || error "(3) mv failed"
2674 wait $PID2 || error "(4) stat failed"
2675 wait $PID3 && error "(5) multiop failed"
2681 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2682 save_lustre_params client "llite.*.xattr_cache" > $p
2683 lctl set_param llite.*.xattr_cache 1 ||
2684 { skip "xattr cache is not supported"; return 0; }
2686 #define OBD_FAIL_MDS_RENAME 0x153
2687 #define OBD_FAIL_MDS_RENAME2 0x154
2688 test_54_part1 0x80000153 || error 10
2689 test_54_part1 0x80000154 || error 11
2690 test_54_part2 0x80000153 || error 12
2691 test_54_part2 0x80000154 || error 13
2693 restore_lustre_params < $p
2696 run_test 54 "rename locking"
2699 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2701 #define OBD_FAIL_MDS_RENAME4 0x156
2702 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2704 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2709 wait $PID1 && error "(2) mv succeeded"
2713 run_test 55a "rename vs unlink target dir"
2717 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2719 #define OBD_FAIL_MDS_RENAME4 0x156
2720 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2722 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2727 wait $PID1 && error "(2) mv succeeded"
2731 run_test 55b "rename vs unlink source dir"
2735 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2737 #define OBD_FAIL_MDS_RENAME4 0x156
2738 do_facet mds1 $LCTL set_param fail_loc=0x156
2740 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2744 # while rename is sleeping, open and remove d3
2745 $MULTIOP $DIR2/d3 D_c &
2751 # while rename is sleeping 2nd time, close d3
2753 wait $PID2 || error "(3) multiop failed"
2755 wait $PID1 && error "(2) mv succeeded"
2759 run_test 55c "rename vs unlink orphan target dir"
2765 #define OBD_FAIL_MDS_RENAME3 0x155
2766 do_facet mds1 $LCTL set_param fail_loc=0x155
2767 mv $DIR/f1 $DIR/$tdir &
2771 # while rename is sleeping, create $tdir, but as a directory
2772 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2774 # link in reverse locking order
2775 ln $DIR2/f1 $DIR2/$tdir/
2777 wait $PID1 && error "(2) mv succeeded"
2780 run_test 55d "rename file vs link"
2783 local MDSVER=$(lustre_build_version $SINGLEMDS)
2784 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2785 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2788 test_mkdir $DIR1/$tdir
2789 file1=$DIR1/$tdir/file
2790 file2=$DIR2/$tdir/file
2792 echo orig > $file2 || error "Could not create $file2"
2793 version=$($LFS data_version $file1)
2796 echo append >> $file2 || error "Could not append to $file2"
2797 version2=$($LFS data_version $file1)
2798 [ "$version" != "$version2" ] ||
2799 error "append did not change data version: $version"
2802 echo overwrite > $file2 || error "Could not overwrite $file2"
2803 version3=$($LFS data_version $file1)
2804 [ "$version2" != "$version3" ] ||
2805 error "overwrite did not change data version: $version2"
2807 # Truncate before EOF
2808 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2809 version4=$($LFS data_version $file1)
2810 [ "$version3" != "$version4" ] ||
2811 error "truncate did not change data version: $version3"
2813 # Truncate after EOF
2814 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2815 version5=$($LFS data_version $file1)
2816 [ "$version4" != "$version5" ] ||
2817 error "truncate did not change data version: $version4"
2819 # Chmod do not change version
2820 chmod 400 $file2 || error "Could not chmod 400 $file2"
2821 version6=$($LFS data_version $file1)
2822 [ "$version5" == "$version6" ] ||
2823 error "chmod should not change data version: $version5 != $version6"
2825 # Chown do not change version
2826 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2827 version7=$($LFS data_version $file1)
2828 [ "$version5" == "$version7" ] ||
2829 error "chown should not change data version: $version5 != $version7"
2831 run_test 60 "Verify data_version behaviour"
2834 local test_dir=$tdir/test_dir
2836 mkdir -p $DIR1/$tdir
2837 if [ $MDSCOUNT -ge 2 ]; then
2839 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2840 error "Create remote directory failed"
2842 mkdir -p $DIR1/$test_dir
2844 cd $DIR2/$test_dir || error "cd directory failed"
2845 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2847 cd $DIR2/$tdir || error "exit directory"
2849 run_test 70a "cd directory && rm directory"
2851 test_70b() { # LU-2781
2853 mkdir -p $DIR1/$tdir
2855 touch $DIR1/$tdir/file
2856 for ((i = 0; i < 32; i++)); do
2857 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2859 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2861 touch $DIR1/$tdir/file
2862 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2863 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2864 rm -rf $DIR1/$tdir/test_dir ||
2865 error "cannot remove directory after rm_entry"
2866 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2868 run_test 70b "remove files after calling rm_entry"
2871 local server_version=$(lustre_version_code $SINGLEMDS)
2873 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2874 skip "Need MDS version at least 2.1.6" && return
2876 # Patch not applied to 2.2 and 2.3 branches
2877 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2878 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2879 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2882 checkfiemap --test ||
2883 { skip "checkfiemap not runnable: $?" && return; }
2884 # write data this way: hole - data - hole - data
2885 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2886 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
2888 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2889 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2890 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2892 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2894 checkfiemap $DIR2/$tfile 81920 ||
2895 error "data is not flushed from client"
2896 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2899 # common case of "create file, copy file" on a single node
2900 # should not flush data from ost
2901 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2902 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2904 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2906 checkfiemap $DIR1/$tfile 81920 ||
2908 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2910 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2912 run_test 71a "correct file map just after write operation is finished"
2915 local server_version=$(lustre_version_code $SINGLEMDS)
2917 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2918 skip "Need MDS version at least 2.1.6" && return
2920 # Patch not applied to 2.2 and 2.3 branches
2921 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2922 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2923 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2925 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2927 checkfiemap --test ||
2928 { skip "error $?: checkfiemap failed" && return; }
2930 mkdir -p $DIR1/$tdir
2932 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2933 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2934 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
2936 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2937 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2939 run_test 71b "check fiemap support for stripecount > 1"
2942 local p="$TMP/sanityN-$TESTNAME.parameters"
2945 save_lustre_params client "llite.*.xattr_cache" > $p
2946 lctl set_param llite.*.xattr_cache 1 ||
2947 { skip "xattr cache is not supported"; return 0; }
2950 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2951 error "setfattr1 failed"
2952 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2953 error "getfattr1 failed"
2954 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2955 error "setfattr2 failed"
2956 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2957 error "getfattr2 failed"
2959 # check that trusted.link is consistent
2960 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2961 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2962 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2963 echo "$tlink1 $tlink2"
2964 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2968 restore_lustre_params < $p
2971 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2974 local p="$TMP/sanityN-$TESTNAME.parameters"
2975 save_lustre_params client "llite.*.xattr_cache" > $p
2976 lctl set_param llite.*.xattr_cache 1 ||
2977 { skip "xattr cache is not supported"; return 0; }
2980 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2981 error "setfattr1 failed"
2982 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2983 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2984 clear_stats llite.*.stats
2985 # PR lock should be cached by now on both clients
2986 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2987 # 2 hits for getfattr(0)+getfattr(size)
2988 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2989 error "not cached in $DIR1"
2990 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2991 # 4 hits for more getfattr(0)+getfattr(size)
2992 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2993 error "not cached in $DIR2"
2996 restore_lustre_params < $p
2999 run_test 73 "getxattr should not cause xattr lock cancellation"
3002 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3003 skip "Need MDS version at least 2.4.93" && return
3005 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3006 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3007 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3009 run_test 74 "flock deadlock: different mounts =============="
3013 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3014 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3015 cancel_lru_locks osc
3017 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3020 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3021 $LCTL set_param fail_loc=0x31d
3022 stat -c %s $DIR1/$tfile &
3027 # For bad lock error handler we should ASSERT and got kernel panic here
3029 $LCTL set_param fail_loc=0
3031 run_test 75 "osc: upcall after unuse lock==================="
3034 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3035 skip "Need MDS version at least 2.5.53" && return
3037 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3038 local fcount=$((MDSCOUNT * 256))
3043 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3049 test_mkdir $DIR/$tdir
3051 # drop all open locks and close any cached "open" files on the client
3052 cancel_lru_locks mdc
3054 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3055 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3056 local already=${#fid_list[@]}
3057 for (( i = 0; i < $already; i++ )) ; do
3058 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3061 echo -n "opening files: "
3062 ulimit -n $((fcount + 50))
3063 for ((i = 0; i < $fcount; i++)); do
3064 touch $DIR/$tdir/f_$i
3065 local fd=$(free_fd ${fd_list[i]})
3066 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3071 (( $i % 32 == 0 )) && echo -n "."
3075 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3077 # Possible errors in openfiles FID list.
3078 # 1. Missing FIDs. Check 1
3079 # 2. Extra FIDs. Check 1
3080 # 3. Duplicated FID. Check 2
3081 # 4. Invalid FIDs. Check 2
3082 # 5. Valid FID, points to some other file. Check 3
3085 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3086 error "${#fid_list[@]} != $fcount (+$already old) open files"
3088 echo -n "closing files: "
3089 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3090 local close_cmd="exec ${fd_list[fd]}<&-"
3092 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3094 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3095 echo "skip old open file $filename"
3097 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3101 rm --interactive=no $filename
3103 error "Nonexisting fid ${fid_list[fid]} listed."
3104 (( $fd % 32 == 0 )) && echo -n "."
3109 ls_op=$(ls $DIR2/$tdir | wc -l)
3111 error "Some openfiles are missing in lproc output"
3115 run_test 76 "Verify MDT open_files listing"
3119 local dir=$DIR/$tdir
3122 mkdir $dir || error "mkdir $dir failed"
3123 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3126 do_nodes $CLIENTS $myRUNAS \
3127 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3128 error "dd at 0 on client failed (1)"
3130 for ((i = 0; i < $n; i++)); do
3131 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3132 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3133 error "dd at ${i}MB on client failed (2)" &
3136 do_nodes $CLIENTS sync;
3137 cancel_lru_locks osc
3139 for ((i = 0; i < $n; i++)); do
3140 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3141 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3142 error "dd at ${i}MB on client failed (3)" &
3145 cancel_lru_locks osc
3147 for ((i = 0; i < $n; i++)); do
3151 rm -rf $dir || error "rm -rf $dir failed"
3154 test_77a() { #LU-3266
3157 oss=$(comma_list $(osts_nodes))
3158 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3160 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3161 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3166 run_test 77a "check FIFO NRS policy"
3168 test_77b() { #LU-3266
3171 oss=$(comma_list $(osts_nodes))
3173 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3174 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3175 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3176 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3178 echo "policy: crr-n, crrn_quantum 1"
3181 do_nodes $oss lctl set_param \
3182 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3183 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3185 echo "policy: crr-n, crrn_quantum 64"
3189 do_nodes $oss lctl set_param \
3190 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3191 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3194 run_test 77b "check CRR-N NRS policy"
3199 oss=$(comma_list $(osts_nodes))
3201 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3202 ost.OSS.*.nrs_"$policy"_quantum=1 \
3203 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3204 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3206 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3207 "physical, ${policy}_supported reads"
3210 do_nodes $oss lctl set_param \
3211 ost.OSS.*.nrs_${policy}_supported="writes" \
3212 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3214 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3215 "physical, ${policy}_supported writes"
3218 do_nodes $oss lctl set_param \
3219 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3220 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3221 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3222 "logical, ${policy}_supported reads_and_writes"
3226 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3231 test_77c() { #LU-3266
3233 orr_trr "orr" || rc=$?
3234 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3235 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3238 run_test 77c "check ORR NRS policy"
3240 test_77d() { #LU-3266
3242 orr_trr "trr" || rc=$?
3243 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3244 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3247 run_test 77d "check TRR nrs policy"
3254 do_facet $facet lctl set_param \
3255 ost.OSS.ost_io.nrs_tbf_rule="$*"
3257 error "failed to run operate '$*' on TBF rules"
3260 cleanup_tbf_verify()
3264 echo "cleanup_tbf $DIR/$tdir"
3267 wait_delete_completed
3272 local dir=$DIR/$tdir
3273 local client1=${CLIENT1:-$(hostname)}
3276 local np=$(check_cpt_number ost1)
3277 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3278 echo "cpu_npartitions on ost1 is $np"
3280 mkdir $dir || error "mkdir $dir failed"
3281 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3284 trap cleanup_tbf_verify EXIT
3285 echo "Limited write rate: $1, read rate: $2"
3286 echo "Verify the write rate is under TBF control"
3287 local start=$SECONDS
3288 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3289 bs=1M count=100 oflag=direct 2>&1
3290 local runtime=$((SECONDS - start + 1))
3291 local rate=$(bc <<< "scale=6; 100 / $runtime")
3292 echo "Write runtime is $runtime s, speed is $rate IOPS"
3294 # verify the write rate does not exceed TBF rate limit
3295 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3296 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3298 cancel_lru_locks osc
3300 echo "Verify the read rate is under TBF control"
3302 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3303 bs=1M count=100 iflag=direct 2>&1
3304 runtime=$((SECONDS - start + 1))
3305 rate=$(bc <<< "scale=6; 100 / $runtime")
3306 echo "Read runtime is $runtime s, speed is $rate IOPS"
3308 # verify the read rate does not exceed TBF rate limit
3309 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3310 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3312 cancel_lru_locks osc
3313 cleanup_tbf_verify || error "rm -rf $dir failed"
3319 oss=$(comma_list $(osts_nodes))
3321 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3323 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3324 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3328 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3333 # Only operate rules on ost1 since OSTs might run on the same OSS
3335 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3336 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3337 local client_nids=$(nids_list $address "\\")
3338 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3339 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3343 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3344 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3345 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3349 tbf_rule_operate ost1 "stop\ localhost"
3350 tbf_rule_operate ost1 "stop\ clients"
3351 tbf_rule_operate ost1 "stop\ others"
3354 # Cleanup the TBF policy
3355 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3356 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3360 run_test 77e "check TBF NID nrs policy"
3365 oss=$(comma_list $(osts_nodes))
3367 do_nodes $oss $LCTL set_param \
3368 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3369 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3370 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3372 # Configure jobid_var
3373 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3375 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3376 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3377 if [ $saved_jobid_var != procname_uid ]; then
3378 set_persistent_param_and_check client \
3379 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3384 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3389 # Only operate rules on ost1 since OSTs might run on the same OSS
3391 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3392 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3393 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3394 nrs_write_read "$RUNAS"
3397 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3398 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3399 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3400 nrs_write_read "$RUNAS"
3403 tbf_rule_operate ost1 "stop\ runas"
3404 tbf_rule_operate ost1 "stop\ iozone_runas"
3405 tbf_rule_operate ost1 "stop\ dd_runas"
3406 nrs_write_read "$RUNAS"
3408 # Cleanup the TBF policy
3409 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3410 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3411 nrs_write_read "$RUNAS"
3413 local current_jobid_var=$($LCTL get_param -n jobid_var)
3414 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3415 if [ $saved_jobid_var != $current_jobid_var ]; then
3416 set_persistent_param_and_check client \
3417 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3421 run_test 77f "check TBF JobID nrs policy"
3426 oss=$(comma_list $(osts_nodes))
3428 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3430 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3431 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3433 do_nodes $oss lctl set_param \
3434 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3435 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3439 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3444 # Add a rule that only valid for Jobid TBF. If direct change between
3445 # TBF types is not supported, this operation will fail.
3446 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3448 # Cleanup the TBF policy
3449 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3450 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3453 run_test 77g "Change TBF type directly"
3456 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3457 { skip "Need OST version at least 2.8.55"; return 0; }
3459 local old_policy=$(do_facet ost1 \
3460 lctl get_param ost.OSS.ost_io.nrs_policies)
3463 do_facet ost1 lctl set_param \
3464 ost.OSS.ost_io.nrs_policies="abc"
3465 [ $? -eq 0 ] && error "should return error"
3467 do_facet ost1 lctl set_param \
3468 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3469 [ $? -eq 0 ] && error "should return error"
3471 do_facet ost1 lctl set_param \
3472 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3473 [ $? -eq 0 ] && error "should return error"
3475 do_facet ost1 lctl set_param \
3476 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3477 [ $? -eq 0 ] && error "should return error"
3479 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3480 [ $? -eq 0 ] || error "shouldn't LBUG"
3482 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3486 run_test 77h "Wrong policy name should report error, not LBUG"
3492 local error_message=$3
3494 for rule in $expected; do
3495 rule_number=$((rule_number + 1))
3497 local stop_line=$(($rule_number + 3))
3498 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3500 local output=$(do_facet $facet lctl get_param \
3501 ost.OSS.ost_io.nrs_tbf_rule |
3505 if [ "$output" != "$expected" ]; then
3506 error "$error_message, expected '$expected', got '$output'"
3511 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3512 { skip "Need OST version at least 2.8.55"; return 0; }
3514 for i in $(seq 1 $OSTCOUNT)
3516 do_facet ost"$i" lctl set_param \
3517 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3519 error "failed to set TBF policy"
3522 tbf_rule_check ost1 "default" "error before inserting any rule"
3524 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3525 tbf_rule_check ost1 "before default" \
3526 "error when inserting rule 'before'"
3528 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3529 tbf_rule_check ost1 "before after default" \
3530 "error when inserting rule 'after'"
3532 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3533 tbf_rule_check ost1 "before target after default" \
3534 "error when inserting rule 'target'"
3536 echo "Move before itself"
3537 tbf_rule_operate ost1 "change\ target\ rank=target"
3538 tbf_rule_check ost1 "before target after default" \
3539 "error when moving before itself"
3541 echo "Move to higher rank"
3542 tbf_rule_operate ost1 "change\ target\ rank=before"
3543 tbf_rule_check ost1 "target before after default" \
3544 "error when moving to higher rank"
3546 echo "Move to lower rank"
3547 tbf_rule_operate ost1 "change\ target\ rank=after"
3548 tbf_rule_check ost1 "before target after default" \
3549 "error when moving to lower rank"
3551 echo "Move before default"
3552 tbf_rule_operate ost1 "change\ target\ rank=default"
3553 tbf_rule_check ost1 "before after target default" \
3554 error "error when moving before default"
3556 # Cleanup the TBF policy
3557 do_nodes $(comma_list $(osts_nodes)) \
3558 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3561 run_test 77i "Change rank of TBF rule"
3566 local ost_version=$(lustre_version_code ost1)
3568 [ $ost_version -ge $(version_code 2.9.53) ] ||
3569 { skip "Need OST version at least 2.9.53"; return 0; }
3570 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3575 do_nodes $(comma_list $(osts_nodes)) \
3576 lctl set_param jobid_var=procname_uid \
3577 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3578 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3579 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3580 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3585 do_nodes $(comma_list $(osts_nodes)) \
3586 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3587 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3588 ost.OSS.ost_io.nrs_policies="fifo"
3590 # sleep 3 seconds to wait the tbf policy stop completely,
3591 # or the next test case is possible get -EAGAIN when
3592 # setting the tbf policy
3595 run_test 77j "check TBF-OPCode NRS policy"
3598 local idstr="${1}id"
3599 local policy="${idstr}={$2}"
3600 local rate="rate=$3"
3602 do_nodes $(comma_list $(osts_nodes)) \
3603 lctl set_param jobid_var=procname_uid \
3604 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3605 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3606 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3608 nrs_write_read "runas $4"
3609 tbf_verify $3 $3 "runas $4"
3611 do_nodes $(comma_list $(osts_nodes)) \
3612 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3613 ost.OSS.ost_io.nrs_policies="fifo"
3615 # sleep 3 seconds to wait the tbf policy stop completely,
3616 # or the next test case is possible get -eagain when
3617 # setting the tbf policy
3622 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3623 skip "Need OST version at least 2.11.50"
3626 test_id "u" "500" "5" "-u 500"
3627 test_id "g" "500" "5" "-u 500 -g 500"
3629 run_test 77ja "check TBF-UID/GID NRS policy"
3637 for rule in $rule_lists; do
3638 do_nodes $(comma_list $(osts_nodes)) \
3639 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3642 do_nodes $(comma_list $(osts_nodes)) \
3643 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3649 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3650 { skip "Need OST version at least 2.9.53"; return 0; }
3652 do_nodes $(comma_list $(osts_nodes)) \
3653 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3654 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3655 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3657 nrs_write_read "$RUNAS"
3658 tbf_verify 20 10 "$RUNAS"
3660 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3661 local client_nids=$(nids_list $address "\\")
3662 do_nodes $(comma_list $(osts_nodes)) \
3663 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3664 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3665 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3666 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3671 do_nodes $(comma_list $(osts_nodes)) \
3672 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3673 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3674 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3676 nrs_write_read "$RUNAS"
3677 tbf_verify 20 20 "$RUNAS"
3679 do_nodes $(comma_list $(osts_nodes)) \
3680 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3681 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3682 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3684 nrs_write_read "$RUNAS"
3685 # with parameter "RUNAS", it will match the latest rule
3686 # "ext_b" first, so the limited write rate is 10.
3687 tbf_verify 10 10 "$RUNAS"
3690 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3692 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3693 { skip "Need OST version at least 2.10.58"; return 0; }
3695 do_nodes $(comma_list $(osts_nodes)) \
3696 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3697 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3698 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3699 nrs_write_read "runas -u 500 -g 1000"
3700 tbf_verify 5 5 "runas -u 500 -g 1000"
3702 do_nodes $(comma_list $(osts_nodes)) \
3703 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3704 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3705 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3707 nrs_write_read "runas -u 500"
3708 tbf_verify 20 10 "runas -u 500"
3710 do_nodes $(comma_list $(osts_nodes)) \
3711 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3712 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3713 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3714 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3715 nrs_write_read "runas -u 500"
3716 tbf_verify 10 10 "runas -u 500"
3717 tbf_verify 20 10 "runas -u 500"
3718 cleanup_77k "ext_a ext_b" "fifo"
3720 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3723 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3724 { skip "Need OST version at least 2.10.56"; return 0; }
3726 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3727 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3729 local output=$(do_facet ost1 lctl get_param \
3730 ost.OSS.ost_io.nrs_policies | \
3731 awk '/name: tbf/ {print;exit}' | \
3732 awk -F ': ' '{print $2}')
3734 if [ "$output" != "tbf" ]; then
3735 error "The generic TBF output is '$output', not 'tbf'"
3738 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3740 run_test 77l "check the output of NRS policies for generic TBF"
3743 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3744 skip "Need OST version at least 2.9.54"
3748 local dir=$DIR/$tdir
3750 mkdir $dir || error "mkdir $dir failed"
3751 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3754 local nodes=$(comma_list $(osts_nodes))
3755 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3756 ost.OSS.ost_io.nrs_delay_min=4 \
3757 ost.OSS.ost_io.nrs_delay_max=4 \
3758 ost.OSS.ost_io.nrs_delay_pct=100
3759 [ $? -ne 0 ] && error "Failed to set delay policy"
3761 local start=$SECONDS
3762 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3763 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3764 oflag=direct conv=fdatasync ||
3765 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3766 error "dd on client failed (1)"; }
3767 local elapsed=$((SECONDS - start))
3769 # NRS delay doesn't do sub-second timing, so a request enqueued at
3770 # 0.9 seconds can be dequeued at 4.0
3771 [ $elapsed -lt 3 ] &&
3772 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3773 error "Single 1M write should take at least 3 seconds"; }
3776 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3777 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3778 oflag=direct conv=fdatasync ||
3779 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3780 error "dd on client failed (2)"; }
3781 elapsed=$((SECONDS - start))
3783 [ $elapsed -lt 30 ] &&
3784 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3785 error "Ten 1M writes should take at least 30 seconds"; }
3787 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3788 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3792 run_test 77m "check NRS Delay slows write RPC processing"
3794 test_77n() { #LU-10802
3795 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3796 skip "Need OST version at least 2.10.58"
3800 # Configure jobid_var
3801 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3802 if [ $saved_jobid_var != procname_uid ]; then
3803 set_persistent_param_and_check client \
3804 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3807 do_nodes $(comma_list $(osts_nodes)) \
3808 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
3809 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3810 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
3813 tbf_verify 20 20 "$RUNAS"
3815 do_nodes $(comma_list $(osts_nodes)) \
3816 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3817 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
3822 do_nodes $(comma_list $(osts_nodes)) \
3823 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3824 ost.OSS.ost_io.nrs_policies="fifo"
3828 local current_jobid_var=$($LCTL get_param -n jobid_var)
3829 if [ $saved_jobid_var != $current_jobid_var ]; then
3830 set_persistent_param_and_check client \
3831 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3834 run_test 77n "check wildcard support for TBF JobID NRS policy"
3836 test_78() { #LU-6673
3839 oss=$(comma_list $(osts_nodes))
3840 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3841 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3843 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3844 # Valid return codes are:
3845 # 0: Tuning succeeded
3846 # ENODEV: Policy is still stopped
3847 # EAGAIN: Policy is being initialized
3848 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3849 error "Expected set_param to return 0|ENODEV|EAGAIN"
3851 # Cleanup the ORR policy
3852 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3853 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3856 run_test 78 "Enable policy and specify tunings right away"
3859 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3860 test_mkdir $DIR/$tdir
3862 # Prevent interference from layout intent RPCs due to
3863 # asynchronous writeback. These will be tested in 130c below.
3864 do_nodes ${CLIENTS:-$HOSTNAME} sync
3866 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3867 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3869 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3870 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
3871 local facet=mds$((mdtidx + 1))
3873 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3874 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3878 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3879 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3884 run_test 79 "xattr: intent error"
3887 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3894 mkdir -p $DIR1/$tdir/dir
3895 createmany -o $DIR1/$tdir/dir/f 10 ||
3896 error "create files under remote dir failed $i"
3898 cp /etc/passwd $DIR1/$tdir/$tfile
3900 #migrate open file should fails
3901 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3903 # give multiop a chance to open
3906 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3907 error "migrate open files should failed with open files"
3911 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3912 error "migrate remote dir error"
3914 echo "Finish migration, then checking.."
3915 for file in $(find $DIR1/$tdir); do
3916 mdt_index=$($LFS getstripe -m $file)
3917 [ $mdt_index == $MDTIDX ] ||
3918 error "$file is not on MDT${MDTIDX}"
3921 diff /etc/passwd $DIR1/$tdir/$tfile ||
3922 error "file different after migration"
3924 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3926 run_test 80a "migrate directory when some children is being opened"
3930 kill -9 $migrate_pid
3934 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3935 local migrate_dir1=$DIR1/$tdir/migrate_dir
3936 local migrate_dir2=$DIR2/$tdir/migrate_dir
3937 local migrate_run=$LUSTRE/tests/migrate.sh
3945 trap cleanup_80b EXIT
3946 #prepare migrate directory
3947 mkdir -p $migrate_dir1
3948 for F in {1,2,3,4,5}; do
3949 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3950 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3953 #migrate the directories among MDTs
3956 mdt_idx=$((RANDOM % MDSCOUNT))
3957 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3959 [ $rc -ne 0 -o $rc -ne 16 ] || break
3964 echo "start migration thread $migrate_pid"
3965 #Access the files at the same time
3966 start_time=$(date +%s)
3967 echo "accessing the migrating directory for 5 minutes..."
3969 ls $migrate_dir2 > /dev/null || {
3970 echo "read dir fails"
3973 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3974 echo "access file1 fails"
3978 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3979 echo "access file2/3 fails"
3983 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3984 echo "access file4 fails"
3988 stat $migrate_dir2/file5 > /dev/null || {
3989 echo "stat file5 fails"
3993 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3994 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3995 echo "touch file failed with $rc1"
3999 if [ -e $migrate_dir2/source_file ]; then
4000 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4001 &>/dev/null || rc1=$?
4002 if [ -e $migrate_dir2/link_file ]; then
4003 rm -rf $migrate_dir2/link_file
4006 mrename $migrate_dir2/source_file \
4007 $migrate_dir2/target_file &>/dev/null || rc1=$?
4008 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4009 echo "rename failed with $rc1"
4013 if [ -e $migrate_dir2/target_file ]; then
4014 rm -rf $migrate_dir2/target_file &>/dev/null ||
4017 rm -rf $migrate_dir2/source_file &>/dev/null ||
4020 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4021 echo "unlink failed with $rc1"
4026 end_time=$(date +%s)
4027 duration=$((end_time - start_time))
4028 if [ $((duration % 10)) -eq 0 ]; then
4029 if [ $show_time -eq 1 ]; then
4030 echo "...$duration seconds"
4037 kill -0 $migrate_pid || {
4038 echo "migration stopped 1"
4042 [ $duration -ge 300 ] && break
4045 #check migration are still there
4046 kill -0 $migrate_pid || error "migration stopped 2"
4049 run_test 80b "Accessing directory during migration"
4052 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4056 mkdir -p $DIR1/$tdir
4058 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4059 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4062 touch d0/0 || error "create 0 failed"
4063 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4064 stat d0/0 && error "stat mv filed succeed"
4065 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4066 stat d0/0 || error "stat failed"
4068 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4070 if [ $t -ne 3 ]; then
4071 ls -ai $DIR1/$tdir/d0
4072 error "expect 3 get $t"
4077 run_test 81a "rename and stat under striped directory"
4080 [ $MDSCOUNT -lt 2 ] &&
4081 skip "We need at least 2 MDTs for this test"
4088 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4089 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4098 for i in $(seq $total); do
4099 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4103 kill -9 $setattr_pid
4105 run_test 81b "rename under striped directory doesn't deadlock"
4108 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4109 { skip "Need MDS version at least 2.6.92"; return 0; }
4111 # Client 1 creates a file.
4112 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4114 # Client 2 opens the file.
4115 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4117 # Client 1 makes the file an orphan.
4118 rm $DIR1/$tfile || error "rm"
4119 # Client 2 sets EA "user.multiop".
4121 wait $pid2 || error "multiop 2"
4122 # Client 1 gets EA "user.multiop". This used to fail because the EA
4123 # cache refill would get "trusted.link" from mdd_xattr_list() but
4124 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4127 wait $pid1 || error "multiop 1"
4129 run_test 82 "fsetxattr and fgetxattr on orphan files"
4132 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4139 $LFS mkdir -i1 -c2 $tdir
4144 echo "start pid $pid1 to create/unlink striped directory"
4146 # Access the directory at the same time
4150 stat $tdir > /dev/null 2>&1
4154 echo "start pid $pid2 to stat striped directory"
4162 run_test 83 "access striped directory while it is being created/unlinked"
4165 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4170 [ "$SLOW" = "yes" ] && duration=600
4171 # Open/Create under striped directory
4175 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4176 touch $tdir/f{0..3} > /dev/null 2>&1
4180 echo "start pid $pid1 to open/create under striped directory"
4182 # unlink the striped directory at the same time
4186 rm -rf $tdir > /dev/null 2>&1
4190 echo "start pid $pid2 to unlink striped directory"
4199 run_test 90 "open/create and unlink striped directory"
4202 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4207 [ "$SLOW" = "yes" ] && duration=600
4208 # chmod striped directory
4212 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4213 chmod go+w $tdir > /dev/null 2>&1
4217 echo "start pid $pid1 to chmod striped directory"
4219 # unlink the striped directory at the same time
4223 rm -rf $tdir > /dev/null 2>&1
4227 echo "start pid $pid2 to unlink striped directory"
4236 run_test 91 "chmod and unlink striped directory"
4239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4242 local cmd="exec $fd<$DIR1/$tdir"
4243 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4246 trap "eval $cmd" EXIT
4247 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4248 rmdir ../$tdir || error "rmdir ../$tdir fails"
4250 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4251 $LCTL set_param fail_loc=0x1408
4252 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4253 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4254 error "create remote dir succeeds"
4255 $LCTL set_param fail_loc=0
4259 run_test 92 "create remote directory under orphan directory"
4266 mkdir -p $DIR1/$tfile-1/
4267 mkdir -p $DIR2/$tfile-2/
4268 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4269 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4270 do_facet $SINGLEMDS lctl set_param -n \
4271 'lod.lustre-MDT*/qos_threshold_rr' 100
4272 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4273 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4275 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4278 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4282 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4283 do_facet $SINGLEMDS "lctl set_param -n \
4284 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4286 $LFS getstripe $DIR1/$tfile-1/file1
4287 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4288 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4289 $LFS getstripe $DIR2/$tfile-2/file2
4290 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4291 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4292 echo "rc1=$rc1 and rc2=$rc2 "
4293 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4294 error "object allocate on same ost detected"
4296 run_test 93 "alloc_rr should not allocate on same ost"
4300 skip "Reserved for glimpse-ahead" && return
4301 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4302 skip "Need MDS version at least 2.10.55" && return
4306 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4308 lctl set_param -n mdc.*.stats=clear
4309 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4311 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4312 # first stat from server should return size data and save glimpse
4313 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4314 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4315 # second stat to check size is NOT cached on client without IO lock
4316 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4318 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4319 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4322 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4325 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4326 skip "Need MDS version at least 2.10.55" && return
4330 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4332 lctl set_param -n mdc.*.stats=clear
4333 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4334 cancel_lru_locks mdc
4335 # first stat data from server should have size
4336 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4337 # second stat to check size is cached on client
4338 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4340 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4341 # both stats should cause no glimpse requests
4342 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4345 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4348 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4349 skip "Need MDS version at least 2.10.55" && return
4353 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4355 lctl set_param -n mdc.*.stats=clear
4356 lctl set_param -n osc.*.stats=clear
4357 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4359 # check that size is merged from MDT and OST correctly
4360 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4361 error "Wrong size from stat #1"
4363 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4364 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4368 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4371 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4372 skip "Need MDS version at least 2.10.55" && return
4376 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4379 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4380 lctl set_param -n mdc.*.stats=clear
4381 $TRUNCATE $DIR2/$tdir/dom 4096
4383 # check that reported size is valid after file grows to OST and
4384 # is truncated back to MDT stripe size
4385 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4386 error "Wrong size from stat #1"
4388 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4389 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4393 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4396 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4397 skip "Need MDS version at least 2.10.55" && return
4399 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4401 $CHECKSTAT -t file $DIR1/$tfile
4403 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4404 sysctl -wq vm.dirty_writeback_centisecs=0
4406 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4409 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4410 error_noexit "Write fails"
4411 # must discard pages
4412 lctl set_param -n mdc.*.stats=clear
4413 rm $DIR2/$tfile || error "Unlink fails"
4415 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4416 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4418 run_test 101a "Discard DoM data on unlink"
4421 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4422 skip "Need MDS version at least 2.10.55" && return
4424 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4425 touch $DIR1/${tfile}_2
4427 $CHECKSTAT -t file $DIR1/$tfile
4429 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4430 sysctl -wq vm.dirty_writeback_centisecs=0
4432 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4435 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4436 # must discard pages
4437 lctl set_param -n mdc.*.stats=clear
4438 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4440 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4441 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4443 run_test 101b "Discard DoM data on rename"
4446 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4447 skip "Need MDS version at least 2.10.55" && return
4449 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4451 $CHECKSTAT -t file $DIR1/$tfile
4453 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4454 sysctl -wq vm.dirty_writeback_centisecs=0
4456 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4459 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4460 $MULTIOP $DIR1/$tfile O_c &
4463 lctl set_param -n mdc.*.stats=clear
4464 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4465 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4467 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4468 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4470 run_test 101c "Discard DoM data on close-unlink"
4472 # test to verify file handle related system calls
4473 # (name_to_handle_at/open_by_handle_at)
4474 # The new system calls are supported in glibc >= 2.14.
4476 # test to verify we can open by handle an unlinked file from > 1 client
4477 # This test opens the file normally on $DIR1, which is on one mount, and then
4478 # opens it by handle on $DIR2, which is on a different mount.
4480 echo "Test file_handle syscalls" > $DIR/$tfile ||
4481 error "write failed"
4482 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4483 error "check_fhandle_syscalls failed"
4486 run_test 102 "Test open by handle of unlinked file"
4488 log "cleanup: ======================================================"
4490 # kill and wait in each test only guarentee script finish, but command in script
4491 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4492 # otherwise umount below will fail
4493 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4498 check_and_cleanup_lustre