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
2479 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2480 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2481 $LFS mkdir -i 1 $DIR1/$tfile &
2484 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2485 check_pdo_conflict $PID1 && { wait $PID1;
2486 error "getattr isn't blocked"; }
2490 run_test 47g "pdirops: remote mkdir vs getattr"
2494 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2495 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2496 do_facet client "lctl set_param fail_loc=0x410"
2497 $TRUNCATE $DIR2/$tfile $trunc_size
2498 do_facet client "lctl set_param fail_loc=0x0"
2500 size=`stat -c %s $DIR2/$tfile`
2501 [ $size -eq $trunc_size ] || error "wrong size"
2503 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2507 local origfile=/etc/hosts
2509 filesize=$(stat -c %s $origfile)
2511 # create an empty file
2512 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2513 # cache layout lock on both mount point
2514 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2515 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2517 # open and sleep 2 seconds then read
2518 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2522 # create the layout of testing file
2523 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2524 error "dd $DIR1/$tfile failed"
2526 # MULTIOP proc should be able to read enough bytes and exit
2527 for ((i = 0; i < 6; i++)); do
2529 kill -0 $pid || break
2531 kill -0 $pid 2> /dev/null && error "multiop is still there"
2532 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2536 run_test 51a "layout lock: refresh layout should work"
2539 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2540 { skip "Need MDS version at least 2.3.59"; return 0; }
2542 local tmpfile=`mktemp`
2544 # create an empty file
2545 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2547 # delay glimpse so that layout has changed when glimpse finish
2548 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2549 $LCTL set_param fail_loc=0x1404
2550 stat -c %s $DIR2/$tfile |tee $tmpfile &
2554 # create layout of testing file
2555 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2556 error "dd $DIR1/$tfile failed"
2559 local fsize=$(cat $tmpfile)
2561 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2563 rm -f $DIR1/$tfile $tmpfile
2565 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2568 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2570 # set default layout to have 1 stripe
2572 $LFS setstripe -c 1 $DIR1/$tdir
2574 # create a file with empty layout
2575 $MCREATE $DIR1/$tdir/$tfile ||
2576 error "$MCREATE $DIR1/$tdir/$tfile failed"
2578 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2579 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2581 # change the layout of testing file
2582 echo "Setting layout to have $OSTCOUNT stripes ..."
2583 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2587 # write something to the file, it should be blocked on fetching layout
2588 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2589 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2592 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2593 # count to succeed with only 3/4 of the number of stripes (rounded up),
2594 # so creating striped files does not fail if an OST is offline or full
2595 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2596 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2600 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2603 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2604 cancel_lru_locks mdc
2606 # open should grant LAYOUT lock, mmap and read will install pages
2607 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2611 # rss before revoking
2612 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2613 echo "Before revoking layout lock: $br KB mapped"
2615 # cancel layout lock manually
2616 cancel_lru_locks mdc
2618 # rss after revoking
2619 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2622 wait $PID || error "wait PID $PID failed"
2624 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2626 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2630 echo "==> rename vs getattr vs setxattr should not deadlock"
2631 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2633 do_facet mds1 $LCTL set_param fail_loc=$1
2635 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2643 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2644 wait $PID1 || error "(3) mv failed"
2645 wait $PID2 || error "(4) stat failed"
2652 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2653 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2655 do_facet mds1 $LCTL set_param fail_loc=$1
2657 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2665 $MULTIOP $DIR2/d1/d2 Oc &
2669 stat $DIR/d1 || error "(2) stat failed"
2671 wait $PID1 || error "(3) mv failed"
2672 wait $PID2 || error "(4) stat failed"
2673 wait $PID3 && error "(5) multiop failed"
2679 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2680 save_lustre_params client "llite.*.xattr_cache" > $p
2681 lctl set_param llite.*.xattr_cache 1 ||
2682 { skip "xattr cache is not supported"; return 0; }
2684 #define OBD_FAIL_MDS_RENAME 0x153
2685 #define OBD_FAIL_MDS_RENAME2 0x154
2686 test_54_part1 0x80000153 || error 10
2687 test_54_part1 0x80000154 || error 11
2688 test_54_part2 0x80000153 || error 12
2689 test_54_part2 0x80000154 || error 13
2691 restore_lustre_params < $p
2694 run_test 54 "rename locking"
2697 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2699 #define OBD_FAIL_MDS_RENAME4 0x156
2700 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2702 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2707 wait $PID1 && error "(2) mv succeeded"
2711 run_test 55a "rename vs unlink target dir"
2715 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2717 #define OBD_FAIL_MDS_RENAME4 0x156
2718 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2720 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2725 wait $PID1 && error "(2) mv succeeded"
2729 run_test 55b "rename vs unlink source dir"
2733 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2735 #define OBD_FAIL_MDS_RENAME4 0x156
2736 do_facet mds1 $LCTL set_param fail_loc=0x156
2738 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2742 # while rename is sleeping, open and remove d3
2743 $MULTIOP $DIR2/d3 D_c &
2749 # while rename is sleeping 2nd time, close d3
2751 wait $PID2 || error "(3) multiop failed"
2753 wait $PID1 && error "(2) mv succeeded"
2757 run_test 55c "rename vs unlink orphan target dir"
2763 #define OBD_FAIL_MDS_RENAME3 0x155
2764 do_facet mds1 $LCTL set_param fail_loc=0x155
2765 mv $DIR/f1 $DIR/$tdir &
2769 # while rename is sleeping, create $tdir, but as a directory
2770 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2772 # link in reverse locking order
2773 ln $DIR2/f1 $DIR2/$tdir/
2775 wait $PID1 && error "(2) mv succeeded"
2778 run_test 55d "rename file vs link"
2781 local MDSVER=$(lustre_build_version $SINGLEMDS)
2782 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2783 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2786 test_mkdir $DIR1/$tdir
2787 file1=$DIR1/$tdir/file
2788 file2=$DIR2/$tdir/file
2790 echo orig > $file2 || error "Could not create $file2"
2791 version=$($LFS data_version $file1)
2794 echo append >> $file2 || error "Could not append to $file2"
2795 version2=$($LFS data_version $file1)
2796 [ "$version" != "$version2" ] ||
2797 error "append did not change data version: $version"
2800 echo overwrite > $file2 || error "Could not overwrite $file2"
2801 version3=$($LFS data_version $file1)
2802 [ "$version2" != "$version3" ] ||
2803 error "overwrite did not change data version: $version2"
2805 # Truncate before EOF
2806 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2807 version4=$($LFS data_version $file1)
2808 [ "$version3" != "$version4" ] ||
2809 error "truncate did not change data version: $version3"
2811 # Truncate after EOF
2812 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2813 version5=$($LFS data_version $file1)
2814 [ "$version4" != "$version5" ] ||
2815 error "truncate did not change data version: $version4"
2817 # Chmod do not change version
2818 chmod 400 $file2 || error "Could not chmod 400 $file2"
2819 version6=$($LFS data_version $file1)
2820 [ "$version5" == "$version6" ] ||
2821 error "chmod should not change data version: $version5 != $version6"
2823 # Chown do not change version
2824 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2825 version7=$($LFS data_version $file1)
2826 [ "$version5" == "$version7" ] ||
2827 error "chown should not change data version: $version5 != $version7"
2829 run_test 60 "Verify data_version behaviour"
2832 local test_dir=$tdir/test_dir
2834 mkdir -p $DIR1/$tdir
2835 if [ $MDSCOUNT -ge 2 ]; then
2837 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2838 error "Create remote directory failed"
2840 mkdir -p $DIR1/$test_dir
2842 cd $DIR2/$test_dir || error "cd directory failed"
2843 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2845 cd $DIR2/$tdir || error "exit directory"
2847 run_test 70a "cd directory && rm directory"
2849 test_70b() { # LU-2781
2851 mkdir -p $DIR1/$tdir
2853 touch $DIR1/$tdir/file
2854 for ((i = 0; i < 32; i++)); do
2855 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2857 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2859 touch $DIR1/$tdir/file
2860 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2861 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2862 rm -rf $DIR1/$tdir/test_dir ||
2863 error "cannot remove directory after rm_entry"
2864 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2866 run_test 70b "remove files after calling rm_entry"
2869 local server_version=$(lustre_version_code $SINGLEMDS)
2871 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2872 skip "Need MDS version at least 2.1.6" && return
2874 # Patch not applied to 2.2 and 2.3 branches
2875 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2876 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2877 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2880 checkfiemap --test ||
2881 { skip "checkfiemap not runnable: $?" && return; }
2882 # write data this way: hole - data - hole - data
2883 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2884 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2886 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2887 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2888 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2890 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2892 checkfiemap $DIR2/$tfile 81920 ||
2893 error "data is not flushed from client"
2894 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2897 # common case of "create file, copy file" on a single node
2898 # should not flush data from ost
2899 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2900 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2902 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2904 checkfiemap $DIR1/$tfile 81920 ||
2906 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2908 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2910 run_test 71a "correct file map just after write operation is finished"
2913 local server_version=$(lustre_version_code $SINGLEMDS)
2915 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2916 skip "Need MDS version at least 2.1.6" && return
2918 # Patch not applied to 2.2 and 2.3 branches
2919 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2920 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2921 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2923 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2925 checkfiemap --test ||
2926 { skip "error $?: checkfiemap failed" && return; }
2928 mkdir -p $DIR1/$tdir
2930 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2931 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2932 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2934 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2935 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2937 run_test 71b "check fiemap support for stripecount > 1"
2940 local p="$TMP/sanityN-$TESTNAME.parameters"
2943 save_lustre_params client "llite.*.xattr_cache" > $p
2944 lctl set_param llite.*.xattr_cache 1 ||
2945 { skip "xattr cache is not supported"; return 0; }
2948 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2949 error "setfattr1 failed"
2950 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2951 error "getfattr1 failed"
2952 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2953 error "setfattr2 failed"
2954 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2955 error "getfattr2 failed"
2957 # check that trusted.link is consistent
2958 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2959 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2960 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2961 echo "$tlink1 $tlink2"
2962 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2966 restore_lustre_params < $p
2969 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2972 local p="$TMP/sanityN-$TESTNAME.parameters"
2973 save_lustre_params client "llite.*.xattr_cache" > $p
2974 lctl set_param llite.*.xattr_cache 1 ||
2975 { skip "xattr cache is not supported"; return 0; }
2978 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2979 error "setfattr1 failed"
2980 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2981 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2982 clear_stats llite.*.stats
2983 # PR lock should be cached by now on both clients
2984 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2985 # 2 hits for getfattr(0)+getfattr(size)
2986 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2987 error "not cached in $DIR1"
2988 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2989 # 4 hits for more getfattr(0)+getfattr(size)
2990 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2991 error "not cached in $DIR2"
2994 restore_lustre_params < $p
2997 run_test 73 "getxattr should not cause xattr lock cancellation"
3000 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3001 skip "Need MDS version at least 2.4.93" && return
3003 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3004 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3005 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3007 run_test 74 "flock deadlock: different mounts =============="
3011 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3012 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3013 cancel_lru_locks osc
3015 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3018 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3019 $LCTL set_param fail_loc=0x31d
3020 stat -c %s $DIR1/$tfile &
3025 # For bad lock error handler we should ASSERT and got kernel panic here
3027 $LCTL set_param fail_loc=0
3029 run_test 75 "osc: upcall after unuse lock==================="
3032 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3033 skip "Need MDS version at least 2.5.53" && return
3035 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3036 local fcount=$((MDSCOUNT * 256))
3041 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3047 test_mkdir $DIR/$tdir
3049 # drop all open locks and close any cached "open" files on the client
3050 cancel_lru_locks mdc
3052 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3053 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3054 local already=${#fid_list[@]}
3055 for (( i = 0; i < $already; i++ )) ; do
3056 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3059 echo -n "opening files: "
3060 ulimit -n $((fcount + 50))
3061 for ((i = 0; i < $fcount; i++)); do
3062 touch $DIR/$tdir/f_$i
3063 local fd=$(free_fd ${fd_list[i]})
3064 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3069 (( $i % 32 == 0 )) && echo -n "."
3073 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3075 # Possible errors in openfiles FID list.
3076 # 1. Missing FIDs. Check 1
3077 # 2. Extra FIDs. Check 1
3078 # 3. Duplicated FID. Check 2
3079 # 4. Invalid FIDs. Check 2
3080 # 5. Valid FID, points to some other file. Check 3
3083 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3084 error "${#fid_list[@]} != $fcount (+$already old) open files"
3086 echo -n "closing files: "
3087 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3088 local close_cmd="exec ${fd_list[fd]}<&-"
3090 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3092 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3093 echo "skip old open file $filename"
3095 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3099 rm --interactive=no $filename
3101 error "Nonexisting fid ${fid_list[fid]} listed."
3102 (( $fd % 32 == 0 )) && echo -n "."
3107 ls_op=$(ls $DIR2/$tdir | wc -l)
3109 error "Some openfiles are missing in lproc output"
3113 run_test 76 "Verify MDT open_files listing"
3117 local dir=$DIR/$tdir
3120 mkdir $dir || error "mkdir $dir failed"
3121 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3124 do_nodes $CLIENTS $myRUNAS \
3125 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3126 error "dd at 0 on client failed (1)"
3128 for ((i = 0; i < $n; i++)); do
3129 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3130 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3131 error "dd at ${i}MB on client failed (2)" &
3134 do_nodes $CLIENTS sync;
3135 cancel_lru_locks osc
3137 for ((i = 0; i < $n; i++)); do
3138 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3139 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3140 error "dd at ${i}MB on client failed (3)" &
3143 cancel_lru_locks osc
3145 for ((i = 0; i < $n; i++)); do
3149 rm -rf $dir || error "rm -rf $dir failed"
3152 test_77a() { #LU-3266
3155 oss=$(comma_list $(osts_nodes))
3156 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3158 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3159 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3164 run_test 77a "check FIFO NRS policy"
3166 test_77b() { #LU-3266
3169 oss=$(comma_list $(osts_nodes))
3171 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3172 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3173 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3174 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3176 echo "policy: crr-n, crrn_quantum 1"
3179 do_nodes $oss lctl set_param \
3180 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3181 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3183 echo "policy: crr-n, crrn_quantum 64"
3187 do_nodes $oss lctl set_param \
3188 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3189 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3192 run_test 77b "check CRR-N NRS policy"
3197 oss=$(comma_list $(osts_nodes))
3199 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3200 ost.OSS.*.nrs_"$policy"_quantum=1 \
3201 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3202 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3204 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3205 "physical, ${policy}_supported reads"
3208 do_nodes $oss lctl set_param \
3209 ost.OSS.*.nrs_${policy}_supported="writes" \
3210 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3212 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3213 "physical, ${policy}_supported writes"
3216 do_nodes $oss lctl set_param \
3217 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3218 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3219 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3220 "logical, ${policy}_supported reads_and_writes"
3224 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3229 test_77c() { #LU-3266
3231 orr_trr "orr" || rc=$?
3232 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3233 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3236 run_test 77c "check ORR NRS policy"
3238 test_77d() { #LU-3266
3240 orr_trr "trr" || rc=$?
3241 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3242 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3245 run_test 77d "check TRR nrs policy"
3252 do_facet $facet lctl set_param \
3253 ost.OSS.ost_io.nrs_tbf_rule="$*"
3255 error "failed to run operate '$*' on TBF rules"
3258 cleanup_tbf_verify()
3262 echo "cleanup_tbf $DIR/$tdir"
3265 wait_delete_completed
3270 local dir=$DIR/$tdir
3271 local client1=${CLIENT1:-$(hostname)}
3274 local np=$(check_cpt_number ost1)
3275 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3276 echo "cpu_npartitions on ost1 is $np"
3278 mkdir $dir || error "mkdir $dir failed"
3279 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3282 trap cleanup_tbf_verify EXIT
3283 echo "Limited write rate: $1, read rate: $2"
3284 echo "Verify the write rate is under TBF control"
3285 local start=$SECONDS
3286 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3287 bs=1M count=100 oflag=direct 2>&1
3288 local runtime=$((SECONDS - start + 1))
3289 local rate=$(bc <<< "scale=6; 100 / $runtime")
3290 echo "Write runtime is $runtime s, speed is $rate IOPS"
3292 # verify the write rate does not exceed TBF rate limit
3293 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3294 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3296 cancel_lru_locks osc
3298 echo "Verify the read rate is under TBF control"
3300 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3301 bs=1M count=100 iflag=direct 2>&1
3302 runtime=$((SECONDS - start + 1))
3303 rate=$(bc <<< "scale=6; 100 / $runtime")
3304 echo "Read runtime is $runtime s, speed is $rate IOPS"
3306 # verify the read rate does not exceed TBF rate limit
3307 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3308 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3310 cancel_lru_locks osc
3311 cleanup_tbf_verify || error "rm -rf $dir failed"
3317 oss=$(comma_list $(osts_nodes))
3319 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3321 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3322 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3326 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3331 # Only operate rules on ost1 since OSTs might run on the same OSS
3333 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3334 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3335 local client_nids=$(nids_list $address "\\")
3336 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3337 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3341 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3342 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3343 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3347 tbf_rule_operate ost1 "stop\ localhost"
3348 tbf_rule_operate ost1 "stop\ clients"
3349 tbf_rule_operate ost1 "stop\ others"
3352 # Cleanup the TBF policy
3353 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3354 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3358 run_test 77e "check TBF NID nrs policy"
3363 oss=$(comma_list $(osts_nodes))
3365 do_nodes $oss $LCTL set_param \
3366 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3367 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3368 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3370 # Configure jobid_var
3371 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3373 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3374 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3375 if [ $saved_jobid_var != procname_uid ]; then
3376 set_persistent_param_and_check client \
3377 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3382 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3387 # Only operate rules on ost1 since OSTs might run on the same OSS
3389 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3390 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3391 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3392 nrs_write_read "$RUNAS"
3395 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3396 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3397 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3398 nrs_write_read "$RUNAS"
3401 tbf_rule_operate ost1 "stop\ runas"
3402 tbf_rule_operate ost1 "stop\ iozone_runas"
3403 tbf_rule_operate ost1 "stop\ dd_runas"
3404 nrs_write_read "$RUNAS"
3406 # Cleanup the TBF policy
3407 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3408 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3409 nrs_write_read "$RUNAS"
3411 local current_jobid_var=$($LCTL get_param -n jobid_var)
3412 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3413 if [ $saved_jobid_var != $current_jobid_var ]; then
3414 set_persistent_param_and_check client \
3415 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3419 run_test 77f "check TBF JobID nrs policy"
3424 oss=$(comma_list $(osts_nodes))
3426 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3428 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3429 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3431 do_nodes $oss lctl set_param \
3432 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3433 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3437 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3442 # Add a rule that only valid for Jobid TBF. If direct change between
3443 # TBF types is not supported, this operation will fail.
3444 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3446 # Cleanup the TBF policy
3447 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3448 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3451 run_test 77g "Change TBF type directly"
3454 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3455 { skip "Need OST version at least 2.8.55"; return 0; }
3457 local old_policy=$(do_facet ost1 \
3458 lctl get_param ost.OSS.ost_io.nrs_policies)
3461 do_facet ost1 lctl set_param \
3462 ost.OSS.ost_io.nrs_policies="abc"
3463 [ $? -eq 0 ] && error "should return error"
3465 do_facet ost1 lctl set_param \
3466 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3467 [ $? -eq 0 ] && error "should return error"
3469 do_facet ost1 lctl set_param \
3470 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3471 [ $? -eq 0 ] && error "should return error"
3473 do_facet ost1 lctl set_param \
3474 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3475 [ $? -eq 0 ] && error "should return error"
3477 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3478 [ $? -eq 0 ] || error "shouldn't LBUG"
3480 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3484 run_test 77h "Wrong policy name should report error, not LBUG"
3490 local error_message=$3
3492 for rule in $expected; do
3493 rule_number=$((rule_number + 1))
3495 local stop_line=$(($rule_number + 3))
3496 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3498 local output=$(do_facet $facet lctl get_param \
3499 ost.OSS.ost_io.nrs_tbf_rule |
3503 if [ "$output" != "$expected" ]; then
3504 error "$error_message, expected '$expected', got '$output'"
3509 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3510 { skip "Need OST version at least 2.8.55"; return 0; }
3512 for i in $(seq 1 $OSTCOUNT)
3514 do_facet ost"$i" lctl set_param \
3515 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3517 error "failed to set TBF policy"
3520 tbf_rule_check ost1 "default" "error before inserting any rule"
3522 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3523 tbf_rule_check ost1 "before default" \
3524 "error when inserting rule 'before'"
3526 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3527 tbf_rule_check ost1 "before after default" \
3528 "error when inserting rule 'after'"
3530 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3531 tbf_rule_check ost1 "before target after default" \
3532 "error when inserting rule 'target'"
3534 echo "Move before itself"
3535 tbf_rule_operate ost1 "change\ target\ rank=target"
3536 tbf_rule_check ost1 "before target after default" \
3537 "error when moving before itself"
3539 echo "Move to higher rank"
3540 tbf_rule_operate ost1 "change\ target\ rank=before"
3541 tbf_rule_check ost1 "target before after default" \
3542 "error when moving to higher rank"
3544 echo "Move to lower rank"
3545 tbf_rule_operate ost1 "change\ target\ rank=after"
3546 tbf_rule_check ost1 "before target after default" \
3547 "error when moving to lower rank"
3549 echo "Move before default"
3550 tbf_rule_operate ost1 "change\ target\ rank=default"
3551 tbf_rule_check ost1 "before after target default" \
3552 error "error when moving before default"
3554 # Cleanup the TBF policy
3555 do_nodes $(comma_list $(osts_nodes)) \
3556 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3559 run_test 77i "Change rank of TBF rule"
3564 local ost_version=$(lustre_version_code ost1)
3566 [ $ost_version -ge $(version_code 2.9.53) ] ||
3567 { skip "Need OST version at least 2.9.53"; return 0; }
3568 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3573 do_nodes $(comma_list $(osts_nodes)) \
3574 lctl set_param jobid_var=procname_uid \
3575 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3576 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3577 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3578 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3583 do_nodes $(comma_list $(osts_nodes)) \
3584 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3585 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3586 ost.OSS.ost_io.nrs_policies="fifo"
3588 # sleep 3 seconds to wait the tbf policy stop completely,
3589 # or the next test case is possible get -EAGAIN when
3590 # setting the tbf policy
3593 run_test 77j "check TBF-OPCode NRS policy"
3596 local idstr="${1}id"
3597 local policy="${idstr}={$2}"
3598 local rate="rate=$3"
3600 do_nodes $(comma_list $(osts_nodes)) \
3601 lctl set_param jobid_var=procname_uid \
3602 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3603 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3604 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3606 nrs_write_read "runas $4"
3607 tbf_verify $3 $3 "runas $4"
3609 do_nodes $(comma_list $(osts_nodes)) \
3610 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3611 ost.OSS.ost_io.nrs_policies="fifo"
3613 # sleep 3 seconds to wait the tbf policy stop completely,
3614 # or the next test case is possible get -eagain when
3615 # setting the tbf policy
3620 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3621 skip "Need OST version at least 2.11.50"
3624 test_id "u" "500" "5" "-u 500"
3625 test_id "g" "500" "5" "-u 500 -g 500"
3627 run_test 77ja "check TBF-UID/GID NRS policy"
3635 for rule in $rule_lists; do
3636 do_nodes $(comma_list $(osts_nodes)) \
3637 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3640 do_nodes $(comma_list $(osts_nodes)) \
3641 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3647 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3648 { skip "Need OST version at least 2.9.53"; return 0; }
3650 do_nodes $(comma_list $(osts_nodes)) \
3651 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3652 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3653 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3655 nrs_write_read "$RUNAS"
3656 tbf_verify 20 10 "$RUNAS"
3658 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3659 local client_nids=$(nids_list $address "\\")
3660 do_nodes $(comma_list $(osts_nodes)) \
3661 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3662 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3663 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3664 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3669 do_nodes $(comma_list $(osts_nodes)) \
3670 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3671 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3672 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3674 nrs_write_read "$RUNAS"
3675 tbf_verify 20 20 "$RUNAS"
3677 do_nodes $(comma_list $(osts_nodes)) \
3678 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3679 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3680 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3682 nrs_write_read "$RUNAS"
3683 # with parameter "RUNAS", it will match the latest rule
3684 # "ext_b" first, so the limited write rate is 10.
3685 tbf_verify 10 10 "$RUNAS"
3688 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3690 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3691 { skip "Need OST version at least 2.10.58"; return 0; }
3693 do_nodes $(comma_list $(osts_nodes)) \
3694 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3695 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3696 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3697 nrs_write_read "runas -u 500 -g 1000"
3698 tbf_verify 5 5 "runas -u 500 -g 1000"
3700 do_nodes $(comma_list $(osts_nodes)) \
3701 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3702 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3703 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3705 nrs_write_read "runas -u 500"
3706 tbf_verify 20 10 "runas -u 500"
3708 do_nodes $(comma_list $(osts_nodes)) \
3709 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3710 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3711 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3712 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3713 nrs_write_read "runas -u 500"
3714 tbf_verify 10 10 "runas -u 500"
3715 tbf_verify 20 10 "runas -u 500"
3716 cleanup_77k "ext_a ext_b" "fifo"
3718 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3721 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3722 { skip "Need OST version at least 2.10.56"; return 0; }
3724 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3725 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3727 local output=$(do_facet ost1 lctl get_param \
3728 ost.OSS.ost_io.nrs_policies | \
3729 awk '/name: tbf/ {print;exit}' | \
3730 awk -F ': ' '{print $2}')
3732 if [ "$output" != "tbf" ]; then
3733 error "The generic TBF output is '$output', not 'tbf'"
3736 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3738 run_test 77l "check the output of NRS policies for generic TBF"
3741 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3742 skip "Need OST version at least 2.9.54"
3746 local dir=$DIR/$tdir
3748 mkdir $dir || error "mkdir $dir failed"
3749 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3752 local nodes=$(comma_list $(osts_nodes))
3753 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3754 ost.OSS.ost_io.nrs_delay_min=4 \
3755 ost.OSS.ost_io.nrs_delay_max=4 \
3756 ost.OSS.ost_io.nrs_delay_pct=100
3757 [ $? -ne 0 ] && error "Failed to set delay policy"
3759 local start=$SECONDS
3760 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3761 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3762 oflag=direct conv=fdatasync ||
3763 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3764 error "dd on client failed (1)"; }
3765 local elapsed=$((SECONDS - start))
3767 # NRS delay doesn't do sub-second timing, so a request enqueued at
3768 # 0.9 seconds can be dequeued at 4.0
3769 [ $elapsed -lt 3 ] &&
3770 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3771 error "Single 1M write should take at least 3 seconds"; }
3774 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3775 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3776 oflag=direct conv=fdatasync ||
3777 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3778 error "dd on client failed (2)"; }
3779 elapsed=$((SECONDS - start))
3781 [ $elapsed -lt 30 ] &&
3782 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3783 error "Ten 1M writes should take at least 30 seconds"; }
3785 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3786 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3790 run_test 77m "check NRS Delay slows write RPC processing"
3792 test_77n() { #LU-10802
3793 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3794 skip "Need OST version at least 2.10.58"
3798 # Configure jobid_var
3799 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3800 if [ $saved_jobid_var != procname_uid ]; then
3801 set_persistent_param_and_check client \
3802 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3805 do_nodes $(comma_list $(osts_nodes)) \
3806 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
3807 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3808 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
3811 tbf_verify 20 20 "$RUNAS"
3813 do_nodes $(comma_list $(osts_nodes)) \
3814 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3815 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
3820 do_nodes $(comma_list $(osts_nodes)) \
3821 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3822 ost.OSS.ost_io.nrs_policies="fifo"
3826 local current_jobid_var=$($LCTL get_param -n jobid_var)
3827 if [ $saved_jobid_var != $current_jobid_var ]; then
3828 set_persistent_param_and_check client \
3829 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3832 run_test 77n "check wildcard support for TBF JobID NRS policy"
3834 test_78() { #LU-6673
3837 oss=$(comma_list $(osts_nodes))
3838 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3839 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3841 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3842 # Valid return codes are:
3843 # 0: Tuning succeeded
3844 # ENODEV: Policy is still stopped
3845 # EAGAIN: Policy is being initialized
3846 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3847 error "Expected set_param to return 0|ENODEV|EAGAIN"
3849 # Cleanup the ORR policy
3850 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3851 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3854 run_test 78 "Enable policy and specify tunings right away"
3857 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3858 test_mkdir $DIR/$tdir
3860 # Prevent interference from layout intent RPCs due to
3861 # asynchronous writeback. These will be tested in 130c below.
3862 do_nodes ${CLIENTS:-$HOSTNAME} sync
3864 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3865 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3867 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3868 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
3869 local facet=mds$((mdtidx + 1))
3871 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3872 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3876 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3877 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3882 run_test 79 "xattr: intent error"
3885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3892 mkdir -p $DIR1/$tdir/dir
3893 createmany -o $DIR1/$tdir/dir/f 10 ||
3894 error "create files under remote dir failed $i"
3896 cp /etc/passwd $DIR1/$tdir/$tfile
3898 #migrate open file should fails
3899 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3901 # give multiop a chance to open
3904 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3905 error "migrate open files should failed with open files"
3909 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3910 error "migrate remote dir error"
3912 echo "Finish migration, then checking.."
3913 for file in $(find $DIR1/$tdir); do
3914 mdt_index=$($LFS getstripe -m $file)
3915 [ $mdt_index == $MDTIDX ] ||
3916 error "$file is not on MDT${MDTIDX}"
3919 diff /etc/passwd $DIR1/$tdir/$tfile ||
3920 error "file different after migration"
3922 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3924 run_test 80a "migrate directory when some children is being opened"
3928 kill -9 $migrate_pid
3932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3933 local migrate_dir1=$DIR1/$tdir/migrate_dir
3934 local migrate_dir2=$DIR2/$tdir/migrate_dir
3935 local migrate_run=$LUSTRE/tests/migrate.sh
3943 trap cleanup_80b EXIT
3944 #prepare migrate directory
3945 mkdir -p $migrate_dir1
3946 for F in {1,2,3,4,5}; do
3947 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3948 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3951 #migrate the directories among MDTs
3954 mdt_idx=$((RANDOM % MDSCOUNT))
3955 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3957 [ $rc -ne 0 -o $rc -ne 16 ] || break
3962 echo "start migration thread $migrate_pid"
3963 #Access the files at the same time
3964 start_time=$(date +%s)
3965 echo "accessing the migrating directory for 5 minutes..."
3967 ls $migrate_dir2 > /dev/null || {
3968 echo "read dir fails"
3971 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3972 echo "access file1 fails"
3976 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3977 echo "access file2/3 fails"
3981 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3982 echo "access file4 fails"
3986 stat $migrate_dir2/file5 > /dev/null || {
3987 echo "stat file5 fails"
3991 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3992 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3993 echo "touch file failed with $rc1"
3997 if [ -e $migrate_dir2/source_file ]; then
3998 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3999 &>/dev/null || rc1=$?
4000 if [ -e $migrate_dir2/link_file ]; then
4001 rm -rf $migrate_dir2/link_file
4004 mrename $migrate_dir2/source_file \
4005 $migrate_dir2/target_file &>/dev/null || rc1=$?
4006 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4007 echo "rename failed with $rc1"
4011 if [ -e $migrate_dir2/target_file ]; then
4012 rm -rf $migrate_dir2/target_file &>/dev/null ||
4015 rm -rf $migrate_dir2/source_file &>/dev/null ||
4018 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4019 echo "unlink failed with $rc1"
4024 end_time=$(date +%s)
4025 duration=$((end_time - start_time))
4026 if [ $((duration % 10)) -eq 0 ]; then
4027 if [ $show_time -eq 1 ]; then
4028 echo "...$duration seconds"
4035 kill -0 $migrate_pid || {
4036 echo "migration stopped 1"
4040 [ $duration -ge 300 ] && break
4043 #check migration are still there
4044 kill -0 $migrate_pid || error "migration stopped 2"
4047 run_test 80b "Accessing directory during migration"
4050 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4054 mkdir -p $DIR1/$tdir
4056 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4057 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4060 touch d0/0 || error "create 0 failed"
4061 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4062 stat d0/0 && error "stat mv filed succeed"
4063 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4064 stat d0/0 || error "stat failed"
4066 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4068 if [ $t -ne 3 ]; then
4069 ls -ai $DIR1/$tdir/d0
4070 error "expect 3 get $t"
4075 run_test 81a "rename and stat under striped directory"
4078 [ $MDSCOUNT -lt 2 ] &&
4079 skip "We need at least 2 MDTs for this test"
4086 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4087 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4096 for i in $(seq $total); do
4097 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4101 kill -9 $setattr_pid
4103 run_test 81b "rename under striped directory doesn't deadlock"
4106 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4107 { skip "Need MDS version at least 2.6.92"; return 0; }
4109 # Client 1 creates a file.
4110 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4112 # Client 2 opens the file.
4113 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4115 # Client 1 makes the file an orphan.
4116 rm $DIR1/$tfile || error "rm"
4117 # Client 2 sets EA "user.multiop".
4119 wait $pid2 || error "multiop 2"
4120 # Client 1 gets EA "user.multiop". This used to fail because the EA
4121 # cache refill would get "trusted.link" from mdd_xattr_list() but
4122 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4125 wait $pid1 || error "multiop 1"
4127 run_test 82 "fsetxattr and fgetxattr on orphan files"
4130 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4137 $LFS mkdir -i1 -c2 $tdir
4142 echo "start pid $pid1 to create/unlink striped directory"
4144 # Access the directory at the same time
4148 stat $tdir > /dev/null 2>&1
4152 echo "start pid $pid2 to stat striped directory"
4160 run_test 83 "access striped directory while it is being created/unlinked"
4163 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4168 [ "$SLOW" = "yes" ] && duration=600
4169 # Open/Create under striped directory
4173 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4174 touch $tdir/f{0..3} > /dev/null 2>&1
4178 echo "start pid $pid1 to open/create under striped directory"
4180 # unlink the striped directory at the same time
4184 rm -rf $tdir > /dev/null 2>&1
4188 echo "start pid $pid2 to unlink striped directory"
4197 run_test 90 "open/create and unlink striped directory"
4200 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4205 [ "$SLOW" = "yes" ] && duration=600
4206 # chmod striped directory
4210 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4211 chmod go+w $tdir > /dev/null 2>&1
4215 echo "start pid $pid1 to chmod striped directory"
4217 # unlink the striped directory at the same time
4221 rm -rf $tdir > /dev/null 2>&1
4225 echo "start pid $pid2 to unlink striped directory"
4234 run_test 91 "chmod and unlink striped directory"
4237 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4240 local cmd="exec $fd<$DIR1/$tdir"
4241 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4244 trap "eval $cmd" EXIT
4245 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4246 rmdir ../$tdir || error "rmdir ../$tdir fails"
4248 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4249 $LCTL set_param fail_loc=0x1408
4250 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4251 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4252 error "create remote dir succeeds"
4253 $LCTL set_param fail_loc=0
4257 run_test 92 "create remote directory under orphan directory"
4264 mkdir -p $DIR1/$tfile-1/
4265 mkdir -p $DIR2/$tfile-2/
4266 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4267 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4268 do_facet $SINGLEMDS lctl set_param -n \
4269 'lod.lustre-MDT*/qos_threshold_rr' 100
4270 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4271 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4273 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4276 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4280 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4281 do_facet $SINGLEMDS "lctl set_param -n \
4282 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4284 $GETSTRIPE $DIR1/$tfile-1/file1
4285 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4286 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4287 $GETSTRIPE $DIR2/$tfile-2/file2
4288 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4289 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4290 echo "rc1=$rc1 and rc2=$rc2 "
4291 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4292 error "object allocate on same ost detected"
4294 run_test 93 "alloc_rr should not allocate on same ost"
4298 skip "Reserved for glimpse-ahead" && return
4299 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4300 skip "Need MDS version at least 2.10.55" && return
4304 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4306 lctl set_param -n mdc.*.stats=clear
4307 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4309 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4310 # first stat from server should return size data and save glimpse
4311 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4312 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4313 # second stat to check size is NOT cached on client without IO lock
4314 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4316 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4317 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4320 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4323 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4324 skip "Need MDS version at least 2.10.55" && return
4328 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4330 lctl set_param -n mdc.*.stats=clear
4331 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4332 cancel_lru_locks mdc
4333 # first stat data from server should have size
4334 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4335 # second stat to check size is cached on client
4336 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4338 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4339 # both stats should cause no glimpse requests
4340 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4343 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4346 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4347 skip "Need MDS version at least 2.10.55" && return
4351 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4353 lctl set_param -n mdc.*.stats=clear
4354 lctl set_param -n osc.*.stats=clear
4355 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4357 # check that size is merged from MDT and OST correctly
4358 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4359 error "Wrong size from stat #1"
4361 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4362 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4366 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4369 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4370 skip "Need MDS version at least 2.10.55" && return
4374 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4377 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4378 lctl set_param -n mdc.*.stats=clear
4379 $TRUNCATE $DIR2/$tdir/dom 4096
4381 # check that reported size is valid after file grows to OST and
4382 # is truncated back to MDT stripe size
4383 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4384 error "Wrong size from stat #1"
4386 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4387 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4391 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4394 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4395 skip "Need MDS version at least 2.10.55" && return
4397 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4399 $CHECKSTAT -t file $DIR1/$tfile
4401 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4402 sysctl -wq vm.dirty_writeback_centisecs=0
4404 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4407 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4408 error_noexit "Write fails"
4409 # must discard pages
4410 lctl set_param -n mdc.*.stats=clear
4411 rm $DIR2/$tfile || error "Unlink fails"
4413 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4414 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4416 run_test 101a "Discard DoM data on unlink"
4419 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4420 skip "Need MDS version at least 2.10.55" && return
4422 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4423 touch $DIR1/${tfile}_2
4425 $CHECKSTAT -t file $DIR1/$tfile
4427 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4428 sysctl -wq vm.dirty_writeback_centisecs=0
4430 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4433 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4434 # must discard pages
4435 lctl set_param -n mdc.*.stats=clear
4436 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4438 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4439 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4441 run_test 101b "Discard DoM data on rename"
4444 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4445 skip "Need MDS version at least 2.10.55" && return
4447 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4449 $CHECKSTAT -t file $DIR1/$tfile
4451 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4452 sysctl -wq vm.dirty_writeback_centisecs=0
4454 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4457 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4458 $MULTIOP $DIR1/$tfile O_c &
4461 lctl set_param -n mdc.*.stats=clear
4462 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4463 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4465 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4466 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4468 run_test 101c "Discard DoM data on close-unlink"
4470 # test to verify file handle related system calls
4471 # (name_to_handle_at/open_by_handle_at)
4472 # The new system calls are supported in glibc >= 2.14.
4474 # test to verify we can open by handle an unlinked file from > 1 client
4475 # This test opens the file normally on $DIR1, which is on one mount, and then
4476 # opens it by handle on $DIR2, which is on a different mount.
4478 echo "Test file_handle syscalls" > $DIR/$tfile ||
4479 error "write failed"
4480 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4481 error "check_fhandle_syscalls failed"
4484 run_test 102 "Test open by handle of unlinked file"
4486 log "cleanup: ======================================================"
4488 # kill and wait in each test only guarentee script finish, but command in script
4489 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4490 # otherwise umount below will fail
4491 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4496 check_and_cleanup_lustre