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}
37 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
38 # bug number for skipped test:
39 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
40 # LU-2829 / LU-2887 - make allowances for ZFS slowness
41 TEST33_NFILES=${TEST33_NFILES:-1000}
44 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
51 check_and_setup_lustre
56 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
58 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
59 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
61 # $RUNAS_ID may get set incorrectly somewhere else
62 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
64 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
70 [ -f $DIR2/$tfile ] || error "Check create"
71 chmod 777 $DIR2/$tfile
72 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
73 error "Check attribute update for 0777"
75 chmod a-x $DIR2/$tfile
76 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
77 error "Check attribute update for 0666"
80 $CHECKSTAT -a $DIR1/$tfile ||
81 error "Check unlink - removes file on other mountpoint"
83 run_test 1 "Check attribute updates on 2 mount points"
89 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
90 error "Either not file type or perms not 0777"
92 run_test 2a "check cached attribute updates on 2 mtpt's ========"
98 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
99 error "Either not file type or perms not 0777"
101 run_test 2b "check cached attribute updates on 2 mtpt's ========"
103 # NEED TO SAVE ROOT DIR MODE
106 $CHECKSTAT -t dir -p 0777 $DIR2 ||
107 error "Either not dir type or perms not 0777"
109 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
113 $CHECKSTAT -t dir -p 0755 $DIR2 ||
114 error "Either not file type or perms not 0775"
116 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
123 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
126 run_test 2e "check chmod on root is propagated to others"
129 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
131 local remote_dir=$tdir/remote_dir
134 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
135 error "Create remote directory failed"
137 touch $DIR1/$remote_dir/$tfile ||
138 error "Create file under remote directory failed"
139 chmod 777 $DIR1/$remote_dir/$tfile ||
140 error "Chmod file under remote directory failed"
142 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
143 error "Check attr of file under remote directory failed"
145 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
146 error "Chown file under remote directory failed"
148 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
149 error "Check owner of file under remote directory failed"
151 cd $DIR2/$remote_dir || error "enter remote dir"
152 rm -rf $DIR1/$remote_dir/$tfile ||
153 error "Unlink remote directory failed"
155 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
156 error "unlink file still exists!"
158 cd $DIR2/$tdir || error "exit remote dir"
159 rm -rf $DIR1/$tdir || error "unlink directory failed"
161 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
164 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
166 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
168 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
169 echo "$DIR1/$tfile has $block1 blocks"
170 echo "$DIR2/$tfile has $block2 blocks"
171 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
173 run_test 2g "check blocks update on sync write"
176 local target="this/is/good"
177 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
178 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
179 error "link $DIR2/$tfile not as expected"
181 run_test 3 "symlink on one mtpt, readlink on another ==========="
184 multifstat $DIR1/f4 $DIR2/f4
186 run_test 4 "fstat validation on multiple mount points =========="
190 $TRUNCATE $DIR2/f5 100
191 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
192 error "Either not file type or size not equal to 100 bytes"
195 run_test 5 "create a file on one mount, truncate it on the other"
198 openunlink $DIR1/$tfile $DIR2/$tfile || \
199 error "openunlink $DIR1/$tfile $DIR2/$tfile"
201 run_test 6 "remove of open file on other node =================="
205 opendirunlink $DIR1/$dir $DIR2/$dir || \
206 error "opendirunlink $DIR1/$dir $DIR2/$dir"
208 run_test 7 "remove of open directory on other node ============="
211 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
212 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
214 run_test 8 "remove of open special file on other node =========="
220 for C in a b c d e f g h i j k l; do
221 dir=`eval echo \\$DIR$MTPT`
222 echo -n $C >> $dir/f9
223 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
225 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
226 error "`od -a $DIR1/f9` != abcdefghijkl"
228 run_test 9a "append of file with sub-page size on multiple mounts"
230 #LU-10681 - tiny writes & appending to sparse striped file
232 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
234 $LFS setstripe -c 2 -S 1M $DIR/$tfile
235 echo "foo" >> $DIR/$tfile
236 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
237 error "sparse dd $DIR2/$tfile failed"
238 echo "foo" >> $DIR/$tfile
240 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
241 echo "Data read (expecting 'foo')": $data
242 [ "$data" = "foo" ] || error "append to sparse striped file failed"
244 run_test 9b "append to striped sparse file"
251 for C in a b c d e f g h i j k l; do
252 dir=`eval echo \\$DIR$MTPT`
253 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
254 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
255 OFFSET=`expr $OFFSET + 1`
257 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
258 error "`od -a $DIR1/f10` != abcdefghijkl"
260 run_test 10a "write of file with sub-page size on multiple mounts "
264 yes "R" | head -c 4000 >$TMP/f10b-seed
265 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
267 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
269 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
271 # create a test file locally to compare
272 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
273 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
274 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
275 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
277 run_test 10b "write of file with sub-page size on multiple mounts "
281 multiop_bg_pause $DIR1/d11/f O_c || return 1
283 cp -p /bin/ls $DIR1/d11/f
287 wait $MULTIPID || error "wait for PID $MULTIPID failed"
288 [ $RC -eq 0 ] && error || true
290 run_test 11 "execution of file opened for write should return error ===="
293 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
295 run_test 12 "test lock ordering (link, stat, unlink)"
297 test_13() { # bug 2451 - directory coherency
299 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
301 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
303 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
304 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
305 # need to run it twice
306 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
308 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
309 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
311 run_test 13 "test directory page revocation"
314 test_mkdir $DIR1/$tdir
315 cp -p /bin/ls $DIR1/$tdir/$tfile
316 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
319 $DIR2/$tdir/$tfile && error || true
321 wait $MULTIPID || return 2
323 run_test 14aa "execution of file open for write returns -ETXTBSY"
326 test_mkdir $DIR1/$tdir
327 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
328 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
331 $MULTIOP $DIR2/$tdir/multiop Oc && error "expected error, got success"
332 kill -USR1 $MULTIOP_PID || return 2
333 wait $MULTIOP_PID || return 3
334 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
336 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
338 test_14b() { # bug 3192, 7040
339 test_mkdir $DIR1/$tdir
340 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
341 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
344 $TRUNCATE $DIR2/$tdir/multiop 0 && kill -9 $MULTIOP_PID && \
345 error "expected truncate error, got success"
346 kill -USR1 $MULTIOP_PID || return 2
347 wait $MULTIOP_PID || return 3
348 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
349 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
351 run_test 14b "truncate of executing file returns -ETXTBSY ======"
353 test_14c() { # bug 3430, 7040
354 test_mkdir $DIR1/$tdir
355 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
356 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
359 cp /etc/hosts $DIR2/$tdir/multiop && error "expected error, got success"
360 kill -USR1 $MULTIOP_PID || return 2
361 wait $MULTIOP_PID || return 3
362 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
363 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
365 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
367 test_14d() { # bug 10921
368 test_mkdir $DIR1/$tdir
369 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
370 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
374 chmod 600 $DIR1/$tdir/multiop || error "chmod failed"
375 kill -USR1 $MULTIOP_PID || return 2
376 wait $MULTIOP_PID || return 3
377 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
378 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
380 run_test 14d "chmod of executing file is still possible ========"
382 test_15() { # bug 974 - ENOSPC
384 sh oos2.sh $MOUNT1 $MOUNT2
385 wait_delete_completed
386 grant_error=`dmesg | grep "> available"`
387 [ -z "$grant_error" ] || error "$grant_error"
389 run_test 15 "test out-of-space with multiple writers ==========="
392 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
393 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
394 # pass a 2500 operation dual-mount run within the time limit.
395 if [ "$(facet_fstype ost1)" = "zfs" ]; then
396 FSXNUM=$((COUNT / 5))
398 elif [ "$SLOW" = "yes" ]; then
399 FSXNUM=$((COUNT * 5))
407 local file1=$DIR1/$tfile
408 local file2=$DIR2/$tfile
409 local stripe_size=$(do_facet $SINGLEMDS \
410 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
412 # to allocate grant because it may run out due to test_15.
413 $LFS setstripe -c -1 $file1
414 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
415 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
418 $LFS setstripe -c -1 $file1 # b=10919
419 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
420 || error "fsx failed"
423 # O_DIRECT reads and writes must be aligned to the device block size.
424 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
425 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
427 run_test 16a "$FSXNUM iterations of dual-mount fsx"
429 # Consistency check for tiny writes, LU-9409
431 local file1=$DIR1/$tfile
432 local file2=$DIR2/$tfile
434 # to allocate grant because it may run out due to test_15.
435 lfs setstripe -c -1 $file1
436 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
437 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
440 lfs setstripe -c -1 $file1 # b=10919
441 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
442 # create a mix of tiny writes & normal writes
443 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
446 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
449 local file1=$DIR1/$tfile
450 local file2=$DIR2/$tfile
451 local stripe_size=$(do_facet $SINGLEMDS \
452 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
454 [ $(facet_fstype ost1) != ldiskfs ] && skip "dio on ldiskfs only"
456 # to allocate grant because it may run out due to test_15.
457 $LFS setstripe -c -1 $file1
458 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
459 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
461 wait_delete_completed
463 local list=$(comma_list $(osts_nodes))
464 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
465 skip "not cache-capable obdfilter"
468 set_osd_param $list '' read_cache_enable 0
469 set_osd_param $list '' writethrough_cache_enable 0
471 $LFS setstripe -c -1 $file1 # b=10919
472 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
473 || error "fsx failed"
476 set_osd_param $list '' read_cache_enable 1
477 set_osd_param $list '' writethrough_cache_enable 1
481 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
484 test_17() { # bug 3513, 3667
485 remote_ost_nodsh && skip "remote OST with nodsh" && return
487 lfs setstripe $DIR1/$tfile -i 0 -c 1
488 cp $SAMPLE_FILE $DIR1/$tfile
489 cancel_lru_locks osc > /dev/null
490 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
491 do_facet ost1 lctl set_param fail_loc=0x8000030a
492 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
493 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
495 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
497 run_test 17 "resource creation/LVB creation race ==============="
500 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
503 for idx in {a..z}; do
504 local ptr=EXCEPT_ALWAYS_18$idx
505 [ x${!ptr} = xtrue ] || continue
507 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
510 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
513 run_test 18 "mmap sanity check ================================="
515 test_19() { # bug3811
516 local node=$(facet_active_host ost1)
518 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
520 # check whether obdfilter is cache capable at all
521 get_osd_param $node '' read_cache_enable >/dev/null ||
522 skip "not cache-capable obdfilter"
524 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
525 set_osd_param $node '' readcache_max_filesize 4096
526 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
527 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
528 cp $TMP/$tfile $DIR1/$tfile
529 for i in `seq 1 20`; do
530 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
531 cancel_lru_locks $OSC > /dev/null
532 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
533 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
535 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
536 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
537 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
538 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
540 set_osd_param $node '' readcache_max_filesize $MAX
543 run_test 19 "test concurrent uncached read races ==============="
547 cancel_lru_locks $OSC
548 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
549 $MULTIOP $DIR1/f20 Ow8190c
550 $MULTIOP $DIR2/f20 Oz8194w8190c
551 $MULTIOP $DIR1/f20 Oz0r8190c
552 cancel_lru_locks $OSC
553 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
555 error $CNTD" page left in cache after lock cancel" || true
557 run_test 20 "test extra readahead page left in cache ===="
564 test_21() { # Bug 5907
565 test_mkdir $DIR1/$tdir
566 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
568 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
569 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
570 test -d $DIR1/$tdir || error "Mounted directory disappeared"
572 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
575 run_test 21 " Try to remove mountpoint on another dir ===="
577 test_23() { # Bug 5972
578 local at_diff=$(do_facet $SINGLEMDS \
579 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
580 echo "atime should be updated while another read" > $DIR1/$tfile
582 # clear the lock(mode: LCK_PW) gotten from creating operation
583 cancel_lru_locks $OSC
586 sleep $((at_diff + 1))
588 echo "starting reads"
589 multiop_bg_pause $DIR1/$tfile or20_c || return 1
590 # with SOM and opencache enabled, we need to close a file and cancel
591 # open lock to get atime propogated to MDS
592 kill -USR1 $! || return 2
595 time2=$(stat -c "%X" $DIR/$tfile)
596 echo "new atime is $time2"
598 [ $time2 -gt $time1 ] || error "atime was not updated"
599 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
602 run_test 23 " others should see updated atime while another read===="
606 lfs df || error "lfs df failed"
607 lfs df -ih || error "lfs df -ih failed"
608 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
609 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
610 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
611 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
613 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
614 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
615 lctl --device %osc deactivate
616 lfs df -i || error "lfs df -i with deactivated OSC failed"
617 lctl --device %osc activate
618 lfs df || error "lfs df with reactivated OSC failed"
620 run_test 24a "lfs df [-ih] [path] test ========================="
624 fsnum=$(lfs_df | grep -c "summary")
625 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
627 run_test 24b "lfs df should show both filesystems ==============="
630 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
632 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
635 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
636 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
638 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
639 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
640 error "setfacl $DIR2/$tdir #1"
641 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
642 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
643 error "setfacl $DIR2/$tdir #2"
644 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
645 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
646 error "setfacl $DIR2/$tdir #3"
647 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
648 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
649 error "setfacl $DIR2/$tdir #4"
650 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
654 run_test 25a "change ACL on one mountpoint be seen on another ==="
657 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
659 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
661 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
664 $LFS mkdir -i 1 $DIR1/$tdir
665 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
666 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
668 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
669 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
670 error "setfacl $DIR2/$tdir #1"
671 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
672 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
673 error "setfacl $DIR2/$tdir #2"
674 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
675 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
676 error "setfacl $DIR2/$tdir #3"
677 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
678 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
679 error "setfacl $DIR2/$tdir #4"
680 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
684 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
687 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
689 run_test 26a "allow mtime to get older"
694 echo "aaa" >> $DIR1/$tfile
696 chmod a+x $DIR2/$tfile
697 mt1=`stat -c %Y $DIR1/$tfile`
698 mt2=`stat -c %Y $DIR2/$tfile`
700 if [ x"$mt1" != x"$mt2" ]; then
701 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
704 run_test 26b "sync mtime between ost and mds"
707 cancel_lru_locks $OSC
709 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
714 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
719 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
721 lctl set_param -n ldlm.dump_namespaces ""
722 wait $DD1_PID $DD2_PID
723 [ $? -ne 0 ] && lctl dk $TMP/debug || true
725 run_test 27 "align non-overlapping extent locks from request ==="
727 test_28() { # bug 9977
728 ECHO_UUID="ECHO_osc1_UUID"
729 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
731 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
732 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
733 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
737 attach echo_client ECHO_osc1 $ECHO_UUID
741 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
742 $LCTL --device $tECHOID destroy "${tOBJID}:0"
750 # reading of 1st stripe should pass
751 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
752 # reading of 2nd stripe should fail (this stripe was destroyed)
753 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
755 # now, recreating test file
756 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
757 # reading of 1st stripe should pass
758 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
759 # reading of 2nd stripe should pass
760 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
763 run_test 28 "read/write/truncate file with lost stripes"
765 test_30() { #b=11110, LU-2523
766 test_mkdir $DIR1/$tdir
767 cp -f /bin/bash $DIR1/$tdir/bash
768 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
769 $DIR1/$tdir/bash -c 'sleep 2;
770 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
774 run_test 30 "recreate file race"
777 test_mkdir $DIR1/$tdir
778 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
779 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
780 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
781 lctl set_param fail_loc=0x314
782 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
783 awk 'BEGIN { FS="+" } /in/ {print $1}')
784 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
786 run_test 31a "voluntary cancel / blocking ast race=============="
789 remote_ost || { skip "local OST" && return 0; }
790 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
792 # make sure there is no local locks due to destroy
793 wait_mds_ost_sync || error "wait_mds_ost_sync()"
794 wait_delete_completed || error "wait_delete_completed()"
796 test_mkdir $DIR1/$tdir
797 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
798 cp /etc/hosts $DIR/$tdir/$tfile
799 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
800 lctl set_param fail_loc=0x314
801 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
802 do_facet ost1 lctl set_param fail_loc=0x316
804 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
805 lctl set_param fail_loc=0
806 do_facet ost1 lctl set_param fail_loc=0
807 # cleanup: reconnect the client back
810 run_test 31b "voluntary OST cancel / blocking ast race=============="
812 # enable/disable lockless truncate feature, depending on the arg 0/1
813 enable_lockless_truncate() {
814 lctl set_param -n $OSC.*.lockless_truncate $1
817 test_32a() { # bug 11270
818 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
819 local stripe_size=$(do_facet $SINGLEMDS \
820 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
822 save_lustre_params client "$OSC.*.lockless_truncate" > $p
823 cancel_lru_locks $OSC
824 enable_lockless_truncate 1
826 lfs setstripe -c -1 $DIR1/$tfile
827 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
829 clear_stats $OSC.*.${OSC}_stats
831 log "checking cached lockless truncate"
832 $TRUNCATE $DIR1/$tfile 8000000
833 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
834 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
835 error "cached truncate isn't lockless"
837 log "checking not cached lockless truncate"
838 $TRUNCATE $DIR2/$tfile 5000000
839 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
840 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
841 error "not cached truncate isn't lockless"
843 log "disabled lockless truncate"
844 enable_lockless_truncate 0
845 clear_stats $OSC.*.${OSC}_stats
846 $TRUNCATE $DIR2/$tfile 3000000
847 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
848 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
849 error "lockless truncate disabling failed"
851 # restore lockless_truncate default values
852 restore_lustre_params < $p
855 run_test 32a "lockless truncate"
857 test_32b() { # bug 11270
858 remote_ost_nodsh && skip "remote OST with nodsh" && return
861 local facets=$(get_facets OST)
862 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
864 save_lustre_params client "osc.*.contention_seconds" > $p
865 save_lustre_params $facets \
866 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
867 save_lustre_params $facets \
868 "ldlm.namespaces.filter-*.contended_locks" >> $p
869 save_lustre_params $facets \
870 "ldlm.namespaces.filter-*.contention_seconds" >> $p
871 clear_stats $OSC.*.${OSC}_stats
873 # agressive lockless i/o settings
874 do_nodes $(comma_list $(osts_nodes)) \
875 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
876 ldlm.namespaces.filter-*.contended_locks=0 \
877 ldlm.namespaces.filter-*.contention_seconds=60"
878 lctl set_param -n $OSC.*.contention_seconds=60
880 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
882 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
885 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
886 error "lockless i/o was not triggered"
887 # disable lockless i/o (it is disabled by default)
888 do_nodes $(comma_list $(osts_nodes)) \
889 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
890 ldlm.namespaces.filter-*.contended_locks=32 \
891 ldlm.namespaces.filter-*.contention_seconds=0"
892 # set contention_seconds to 0 at client too, otherwise Lustre still
893 # remembers lock contention
894 lctl set_param -n $OSC.*.contention_seconds=0
895 clear_stats $OSC.*.${OSC}_stats
897 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
899 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
902 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
903 error "lockless i/o works when disabled"
905 restore_lustre_params <$p
908 run_test 32b "lockless i/o"
912 local mdts=$(get_facets MDS)
917 for mds in ${mdts//,/ }; do
919 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
920 xargs readlink -f" ))
921 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
924 stat=$(( stat + val))
929 # commit on sharing tests
931 remote_mds_nodsh && skip "remote MDS with nodsh" && return
933 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
934 [ $CLIENTCOUNT -lt 2 ] &&
935 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
937 local nfiles=${TEST33_NFILES:-10000}
938 local param_file=$TMP/$tfile-params
939 local fstype=$(facet_fstype $SINGLEMDS)
941 save_lustre_params $(get_facets MDS) \
942 "mdt.*.commit_on_sharing" > $param_file
950 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
954 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
956 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
957 echo "=== START createmany old: $jbdold transaction"
958 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")
959 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
960 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
961 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
962 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
963 avgtime=$(( avgtime + elapsed ))
965 eval cos${COS}_jbd=$((avgjbd / 3))
966 eval cos${COS}_time=$((avgtime / 3))
969 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
970 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
971 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
972 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
974 restore_lustre_params < $param_file
978 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
980 # commit on sharing tests
982 remote_mds_nodsh && skip "remote MDS with nodsh" && return
984 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
985 [ $CLIENTCOUNT -ge 2 ] ||
986 { skip "Need two or more clients, have $CLIENTCOUNT" &&
988 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
990 local nfiles=${TEST33_NFILES:-10000}
991 local param_file=$TMP/$tfile-params
993 save_lustre_params $(get_facets MDS) \
994 "mdt.*.commit_on_sharing" > $param_file
1003 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1007 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1008 $DIR1/$tdir-\\\$(hostname)-$i"
1010 jbdold=$(print_jbd_stat)
1011 echo "=== START createmany old: $jbdold transaction"
1012 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1013 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1014 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1016 jbdnew=$(print_jbd_stat)
1017 jbd=$(( jbdnew - jbdold ))
1018 echo "=== END createmany new: $jbdnew transaction : \
1019 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1020 avgjbd=$(( avgjbd + jbd ))
1021 avgtime=$(( avgtime + elapsed ))
1023 eval cos${COS}_jbd=$((avgjbd / 3))
1024 eval cos${COS}_time=$((avgtime / 3))
1027 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1028 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1029 [ "$cos0_jbd" != 0 ] &&
1030 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1031 [ "$cos0_time" != 0 ] &&
1032 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1034 restore_lustre_params < $param_file
1038 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1041 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1042 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1043 skip "DNE CoS not supported" && return
1049 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1050 # do twice in case transaction is committed before unlock, see LU-8200
1052 # remote dir is created on MDT1, which enqueued lock of $tdir on
1054 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1055 mkdir $DIR/$tdir/local.$i
1057 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1058 echo "sync_count $sync_count"
1059 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1062 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1063 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1064 # during sleep remote mkdir should have been committed and canceled
1065 # remote lock spontaneously, which shouldn't trigger sync
1067 mkdir $DIR/$tdir/local.3
1068 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1069 echo "sync_count $sync_count"
1070 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1072 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1074 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1078 local nodes=$(comma_list $(mdts_nodes))
1082 # trigger CoS twice in case transaction commit before unlock
1085 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1087 commit_nr=$(do_nodes $nodes \
1088 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1089 total=$((total + commit_nr));
1094 echo "CoS count $total"
1095 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1099 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1100 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1101 skip "DNE CoS not supported" && return
1103 # remote directory create
1104 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1105 # remote directory unlink
1106 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1107 # striped directory create
1108 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1109 # striped directory setattr
1110 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1111 "chmod 713 $DIR/$tdir"
1112 # striped directory unlink
1113 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1116 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1117 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1118 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1119 touch $DIR/$tdir/d1/tgt" \
1120 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1122 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1123 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1124 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1125 touch $DIR/$tdir/d1/src" \
1126 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1128 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1129 "$LFS migrate -m 1 $DIR/$tdir"
1133 run_test 33d "DNE distributed operation should trigger COS"
1136 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1137 [ $CLIENTCOUNT -ge 2 ] ||
1138 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1140 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1141 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1142 skip "DNE CoS not supported" && return
1144 local client2=${CLIENT2:-$(hostname)}
1148 local nodes=$(comma_list $(mdts_nodes))
1149 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1151 $LFS mkdir -c 2 $DIR/$tdir
1152 mkdir $DIR/$tdir/subdir
1153 echo abc > $DIR/$tdir/$tfile
1154 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1155 do_node $client2 touch $DIR/$tdir/subdir
1157 local async_commit_count=$(do_nodes $nodes \
1158 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1159 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1163 run_test 33e "DNE local operation shouldn't trigger COS"
1165 # End commit on sharing tests
1167 get_ost_lock_timeouts() {
1168 local nodes=${1:-$(comma_list $(osts_nodes))}
1170 local locks=$(do_nodes $nodes \
1171 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1179 do_nodes $(comma_list $(osts_nodes)) \
1180 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1181 for i in $(seq $OSTCOUNT); do
1182 wait_osc_import_ready client ost$i
1187 remote_ost_nodsh && skip "remote OST with nodsh" && return
1191 trap cleanup_34 EXIT RETURN
1192 for OPER in notimeout timeout ; do
1193 rm $DIR1/$tfile 2>/dev/null
1194 lock_in=$(get_ost_lock_timeouts)
1195 if [ $OPER == "timeout" ] ; then
1196 for j in `seq $OSTCOUNT`; do
1197 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1198 do_facet ost$j lctl set_param fail_loc=0x511
1200 echo lock should expire
1202 for j in `seq $OSTCOUNT`; do
1203 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1204 do_facet ost$j lctl set_param fail_loc=0x512
1206 echo lock should not expire
1208 echo writing on client1
1209 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1211 echo reading on client2
1212 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1213 # wait for a lock timeout
1215 lock_out=$(get_ost_lock_timeouts)
1216 if [ $OPER == "timeout" ] ; then
1217 if [ $lock_in == $lock_out ]; then
1218 error "no lock timeout happened"
1223 if [ $lock_in != $lock_out ]; then
1224 error "lock timeout happened"
1232 run_test 34 "no lock timeout under IO"
1234 test_35() { # bug 17645
1237 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1238 awk '/generation/{print $2}')
1240 generation[count]=$g
1244 test_mkdir $MOUNT1/$tdir
1245 cancel_lru_locks mdc
1247 # Let's initiate -EINTR situation by setting fail_loc and take
1248 # write lock on same file from same client. This will not cause
1249 # bl_ast yet as lock is already in local cache.
1250 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1251 do_facet client "lctl set_param fail_loc=0x80000317"
1252 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1253 let timeout=timeout*3
1255 while test $nr -lt 10; do
1256 log "Race attempt $nr"
1257 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1258 awk '/ldlm_bl_callback/ { print $2 }')
1259 test "x$blk1" = "x" && blk1=0
1260 createmany -o $MOUNT2/$tdir/a 4000 &
1264 # Let's make conflict and bl_ast
1265 ls -la $MOUNT1/$tdir > /dev/null &
1268 log "Wait for $pid1 $pid2 for $timeout sec..."
1270 kill -9 $pid1 $pid2 > /dev/null 2>&1
1272 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1273 awk '/ldlm_bl_callback/ { print $2 }')
1274 test "x$blk2" = "x" && blk2=0
1275 test $blk2 -gt $blk1 && break
1276 rm -fr $MOUNT1/$tdir
1277 cancel_lru_locks mdc
1280 do_facet client "lctl set_param fail_loc=0x0"
1281 df -h $MOUNT1 $MOUNT2
1283 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1284 awk '/generation/{print $2}')
1286 if ! test "$g" -eq "${generation[count]}"; then
1287 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1289 for imp in $list; do
1290 if [ $c = $count ]; then
1295 imp=$(echo "$imp" | awk -F"." '{print $2}')
1296 error "Eviction happened on import $imp"
1301 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1303 test_36() { #bug 16417
1308 test_mkdir $DIR1/$tdir
1309 $LFS setstripe -c -1 $DIR1/$tdir
1312 let SIZE_B=SIZE*1024*1024
1313 sync; sleep 2; sync # wait for delete thread
1314 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1315 wait_destroy_complete || error "wait_destroy_complete failed"
1317 while [ $i -le 10 ]; do
1318 lctl mark "start test - cycle ($i)"
1319 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1320 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1321 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1322 sync # sync data from client cache
1323 sync_all_data # sync data from server cache (delayed allocation)
1325 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1326 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1328 rm -f $DIR1/$tdir/$tfile
1329 kill -USR1 $read_pid
1331 sync; sleep 2; sync # Ensure new statfs
1332 wait_delete_completed
1333 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1334 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1336 # this free space! not used
1337 (( $after_dd <= $after)) ||
1338 error "space leaked after_dd:$after_dd > after:$after"
1342 run_test 36 "handle ESTALE/open-unlink correctly"
1344 test_37() { # bug 18695
1345 test_mkdir $DIR1/$tdir
1346 multiop_bg_pause $DIR1/$tdir D_c || return 1
1348 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1349 createmany -m $DIR2/$tdir/f 10000
1350 # set mtime/atime backward
1351 touch -t 198001010000 $DIR2/$tdir
1352 kill -USR1 $MULTIPID
1353 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1354 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1357 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1359 # this should be set to past
1360 TEST_39_MTIME=`date -d "1 year ago" +%s`
1364 local client1=${CLIENT1:-`hostname`}
1365 local client2=${CLIENT2:-`hostname`}
1367 do_node $client1 "touch $DIR1/$tfile"
1369 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1370 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1371 [ "$mtime1" = $TEST_39_MTIME ] || \
1372 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1374 local d1=`do_node $client1 date +%s`
1375 do_node $client1 'echo hello >> '$DIR1/$tfile
1376 local d2=`do_node $client1 date +%s`
1378 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1379 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1380 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1382 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1384 for (( i=0; i < 2; i++ )) ; do
1385 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1386 [ "$mtime2" = "$mtime3" ] || \
1387 error "mtime ($mtime2) changed (to $mtime3) on rename"
1389 cancel_lru_locks osc
1390 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1393 run_test 39a "test from 11063 =================================="
1396 local client1=${CLIENT1:-`hostname`}
1397 local client2=${CLIENT2:-`hostname`}
1401 local mtime1=`stat -c %Y $DIR1/$tfile`
1402 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1405 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1407 for (( i=0; i < 2; i++ )) ; do
1408 local mtime3=`stat -c %Y $DIR1/$tfile`
1409 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1411 [ "$mtime3" = "$mtime4" ] || \
1412 error "different mtime on clients: $mtime3, $mtime4"
1413 [ "$mtime3" = $TEST_39_MTIME ] || \
1414 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1416 cancel_lru_locks osc
1417 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1420 run_test 39b "11063 problem 1 =================================="
1423 local client1=${CLIENT1:-`hostname`}
1424 local client2=${CLIENT2:-`hostname`}
1426 echo hello > $DIR1/$tfile
1428 local mtime1=`stat -c %Y $DIR1/$tfile`
1429 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1430 [ "$mtime1" = "$mtime2" ] || \
1431 error "create: different mtime on clients: $mtime1, $mtime2"
1434 $TRUNCATE $DIR1/$tfile 1
1436 for (( i=0; i < 2; i++ )) ; do
1437 local mtime3=`stat -c %Y $DIR1/$tfile`
1438 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1440 [ "$mtime3" = "$mtime4" ] || \
1441 error "different mtime on clients: $mtime3, $mtime4"
1442 [ "$mtime3" -gt $mtime2 ] || \
1443 error "truncate did not update mtime: $mtime2, $mtime3"
1445 cancel_lru_locks osc
1446 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1449 run_test 39c "check truncate mtime update ======================"
1451 test_39d() { # LU-7310
1453 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1455 local mtime1=$(stat -c %Y $DIR2/$tfile)
1456 [ "$mtime1" = $TEST_39_MTIME ] ||
1457 error "mtime: $mtime1, should be $TEST_39_MTIME"
1460 # define OBD_FAIL_OSC_NO_GRANT 0x411
1461 $LCTL set_param fail_loc=0x411
1463 local d1=$(date +%s)
1464 echo hello >> $DIR1/$tfile
1465 local d2=$(date +%s)
1467 $LCTL set_param fail_loc=0
1469 cancel_lru_locks $OSC
1471 local mtime2=$(stat -c %Y $DIR2/$tfile)
1472 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1473 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1475 run_test 39d "sync write should update mtime"
1477 # check that pid exists hence second operation wasn't blocked by first one
1478 # if it is so then there is no conflict, return 0
1479 # else second operation is conflicting with first one, return 1
1480 check_pdo_conflict() {
1483 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1484 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1494 # test 40: check non-blocking operations
1496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1497 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1498 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1500 mkdir $DIR1/$tfile &
1503 touch $DIR2/$tfile-2
1504 check_pdo_conflict $PID1 || error "create is blocked"
1505 mkdir $DIR2/$tfile-3
1506 check_pdo_conflict $PID1 || error "mkdir is blocked"
1507 link $DIR2/$tfile-2 $DIR2/$tfile-4
1508 check_pdo_conflict $PID1 || error "link is blocked"
1509 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1510 check_pdo_conflict $PID1 || error "rename is blocked"
1511 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1512 check_pdo_conflict $PID1 || error "getattr is blocked"
1513 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1514 rmdir $DIR2/$tfile-3
1515 check_pdo_conflict $PID1 || error "unlink is blocked"
1517 # all operations above shouldn't wait the first one
1518 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1523 run_test 40a "pdirops: create vs others =============="
1526 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1527 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1528 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1529 touch $DIR1/$tfile &
1533 touch $DIR2/$tfile-2
1534 check_pdo_conflict $PID1 || error "create is blocked"
1535 mkdir $DIR2/$tfile-3
1536 check_pdo_conflict $PID1 || error "mkdir is blocked"
1537 link $DIR2/$tfile-2 $DIR2/$tfile-4
1538 check_pdo_conflict $PID1 || error "link is blocked"
1539 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1540 check_pdo_conflict $PID1 || error "rename is blocked"
1541 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1542 check_pdo_conflict $PID1 || error "getattr is blocked"
1543 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1544 rmdir $DIR2/$tfile-3
1545 check_pdo_conflict $PID1 || error "unlink is blocked"
1546 # all operations above shouldn't wait the first one
1548 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1553 run_test 40b "pdirops: open|create and others =============="
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1558 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1559 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1560 link $DIR1/$tfile $DIR1/$tfile-0 &
1564 touch $DIR2/$tfile-2
1565 check_pdo_conflict $PID1 || error "create is blocked"
1566 mkdir $DIR2/$tfile-3
1567 check_pdo_conflict $PID1 || error "mkdir is blocked"
1568 link $DIR2/$tfile-2 $DIR2/$tfile-4
1569 check_pdo_conflict $PID1 || error "link is blocked"
1570 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1571 check_pdo_conflict $PID1 || error "rename is blocked"
1572 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1573 check_pdo_conflict $PID1 || error "getattr is blocked"
1574 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1575 rmdir $DIR2/$tfile-3
1576 check_pdo_conflict $PID1 || error "unlink is blocked"
1578 # all operations above shouldn't wait the first one
1579 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1584 run_test 40c "pdirops: link and others =============="
1587 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1589 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1590 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1595 touch $DIR2/$tfile-2
1596 check_pdo_conflict $PID1 || error "create is blocked"
1597 mkdir $DIR2/$tfile-3
1598 check_pdo_conflict $PID1 || error "mkdir is blocked"
1599 link $DIR2/$tfile-2 $DIR2/$tfile-4
1600 check_pdo_conflict $PID1 || error "link is blocked"
1601 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1602 check_pdo_conflict $PID1 || error "rename is blocked"
1603 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1604 check_pdo_conflict $PID1 || error "getattr is blocked"
1605 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1606 rmdir $DIR2/$tfile-3
1607 check_pdo_conflict $PID1 || error "unlink is blocked"
1609 # all operations above shouldn't wait the first one
1610 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1614 run_test 40d "pdirops: unlink and others =============="
1617 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1619 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1620 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1621 mv $DIR1/$tfile $DIR1/$tfile-0 &
1625 touch $DIR2/$tfile-2
1626 check_pdo_conflict $PID1 || error "create is blocked"
1627 mkdir $DIR2/$tfile-3
1628 check_pdo_conflict $PID1 || error "mkdir is blocked"
1629 link $DIR2/$tfile-2 $DIR2/$tfile-4
1630 check_pdo_conflict $PID1 || error "link is blocked"
1631 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1632 check_pdo_conflict $PID1 || error "getattr is blocked"
1633 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1634 rmdir $DIR2/$tfile-3
1635 check_pdo_conflict $PID1 || error "unlink is blocked"
1637 # all operations above shouldn't wait the first one
1638 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1643 run_test 40e "pdirops: rename and others =============="
1645 # test 41: create blocking operations
1647 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1648 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1649 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1652 mkdir $DIR2/$tfile && error "mkdir must fail"
1653 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1657 run_test 41a "pdirops: create vs mkdir =============="
1660 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1661 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1662 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1665 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1666 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1670 run_test 41b "pdirops: create vs create =============="
1673 touch $DIR1/$tfile-2
1674 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1675 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1676 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1679 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1680 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1684 run_test 41c "pdirops: create vs link =============="
1687 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1688 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1689 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1692 rm $DIR2/$tfile || error "unlink must succeed"
1693 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1697 run_test 41d "pdirops: create vs unlink =============="
1700 touch $DIR1/$tfile-2
1701 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1702 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1703 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1706 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1707 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1711 run_test 41e "pdirops: create and rename (tgt) =============="
1714 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1715 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1716 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1719 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1720 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1724 run_test 41f "pdirops: create and rename (src) =============="
1727 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1728 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1729 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1732 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1733 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1737 run_test 41g "pdirops: create vs getattr =============="
1740 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1741 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1742 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1745 ls -lia $DIR2/ > /dev/null
1746 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1750 run_test 41h "pdirops: create vs readdir =============="
1752 # test 42: unlink and blocking operations
1754 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1755 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1756 mkdir $DIR1/$tfile &
1759 mkdir $DIR2/$tfile && error "mkdir must fail"
1760 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1764 run_test 42a "pdirops: mkdir vs mkdir =============="
1767 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1768 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1769 mkdir $DIR1/$tfile &
1772 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1773 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1777 run_test 42b "pdirops: mkdir vs create =============="
1780 touch $DIR1/$tfile-2
1781 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1782 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1783 mkdir $DIR1/$tfile &
1786 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1787 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1791 run_test 42c "pdirops: mkdir vs link =============="
1794 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1795 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1796 mkdir $DIR1/$tfile &
1799 rmdir $DIR2/$tfile || error "unlink must succeed"
1800 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1804 run_test 42d "pdirops: mkdir vs unlink =============="
1807 touch $DIR1/$tfile-2
1808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1809 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1810 mkdir $DIR1/$tfile &
1813 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1818 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1821 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1822 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1823 mkdir $DIR1/$tfile &
1826 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1827 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1831 run_test 42f "pdirops: mkdir and rename (src) =============="
1834 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1835 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1836 mkdir $DIR1/$tfile &
1839 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1840 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1844 run_test 42g "pdirops: mkdir vs getattr =============="
1847 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1848 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1849 mkdir $DIR1/$tfile &
1852 ls -lia $DIR2/ > /dev/null
1853 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1857 run_test 42h "pdirops: mkdir vs readdir =============="
1859 # test 43: unlink and blocking operations
1862 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1863 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1867 mkdir $DIR2/$tfile || error "mkdir must succeed"
1868 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1872 run_test 43a "pdirops: unlink vs mkdir =============="
1876 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1877 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1881 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1882 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1886 run_test 43b "pdirops: unlink vs create =============="
1890 touch $DIR1/$tfile-2
1891 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1892 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1896 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1897 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1901 run_test 43c "pdirops: unlink vs link =============="
1905 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1906 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1910 rm $DIR2/$tfile && error "unlink must fail"
1911 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1915 run_test 43d "pdirops: unlink vs unlink =============="
1919 touch $DIR1/$tfile-2
1920 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1921 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1925 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1926 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1930 run_test 43e "pdirops: unlink and rename (tgt) =============="
1934 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1935 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1939 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1940 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1944 run_test 43f "pdirops: unlink and rename (src) =============="
1948 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1949 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1953 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1954 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1958 run_test 43g "pdirops: unlink vs getattr =============="
1962 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1963 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1967 ls -lia $DIR2/ > /dev/null
1968 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1972 run_test 43h "pdirops: unlink vs readdir =============="
1975 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1977 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1978 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1982 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1983 check_pdo_conflict $PID1 &&
1984 { wait $PID1; error "remote mkdir isn't blocked"; }
1988 run_test 43i "pdirops: unlink vs remote mkdir"
1990 # test 44: rename tgt and blocking operations
1992 touch $DIR1/$tfile-2
1993 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1994 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1995 mv $DIR1/$tfile-2 $DIR1/$tfile &
1998 mkdir $DIR2/$tfile && error "mkdir must fail"
1999 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2003 run_test 44a "pdirops: rename tgt vs mkdir =============="
2006 touch $DIR1/$tfile-2
2007 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2008 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2009 mv $DIR1/$tfile-2 $DIR1/$tfile &
2012 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2013 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2017 run_test 44b "pdirops: rename tgt vs create =============="
2020 touch $DIR1/$tfile-2
2021 touch $DIR1/$tfile-3
2022 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2023 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2024 mv $DIR1/$tfile-2 $DIR1/$tfile &
2027 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
2028 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2032 run_test 44c "pdirops: rename tgt vs link =============="
2035 touch $DIR1/$tfile-2
2036 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2037 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2038 mv $DIR1/$tfile-2 $DIR1/$tfile &
2041 rm $DIR2/$tfile || error "unlink must succeed"
2042 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2046 run_test 44d "pdirops: rename tgt vs unlink =============="
2050 touch $DIR1/$tfile-2
2051 touch $DIR1/$tfile-3
2052 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2053 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2054 mv $DIR1/$tfile-2 $DIR1/$tfile &
2057 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2058 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2062 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2065 touch $DIR1/$tfile-2
2066 touch $DIR1/$tfile-3
2067 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2068 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2069 mv $DIR1/$tfile-2 $DIR1/$tfile &
2072 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2073 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2077 run_test 44f "pdirops: rename tgt and rename (src) =============="
2080 touch $DIR1/$tfile-2
2081 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2082 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2083 mv $DIR1/$tfile-2 $DIR1/$tfile &
2086 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2087 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2091 run_test 44g "pdirops: rename tgt vs getattr =============="
2094 touch $DIR1/$tfile-2
2095 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2096 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2097 mv $DIR1/$tfile-2 $DIR1/$tfile &
2100 ls -lia $DIR2/ > /dev/null
2101 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2105 run_test 44h "pdirops: rename tgt vs readdir =============="
2107 # test 44: rename tgt and blocking operations
2109 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2110 touch $DIR1/$tfile-2
2111 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2112 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2113 mv $DIR1/$tfile-2 $DIR1/$tfile &
2116 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2117 check_pdo_conflict $PID1 && { wait $PID1;
2118 error "remote mkdir isn't blocked"; }
2122 run_test 44i "pdirops: rename tgt vs remote mkdir"
2124 # test 45: rename src and blocking operations
2127 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2128 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2129 mv $DIR1/$tfile $DIR1/$tfile-2 &
2132 mkdir $DIR2/$tfile || error "mkdir must succeed"
2133 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2137 run_test 45a "pdirops: rename src vs mkdir =============="
2141 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2142 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2143 mv $DIR1/$tfile $DIR1/$tfile-2 &
2146 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2147 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2151 run_test 45b "pdirops: rename src vs create =============="
2155 touch $DIR1/$tfile-3
2156 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2157 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2158 mv $DIR1/$tfile $DIR1/$tfile-2 &
2161 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2162 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2166 run_test 45c "pdirops: rename src vs link =============="
2170 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2171 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2172 mv $DIR1/$tfile $DIR1/$tfile-2 &
2175 rm $DIR2/$tfile && error "unlink must fail"
2176 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2180 run_test 45d "pdirops: rename src vs unlink =============="
2184 touch $DIR1/$tfile-3
2185 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2186 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2187 mv $DIR1/$tfile $DIR1/$tfile-2 &
2190 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2191 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2195 run_test 45e "pdirops: rename src and rename (tgt) =============="
2199 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2200 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2201 mv $DIR1/$tfile $DIR1/$tfile-2 &
2204 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2205 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2209 run_test 45f "pdirops: rename src and rename (src) =============="
2213 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2214 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2215 mv $DIR1/$tfile $DIR1/$tfile-2 &
2218 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2219 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2223 run_test 45g "pdirops: rename src vs getattr =============="
2227 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2228 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2229 mv $DIR1/$tfile $DIR1/$tfile-2 &
2232 ls -lia $DIR2/ > /dev/null
2233 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2237 run_test 45h "pdirops: unlink vs readdir =============="
2240 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2242 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2243 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2244 mv $DIR1/$tfile $DIR1/$tfile-2 &
2247 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2248 check_pdo_conflict $PID1 && { wait $PID1;
2249 error "create remote dir isn't blocked"; }
2253 run_test 45i "pdirops: rename src vs remote mkdir"
2255 # test 46: link and blocking operations
2257 touch $DIR1/$tfile-2
2258 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2259 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2260 link $DIR1/$tfile-2 $DIR1/$tfile &
2263 mkdir $DIR2/$tfile && error "mkdir must fail"
2264 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2268 run_test 46a "pdirops: link vs mkdir =============="
2271 touch $DIR1/$tfile-2
2272 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2273 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2274 link $DIR1/$tfile-2 $DIR1/$tfile &
2277 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2278 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2282 run_test 46b "pdirops: link vs create =============="
2285 touch $DIR1/$tfile-2
2286 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2287 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2288 link $DIR1/$tfile-2 $DIR1/$tfile &
2291 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2292 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2296 run_test 46c "pdirops: link vs link =============="
2299 touch $DIR1/$tfile-2
2300 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2301 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2302 link $DIR1/$tfile-2 $DIR1/$tfile &
2305 rm $DIR2/$tfile || error "unlink must succeed"
2306 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2310 run_test 46d "pdirops: link vs unlink =============="
2313 touch $DIR1/$tfile-2
2314 touch $DIR1/$tfile-3
2315 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2316 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2317 link $DIR1/$tfile-2 $DIR1/$tfile &
2320 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2321 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2325 run_test 46e "pdirops: link and rename (tgt) =============="
2328 touch $DIR1/$tfile-2
2329 touch $DIR1/$tfile-3
2330 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2331 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2332 link $DIR1/$tfile-2 $DIR1/$tfile &
2335 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2336 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2340 run_test 46f "pdirops: link and rename (src) =============="
2343 touch $DIR1/$tfile-2
2344 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2345 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2346 link $DIR1/$tfile-2 $DIR1/$tfile &
2349 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2350 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2354 run_test 46g "pdirops: link vs getattr =============="
2357 touch $DIR1/$tfile-2
2358 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2359 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2360 link $DIR1/$tfile-2 $DIR1/$tfile &
2363 ls -lia $DIR2/ > /dev/null
2364 check_pdo_conflict $PID1 && { wait $PID1;
2365 error "readdir isn't blocked"; }
2369 run_test 46h "pdirops: link vs readdir =============="
2372 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2373 touch $DIR1/$tfile-2
2374 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2375 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2376 link $DIR1/$tfile-2 $DIR1/$tfile &
2379 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2380 check_pdo_conflict $PID1 && { wait $PID1;
2381 error "remote mkdir isn't blocked"; }
2385 run_test 46i "pdirops: link vs remote mkdir"
2387 # test 47: remote mkdir and blocking operations
2389 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2390 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2391 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2392 $LFS mkdir -i 1 $DIR1/$tfile &
2395 mkdir $DIR2/$tfile && error "mkdir must fail"
2396 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2400 run_test 47a "pdirops: remote mkdir vs mkdir"
2403 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2404 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2405 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2406 $LFS mkdir -i 1 $DIR1/$tfile &
2409 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2410 check_pdo_conflict $PID1 && { wait $PID1;
2411 error "create isn't blocked"; }
2415 run_test 47b "pdirops: remote mkdir vs create"
2418 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2419 touch $DIR1/$tfile-2
2420 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2421 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2422 $LFS mkdir -i 1 $DIR1/$tfile &
2425 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2426 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2430 run_test 47c "pdirops: remote mkdir vs link"
2433 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2434 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2435 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2436 $LFS mkdir -i 1 $DIR1/$tfile &
2439 rmdir $DIR2/$tfile || error "unlink must succeed"
2440 check_pdo_conflict $PID1 && { wait $PID1;
2441 error "unlink isn't blocked"; }
2445 run_test 47d "pdirops: remote mkdir vs unlink"
2448 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2449 touch $DIR1/$tfile-2
2450 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2451 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2452 $LFS mkdir -i 1 $DIR1/$tfile &
2455 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2456 check_pdo_conflict $PID1 && { wait $PID1;
2457 error "rename isn't blocked"; }
2461 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2464 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2465 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2466 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2467 $LFS mkdir -i 1 $DIR1/$tfile &
2470 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2471 check_pdo_conflict $PID1 && { wait $PID1;
2472 error "rename isn't blocked"; }
2476 run_test 47f "pdirops: remote mkdir and rename (src)"
2479 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2480 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2481 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2482 $LFS mkdir -i 1 $DIR1/$tfile &
2485 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2486 check_pdo_conflict $PID1 && { wait $PID1;
2487 error "getattr isn't blocked"; }
2491 run_test 47g "pdirops: remote mkdir vs getattr"
2495 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2496 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2497 do_facet client "lctl set_param fail_loc=0x410"
2498 $TRUNCATE $DIR2/$tfile $trunc_size
2499 do_facet client "lctl set_param fail_loc=0x0"
2501 size=`stat -c %s $DIR2/$tfile`
2502 [ $size -eq $trunc_size ] || error "wrong size"
2504 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2508 local origfile=/etc/hosts
2510 filesize=$(stat -c %s $origfile)
2512 # create an empty file
2513 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2514 # cache layout lock on both mount point
2515 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2516 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2518 # open and sleep 2 seconds then read
2519 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2523 # create the layout of testing file
2524 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2525 error "dd $DIR1/$tfile failed"
2527 # MULTIOP proc should be able to read enough bytes and exit
2528 for ((i = 0; i < 6; i++)); do
2530 kill -0 $pid || break
2532 kill -0 $pid 2> /dev/null && error "multiop is still there"
2533 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2537 run_test 51a "layout lock: refresh layout should work"
2540 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2541 { skip "Need MDS version at least 2.3.59"; return 0; }
2543 local tmpfile=`mktemp`
2545 # create an empty file
2546 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2548 # delay glimpse so that layout has changed when glimpse finish
2549 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2550 $LCTL set_param fail_loc=0x1404
2551 stat -c %s $DIR2/$tfile |tee $tmpfile &
2555 # create layout of testing file
2556 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2557 error "dd $DIR1/$tfile failed"
2560 local fsize=$(cat $tmpfile)
2562 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2564 rm -f $DIR1/$tfile $tmpfile
2566 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2569 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2571 # set default layout to have 1 stripe
2573 $LFS setstripe -c 1 $DIR1/$tdir
2575 # create a file with empty layout
2576 $MCREATE $DIR1/$tdir/$tfile ||
2577 error "$MCREATE $DIR1/$tdir/$tfile failed"
2579 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2580 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2582 # change the layout of testing file
2583 echo "Setting layout to have $OSTCOUNT stripes ..."
2584 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2588 # write something to the file, it should be blocked on fetching layout
2589 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2590 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2593 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2594 # count to succeed with only 3/4 of the number of stripes (rounded up),
2595 # so creating striped files does not fail if an OST is offline or full
2596 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2597 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2601 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2604 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2605 cancel_lru_locks mdc
2607 # open should grant LAYOUT lock, mmap and read will install pages
2608 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2612 # rss before revoking
2613 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2614 echo "Before revoking layout lock: $br KB mapped"
2616 # cancel layout lock manually
2617 cancel_lru_locks mdc
2619 # rss after revoking
2620 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2623 wait $PID || error "wait PID $PID failed"
2625 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2627 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2631 echo "==> rename vs getattr vs setxattr should not deadlock"
2632 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2634 do_facet mds1 $LCTL set_param fail_loc=$1
2636 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2644 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2645 wait $PID1 || error "(3) mv failed"
2646 wait $PID2 || error "(4) stat failed"
2653 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2654 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2656 do_facet mds1 $LCTL set_param fail_loc=$1
2658 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2666 $MULTIOP $DIR2/d1/d2 Oc &
2670 stat $DIR/d1 || error "(2) stat failed"
2672 wait $PID1 || error "(3) mv failed"
2673 wait $PID2 || error "(4) stat failed"
2674 wait $PID3 && error "(5) multiop failed"
2680 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2681 save_lustre_params client "llite.*.xattr_cache" > $p
2682 lctl set_param llite.*.xattr_cache 1 ||
2683 { skip "xattr cache is not supported"; return 0; }
2685 #define OBD_FAIL_MDS_RENAME 0x153
2686 #define OBD_FAIL_MDS_RENAME2 0x154
2687 test_54_part1 0x80000153 || error 10
2688 test_54_part1 0x80000154 || error 11
2689 test_54_part2 0x80000153 || error 12
2690 test_54_part2 0x80000154 || error 13
2692 restore_lustre_params < $p
2695 run_test 54 "rename locking"
2698 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2700 #define OBD_FAIL_MDS_RENAME4 0x156
2701 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2703 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2708 wait $PID1 && error "(2) mv succeeded"
2712 run_test 55a "rename vs unlink target dir"
2716 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2718 #define OBD_FAIL_MDS_RENAME4 0x156
2719 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2721 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2726 wait $PID1 && error "(2) mv succeeded"
2730 run_test 55b "rename vs unlink source dir"
2734 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2736 #define OBD_FAIL_MDS_RENAME4 0x156
2737 do_facet mds1 $LCTL set_param fail_loc=0x156
2739 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2743 # while rename is sleeping, open and remove d3
2744 $MULTIOP $DIR2/d3 D_c &
2750 # while rename is sleeping 2nd time, close d3
2752 wait $PID2 || error "(3) multiop failed"
2754 wait $PID1 && error "(2) mv succeeded"
2758 run_test 55c "rename vs unlink orphan target dir"
2764 #define OBD_FAIL_MDS_RENAME3 0x155
2765 do_facet mds1 $LCTL set_param fail_loc=0x155
2766 mv $DIR/f1 $DIR/$tdir &
2770 # while rename is sleeping, create $tdir, but as a directory
2771 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2773 # link in reverse locking order
2774 ln $DIR2/f1 $DIR2/$tdir/
2776 wait $PID1 && error "(2) mv succeeded"
2779 run_test 55d "rename file vs link"
2782 local MDSVER=$(lustre_build_version $SINGLEMDS)
2783 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2784 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2787 test_mkdir $DIR1/$tdir
2788 file1=$DIR1/$tdir/file
2789 file2=$DIR2/$tdir/file
2791 echo orig > $file2 || error "Could not create $file2"
2792 version=$($LFS data_version $file1)
2795 echo append >> $file2 || error "Could not append to $file2"
2796 version2=$($LFS data_version $file1)
2797 [ "$version" != "$version2" ] ||
2798 error "append did not change data version: $version"
2801 echo overwrite > $file2 || error "Could not overwrite $file2"
2802 version3=$($LFS data_version $file1)
2803 [ "$version2" != "$version3" ] ||
2804 error "overwrite did not change data version: $version2"
2806 # Truncate before EOF
2807 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2808 version4=$($LFS data_version $file1)
2809 [ "$version3" != "$version4" ] ||
2810 error "truncate did not change data version: $version3"
2812 # Truncate after EOF
2813 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2814 version5=$($LFS data_version $file1)
2815 [ "$version4" != "$version5" ] ||
2816 error "truncate did not change data version: $version4"
2818 # Chmod do not change version
2819 chmod 400 $file2 || error "Could not chmod 400 $file2"
2820 version6=$($LFS data_version $file1)
2821 [ "$version5" == "$version6" ] ||
2822 error "chmod should not change data version: $version5 != $version6"
2824 # Chown do not change version
2825 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2826 version7=$($LFS data_version $file1)
2827 [ "$version5" == "$version7" ] ||
2828 error "chown should not change data version: $version5 != $version7"
2830 run_test 60 "Verify data_version behaviour"
2833 local test_dir=$tdir/test_dir
2835 mkdir -p $DIR1/$tdir
2836 if [ $MDSCOUNT -ge 2 ]; then
2838 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2839 error "Create remote directory failed"
2841 mkdir -p $DIR1/$test_dir
2843 cd $DIR2/$test_dir || error "cd directory failed"
2844 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2846 cd $DIR2/$tdir || error "exit directory"
2848 run_test 70a "cd directory && rm directory"
2850 test_70b() { # LU-2781
2852 mkdir -p $DIR1/$tdir
2854 touch $DIR1/$tdir/file
2855 for ((i = 0; i < 32; i++)); do
2856 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2858 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2860 touch $DIR1/$tdir/file
2861 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2862 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2863 rm -rf $DIR1/$tdir/test_dir ||
2864 error "cannot remove directory after rm_entry"
2865 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2867 run_test 70b "remove files after calling rm_entry"
2870 local server_version=$(lustre_version_code $SINGLEMDS)
2872 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2873 skip "Need MDS version at least 2.1.6" && return
2875 # Patch not applied to 2.2 and 2.3 branches
2876 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2877 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2878 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2881 checkfiemap --test ||
2882 { skip "checkfiemap not runnable: $?" && return; }
2883 # write data this way: hole - data - hole - data
2884 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2885 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2887 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2888 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2889 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2891 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2893 checkfiemap $DIR2/$tfile 81920 ||
2894 error "data is not flushed from client"
2895 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2898 # common case of "create file, copy file" on a single node
2899 # should not flush data from ost
2900 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2901 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2903 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2905 checkfiemap $DIR1/$tfile 81920 ||
2907 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2909 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2911 run_test 71a "correct file map just after write operation is finished"
2914 local server_version=$(lustre_version_code $SINGLEMDS)
2916 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2917 skip "Need MDS version at least 2.1.6" && return
2919 # Patch not applied to 2.2 and 2.3 branches
2920 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2921 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2922 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2924 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2926 checkfiemap --test ||
2927 { skip "error $?: checkfiemap failed" && return; }
2929 mkdir -p $DIR1/$tdir
2931 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2932 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2933 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2935 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2936 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2938 run_test 71b "check fiemap support for stripecount > 1"
2941 local p="$TMP/sanityN-$TESTNAME.parameters"
2944 save_lustre_params client "llite.*.xattr_cache" > $p
2945 lctl set_param llite.*.xattr_cache 1 ||
2946 { skip "xattr cache is not supported"; return 0; }
2949 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2950 error "setfattr1 failed"
2951 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2952 error "getfattr1 failed"
2953 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2954 error "setfattr2 failed"
2955 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2956 error "getfattr2 failed"
2958 # check that trusted.link is consistent
2959 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2960 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2961 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2962 echo "$tlink1 $tlink2"
2963 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2967 restore_lustre_params < $p
2970 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2973 local p="$TMP/sanityN-$TESTNAME.parameters"
2974 save_lustre_params client "llite.*.xattr_cache" > $p
2975 lctl set_param llite.*.xattr_cache 1 ||
2976 { skip "xattr cache is not supported"; return 0; }
2979 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2980 error "setfattr1 failed"
2981 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2982 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2983 clear_stats llite.*.stats
2984 # PR lock should be cached by now on both clients
2985 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2986 # 2 hits for getfattr(0)+getfattr(size)
2987 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2988 error "not cached in $DIR1"
2989 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2990 # 4 hits for more getfattr(0)+getfattr(size)
2991 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2992 error "not cached in $DIR2"
2995 restore_lustre_params < $p
2998 run_test 73 "getxattr should not cause xattr lock cancellation"
3001 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3002 skip "Need MDS version at least 2.4.93" && return
3004 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3005 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3006 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3008 run_test 74 "flock deadlock: different mounts =============="
3012 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3013 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3014 cancel_lru_locks osc
3016 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3019 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3020 $LCTL set_param fail_loc=0x31d
3021 stat -c %s $DIR1/$tfile &
3026 # For bad lock error handler we should ASSERT and got kernel panic here
3028 $LCTL set_param fail_loc=0
3030 run_test 75 "osc: upcall after unuse lock==================="
3033 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3034 skip "Need MDS version at least 2.5.53" && return
3036 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3037 local fcount=$((MDSCOUNT * 256))
3042 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3048 test_mkdir $DIR/$tdir
3050 # drop all open locks and close any cached "open" files on the client
3051 cancel_lru_locks mdc
3053 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3054 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3055 local already=${#fid_list[@]}
3056 for (( i = 0; i < $already; i++ )) ; do
3057 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3060 echo -n "opening files: "
3061 ulimit -n $((fcount + 50))
3062 for ((i = 0; i < $fcount; i++)); do
3063 touch $DIR/$tdir/f_$i
3064 local fd=$(free_fd ${fd_list[i]})
3065 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3070 (( $i % 32 == 0 )) && echo -n "."
3074 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3076 # Possible errors in openfiles FID list.
3077 # 1. Missing FIDs. Check 1
3078 # 2. Extra FIDs. Check 1
3079 # 3. Duplicated FID. Check 2
3080 # 4. Invalid FIDs. Check 2
3081 # 5. Valid FID, points to some other file. Check 3
3084 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3085 error "${#fid_list[@]} != $fcount (+$already old) open files"
3087 echo -n "closing files: "
3088 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3089 local close_cmd="exec ${fd_list[fd]}<&-"
3091 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3093 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3094 echo "skip old open file $filename"
3096 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3100 rm --interactive=no $filename
3102 error "Nonexisting fid ${fid_list[fid]} listed."
3103 (( $fd % 32 == 0 )) && echo -n "."
3108 ls_op=$(ls $DIR2/$tdir | wc -l)
3110 error "Some openfiles are missing in lproc output"
3114 run_test 76 "Verify MDT open_files listing"
3118 local dir=$DIR/$tdir
3121 mkdir $dir || error "mkdir $dir failed"
3122 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3125 do_nodes $CLIENTS $myRUNAS \
3126 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3127 error "dd at 0 on client failed (1)"
3129 for ((i = 0; i < $n; i++)); do
3130 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3131 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3132 error "dd at ${i}MB on client failed (2)" &
3135 do_nodes $CLIENTS sync;
3136 cancel_lru_locks osc
3138 for ((i = 0; i < $n; i++)); do
3139 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3140 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3141 error "dd at ${i}MB on client failed (3)" &
3144 cancel_lru_locks osc
3146 for ((i = 0; i < $n; i++)); do
3150 rm -rf $dir || error "rm -rf $dir failed"
3153 test_77a() { #LU-3266
3156 oss=$(comma_list $(osts_nodes))
3157 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3159 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3160 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3165 run_test 77a "check FIFO NRS policy"
3167 test_77b() { #LU-3266
3170 oss=$(comma_list $(osts_nodes))
3172 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3173 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3174 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3175 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3177 echo "policy: crr-n, crrn_quantum 1"
3180 do_nodes $oss lctl set_param \
3181 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3182 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3184 echo "policy: crr-n, crrn_quantum 64"
3188 do_nodes $oss lctl set_param \
3189 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3190 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3193 run_test 77b "check CRR-N NRS policy"
3198 oss=$(comma_list $(osts_nodes))
3200 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3201 ost.OSS.*.nrs_"$policy"_quantum=1 \
3202 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3203 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3205 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3206 "physical, ${policy}_supported reads"
3209 do_nodes $oss lctl set_param \
3210 ost.OSS.*.nrs_${policy}_supported="writes" \
3211 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3213 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3214 "physical, ${policy}_supported writes"
3217 do_nodes $oss lctl set_param \
3218 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3219 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3220 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3221 "logical, ${policy}_supported reads_and_writes"
3225 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3230 test_77c() { #LU-3266
3232 orr_trr "orr" || rc=$?
3233 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3234 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3237 run_test 77c "check ORR NRS policy"
3239 test_77d() { #LU-3266
3241 orr_trr "trr" || rc=$?
3242 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3243 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3246 run_test 77d "check TRR nrs policy"
3253 do_facet $facet lctl set_param \
3254 ost.OSS.ost_io.nrs_tbf_rule="$*"
3256 error "failed to run operate '$*' on TBF rules"
3259 cleanup_tbf_verify()
3263 echo "cleanup_tbf $DIR/$tdir"
3266 wait_delete_completed
3271 local dir=$DIR/$tdir
3272 local client1=${CLIENT1:-$(hostname)}
3275 local np=$(check_cpt_number ost1)
3276 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3277 echo "cpu_npartitions on ost1 is $np"
3279 mkdir $dir || error "mkdir $dir failed"
3280 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3283 trap cleanup_tbf_verify EXIT
3284 echo "Limited write rate: $1, read rate: $2"
3285 echo "Verify the write rate is under TBF control"
3286 local start=$SECONDS
3287 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3288 bs=1M count=100 oflag=direct 2>&1
3289 local runtime=$((SECONDS - start + 1))
3290 local rate=$(bc <<< "scale=6; 100 / $runtime")
3291 echo "Write runtime is $runtime s, speed is $rate IOPS"
3293 # verify the write rate does not exceed TBF rate limit
3294 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3295 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3297 cancel_lru_locks osc
3299 echo "Verify the read rate is under TBF control"
3301 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3302 bs=1M count=100 iflag=direct 2>&1
3303 runtime=$((SECONDS - start + 1))
3304 rate=$(bc <<< "scale=6; 100 / $runtime")
3305 echo "Read runtime is $runtime s, speed is $rate IOPS"
3307 # verify the read rate does not exceed TBF rate limit
3308 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3309 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3311 cancel_lru_locks osc
3312 cleanup_tbf_verify || error "rm -rf $dir failed"
3318 oss=$(comma_list $(osts_nodes))
3320 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3322 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3323 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3327 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3332 # Only operate rules on ost1 since OSTs might run on the same OSS
3334 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3335 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3336 local client_nids=$(nids_list $address "\\")
3337 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3338 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3342 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3343 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3344 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3348 tbf_rule_operate ost1 "stop\ localhost"
3349 tbf_rule_operate ost1 "stop\ clients"
3350 tbf_rule_operate ost1 "stop\ others"
3353 # Cleanup the TBF policy
3354 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3355 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3359 run_test 77e "check TBF NID nrs policy"
3364 oss=$(comma_list $(osts_nodes))
3366 do_nodes $oss $LCTL set_param \
3367 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3368 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3369 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3371 # Configure jobid_var
3372 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3374 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3375 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3376 if [ $saved_jobid_var != procname_uid ]; then
3377 set_persistent_param_and_check client \
3378 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3383 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3388 # Only operate rules on ost1 since OSTs might run on the same OSS
3390 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3391 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3392 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3393 nrs_write_read "$RUNAS"
3396 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3397 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3398 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3399 nrs_write_read "$RUNAS"
3402 tbf_rule_operate ost1 "stop\ runas"
3403 tbf_rule_operate ost1 "stop\ iozone_runas"
3404 tbf_rule_operate ost1 "stop\ dd_runas"
3405 nrs_write_read "$RUNAS"
3407 # Cleanup the TBF policy
3408 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3409 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3410 nrs_write_read "$RUNAS"
3412 local current_jobid_var=$($LCTL get_param -n jobid_var)
3413 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3414 if [ $saved_jobid_var != $current_jobid_var ]; then
3415 set_persistent_param_and_check client \
3416 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3420 run_test 77f "check TBF JobID nrs policy"
3425 oss=$(comma_list $(osts_nodes))
3427 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3429 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3430 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3432 do_nodes $oss lctl set_param \
3433 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3434 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3438 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3443 # Add a rule that only valid for Jobid TBF. If direct change between
3444 # TBF types is not supported, this operation will fail.
3445 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3447 # Cleanup the TBF policy
3448 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3449 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3452 run_test 77g "Change TBF type directly"
3455 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3456 { skip "Need OST version at least 2.8.55"; return 0; }
3458 local old_policy=$(do_facet ost1 \
3459 lctl get_param ost.OSS.ost_io.nrs_policies)
3462 do_facet ost1 lctl set_param \
3463 ost.OSS.ost_io.nrs_policies="abc"
3464 [ $? -eq 0 ] && error "should return error"
3466 do_facet ost1 lctl set_param \
3467 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3468 [ $? -eq 0 ] && error "should return error"
3470 do_facet ost1 lctl set_param \
3471 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3472 [ $? -eq 0 ] && error "should return error"
3474 do_facet ost1 lctl set_param \
3475 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3476 [ $? -eq 0 ] && error "should return error"
3478 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3479 [ $? -eq 0 ] || error "shouldn't LBUG"
3481 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3485 run_test 77h "Wrong policy name should report error, not LBUG"
3491 local error_message=$3
3493 for rule in $expected; do
3494 rule_number=$((rule_number + 1))
3496 local stop_line=$(($rule_number + 3))
3497 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3499 local output=$(do_facet $facet lctl get_param \
3500 ost.OSS.ost_io.nrs_tbf_rule |
3504 if [ "$output" != "$expected" ]; then
3505 error "$error_message, expected '$expected', got '$output'"
3510 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3511 { skip "Need OST version at least 2.8.55"; return 0; }
3513 for i in $(seq 1 $OSTCOUNT)
3515 do_facet ost"$i" lctl set_param \
3516 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3518 error "failed to set TBF policy"
3521 tbf_rule_check ost1 "default" "error before inserting any rule"
3523 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3524 tbf_rule_check ost1 "before default" \
3525 "error when inserting rule 'before'"
3527 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3528 tbf_rule_check ost1 "before after default" \
3529 "error when inserting rule 'after'"
3531 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3532 tbf_rule_check ost1 "before target after default" \
3533 "error when inserting rule 'target'"
3535 echo "Move before itself"
3536 tbf_rule_operate ost1 "change\ target\ rank=target"
3537 tbf_rule_check ost1 "before target after default" \
3538 "error when moving before itself"
3540 echo "Move to higher rank"
3541 tbf_rule_operate ost1 "change\ target\ rank=before"
3542 tbf_rule_check ost1 "target before after default" \
3543 "error when moving to higher rank"
3545 echo "Move to lower rank"
3546 tbf_rule_operate ost1 "change\ target\ rank=after"
3547 tbf_rule_check ost1 "before target after default" \
3548 "error when moving to lower rank"
3550 echo "Move before default"
3551 tbf_rule_operate ost1 "change\ target\ rank=default"
3552 tbf_rule_check ost1 "before after target default" \
3553 error "error when moving before default"
3555 # Cleanup the TBF policy
3556 do_nodes $(comma_list $(osts_nodes)) \
3557 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3560 run_test 77i "Change rank of TBF rule"
3565 local ost_version=$(lustre_version_code ost1)
3567 [ $ost_version -ge $(version_code 2.9.53) ] ||
3568 { skip "Need OST version at least 2.9.53"; return 0; }
3569 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3574 do_nodes $(comma_list $(osts_nodes)) \
3575 lctl set_param jobid_var=procname_uid \
3576 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3577 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3578 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3579 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3584 do_nodes $(comma_list $(osts_nodes)) \
3585 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3586 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3587 ost.OSS.ost_io.nrs_policies="fifo"
3589 # sleep 3 seconds to wait the tbf policy stop completely,
3590 # or the next test case is possible get -EAGAIN when
3591 # setting the tbf policy
3594 run_test 77j "check TBF-OPCode NRS policy"
3597 local idstr="${1}id"
3598 local policy="${idstr}={$2}"
3599 local rate="rate=$3"
3601 do_nodes $(comma_list $(osts_nodes)) \
3602 lctl set_param jobid_var=procname_uid \
3603 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3604 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3605 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3607 nrs_write_read "runas $4"
3608 tbf_verify $3 $3 "runas $4"
3610 do_nodes $(comma_list $(osts_nodes)) \
3611 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3612 ost.OSS.ost_io.nrs_policies="fifo"
3614 # sleep 3 seconds to wait the tbf policy stop completely,
3615 # or the next test case is possible get -eagain when
3616 # setting the tbf policy
3621 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3622 skip "Need OST version at least 2.11.50"
3625 test_id "u" "500" "5" "-u 500"
3626 test_id "g" "500" "5" "-u 500 -g 500"
3628 run_test 77ja "check TBF-UID/GID NRS policy"
3636 for rule in $rule_lists; do
3637 do_nodes $(comma_list $(osts_nodes)) \
3638 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3641 do_nodes $(comma_list $(osts_nodes)) \
3642 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3648 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3649 { skip "Need OST version at least 2.9.53"; return 0; }
3651 do_nodes $(comma_list $(osts_nodes)) \
3652 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3653 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3654 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3656 nrs_write_read "$RUNAS"
3657 tbf_verify 20 10 "$RUNAS"
3659 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3660 local client_nids=$(nids_list $address "\\")
3661 do_nodes $(comma_list $(osts_nodes)) \
3662 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3663 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3664 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3665 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3670 do_nodes $(comma_list $(osts_nodes)) \
3671 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3672 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3673 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3675 nrs_write_read "$RUNAS"
3676 tbf_verify 20 20 "$RUNAS"
3678 do_nodes $(comma_list $(osts_nodes)) \
3679 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3680 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3681 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3683 nrs_write_read "$RUNAS"
3684 # with parameter "RUNAS", it will match the latest rule
3685 # "ext_b" first, so the limited write rate is 10.
3686 tbf_verify 10 10 "$RUNAS"
3689 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3691 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3692 { skip "Need OST version at least 2.10.58"; return 0; }
3694 do_nodes $(comma_list $(osts_nodes)) \
3695 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3696 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3697 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3698 nrs_write_read "runas -u 500 -g 1000"
3699 tbf_verify 5 5 "runas -u 500 -g 1000"
3701 do_nodes $(comma_list $(osts_nodes)) \
3702 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3703 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3704 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3706 nrs_write_read "runas -u 500"
3707 tbf_verify 20 10 "runas -u 500"
3709 do_nodes $(comma_list $(osts_nodes)) \
3710 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3711 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3712 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3713 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3714 nrs_write_read "runas -u 500"
3715 tbf_verify 10 10 "runas -u 500"
3716 tbf_verify 20 10 "runas -u 500"
3717 cleanup_77k "ext_a ext_b" "fifo"
3719 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3722 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3723 { skip "Need OST version at least 2.10.56"; return 0; }
3725 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3726 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3728 local output=$(do_facet ost1 lctl get_param \
3729 ost.OSS.ost_io.nrs_policies | \
3730 awk '/name: tbf/ {print;exit}' | \
3731 awk -F ': ' '{print $2}')
3733 if [ "$output" != "tbf" ]; then
3734 error "The generic TBF output is '$output', not 'tbf'"
3737 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3739 run_test 77l "check the output of NRS policies for generic TBF"
3742 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3743 skip "Need OST version at least 2.9.54"
3747 local dir=$DIR/$tdir
3749 mkdir $dir || error "mkdir $dir failed"
3750 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3753 local nodes=$(comma_list $(osts_nodes))
3754 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3755 ost.OSS.ost_io.nrs_delay_min=4 \
3756 ost.OSS.ost_io.nrs_delay_max=4 \
3757 ost.OSS.ost_io.nrs_delay_pct=100
3758 [ $? -ne 0 ] && error "Failed to set delay policy"
3760 local start=$SECONDS
3761 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3762 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3763 oflag=direct conv=fdatasync ||
3764 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3765 error "dd on client failed (1)"; }
3766 local elapsed=$((SECONDS - start))
3768 # NRS delay doesn't do sub-second timing, so a request enqueued at
3769 # 0.9 seconds can be dequeued at 4.0
3770 [ $elapsed -lt 3 ] &&
3771 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3772 error "Single 1M write should take at least 3 seconds"; }
3775 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3776 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3777 oflag=direct conv=fdatasync ||
3778 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3779 error "dd on client failed (2)"; }
3780 elapsed=$((SECONDS - start))
3782 [ $elapsed -lt 30 ] &&
3783 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3784 error "Ten 1M writes should take at least 30 seconds"; }
3786 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3787 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3791 run_test 77m "check NRS Delay slows write RPC processing"
3793 test_77n() { #LU-10802
3794 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3795 skip "Need OST version at least 2.10.58"
3799 # Configure jobid_var
3800 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3801 if [ $saved_jobid_var != procname_uid ]; then
3802 set_persistent_param_and_check client \
3803 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3806 do_nodes $(comma_list $(osts_nodes)) \
3807 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
3808 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3809 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
3812 tbf_verify 20 20 "$RUNAS"
3814 do_nodes $(comma_list $(osts_nodes)) \
3815 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3816 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
3821 do_nodes $(comma_list $(osts_nodes)) \
3822 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
3823 ost.OSS.ost_io.nrs_policies="fifo"
3827 local current_jobid_var=$($LCTL get_param -n jobid_var)
3828 if [ $saved_jobid_var != $current_jobid_var ]; then
3829 set_persistent_param_and_check client \
3830 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3833 run_test 77n "check wildcard support for TBF JobID NRS policy"
3835 test_78() { #LU-6673
3838 oss=$(comma_list $(osts_nodes))
3839 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3840 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3842 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3843 # Valid return codes are:
3844 # 0: Tuning succeeded
3845 # ENODEV: Policy is still stopped
3846 # EAGAIN: Policy is being initialized
3847 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3848 error "Expected set_param to return 0|ENODEV|EAGAIN"
3850 # Cleanup the ORR policy
3851 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3852 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3855 run_test 78 "Enable policy and specify tunings right away"
3858 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3859 test_mkdir $DIR/$tdir
3861 # Prevent interference from layout intent RPCs due to
3862 # asynchronous writeback. These will be tested in 130c below.
3863 do_nodes ${CLIENTS:-$HOSTNAME} sync
3865 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3866 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3868 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3869 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
3870 local facet=mds$((mdtidx + 1))
3872 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3873 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3877 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3878 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3883 run_test 79 "xattr: intent error"
3886 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3893 mkdir -p $DIR1/$tdir/dir
3894 createmany -o $DIR1/$tdir/dir/f 10 ||
3895 error "create files under remote dir failed $i"
3897 cp /etc/passwd $DIR1/$tdir/$tfile
3899 #migrate open file should fails
3900 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3902 # give multiop a chance to open
3905 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3906 error "migrate open files should failed with open files"
3910 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3911 error "migrate remote dir error"
3913 echo "Finish migration, then checking.."
3914 for file in $(find $DIR1/$tdir); do
3915 mdt_index=$($LFS getstripe -m $file)
3916 [ $mdt_index == $MDTIDX ] ||
3917 error "$file is not on MDT${MDTIDX}"
3920 diff /etc/passwd $DIR1/$tdir/$tfile ||
3921 error "file different after migration"
3923 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3925 run_test 80a "migrate directory when some children is being opened"
3929 kill -9 $migrate_pid
3933 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3934 local migrate_dir1=$DIR1/$tdir/migrate_dir
3935 local migrate_dir2=$DIR2/$tdir/migrate_dir
3936 local migrate_run=$LUSTRE/tests/migrate.sh
3944 trap cleanup_80b EXIT
3945 #prepare migrate directory
3946 mkdir -p $migrate_dir1
3947 for F in {1,2,3,4,5}; do
3948 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3949 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3952 #migrate the directories among MDTs
3955 mdt_idx=$((RANDOM % MDSCOUNT))
3956 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3958 [ $rc -ne 0 -o $rc -ne 16 ] || break
3963 echo "start migration thread $migrate_pid"
3964 #Access the files at the same time
3965 start_time=$(date +%s)
3966 echo "accessing the migrating directory for 5 minutes..."
3968 ls $migrate_dir2 > /dev/null || {
3969 echo "read dir fails"
3972 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3973 echo "access file1 fails"
3977 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3978 echo "access file2/3 fails"
3982 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3983 echo "access file4 fails"
3987 stat $migrate_dir2/file5 > /dev/null || {
3988 echo "stat file5 fails"
3992 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3993 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3994 echo "touch file failed with $rc1"
3998 if [ -e $migrate_dir2/source_file ]; then
3999 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4000 &>/dev/null || rc1=$?
4001 if [ -e $migrate_dir2/link_file ]; then
4002 rm -rf $migrate_dir2/link_file
4005 mrename $migrate_dir2/source_file \
4006 $migrate_dir2/target_file &>/dev/null || rc1=$?
4007 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4008 echo "rename failed with $rc1"
4012 if [ -e $migrate_dir2/target_file ]; then
4013 rm -rf $migrate_dir2/target_file &>/dev/null ||
4016 rm -rf $migrate_dir2/source_file &>/dev/null ||
4019 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4020 echo "unlink failed with $rc1"
4025 end_time=$(date +%s)
4026 duration=$((end_time - start_time))
4027 if [ $((duration % 10)) -eq 0 ]; then
4028 if [ $show_time -eq 1 ]; then
4029 echo "...$duration seconds"
4036 kill -0 $migrate_pid || {
4037 echo "migration stopped 1"
4041 [ $duration -ge 300 ] && break
4044 #check migration are still there
4045 kill -0 $migrate_pid || error "migration stopped 2"
4048 run_test 80b "Accessing directory during migration"
4051 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4055 mkdir -p $DIR1/$tdir
4057 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4058 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4061 touch d0/0 || error "create 0 failed"
4062 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4063 stat d0/0 && error "stat mv filed succeed"
4064 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4065 stat d0/0 || error "stat failed"
4067 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4069 if [ $t -ne 3 ]; then
4070 ls -ai $DIR1/$tdir/d0
4071 error "expect 3 get $t"
4076 run_test 81a "rename and stat under striped directory"
4079 [ $MDSCOUNT -lt 2 ] &&
4080 skip "We need at least 2 MDTs for this test"
4087 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4088 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4097 for i in $(seq $total); do
4098 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4102 kill -9 $setattr_pid
4104 run_test 81b "rename under striped directory doesn't deadlock"
4107 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4108 { skip "Need MDS version at least 2.6.92"; return 0; }
4110 # Client 1 creates a file.
4111 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4113 # Client 2 opens the file.
4114 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4116 # Client 1 makes the file an orphan.
4117 rm $DIR1/$tfile || error "rm"
4118 # Client 2 sets EA "user.multiop".
4120 wait $pid2 || error "multiop 2"
4121 # Client 1 gets EA "user.multiop". This used to fail because the EA
4122 # cache refill would get "trusted.link" from mdd_xattr_list() but
4123 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4126 wait $pid1 || error "multiop 1"
4128 run_test 82 "fsetxattr and fgetxattr on orphan files"
4131 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4138 $LFS mkdir -i1 -c2 $tdir
4143 echo "start pid $pid1 to create/unlink striped directory"
4145 # Access the directory at the same time
4149 stat $tdir > /dev/null 2>&1
4153 echo "start pid $pid2 to stat striped directory"
4161 run_test 83 "access striped directory while it is being created/unlinked"
4164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4169 [ "$SLOW" = "yes" ] && duration=600
4170 # Open/Create under striped directory
4174 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4175 touch $tdir/f{0..3} > /dev/null 2>&1
4179 echo "start pid $pid1 to open/create under striped directory"
4181 # unlink the striped directory at the same time
4185 rm -rf $tdir > /dev/null 2>&1
4189 echo "start pid $pid2 to unlink striped directory"
4198 run_test 90 "open/create and unlink striped directory"
4201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4206 [ "$SLOW" = "yes" ] && duration=600
4207 # chmod striped directory
4211 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4212 chmod go+w $tdir > /dev/null 2>&1
4216 echo "start pid $pid1 to chmod striped directory"
4218 # unlink the striped directory at the same time
4222 rm -rf $tdir > /dev/null 2>&1
4226 echo "start pid $pid2 to unlink striped directory"
4235 run_test 91 "chmod and unlink striped directory"
4238 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4241 local cmd="exec $fd<$DIR1/$tdir"
4242 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4245 trap "eval $cmd" EXIT
4246 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4247 rmdir ../$tdir || error "rmdir ../$tdir fails"
4249 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4250 $LCTL set_param fail_loc=0x1408
4251 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4252 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4253 error "create remote dir succeeds"
4254 $LCTL set_param fail_loc=0
4258 run_test 92 "create remote directory under orphan directory"
4265 mkdir -p $DIR1/$tfile-1/
4266 mkdir -p $DIR2/$tfile-2/
4267 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4268 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4269 do_facet $SINGLEMDS lctl set_param -n \
4270 'lod.lustre-MDT*/qos_threshold_rr' 100
4271 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4272 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4274 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4277 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4281 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4282 do_facet $SINGLEMDS "lctl set_param -n \
4283 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4285 $GETSTRIPE $DIR1/$tfile-1/file1
4286 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4287 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4288 $GETSTRIPE $DIR2/$tfile-2/file2
4289 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4290 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4291 echo "rc1=$rc1 and rc2=$rc2 "
4292 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4293 error "object allocate on same ost detected"
4295 run_test 93 "alloc_rr should not allocate on same ost"
4299 skip "Reserved for glimpse-ahead" && return
4300 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4301 skip "Need MDS version at least 2.10.55" && return
4305 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4307 lctl set_param -n mdc.*.stats=clear
4308 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4310 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4311 # first stat from server should return size data and save glimpse
4312 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4313 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4314 # second stat to check size is NOT cached on client without IO lock
4315 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4317 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4318 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4321 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4324 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4325 skip "Need MDS version at least 2.10.55" && return
4329 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4331 lctl set_param -n mdc.*.stats=clear
4332 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4333 cancel_lru_locks mdc
4334 # first stat data from server should have size
4335 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4336 # second stat to check size is cached on client
4337 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4339 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4340 # both stats should cause no glimpse requests
4341 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4344 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4347 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4348 skip "Need MDS version at least 2.10.55" && return
4352 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4354 lctl set_param -n mdc.*.stats=clear
4355 lctl set_param -n osc.*.stats=clear
4356 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4358 # check that size is merged from MDT and OST correctly
4359 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4360 error "Wrong size from stat #1"
4362 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4363 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4367 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4370 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4371 skip "Need MDS version at least 2.10.55" && return
4375 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4378 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4379 lctl set_param -n mdc.*.stats=clear
4380 $TRUNCATE $DIR2/$tdir/dom 4096
4382 # check that reported size is valid after file grows to OST and
4383 # is truncated back to MDT stripe size
4384 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4385 error "Wrong size from stat #1"
4387 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4388 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4392 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4395 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4396 skip "Need MDS version at least 2.10.55" && return
4398 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4400 $CHECKSTAT -t file $DIR1/$tfile
4402 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4403 sysctl -wq vm.dirty_writeback_centisecs=0
4405 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4408 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4409 error_noexit "Write fails"
4410 # must discard pages
4411 lctl set_param -n mdc.*.stats=clear
4412 rm $DIR2/$tfile || error "Unlink fails"
4414 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4415 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4417 run_test 101a "Discard DoM data on unlink"
4420 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4421 skip "Need MDS version at least 2.10.55" && return
4423 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4424 touch $DIR1/${tfile}_2
4426 $CHECKSTAT -t file $DIR1/$tfile
4428 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4429 sysctl -wq vm.dirty_writeback_centisecs=0
4431 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4434 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4435 # must discard pages
4436 lctl set_param -n mdc.*.stats=clear
4437 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4439 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4440 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4442 run_test 101b "Discard DoM data on rename"
4445 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4446 skip "Need MDS version at least 2.10.55" && return
4448 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4450 $CHECKSTAT -t file $DIR1/$tfile
4452 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4453 sysctl -wq vm.dirty_writeback_centisecs=0
4455 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4458 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4459 $MULTIOP $DIR1/$tfile O_c &
4462 lctl set_param -n mdc.*.stats=clear
4463 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4464 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4466 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4467 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4469 run_test 101c "Discard DoM data on close-unlink"
4471 # test to verify file handle related system calls
4472 # (name_to_handle_at/open_by_handle_at)
4473 # The new system calls are supported in glibc >= 2.14.
4475 # test to verify we can open by handle an unlinked file from > 1 client
4476 # This test opens the file normally on $DIR1, which is on one mount, and then
4477 # opens it by handle on $DIR2, which is on a different mount.
4479 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
4480 skip "Needs MDS version 2.11.57 or later"
4482 echo "Test file_handle syscalls" > $DIR/$tfile ||
4483 error "write failed"
4484 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4485 error "check_fhandle_syscalls failed"
4488 run_test 102 "Test open by handle of unlinked file"
4490 log "cleanup: ======================================================"
4492 # kill and wait in each test only guarentee script finish, but command in script
4493 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4494 # otherwise umount below will fail
4495 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4500 check_and_cleanup_lustre