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
322 run_test 14aa "execution of file open for write returns -ETXTBSY"
325 test_mkdir $DIR1/$tdir
326 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
327 $DIR1/$tdir/sleep 60 &
329 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
332 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
334 test_14b() { # bug 3192, 7040
335 test_mkdir $DIR1/$tdir
336 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
337 $DIR1/$tdir/sleep 60 &
339 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
340 error "expected truncate error, got success"
342 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
344 run_test 14b "truncate of executing file returns -ETXTBSY ======"
346 test_14c() { # bug 3430, 7040
347 test_mkdir $DIR1/$tdir
348 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
349 $DIR1/$tdir/sleep 60 &
351 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
353 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
355 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
357 test_14d() { # bug 10921
358 test_mkdir $DIR1/$tdir
359 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
360 $DIR1/$tdir/sleep 60 &
363 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
365 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
367 run_test 14d "chmod of executing file is still possible ========"
369 test_15() { # bug 974 - ENOSPC
371 sh oos2.sh $MOUNT1 $MOUNT2
372 wait_delete_completed
373 grant_error=`dmesg | grep "> available"`
374 [ -z "$grant_error" ] || error "$grant_error"
376 run_test 15 "test out-of-space with multiple writers ==========="
379 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
380 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
381 # pass a 2500 operation dual-mount run within the time limit.
382 if [ "$(facet_fstype ost1)" = "zfs" ]; then
383 FSXNUM=$((COUNT / 5))
385 elif [ "$SLOW" = "yes" ]; then
386 FSXNUM=$((COUNT * 5))
394 local file1=$DIR1/$tfile
395 local file2=$DIR2/$tfile
396 local stripe_size=$(do_facet $SINGLEMDS \
397 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
399 # to allocate grant because it may run out due to test_15.
400 $LFS setstripe -c -1 $file1
401 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
402 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
405 $LFS setstripe -c -1 $file1 # b=10919
406 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
407 || error "fsx failed"
410 # O_DIRECT reads and writes must be aligned to the device block size.
411 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
412 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
414 run_test 16a "$FSXNUM iterations of dual-mount fsx"
416 # Consistency check for tiny writes, LU-9409
418 local file1=$DIR1/$tfile
419 local file2=$DIR2/$tfile
420 local stripe_size=($($LFS getstripe -S $DIR))
422 # to allocate grant because it may run out due to test_15.
423 lfs setstripe -c -1 $file1
424 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
425 error "dd failed writing to file=$file1"
426 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
427 error "dd failed writing to file=$file2"
430 lfs setstripe -c -1 $file1 # b=10919
431 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
432 # create a mix of tiny writes & normal writes
433 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
434 $file2 || error "fsx with tiny write failed."
436 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
439 local file1=$DIR1/$tfile
440 local file2=$DIR2/$tfile
441 local stripe_size=$(do_facet $SINGLEMDS \
442 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
444 [ $(facet_fstype ost1) != ldiskfs ] && skip "dio on ldiskfs only"
446 # to allocate grant because it may run out due to test_15.
447 $LFS setstripe -c -1 $file1
448 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
449 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
451 wait_delete_completed
453 local list=$(comma_list $(osts_nodes))
454 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
455 skip "not cache-capable obdfilter"
458 set_osd_param $list '' read_cache_enable 0
459 set_osd_param $list '' writethrough_cache_enable 0
461 $LFS setstripe -c -1 $file1 # b=10919
462 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
463 || error "fsx failed"
466 set_osd_param $list '' read_cache_enable 1
467 set_osd_param $list '' writethrough_cache_enable 1
471 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
474 test_17() { # bug 3513, 3667
475 remote_ost_nodsh && skip "remote OST with nodsh" && return
477 lfs setstripe $DIR1/$tfile -i 0 -c 1
478 cp $SAMPLE_FILE $DIR1/$tfile
479 cancel_lru_locks osc > /dev/null
480 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
481 do_facet ost1 lctl set_param fail_loc=0x8000030a
482 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
483 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
485 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
487 run_test 17 "resource creation/LVB creation race ==============="
490 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
493 for idx in {a..z}; do
494 local ptr=EXCEPT_ALWAYS_18$idx
495 [ x${!ptr} = xtrue ] || continue
497 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
500 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
503 run_test 18 "mmap sanity check ================================="
505 test_19() { # bug3811
506 local node=$(facet_active_host ost1)
508 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
510 # check whether obdfilter is cache capable at all
511 get_osd_param $node '' read_cache_enable >/dev/null ||
512 skip "not cache-capable obdfilter"
514 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
515 set_osd_param $node '' readcache_max_filesize 4096
516 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
517 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
518 cp $TMP/$tfile $DIR1/$tfile
519 for i in `seq 1 20`; do
520 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
521 cancel_lru_locks $OSC > /dev/null
522 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
523 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
525 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
526 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
527 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
528 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
530 set_osd_param $node '' readcache_max_filesize $MAX
533 run_test 19 "test concurrent uncached read races ==============="
537 cancel_lru_locks $OSC
538 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
539 $MULTIOP $DIR1/f20 Ow8190c
540 $MULTIOP $DIR2/f20 Oz8194w8190c
541 $MULTIOP $DIR1/f20 Oz0r8190c
542 cancel_lru_locks $OSC
543 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
545 error $CNTD" page left in cache after lock cancel" || true
547 run_test 20 "test extra readahead page left in cache ===="
554 test_21() { # Bug 5907
555 test_mkdir $DIR1/$tdir
556 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
558 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
559 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
560 test -d $DIR1/$tdir || error "Mounted directory disappeared"
562 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
565 run_test 21 " Try to remove mountpoint on another dir ===="
567 test_23() { # Bug 5972
568 local at_diff=$(do_facet $SINGLEMDS \
569 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
570 echo "atime should be updated while another read" > $DIR1/$tfile
572 # clear the lock(mode: LCK_PW) gotten from creating operation
573 cancel_lru_locks $OSC
576 sleep $((at_diff + 1))
578 echo "starting reads"
579 multiop_bg_pause $DIR1/$tfile or20_c || return 1
580 # with SOM and opencache enabled, we need to close a file and cancel
581 # open lock to get atime propogated to MDS
582 kill -USR1 $! || return 2
585 time2=$(stat -c "%X" $DIR/$tfile)
586 echo "new atime is $time2"
588 [ $time2 -gt $time1 ] || error "atime was not updated"
589 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
592 run_test 23 " others should see updated atime while another read===="
596 lfs df || error "lfs df failed"
597 lfs df -ih || error "lfs df -ih failed"
598 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
599 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
600 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
601 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
603 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
604 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
605 lctl --device %osc deactivate
606 lfs df -i || error "lfs df -i with deactivated OSC failed"
607 lctl --device %osc activate
608 lfs df || error "lfs df with reactivated OSC failed"
610 run_test 24a "lfs df [-ih] [path] test ========================="
614 fsnum=$(lfs_df | grep -c "summary")
615 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
617 run_test 24b "lfs df should show both filesystems ==============="
620 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
622 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
625 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
626 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
628 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
629 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
630 error "setfacl $DIR2/$tdir #1"
631 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
632 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
633 error "setfacl $DIR2/$tdir #2"
634 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
635 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
636 error "setfacl $DIR2/$tdir #3"
637 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
638 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
639 error "setfacl $DIR2/$tdir #4"
640 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
644 run_test 25a "change ACL on one mountpoint be seen on another ==="
647 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
649 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
651 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
654 $LFS mkdir -i 1 $DIR1/$tdir
655 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
656 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
658 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
659 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
660 error "setfacl $DIR2/$tdir #1"
661 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
662 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
663 error "setfacl $DIR2/$tdir #2"
664 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
665 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
666 error "setfacl $DIR2/$tdir #3"
667 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
668 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
669 error "setfacl $DIR2/$tdir #4"
670 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
674 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
677 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
679 run_test 26a "allow mtime to get older"
684 echo "aaa" >> $DIR1/$tfile
686 chmod a+x $DIR2/$tfile
687 mt1=`stat -c %Y $DIR1/$tfile`
688 mt2=`stat -c %Y $DIR2/$tfile`
690 if [ x"$mt1" != x"$mt2" ]; then
691 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
694 run_test 26b "sync mtime between ost and mds"
697 cancel_lru_locks $OSC
699 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
704 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
709 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
711 lctl set_param -n ldlm.dump_namespaces ""
712 wait $DD1_PID $DD2_PID
713 [ $? -ne 0 ] && lctl dk $TMP/debug || true
715 run_test 27 "align non-overlapping extent locks from request ==="
717 test_28() { # bug 9977
718 ECHO_UUID="ECHO_osc1_UUID"
719 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
721 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
722 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
723 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
727 attach echo_client ECHO_osc1 $ECHO_UUID
731 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
732 $LCTL --device $tECHOID destroy "${tOBJID}:0"
740 # reading of 1st stripe should pass
741 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
742 # reading of 2nd stripe should fail (this stripe was destroyed)
743 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
745 # now, recreating test file
746 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
747 # reading of 1st stripe should pass
748 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
749 # reading of 2nd stripe should pass
750 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
753 run_test 28 "read/write/truncate file with lost stripes"
755 test_30() { #b=11110, LU-2523
756 test_mkdir $DIR1/$tdir
757 cp -f /bin/bash $DIR1/$tdir/bash
758 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
759 $DIR1/$tdir/bash -c 'sleep 2;
760 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
764 run_test 30 "recreate file race"
767 test_mkdir $DIR1/$tdir
768 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
769 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
770 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
771 lctl set_param fail_loc=0x314
772 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
773 awk 'BEGIN { FS="+" } /in/ {print $1}')
774 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
776 run_test 31a "voluntary cancel / blocking ast race=============="
779 remote_ost || { skip "local OST" && return 0; }
780 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
782 # make sure there is no local locks due to destroy
783 wait_mds_ost_sync || error "wait_mds_ost_sync()"
784 wait_delete_completed || error "wait_delete_completed()"
786 test_mkdir $DIR1/$tdir
787 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
788 cp /etc/hosts $DIR/$tdir/$tfile
789 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
790 lctl set_param fail_loc=0x314
791 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
792 do_facet ost1 lctl set_param fail_loc=0x316
794 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
795 lctl set_param fail_loc=0
796 do_facet ost1 lctl set_param fail_loc=0
797 # cleanup: reconnect the client back
800 run_test 31b "voluntary OST cancel / blocking ast race=============="
802 # enable/disable lockless truncate feature, depending on the arg 0/1
803 enable_lockless_truncate() {
804 lctl set_param -n $OSC.*.lockless_truncate $1
807 test_32a() { # bug 11270
808 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
809 local stripe_size=$(do_facet $SINGLEMDS \
810 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
812 save_lustre_params client "$OSC.*.lockless_truncate" > $save
813 # restore lockless_truncate default values on exit
814 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
815 cancel_lru_locks $OSC
816 enable_lockless_truncate 1
818 lfs setstripe -c -1 $DIR1/$tfile
819 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
821 clear_stats $OSC.*.${OSC}_stats
823 log "checking cached lockless truncate"
824 $TRUNCATE $DIR1/$tfile 8000000
825 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
826 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
827 error "cached truncate isn't lockless"
829 log "checking not cached lockless truncate"
830 $TRUNCATE $DIR2/$tfile 5000000
831 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
832 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
833 error "not cached truncate isn't lockless"
835 log "disabled lockless truncate"
836 enable_lockless_truncate 0
837 clear_stats $OSC.*.${OSC}_stats
838 $TRUNCATE $DIR2/$tfile 3000000
839 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
840 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
841 error "lockless truncate disabling failed"
844 run_test 32a "lockless truncate"
846 test_32b() { # bug 11270
847 remote_ost_nodsh && skip "remote OST with nodsh" && return
850 local facets=$(get_facets OST)
851 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
853 save_lustre_params client "osc.*.contention_seconds" > $p
854 save_lustre_params $facets \
855 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
856 save_lustre_params $facets \
857 "ldlm.namespaces.filter-*.contended_locks" >> $p
858 save_lustre_params $facets \
859 "ldlm.namespaces.filter-*.contention_seconds" >> $p
860 clear_stats $OSC.*.${OSC}_stats
862 # agressive lockless i/o settings
863 do_nodes $(comma_list $(osts_nodes)) \
864 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
865 ldlm.namespaces.filter-*.contended_locks=0 \
866 ldlm.namespaces.filter-*.contention_seconds=60"
867 lctl set_param -n $OSC.*.contention_seconds=60
869 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
871 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
874 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
875 error "lockless i/o was not triggered"
876 # disable lockless i/o (it is disabled by default)
877 do_nodes $(comma_list $(osts_nodes)) \
878 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
879 ldlm.namespaces.filter-*.contended_locks=32 \
880 ldlm.namespaces.filter-*.contention_seconds=0"
881 # set contention_seconds to 0 at client too, otherwise Lustre still
882 # remembers lock contention
883 lctl set_param -n $OSC.*.contention_seconds=0
884 clear_stats $OSC.*.${OSC}_stats
886 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
888 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
891 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
892 error "lockless i/o works when disabled"
894 restore_lustre_params <$p
897 run_test 32b "lockless i/o"
901 local mdts=$(get_facets MDS)
906 for mds in ${mdts//,/ }; do
908 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
909 xargs readlink -f" ))
910 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
913 stat=$(( stat + val))
918 # commit on sharing tests
920 remote_mds_nodsh && skip "remote MDS with nodsh" && return
922 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
923 [ $CLIENTCOUNT -lt 2 ] &&
924 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
926 local nfiles=${TEST33_NFILES:-10000}
927 local param_file=$TMP/$tfile-params
928 local fstype=$(facet_fstype $SINGLEMDS)
930 save_lustre_params $(get_facets MDS) \
931 "mdt.*.commit_on_sharing" > $param_file
939 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
943 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
945 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
946 echo "=== START createmany old: $jbdold transaction"
947 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")
948 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
949 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
950 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
951 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
952 avgtime=$(( avgtime + elapsed ))
954 eval cos${COS}_jbd=$((avgjbd / 3))
955 eval cos${COS}_time=$((avgtime / 3))
958 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
959 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
960 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
961 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
963 restore_lustre_params < $param_file
967 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
969 # commit on sharing tests
971 remote_mds_nodsh && skip "remote MDS with nodsh" && return
973 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
974 [ $CLIENTCOUNT -ge 2 ] ||
975 { skip "Need two or more clients, have $CLIENTCOUNT" &&
977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
979 local nfiles=${TEST33_NFILES:-10000}
980 local param_file=$TMP/$tfile-params
982 save_lustre_params $(get_facets MDS) \
983 "mdt.*.commit_on_sharing" > $param_file
992 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
996 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
997 $DIR1/$tdir-\\\$(hostname)-$i"
999 jbdold=$(print_jbd_stat)
1000 echo "=== START createmany old: $jbdold transaction"
1001 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1002 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1003 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1005 jbdnew=$(print_jbd_stat)
1006 jbd=$(( jbdnew - jbdold ))
1007 echo "=== END createmany new: $jbdnew transaction : \
1008 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1009 avgjbd=$(( avgjbd + jbd ))
1010 avgtime=$(( avgtime + elapsed ))
1012 eval cos${COS}_jbd=$((avgjbd / 3))
1013 eval cos${COS}_time=$((avgtime / 3))
1016 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1017 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1018 [ "$cos0_jbd" != 0 ] &&
1019 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1020 [ "$cos0_time" != 0 ] &&
1021 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1023 restore_lustre_params < $param_file
1027 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1030 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1031 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1032 skip "DNE CoS not supported" && return
1038 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1039 # do twice in case transaction is committed before unlock, see LU-8200
1041 # remote dir is created on MDT1, which enqueued lock of $tdir on
1043 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1044 mkdir $DIR/$tdir/local.$i
1046 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1047 echo "sync_count $sync_count"
1048 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1051 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1052 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1053 # during sleep remote mkdir should have been committed and canceled
1054 # remote lock spontaneously, which shouldn't trigger sync
1056 mkdir $DIR/$tdir/local.3
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 triggered"
1061 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1063 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1067 local nodes=$(comma_list $(mdts_nodes))
1071 # trigger CoS twice in case transaction commit before unlock
1074 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1076 commit_nr=$(do_nodes $nodes \
1077 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1078 total=$((total + commit_nr));
1083 echo "CoS count $total"
1084 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1088 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1089 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1090 skip "DNE CoS not supported" && return
1092 # remote directory create
1093 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1094 # remote directory unlink
1095 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1096 # striped directory create
1097 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1098 # striped directory setattr
1099 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1100 "chmod 713 $DIR/$tdir"
1101 # striped directory unlink
1102 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1105 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1106 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1107 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1108 touch $DIR/$tdir/d1/tgt" \
1109 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1111 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1112 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1113 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1114 touch $DIR/$tdir/d1/src" \
1115 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1117 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1118 "$LFS migrate -m 1 $DIR/$tdir"
1122 run_test 33d "DNE distributed operation should trigger COS"
1125 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1126 [ $CLIENTCOUNT -ge 2 ] ||
1127 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1129 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1130 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1131 skip "DNE CoS not supported" && return
1133 local client2=${CLIENT2:-$(hostname)}
1137 local nodes=$(comma_list $(mdts_nodes))
1138 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1140 $LFS mkdir -c 2 $DIR/$tdir
1141 mkdir $DIR/$tdir/subdir
1142 echo abc > $DIR/$tdir/$tfile
1143 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1144 do_node $client2 touch $DIR/$tdir/subdir
1146 local async_commit_count=$(do_nodes $nodes \
1147 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1148 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1152 run_test 33e "DNE local operation shouldn't trigger COS"
1154 # End commit on sharing tests
1156 get_ost_lock_timeouts() {
1157 local nodes=${1:-$(comma_list $(osts_nodes))}
1159 local locks=$(do_nodes $nodes \
1160 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1168 do_nodes $(comma_list $(osts_nodes)) \
1169 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1170 for i in $(seq $OSTCOUNT); do
1171 wait_osc_import_ready client ost$i
1176 remote_ost_nodsh && skip "remote OST with nodsh" && return
1180 trap cleanup_34 EXIT RETURN
1181 for OPER in notimeout timeout ; do
1182 rm $DIR1/$tfile 2>/dev/null
1183 lock_in=$(get_ost_lock_timeouts)
1184 if [ $OPER == "timeout" ] ; then
1185 for j in `seq $OSTCOUNT`; do
1186 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1187 do_facet ost$j lctl set_param fail_loc=0x511
1189 echo lock should expire
1191 for j in `seq $OSTCOUNT`; do
1192 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1193 do_facet ost$j lctl set_param fail_loc=0x512
1195 echo lock should not expire
1197 echo writing on client1
1198 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1200 echo reading on client2
1201 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1202 # wait for a lock timeout
1204 lock_out=$(get_ost_lock_timeouts)
1205 if [ $OPER == "timeout" ] ; then
1206 if [ $lock_in == $lock_out ]; then
1207 error "no lock timeout happened"
1212 if [ $lock_in != $lock_out ]; then
1213 error "lock timeout happened"
1221 run_test 34 "no lock timeout under IO"
1223 test_35() { # bug 17645
1226 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1227 awk '/generation/{print $2}')
1229 generation[count]=$g
1233 test_mkdir $MOUNT1/$tdir
1234 cancel_lru_locks mdc
1236 # Let's initiate -EINTR situation by setting fail_loc and take
1237 # write lock on same file from same client. This will not cause
1238 # bl_ast yet as lock is already in local cache.
1239 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1240 do_facet client "lctl set_param fail_loc=0x80000317"
1241 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1242 let timeout=timeout*3
1244 while test $nr -lt 10; do
1245 log "Race attempt $nr"
1246 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1247 awk '/ldlm_bl_callback/ { print $2 }')
1248 test "x$blk1" = "x" && blk1=0
1249 createmany -o $MOUNT2/$tdir/a 4000 &
1253 # Let's make conflict and bl_ast
1254 ls -la $MOUNT1/$tdir > /dev/null &
1257 log "Wait for $pid1 $pid2 for $timeout sec..."
1259 kill -9 $pid1 $pid2 > /dev/null 2>&1
1261 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1262 awk '/ldlm_bl_callback/ { print $2 }')
1263 test "x$blk2" = "x" && blk2=0
1264 test $blk2 -gt $blk1 && break
1265 rm -fr $MOUNT1/$tdir
1266 cancel_lru_locks mdc
1269 do_facet client "lctl set_param fail_loc=0x0"
1270 df -h $MOUNT1 $MOUNT2
1272 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1273 awk '/generation/{print $2}')
1275 if ! test "$g" -eq "${generation[count]}"; then
1276 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1278 for imp in $list; do
1279 if [ $c = $count ]; then
1284 imp=$(echo "$imp" | awk -F"." '{print $2}')
1285 error "Eviction happened on import $imp"
1290 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1292 test_36() { #bug 16417
1297 test_mkdir $DIR1/$tdir
1298 $LFS setstripe -c -1 $DIR1/$tdir
1301 let SIZE_B=SIZE*1024*1024
1302 sync; sleep 2; sync # wait for delete thread
1303 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1304 wait_destroy_complete || error "wait_destroy_complete failed"
1306 while [ $i -le 10 ]; do
1307 lctl mark "start test - cycle ($i)"
1308 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1309 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1310 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1311 sync # sync data from client cache
1312 sync_all_data # sync data from server cache (delayed allocation)
1314 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1315 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1317 rm -f $DIR1/$tdir/$tfile
1318 kill -USR1 $read_pid
1320 sync; sleep 2; sync # Ensure new statfs
1321 wait_delete_completed
1322 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1323 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1325 # this free space! not used
1326 (( $after_dd <= $after)) ||
1327 error "space leaked after_dd:$after_dd > after:$after"
1331 run_test 36 "handle ESTALE/open-unlink correctly"
1333 test_37() { # bug 18695
1334 test_mkdir $DIR1/$tdir
1335 multiop_bg_pause $DIR1/$tdir D_c || return 1
1337 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1338 createmany -m $DIR2/$tdir/f 10000
1339 # set mtime/atime backward
1340 touch -t 198001010000 $DIR2/$tdir
1341 kill -USR1 $MULTIPID
1342 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1343 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1346 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1348 # this should be set to past
1349 TEST_39_MTIME=`date -d "1 year ago" +%s`
1353 local client1=${CLIENT1:-`hostname`}
1354 local client2=${CLIENT2:-`hostname`}
1356 do_node $client1 "touch $DIR1/$tfile"
1358 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1359 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1360 [ "$mtime1" = $TEST_39_MTIME ] || \
1361 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1363 local d1=`do_node $client1 date +%s`
1364 do_node $client1 'echo hello >> '$DIR1/$tfile
1365 local d2=`do_node $client1 date +%s`
1367 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1368 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1369 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1371 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1373 for (( i=0; i < 2; i++ )) ; do
1374 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1375 [ "$mtime2" = "$mtime3" ] || \
1376 error "mtime ($mtime2) changed (to $mtime3) on rename"
1378 cancel_lru_locks osc
1379 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1382 run_test 39a "test from 11063 =================================="
1385 local client1=${CLIENT1:-`hostname`}
1386 local client2=${CLIENT2:-`hostname`}
1390 local mtime1=`stat -c %Y $DIR1/$tfile`
1391 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1394 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1396 for (( i=0; i < 2; i++ )) ; do
1397 local mtime3=`stat -c %Y $DIR1/$tfile`
1398 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1400 [ "$mtime3" = "$mtime4" ] || \
1401 error "different mtime on clients: $mtime3, $mtime4"
1402 [ "$mtime3" = $TEST_39_MTIME ] || \
1403 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1405 cancel_lru_locks osc
1406 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1409 run_test 39b "11063 problem 1 =================================="
1412 local client1=${CLIENT1:-`hostname`}
1413 local client2=${CLIENT2:-`hostname`}
1415 echo hello > $DIR1/$tfile
1417 local mtime1=`stat -c %Y $DIR1/$tfile`
1418 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1419 [ "$mtime1" = "$mtime2" ] || \
1420 error "create: different mtime on clients: $mtime1, $mtime2"
1423 $TRUNCATE $DIR1/$tfile 1
1425 for (( i=0; i < 2; i++ )) ; do
1426 local mtime3=`stat -c %Y $DIR1/$tfile`
1427 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1429 [ "$mtime3" = "$mtime4" ] || \
1430 error "different mtime on clients: $mtime3, $mtime4"
1431 [ "$mtime3" -gt $mtime2 ] || \
1432 error "truncate did not update mtime: $mtime2, $mtime3"
1434 cancel_lru_locks osc
1435 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1438 run_test 39c "check truncate mtime update ======================"
1440 test_39d() { # LU-7310
1442 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1444 local mtime1=$(stat -c %Y $DIR2/$tfile)
1445 [ "$mtime1" = $TEST_39_MTIME ] ||
1446 error "mtime: $mtime1, should be $TEST_39_MTIME"
1449 # define OBD_FAIL_OSC_NO_GRANT 0x411
1450 $LCTL set_param fail_loc=0x411
1452 local d1=$(date +%s)
1453 echo hello >> $DIR1/$tfile
1454 local d2=$(date +%s)
1456 $LCTL set_param fail_loc=0
1458 cancel_lru_locks $OSC
1460 local mtime2=$(stat -c %Y $DIR2/$tfile)
1461 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1462 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1464 run_test 39d "sync write should update mtime"
1467 # how long 40-47 take with specific delay
1474 # check that pid exists hence second operation wasn't blocked by first one
1475 # if it is so then there is no conflict, return 0
1476 # else second operation is conflicting with first one, return 1
1477 check_pdo_conflict() {
1480 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1481 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1491 # test 40: check non-blocking operations
1493 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1494 cancel_lru_locks mdc
1495 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1496 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1498 mkdir $DIR1/$tfile &
1500 touch $DIR2/$tfile-2
1501 check_pdo_conflict $PID1 || error "create is blocked"
1502 mkdir $DIR2/$tfile-3
1503 check_pdo_conflict $PID1 || error "mkdir is blocked"
1504 link $DIR2/$tfile-2 $DIR2/$tfile-4
1505 check_pdo_conflict $PID1 || error "link is blocked"
1506 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1507 check_pdo_conflict $PID1 || error "rename is blocked"
1508 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1509 check_pdo_conflict $PID1 || error "getattr is blocked"
1510 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1511 rmdir $DIR2/$tfile-3
1512 check_pdo_conflict $PID1 || error "unlink is blocked"
1514 # all operations above shouldn't wait the first one
1515 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1516 do_facet $SINGLEMDS lctl set_param fail_loc=0
1521 run_test 40a "pdirops: create vs others =============="
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 cancel_lru_locks mdc
1526 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1527 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1528 touch $DIR1/$tfile &
1531 touch $DIR2/$tfile-2
1532 check_pdo_conflict $PID1 || error "create is blocked"
1533 mkdir $DIR2/$tfile-3
1534 check_pdo_conflict $PID1 || error "mkdir is blocked"
1535 link $DIR2/$tfile-2 $DIR2/$tfile-4
1536 check_pdo_conflict $PID1 || error "link is blocked"
1537 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1538 check_pdo_conflict $PID1 || error "rename is blocked"
1539 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1540 check_pdo_conflict $PID1 || error "getattr is blocked"
1541 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1542 rmdir $DIR2/$tfile-3
1543 check_pdo_conflict $PID1 || error "unlink is blocked"
1544 # all operations above shouldn't wait the first one
1546 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1547 do_facet $SINGLEMDS lctl set_param fail_loc=0
1552 run_test 40b "pdirops: open|create and others =============="
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1556 cancel_lru_locks mdc
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 &
1563 touch $DIR2/$tfile-2
1564 check_pdo_conflict $PID1 || error "create is blocked"
1565 mkdir $DIR2/$tfile-3
1566 check_pdo_conflict $PID1 || error "mkdir is blocked"
1567 link $DIR2/$tfile-2 $DIR2/$tfile-4
1568 check_pdo_conflict $PID1 || error "link is blocked"
1569 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1570 check_pdo_conflict $PID1 || error "rename is blocked"
1571 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1572 check_pdo_conflict $PID1 || error "getattr is blocked"
1573 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1574 rmdir $DIR2/$tfile-3
1575 check_pdo_conflict $PID1 || error "unlink is blocked"
1577 # all operations above shouldn't wait the first one
1578 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1579 do_facet $SINGLEMDS lctl set_param fail_loc=0
1584 run_test 40c "pdirops: link and others =============="
1587 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1588 cancel_lru_locks mdc
1590 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1591 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"
1611 do_facet $SINGLEMDS lctl set_param fail_loc=0
1615 run_test 40d "pdirops: unlink and others =============="
1618 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1619 cancel_lru_locks mdc
1621 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1622 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1623 mv $DIR1/$tfile $DIR1/$tfile-0 &
1626 touch $DIR2/$tfile-2
1627 check_pdo_conflict $PID1 || error "create is blocked"
1628 mkdir $DIR2/$tfile-3
1629 check_pdo_conflict $PID1 || error "mkdir is blocked"
1630 link $DIR2/$tfile-2 $DIR2/$tfile-4
1631 check_pdo_conflict $PID1 || error "link is blocked"
1632 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1633 check_pdo_conflict $PID1 || error "getattr is blocked"
1634 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1635 rmdir $DIR2/$tfile-3
1636 check_pdo_conflict $PID1 || error "unlink is blocked"
1638 # all operations above shouldn't wait the first one
1639 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1640 do_facet $SINGLEMDS lctl set_param fail_loc=0
1645 run_test 40e "pdirops: rename and others =============="
1647 # test 41: create blocking operations
1649 cancel_lru_locks mdc
1650 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1651 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1652 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1654 mkdir $DIR2/$tfile &
1656 do_facet $SINGLEMDS lctl set_param fail_loc=0
1657 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1658 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1662 run_test 41a "pdirops: create vs mkdir =============="
1665 cancel_lru_locks mdc
1666 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1667 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1668 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1670 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1672 do_facet $SINGLEMDS lctl set_param fail_loc=0
1673 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1674 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1678 run_test 41b "pdirops: create vs create =============="
1681 cancel_lru_locks mdc
1682 touch $DIR1/$tfile-2
1683 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1684 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1685 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1687 link $DIR2/$tfile-2 $DIR2/$tfile &
1689 do_facet $SINGLEMDS lctl set_param fail_loc=0
1690 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1691 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1695 run_test 41c "pdirops: create vs link =============="
1698 cancel_lru_locks mdc
1699 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1700 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1701 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1705 do_facet $SINGLEMDS lctl set_param fail_loc=0
1706 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1707 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1711 run_test 41d "pdirops: create vs unlink =============="
1714 cancel_lru_locks mdc
1715 touch $DIR1/$tfile-2
1716 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1717 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1718 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1720 mv $DIR2/$tfile-2 $DIR2/$tfile &
1722 do_facet $SINGLEMDS lctl set_param fail_loc=0
1723 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1724 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1728 run_test 41e "pdirops: create and rename (tgt) =============="
1731 cancel_lru_locks mdc
1732 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1733 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1734 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1736 mv $DIR2/$tfile $DIR2/$tfile-2 &
1738 do_facet $SINGLEMDS lctl set_param fail_loc=0
1739 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1740 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1744 run_test 41f "pdirops: create and rename (src) =============="
1747 cancel_lru_locks mdc
1748 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1749 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1750 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1752 stat $DIR2/$tfile > /dev/null &
1754 do_facet $SINGLEMDS lctl set_param fail_loc=0
1755 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1756 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1760 run_test 41g "pdirops: create vs getattr =============="
1763 cancel_lru_locks mdc
1764 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1765 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1766 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1768 ls -lia $DIR2/ > /dev/null &
1770 do_facet $SINGLEMDS lctl set_param fail_loc=0
1771 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1776 run_test 41h "pdirops: create vs readdir =============="
1778 # test 42: unlink and blocking operations
1780 cancel_lru_locks mdc
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 &
1785 mkdir $DIR2/$tfile &
1787 do_facet $SINGLEMDS lctl set_param fail_loc=0
1788 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1789 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1793 run_test 42a "pdirops: mkdir vs mkdir =============="
1796 cancel_lru_locks mdc
1797 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1798 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1799 mkdir $DIR1/$tfile &
1801 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1803 do_facet $SINGLEMDS lctl set_param fail_loc=0
1804 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1805 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1809 run_test 42b "pdirops: mkdir vs create =============="
1812 cancel_lru_locks mdc
1813 touch $DIR1/$tfile-2
1814 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1815 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1816 mkdir $DIR1/$tfile &
1818 link $DIR2/$tfile-2 $DIR2/$tfile &
1820 do_facet $SINGLEMDS lctl set_param fail_loc=0
1821 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1822 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1826 run_test 42c "pdirops: mkdir vs link =============="
1829 cancel_lru_locks mdc
1830 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1831 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1832 mkdir $DIR1/$tfile &
1834 rmdir $DIR2/$tfile &
1836 do_facet $SINGLEMDS lctl set_param fail_loc=0
1837 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1838 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1842 run_test 42d "pdirops: mkdir vs unlink =============="
1845 cancel_lru_locks mdc
1846 touch $DIR1/$tfile-2
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 &
1851 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1853 do_facet $SINGLEMDS lctl set_param fail_loc=0
1854 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1855 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1859 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1862 cancel_lru_locks mdc
1863 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1864 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1865 mkdir $DIR1/$tfile &
1867 mv $DIR2/$tfile $DIR2/$tfile-2 &
1869 do_facet $SINGLEMDS lctl set_param fail_loc=0
1870 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1871 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1875 run_test 42f "pdirops: mkdir and rename (src) =============="
1878 cancel_lru_locks mdc
1879 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1880 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1881 mkdir $DIR1/$tfile &
1883 stat $DIR2/$tfile > /dev/null &
1885 do_facet $SINGLEMDS lctl set_param fail_loc=0
1886 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1887 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1891 run_test 42g "pdirops: mkdir vs getattr =============="
1894 cancel_lru_locks mdc
1895 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1896 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1897 mkdir $DIR1/$tfile &
1899 ls -lia $DIR2/ > /dev/null &
1901 do_facet $SINGLEMDS lctl set_param fail_loc=0
1902 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1907 run_test 42h "pdirops: mkdir vs readdir =============="
1909 # test 43: unlink and blocking operations
1911 cancel_lru_locks mdc
1913 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1914 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1917 mkdir $DIR2/$tfile &
1919 do_facet $SINGLEMDS lctl set_param fail_loc=0
1920 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1921 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
1925 run_test 43a "pdirops: unlink vs mkdir =============="
1928 cancel_lru_locks mdc
1930 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1931 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1934 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1936 do_facet $SINGLEMDS lctl set_param fail_loc=0
1937 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1938 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
1942 run_test 43b "pdirops: unlink vs create =============="
1945 cancel_lru_locks mdc
1947 touch $DIR1/$tfile-2
1948 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1949 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1952 link $DIR2/$tfile-2 $DIR2/$tfile &
1954 do_facet $SINGLEMDS lctl set_param fail_loc=0
1955 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1956 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
1960 run_test 43c "pdirops: unlink vs link =============="
1963 cancel_lru_locks mdc
1965 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1966 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1971 do_facet $SINGLEMDS lctl set_param fail_loc=0
1972 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1973 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
1977 run_test 43d "pdirops: unlink vs unlink =============="
1980 cancel_lru_locks mdc
1982 touch $DIR1/$tfile-2
1983 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1984 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1987 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0
1990 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1991 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1995 run_test 43e "pdirops: unlink and rename (tgt) =============="
1998 cancel_lru_locks mdc
2000 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2001 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2004 mv $DIR2/$tfile $DIR2/$tfile-2 &
2006 do_facet $SINGLEMDS lctl set_param fail_loc=0
2007 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2008 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2012 run_test 43f "pdirops: unlink and rename (src) =============="
2015 cancel_lru_locks mdc
2017 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2018 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2021 stat $DIR2/$tfile > /dev/null &
2023 do_facet $SINGLEMDS lctl set_param fail_loc=0
2024 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2025 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2029 run_test 43g "pdirops: unlink vs getattr =============="
2032 cancel_lru_locks mdc
2034 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2035 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2038 ls -lia $DIR2/ > /dev/null &
2040 do_facet $SINGLEMDS lctl set_param fail_loc=0
2041 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2046 run_test 43h "pdirops: unlink vs readdir =============="
2049 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2050 cancel_lru_locks mdc
2052 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2053 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2056 $LFS mkdir -i 1 $DIR2/$tfile &
2058 do_facet $SINGLEMDS lctl set_param fail_loc=0
2059 check_pdo_conflict $PID1 &&
2060 { wait $PID1; error "remote mkdir isn't blocked"; }
2061 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2065 run_test 43i "pdirops: unlink vs remote mkdir"
2067 # test 44: rename tgt and blocking operations
2069 cancel_lru_locks mdc
2070 touch $DIR1/$tfile-2
2071 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2072 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2073 mv $DIR1/$tfile-2 $DIR1/$tfile &
2075 mkdir $DIR2/$tfile &
2077 do_facet $SINGLEMDS lctl set_param fail_loc=0
2078 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2079 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2084 run_test 44a "pdirops: rename tgt vs mkdir =============="
2087 cancel_lru_locks mdc
2088 touch $DIR1/$tfile-2
2089 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2090 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2091 mv $DIR1/$tfile-2 $DIR1/$tfile &
2093 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2095 do_facet $SINGLEMDS lctl set_param fail_loc=0
2096 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2097 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2101 run_test 44b "pdirops: rename tgt vs create =============="
2104 cancel_lru_locks mdc
2105 touch $DIR1/$tfile-2
2106 touch $DIR1/$tfile-3
2107 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2108 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2109 mv $DIR1/$tfile-2 $DIR1/$tfile &
2111 link $DIR2/$tfile-3 $DIR2/$tfile &
2113 do_facet $SINGLEMDS lctl set_param fail_loc=0
2114 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2115 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2119 run_test 44c "pdirops: rename tgt vs link =============="
2122 cancel_lru_locks mdc
2123 touch $DIR1/$tfile-2
2124 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2125 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2126 mv $DIR1/$tfile-2 $DIR1/$tfile &
2130 do_facet $SINGLEMDS lctl set_param fail_loc=0
2131 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2132 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2136 run_test 44d "pdirops: rename tgt vs unlink =============="
2139 cancel_lru_locks mdc
2141 touch $DIR1/$tfile-2
2142 touch $DIR1/$tfile-3
2143 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2144 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2145 mv $DIR1/$tfile-2 $DIR1/$tfile &
2147 mv $DIR2/$tfile-3 $DIR2/$tfile &
2149 do_facet $SINGLEMDS lctl set_param fail_loc=0
2150 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2151 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2155 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2158 cancel_lru_locks mdc
2159 touch $DIR1/$tfile-2
2160 touch $DIR1/$tfile-3
2161 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2162 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2163 mv $DIR1/$tfile-2 $DIR1/$tfile &
2165 mv $DIR2/$tfile $DIR2/$tfile-3 &
2167 do_facet $SINGLEMDS lctl set_param fail_loc=0
2168 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2169 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2173 run_test 44f "pdirops: rename tgt and rename (src) =============="
2176 cancel_lru_locks mdc
2177 touch $DIR1/$tfile-2
2178 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2179 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2180 mv $DIR1/$tfile-2 $DIR1/$tfile &
2182 stat $DIR2/$tfile > /dev/null &
2184 do_facet $SINGLEMDS lctl set_param fail_loc=0
2185 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2186 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2190 run_test 44g "pdirops: rename tgt vs getattr =============="
2193 cancel_lru_locks mdc
2194 touch $DIR1/$tfile-2
2195 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2196 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2197 mv $DIR1/$tfile-2 $DIR1/$tfile &
2199 ls -lia $DIR2/ > /dev/null &
2201 do_facet $SINGLEMDS lctl set_param fail_loc=0
2202 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2207 run_test 44h "pdirops: rename tgt vs readdir =============="
2209 # test 44: rename tgt and blocking operations
2211 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2212 cancel_lru_locks mdc
2213 touch $DIR1/$tfile-2
2214 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2215 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2216 mv $DIR1/$tfile-2 $DIR1/$tfile &
2218 $LFS mkdir -i 1 $DIR2/$tfile &
2220 do_facet $SINGLEMDS lctl set_param fail_loc=0
2221 check_pdo_conflict $PID1 && { wait $PID1;
2222 error "remote mkdir isn't blocked"; }
2223 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2227 run_test 44i "pdirops: rename tgt vs remote mkdir"
2229 # test 45: rename src and blocking operations
2231 cancel_lru_locks mdc
2233 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2234 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2235 mv $DIR1/$tfile $DIR1/$tfile-2 &
2237 mkdir $DIR2/$tfile &
2239 do_facet $SINGLEMDS lctl set_param fail_loc=0
2240 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2241 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
2245 run_test 45a "pdirops: rename src vs mkdir =============="
2248 cancel_lru_locks mdc
2250 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2251 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2252 mv $DIR1/$tfile $DIR1/$tfile-2 &
2254 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2256 do_facet $SINGLEMDS lctl set_param fail_loc=0
2257 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2258 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2262 run_test 45b "pdirops: rename src vs create =============="
2265 cancel_lru_locks mdc
2267 touch $DIR1/$tfile-3
2268 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2269 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2270 mv $DIR1/$tfile $DIR1/$tfile-2 &
2272 link $DIR2/$tfile-3 $DIR2/$tfile &
2274 do_facet $SINGLEMDS lctl set_param fail_loc=0
2275 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2276 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2280 run_test 45c "pdirops: rename src vs link =============="
2283 cancel_lru_locks mdc
2285 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2286 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2287 mv $DIR1/$tfile $DIR1/$tfile-2 &
2291 do_facet $SINGLEMDS lctl set_param fail_loc=0
2292 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2293 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2297 run_test 45d "pdirops: rename src vs unlink =============="
2300 cancel_lru_locks mdc
2302 touch $DIR1/$tfile-3
2303 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2304 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2305 mv $DIR1/$tfile $DIR1/$tfile-2 &
2307 mv $DIR2/$tfile-3 $DIR2/$tfile &
2309 do_facet $SINGLEMDS lctl set_param fail_loc=0
2310 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2311 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2315 run_test 45e "pdirops: rename src and rename (tgt) =============="
2318 cancel_lru_locks mdc
2320 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2321 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2322 mv $DIR1/$tfile $DIR1/$tfile-2 &
2324 mv $DIR2/$tfile $DIR2/$tfile-3 &
2326 do_facet $SINGLEMDS lctl set_param fail_loc=0
2327 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2328 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2332 run_test 45f "pdirops: rename src and rename (src) =============="
2335 cancel_lru_locks mdc
2337 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2338 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2339 mv $DIR1/$tfile $DIR1/$tfile-2 &
2341 stat $DIR2/$tfile > /dev/null &
2343 do_facet $SINGLEMDS lctl set_param fail_loc=0
2344 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2345 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2349 run_test 45g "pdirops: rename src vs getattr =============="
2352 cancel_lru_locks mdc
2354 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2355 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2356 mv $DIR1/$tfile $DIR1/$tfile-2 &
2358 ls -lia $DIR2/ > /dev/null &
2359 do_facet $SINGLEMDS lctl set_param fail_loc=0
2360 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2365 run_test 45h "pdirops: unlink vs readdir =============="
2368 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2369 cancel_lru_locks mdc
2371 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2372 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2373 mv $DIR1/$tfile $DIR1/$tfile-2 &
2375 $LFS mkdir -i 1 $DIR2/$tfile &
2377 do_facet $SINGLEMDS lctl set_param fail_loc=0
2378 check_pdo_conflict $PID1 && { wait $PID1;
2379 error "create remote dir isn't blocked"; }
2380 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2384 run_test 45i "pdirops: rename src vs remote mkdir"
2386 # test 46: link and blocking operations
2388 cancel_lru_locks mdc
2389 touch $DIR1/$tfile-2
2390 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2391 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2392 link $DIR1/$tfile-2 $DIR1/$tfile &
2394 mkdir $DIR2/$tfile &
2396 do_facet $SINGLEMDS lctl set_param fail_loc=0
2397 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2398 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2402 run_test 46a "pdirops: link vs mkdir =============="
2405 cancel_lru_locks mdc
2406 touch $DIR1/$tfile-2
2407 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2408 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2409 link $DIR1/$tfile-2 $DIR1/$tfile &
2411 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2413 do_facet $SINGLEMDS lctl set_param fail_loc=0
2414 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2415 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2419 run_test 46b "pdirops: link vs create =============="
2422 cancel_lru_locks mdc
2423 touch $DIR1/$tfile-2
2424 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2425 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2426 link $DIR1/$tfile-2 $DIR1/$tfile &
2428 link $DIR2/$tfile $DIR2/$tfile &
2430 do_facet $SINGLEMDS lctl set_param fail_loc=0
2431 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2432 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2436 run_test 46c "pdirops: link vs link =============="
2439 cancel_lru_locks mdc
2440 touch $DIR1/$tfile-2
2441 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2442 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2443 link $DIR1/$tfile-2 $DIR1/$tfile &
2447 do_facet $SINGLEMDS lctl set_param fail_loc=0
2448 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2449 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2453 run_test 46d "pdirops: link vs unlink =============="
2456 cancel_lru_locks mdc
2457 touch $DIR1/$tfile-2
2458 touch $DIR1/$tfile-3
2459 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2460 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2461 link $DIR1/$tfile-2 $DIR1/$tfile &
2463 mv $DIR2/$tfile-3 $DIR2/$tfile &
2465 do_facet $SINGLEMDS lctl set_param fail_loc=0
2466 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2467 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2471 run_test 46e "pdirops: link and rename (tgt) =============="
2474 cancel_lru_locks mdc
2475 touch $DIR1/$tfile-2
2476 touch $DIR1/$tfile-3
2477 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2478 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2479 link $DIR1/$tfile-2 $DIR1/$tfile &
2481 mv $DIR2/$tfile $DIR2/$tfile-3 &
2483 do_facet $SINGLEMDS lctl set_param fail_loc=0
2484 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2485 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2489 run_test 46f "pdirops: link and rename (src) =============="
2492 cancel_lru_locks mdc
2493 touch $DIR1/$tfile-2
2494 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2495 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2496 link $DIR1/$tfile-2 $DIR1/$tfile &
2498 stat $DIR2/$tfile > /dev/null &
2500 do_facet $SINGLEMDS lctl set_param fail_loc=0
2501 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2502 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2506 run_test 46g "pdirops: link vs getattr =============="
2509 cancel_lru_locks mdc
2510 touch $DIR1/$tfile-2
2511 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2512 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2513 link $DIR1/$tfile-2 $DIR1/$tfile &
2515 ls -lia $DIR2/ > /dev/null &
2517 do_facet $SINGLEMDS lctl set_param fail_loc=0
2518 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2523 run_test 46h "pdirops: link vs readdir =============="
2526 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2527 cancel_lru_locks mdc
2528 touch $DIR1/$tfile-2
2529 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2530 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2531 link $DIR1/$tfile-2 $DIR1/$tfile &
2533 $LFS mkdir -i 1 $DIR2/$tfile &
2535 do_facet $SINGLEMDS lctl set_param fail_loc=0
2536 check_pdo_conflict $PID1 && { wait $PID1;
2537 error "remote mkdir isn't blocked"; }
2538 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2542 run_test 46i "pdirops: link vs remote mkdir"
2544 # test 47: remote mkdir and blocking operations
2546 cancel_lru_locks mdc
2547 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2548 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2549 cancel_lru_locks mdc
2550 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2551 $LFS mkdir -i 1 $DIR1/$tfile &
2553 mkdir $DIR2/$tfile &
2555 do_facet $SINGLEMDS lctl set_param fail_loc=0
2556 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2557 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2561 run_test 47a "pdirops: remote mkdir vs mkdir"
2564 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2565 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2566 cancel_lru_locks mdc
2567 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2568 $LFS mkdir -i 1 $DIR1/$tfile &
2570 sleep 1 # please do not remove this sleep, see LU-10754
2571 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2573 do_facet $SINGLEMDS lctl set_param fail_loc=0
2574 check_pdo_conflict $PID1 && { wait $PID1;
2575 error "create isn't blocked"; }
2576 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2580 run_test 47b "pdirops: remote mkdir vs create"
2583 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2584 cancel_lru_locks mdc
2585 touch $DIR1/$tfile-2
2586 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2587 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2588 $LFS mkdir -i 1 $DIR1/$tfile &
2590 link $DIR2/$tfile-2 $DIR2/$tfile &
2592 do_facet $SINGLEMDS lctl set_param fail_loc=0
2593 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2594 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2598 run_test 47c "pdirops: remote mkdir vs link"
2601 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2602 cancel_lru_locks mdc
2603 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2604 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2605 $LFS mkdir -i 1 $DIR1/$tfile &
2607 rmdir $DIR2/$tfile &
2609 do_facet $SINGLEMDS lctl set_param fail_loc=0
2610 check_pdo_conflict $PID1 && { wait $PID1;
2611 error "unlink isn't blocked"; }
2612 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2616 run_test 47d "pdirops: remote mkdir vs unlink"
2619 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2620 cancel_lru_locks mdc
2621 touch $DIR1/$tfile-2
2622 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2623 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2624 $LFS mkdir -i 1 $DIR1/$tfile &
2626 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2628 do_facet $SINGLEMDS lctl set_param fail_loc=0
2629 check_pdo_conflict $PID1 && { wait $PID1;
2630 error "rename isn't blocked"; }
2631 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2635 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2638 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2639 cancel_lru_locks mdc
2640 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2641 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2642 $LFS mkdir -i 1 $DIR1/$tfile &
2644 mv $DIR2/$tfile $DIR2/$tfile-2 &
2646 do_facet $SINGLEMDS lctl set_param fail_loc=0
2647 check_pdo_conflict $PID1 && { wait $PID1;
2648 error "rename isn't blocked"; }
2649 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2653 run_test 47f "pdirops: remote mkdir and rename (src)"
2656 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2659 cancel_lru_locks mdc
2660 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2661 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2662 $LFS mkdir -i 1 $DIR1/$tfile &
2664 stat $DIR2/$tfile > /dev/null &
2666 do_facet $SINGLEMDS lctl set_param fail_loc=0
2667 check_pdo_conflict $PID1 && { wait $PID1;
2668 error "getattr isn't blocked"; }
2669 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2673 run_test 47g "pdirops: remote mkdir vs getattr"
2677 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2678 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2679 do_facet client "lctl set_param fail_loc=0x410"
2680 $TRUNCATE $DIR2/$tfile $trunc_size
2681 do_facet client "lctl set_param fail_loc=0x0"
2683 size=`stat -c %s $DIR2/$tfile`
2684 [ $size -eq $trunc_size ] || error "wrong size"
2686 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2690 local origfile=/etc/hosts
2692 filesize=$(stat -c %s $origfile)
2694 # create an empty file
2695 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2696 # cache layout lock on both mount point
2697 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2698 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2700 # open and sleep 2 seconds then read
2701 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2705 # create the layout of testing file
2706 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2707 error "dd $DIR1/$tfile failed"
2709 # MULTIOP proc should be able to read enough bytes and exit
2710 for ((i = 0; i < 6; i++)); do
2712 kill -0 $pid || break
2714 kill -0 $pid 2> /dev/null && error "multiop is still there"
2715 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2719 run_test 51a "layout lock: refresh layout should work"
2722 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2723 { skip "Need MDS version at least 2.3.59"; return 0; }
2725 local tmpfile=`mktemp`
2727 # create an empty file
2728 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2730 # delay glimpse so that layout has changed when glimpse finish
2731 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2732 $LCTL set_param fail_loc=0x1404
2733 stat -c %s $DIR2/$tfile |tee $tmpfile &
2737 # create layout of testing file
2738 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2739 error "dd $DIR1/$tfile failed"
2742 local fsize=$(cat $tmpfile)
2744 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2746 rm -f $DIR1/$tfile $tmpfile
2748 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2751 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2753 # set default layout to have 1 stripe
2755 $LFS setstripe -c 1 $DIR1/$tdir
2757 # create a file with empty layout
2758 $MCREATE $DIR1/$tdir/$tfile ||
2759 error "$MCREATE $DIR1/$tdir/$tfile failed"
2761 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2762 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2764 # change the layout of testing file
2765 echo "Setting layout to have $OSTCOUNT stripes ..."
2766 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2770 # write something to the file, it should be blocked on fetching layout
2771 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2772 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2775 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2776 # count to succeed with only 3/4 of the number of stripes (rounded up),
2777 # so creating striped files does not fail if an OST is offline or full
2778 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2779 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2783 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2786 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2787 cancel_lru_locks mdc
2789 # open should grant LAYOUT lock, mmap and read will install pages
2790 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2794 # rss before revoking
2795 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2796 echo "Before revoking layout lock: $br KB mapped"
2798 # cancel layout lock manually
2799 cancel_lru_locks mdc
2801 # rss after revoking
2802 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2805 wait $PID || error "wait PID $PID failed"
2807 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2809 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2813 echo "==> rename vs getattr vs setxattr should not deadlock"
2814 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2816 do_facet mds1 $LCTL set_param fail_loc=$1
2818 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2826 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2827 wait $PID1 || error "(3) mv failed"
2828 wait $PID2 || error "(4) stat failed"
2835 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2836 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2838 do_facet mds1 $LCTL set_param fail_loc=$1
2840 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2848 $MULTIOP $DIR2/d1/d2 Oc &
2852 stat $DIR/d1 || error "(2) stat failed"
2854 wait $PID1 || error "(3) mv failed"
2855 wait $PID2 || error "(4) stat failed"
2856 wait $PID3 && error "(5) multiop failed"
2862 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2863 save_lustre_params client "llite.*.xattr_cache" > $p
2864 lctl set_param llite.*.xattr_cache 1 ||
2865 { skip "xattr cache is not supported"; return 0; }
2867 #define OBD_FAIL_MDS_RENAME 0x153
2868 #define OBD_FAIL_MDS_RENAME2 0x154
2869 test_54_part1 0x80000153 || error 10
2870 test_54_part1 0x80000154 || error 11
2871 test_54_part2 0x80000153 || error 12
2872 test_54_part2 0x80000154 || error 13
2874 restore_lustre_params < $p
2877 run_test 54 "rename locking"
2880 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2882 #define OBD_FAIL_MDS_RENAME4 0x156
2883 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2885 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2890 wait $PID1 && error "(2) mv succeeded"
2894 run_test 55a "rename vs unlink target dir"
2898 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2900 #define OBD_FAIL_MDS_RENAME4 0x156
2901 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2903 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2908 wait $PID1 && error "(2) mv succeeded"
2912 run_test 55b "rename vs unlink source dir"
2916 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2918 #define OBD_FAIL_MDS_RENAME4 0x156
2919 do_facet mds1 $LCTL set_param fail_loc=0x156
2921 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2925 # while rename is sleeping, open and remove d3
2926 $MULTIOP $DIR2/d3 D_c &
2932 # while rename is sleeping 2nd time, close d3
2934 wait $PID2 || error "(3) multiop failed"
2936 wait $PID1 && error "(2) mv succeeded"
2940 run_test 55c "rename vs unlink orphan target dir"
2946 #define OBD_FAIL_MDS_RENAME3 0x155
2947 do_facet mds1 $LCTL set_param fail_loc=0x155
2948 mv $DIR/f1 $DIR/$tdir &
2952 # while rename is sleeping, create $tdir, but as a directory
2953 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2955 # link in reverse locking order
2956 ln $DIR2/f1 $DIR2/$tdir/
2958 wait $PID1 && error "(2) mv succeeded"
2961 run_test 55d "rename file vs link"
2964 local MDSVER=$(lustre_build_version $SINGLEMDS)
2965 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2966 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2969 test_mkdir $DIR1/$tdir
2970 file1=$DIR1/$tdir/file
2971 file2=$DIR2/$tdir/file
2973 echo orig > $file2 || error "Could not create $file2"
2974 version=$($LFS data_version $file1)
2977 echo append >> $file2 || error "Could not append to $file2"
2978 version2=$($LFS data_version $file1)
2979 [ "$version" != "$version2" ] ||
2980 error "append did not change data version: $version"
2983 echo overwrite > $file2 || error "Could not overwrite $file2"
2984 version3=$($LFS data_version $file1)
2985 [ "$version2" != "$version3" ] ||
2986 error "overwrite did not change data version: $version2"
2988 # Truncate before EOF
2989 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2990 version4=$($LFS data_version $file1)
2991 [ "$version3" != "$version4" ] ||
2992 error "truncate did not change data version: $version3"
2994 # Truncate after EOF
2995 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2996 version5=$($LFS data_version $file1)
2997 [ "$version4" != "$version5" ] ||
2998 error "truncate did not change data version: $version4"
3000 # Chmod do not change version
3001 chmod 400 $file2 || error "Could not chmod 400 $file2"
3002 version6=$($LFS data_version $file1)
3003 [ "$version5" == "$version6" ] ||
3004 error "chmod should not change data version: $version5 != $version6"
3006 # Chown do not change version
3007 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3008 version7=$($LFS data_version $file1)
3009 [ "$version5" == "$version7" ] ||
3010 error "chown should not change data version: $version5 != $version7"
3012 run_test 60 "Verify data_version behaviour"
3015 local test_dir=$tdir/test_dir
3017 mkdir -p $DIR1/$tdir
3018 if [ $MDSCOUNT -ge 2 ]; then
3020 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3021 error "Create remote directory failed"
3023 mkdir -p $DIR1/$test_dir
3025 cd $DIR2/$test_dir || error "cd directory failed"
3026 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3028 cd $DIR2/$tdir || error "exit directory"
3030 run_test 70a "cd directory && rm directory"
3032 test_70b() { # LU-2781
3034 mkdir -p $DIR1/$tdir
3036 touch $DIR1/$tdir/file
3037 for ((i = 0; i < 32; i++)); do
3038 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3040 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3042 touch $DIR1/$tdir/file
3043 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3044 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3045 rm -rf $DIR1/$tdir/test_dir ||
3046 error "cannot remove directory after rm_entry"
3047 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3049 run_test 70b "remove files after calling rm_entry"
3052 local server_version=$(lustre_version_code $SINGLEMDS)
3054 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3055 skip "Need MDS version at least 2.1.6" && return
3057 # Patch not applied to 2.2 and 2.3 branches
3058 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3059 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3060 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3063 checkfiemap --test ||
3064 { skip "checkfiemap not runnable: $?" && return; }
3065 # write data this way: hole - data - hole - data
3066 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3067 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3069 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3070 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3071 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3073 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3075 checkfiemap $DIR2/$tfile 81920 ||
3076 error "data is not flushed from client"
3077 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3080 # common case of "create file, copy file" on a single node
3081 # should not flush data from ost
3082 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3083 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3085 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3087 checkfiemap $DIR1/$tfile 81920 ||
3089 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3091 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3093 run_test 71a "correct file map just after write operation is finished"
3096 local server_version=$(lustre_version_code $SINGLEMDS)
3098 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3099 skip "Need MDS version at least 2.1.6" && return
3101 # Patch not applied to 2.2 and 2.3 branches
3102 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3103 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3104 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3106 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
3108 checkfiemap --test ||
3109 { skip "error $?: checkfiemap failed" && return; }
3111 mkdir -p $DIR1/$tdir
3113 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3114 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3115 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3117 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3118 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3120 run_test 71b "check fiemap support for stripecount > 1"
3123 local p="$TMP/sanityN-$TESTNAME.parameters"
3126 save_lustre_params client "llite.*.xattr_cache" > $p
3127 lctl set_param llite.*.xattr_cache 1 ||
3128 { skip "xattr cache is not supported"; return 0; }
3131 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3132 error "setfattr1 failed"
3133 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3134 error "getfattr1 failed"
3135 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3136 error "setfattr2 failed"
3137 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3138 error "getfattr2 failed"
3140 # check that trusted.link is consistent
3141 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3142 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3143 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3144 echo "$tlink1 $tlink2"
3145 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3149 restore_lustre_params < $p
3152 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3155 local p="$TMP/sanityN-$TESTNAME.parameters"
3156 save_lustre_params client "llite.*.xattr_cache" > $p
3157 lctl set_param llite.*.xattr_cache 1 ||
3158 { skip "xattr cache is not supported"; return 0; }
3161 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3162 error "setfattr1 failed"
3163 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3164 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3165 clear_stats llite.*.stats
3166 # PR lock should be cached by now on both clients
3167 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3168 # 2 hits for getfattr(0)+getfattr(size)
3169 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3170 error "not cached in $DIR1"
3171 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3172 # 4 hits for more getfattr(0)+getfattr(size)
3173 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3174 error "not cached in $DIR2"
3177 restore_lustre_params < $p
3180 run_test 73 "getxattr should not cause xattr lock cancellation"
3183 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3184 skip "Need MDS version at least 2.4.93" && return
3186 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3187 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3188 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3190 run_test 74 "flock deadlock: different mounts =============="
3194 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3195 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3196 cancel_lru_locks osc
3198 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3201 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3202 $LCTL set_param fail_loc=0x31d
3203 stat -c %s $DIR1/$tfile &
3208 # For bad lock error handler we should ASSERT and got kernel panic here
3210 $LCTL set_param fail_loc=0
3212 run_test 75 "osc: upcall after unuse lock==================="
3215 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3216 skip "Need MDS version at least 2.5.53" && return
3218 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3219 local fcount=$((MDSCOUNT * 256))
3224 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3230 test_mkdir $DIR/$tdir
3232 # drop all open locks and close any cached "open" files on the client
3233 cancel_lru_locks mdc
3235 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3236 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3237 local already=${#fid_list[@]}
3238 for (( i = 0; i < $already; i++ )) ; do
3239 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3242 echo -n "opening files: "
3243 ulimit -n $((fcount + 50))
3244 for ((i = 0; i < $fcount; i++)); do
3245 touch $DIR/$tdir/f_$i
3246 local fd=$(free_fd ${fd_list[i]})
3247 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3252 (( $i % 32 == 0 )) && echo -n "."
3256 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3258 # Possible errors in openfiles FID list.
3259 # 1. Missing FIDs. Check 1
3260 # 2. Extra FIDs. Check 1
3261 # 3. Duplicated FID. Check 2
3262 # 4. Invalid FIDs. Check 2
3263 # 5. Valid FID, points to some other file. Check 3
3266 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3267 error "${#fid_list[@]} != $fcount (+$already old) open files"
3269 echo -n "closing files: "
3270 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3271 local close_cmd="exec ${fd_list[fd]}<&-"
3273 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3275 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3276 echo "skip old open file $filename"
3278 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3282 rm --interactive=no $filename
3284 error "Nonexisting fid ${fid_list[fid]} listed."
3285 (( $fd % 32 == 0 )) && echo -n "."
3290 ls_op=$(ls $DIR2/$tdir | wc -l)
3292 error "Some openfiles are missing in lproc output"
3296 run_test 76 "Verify MDT open_files listing"
3300 local dir=$DIR/$tdir
3303 mkdir $dir || error "mkdir $dir failed"
3304 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3307 do_nodes $CLIENTS $myRUNAS \
3308 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3309 error "dd at 0 on client failed (1)"
3311 do_nodes $CLIENTS $myRUNAS \
3313 for ((i = 0; i < $n; i++)); do
3314 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3315 seek=\\\$i count=1 conv=notrunc &
3316 pids_w[\\\$i]=\\\$!;
3319 for ((i = 0; i < $n; i++)); do
3320 wait \\\${pids_w[\\\$i]};
3322 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3326 do_nodes $CLIENTS sync;
3327 cancel_lru_locks osc
3329 do_nodes $CLIENTS $myRUNAS \
3331 for ((i = 0; i < $n; i++)); do
3332 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3333 seek=\\\$i count=1 &
3334 pids_r[\\\$i]=\\\$!;
3337 for ((i = 0; i < $n; i++)); do
3338 wait \\\${pids_r[\\\$i]};
3340 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3344 cancel_lru_locks osc
3346 wait $pid_w || error "dd (write) failed (2)"
3347 wait $pid_r || error "dd (read) failed (3)"
3348 rm -rvf $dir || error "rm -rf $dir failed"
3351 test_77a() { #LU-3266
3354 oss=$(comma_list $(osts_nodes))
3355 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3357 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3358 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3363 run_test 77a "check FIFO NRS policy"
3365 test_77b() { #LU-3266
3368 oss=$(comma_list $(osts_nodes))
3370 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3371 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3372 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3373 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3375 echo "policy: crr-n, crrn_quantum 1"
3378 do_nodes $oss lctl set_param \
3379 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3380 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3382 echo "policy: crr-n, crrn_quantum 64"
3386 do_nodes $oss lctl set_param \
3387 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3388 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3391 run_test 77b "check CRR-N NRS policy"
3396 oss=$(comma_list $(osts_nodes))
3398 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3399 ost.OSS.*.nrs_"$policy"_quantum=1 \
3400 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3401 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3403 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3404 "physical, ${policy}_supported reads"
3407 do_nodes $oss lctl set_param \
3408 ost.OSS.*.nrs_${policy}_supported="writes" \
3409 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3411 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3412 "physical, ${policy}_supported writes"
3415 do_nodes $oss lctl set_param \
3416 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3417 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3418 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3419 "logical, ${policy}_supported reads_and_writes"
3423 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3428 test_77c() { #LU-3266
3430 orr_trr "orr" || rc=$?
3431 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3432 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3435 run_test 77c "check ORR NRS policy"
3437 test_77d() { #LU-3266
3439 orr_trr "trr" || rc=$?
3440 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3441 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3444 run_test 77d "check TRR nrs policy"
3451 do_facet $facet lctl set_param \
3452 ost.OSS.ost_io.nrs_tbf_rule="$*"
3454 error "failed to run operate '$*' on TBF rules"
3457 cleanup_tbf_verify()
3461 echo "cleanup_tbf $DIR/$tdir"
3464 wait_delete_completed
3469 local dir=$DIR/$tdir
3470 local client1=${CLIENT1:-$(hostname)}
3473 local np=$(check_cpt_number ost1)
3474 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3475 echo "cpu_npartitions on ost1 is $np"
3477 mkdir $dir || error "mkdir $dir failed"
3478 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3481 trap cleanup_tbf_verify EXIT
3482 echo "Limited write rate: $1, read rate: $2"
3483 echo "Verify the write rate is under TBF control"
3484 local start=$SECONDS
3485 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3486 bs=1M count=100 oflag=direct 2>&1
3487 local runtime=$((SECONDS - start + 1))
3488 local rate=$(bc <<< "scale=6; 100 / $runtime")
3489 echo "Write runtime is $runtime s, speed is $rate IOPS"
3491 # verify the write rate does not exceed TBF rate limit
3492 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3493 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3495 cancel_lru_locks osc
3497 echo "Verify the read rate is under TBF control"
3499 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3500 bs=1M count=100 iflag=direct 2>&1
3501 runtime=$((SECONDS - start + 1))
3502 rate=$(bc <<< "scale=6; 100 / $runtime")
3503 echo "Read runtime is $runtime s, speed is $rate IOPS"
3505 # verify the read rate does not exceed TBF rate limit
3506 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3507 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3509 cancel_lru_locks osc
3510 cleanup_tbf_verify || error "rm -rf $dir failed"
3516 oss=$(comma_list $(osts_nodes))
3518 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3520 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3521 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3525 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3530 # Only operate rules on ost1 since OSTs might run on the same OSS
3532 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3533 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3534 local client_nids=$(nids_list $address "\\")
3535 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3536 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3540 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3541 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3542 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3546 tbf_rule_operate ost1 "stop\ localhost"
3547 tbf_rule_operate ost1 "stop\ clients"
3548 tbf_rule_operate ost1 "stop\ others"
3551 # Cleanup the TBF policy
3552 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3553 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3557 run_test 77e "check TBF NID nrs policy"
3562 oss=$(comma_list $(osts_nodes))
3564 do_nodes $oss $LCTL set_param \
3565 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3566 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3567 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3569 # Configure jobid_var
3570 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3572 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3573 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3574 if [ $saved_jobid_var != procname_uid ]; then
3575 set_persistent_param_and_check client \
3576 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3581 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3586 # Only operate rules on ost1 since OSTs might run on the same OSS
3588 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3589 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3590 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3591 nrs_write_read "$RUNAS"
3594 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3595 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3596 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3597 nrs_write_read "$RUNAS"
3600 tbf_rule_operate ost1 "stop\ runas"
3601 tbf_rule_operate ost1 "stop\ iozone_runas"
3602 tbf_rule_operate ost1 "stop\ dd_runas"
3603 nrs_write_read "$RUNAS"
3605 # Cleanup the TBF policy
3606 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3607 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3608 nrs_write_read "$RUNAS"
3610 local current_jobid_var=$($LCTL get_param -n jobid_var)
3611 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3612 if [ $saved_jobid_var != $current_jobid_var ]; then
3613 set_persistent_param_and_check client \
3614 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3618 run_test 77f "check TBF JobID nrs policy"
3623 oss=$(comma_list $(osts_nodes))
3625 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3627 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3628 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3630 do_nodes $oss lctl set_param \
3631 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3632 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3636 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3641 # Add a rule that only valid for Jobid TBF. If direct change between
3642 # TBF types is not supported, this operation will fail.
3643 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3645 # Cleanup the TBF policy
3646 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3647 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3650 run_test 77g "Change TBF type directly"
3653 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3654 { skip "Need OST version at least 2.8.55"; return 0; }
3656 local old_policy=$(do_facet ost1 \
3657 lctl get_param ost.OSS.ost_io.nrs_policies)
3660 do_facet ost1 lctl set_param \
3661 ost.OSS.ost_io.nrs_policies="abc"
3662 [ $? -eq 0 ] && error "should return error"
3664 do_facet ost1 lctl set_param \
3665 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3666 [ $? -eq 0 ] && error "should return error"
3668 do_facet ost1 lctl set_param \
3669 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3670 [ $? -eq 0 ] && error "should return error"
3672 do_facet ost1 lctl set_param \
3673 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3674 [ $? -eq 0 ] && error "should return error"
3676 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3677 [ $? -eq 0 ] || error "shouldn't LBUG"
3679 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3683 run_test 77h "Wrong policy name should report error, not LBUG"
3689 local error_message=$3
3691 for rule in $expected; do
3692 rule_number=$((rule_number + 1))
3694 local stop_line=$(($rule_number + 3))
3695 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3697 local output=$(do_facet $facet lctl get_param \
3698 ost.OSS.ost_io.nrs_tbf_rule |
3702 if [ "$output" != "$expected" ]; then
3703 error "$error_message, expected '$expected', got '$output'"
3708 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3709 { skip "Need OST version at least 2.8.55"; return 0; }
3711 for i in $(seq 1 $OSTCOUNT)
3713 do_facet ost"$i" lctl set_param \
3714 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3716 error "failed to set TBF policy"
3719 tbf_rule_check ost1 "default" "error before inserting any rule"
3721 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3722 tbf_rule_check ost1 "before default" \
3723 "error when inserting rule 'before'"
3725 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3726 tbf_rule_check ost1 "before after default" \
3727 "error when inserting rule 'after'"
3729 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3730 tbf_rule_check ost1 "before target after default" \
3731 "error when inserting rule 'target'"
3733 echo "Move before itself"
3734 tbf_rule_operate ost1 "change\ target\ rank=target"
3735 tbf_rule_check ost1 "before target after default" \
3736 "error when moving before itself"
3738 echo "Move to higher rank"
3739 tbf_rule_operate ost1 "change\ target\ rank=before"
3740 tbf_rule_check ost1 "target before after default" \
3741 "error when moving to higher rank"
3743 echo "Move to lower rank"
3744 tbf_rule_operate ost1 "change\ target\ rank=after"
3745 tbf_rule_check ost1 "before target after default" \
3746 "error when moving to lower rank"
3748 echo "Move before default"
3749 tbf_rule_operate ost1 "change\ target\ rank=default"
3750 tbf_rule_check ost1 "before after target default" \
3751 error "error when moving before default"
3753 # Cleanup the TBF policy
3754 do_nodes $(comma_list $(osts_nodes)) \
3755 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3758 run_test 77i "Change rank of TBF rule"
3763 local ost_version=$(lustre_version_code ost1)
3765 [ $ost_version -ge $(version_code 2.9.53) ] ||
3766 { skip "Need OST version at least 2.9.53"; return 0; }
3767 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3772 do_nodes $(comma_list $(osts_nodes)) \
3773 lctl set_param jobid_var=procname_uid \
3774 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3775 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3776 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3777 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3782 do_nodes $(comma_list $(osts_nodes)) \
3783 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3784 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3785 ost.OSS.ost_io.nrs_policies="fifo"
3787 # sleep 3 seconds to wait the tbf policy stop completely,
3788 # or the next test case is possible get -EAGAIN when
3789 # setting the tbf policy
3792 run_test 77j "check TBF-OPCode NRS policy"
3795 local idstr="${1}id"
3796 local policy="${idstr}={$2}"
3797 local rate="rate=$3"
3799 do_nodes $(comma_list $(osts_nodes)) \
3800 lctl set_param jobid_var=procname_uid \
3801 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3802 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3803 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3805 nrs_write_read "runas $4"
3806 tbf_verify $3 $3 "runas $4"
3808 do_nodes $(comma_list $(osts_nodes)) \
3809 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3810 ost.OSS.ost_io.nrs_policies="fifo"
3812 # sleep 3 seconds to wait the tbf policy stop completely,
3813 # or the next test case is possible get -eagain when
3814 # setting the tbf policy
3819 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3820 skip "Need OST version at least 2.11.50"
3823 test_id "u" "500" "5" "-u 500"
3824 test_id "g" "500" "5" "-u 500 -g 500"
3826 run_test 77ja "check TBF-UID/GID NRS policy"
3834 for rule in $rule_lists; do
3835 do_nodes $(comma_list $(osts_nodes)) \
3836 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3839 do_nodes $(comma_list $(osts_nodes)) \
3840 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3846 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3847 { skip "Need OST version at least 2.9.53"; return 0; }
3849 do_nodes $(comma_list $(osts_nodes)) \
3850 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3851 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3852 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3854 nrs_write_read "$RUNAS"
3855 tbf_verify 20 10 "$RUNAS"
3857 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3858 local client_nids=$(nids_list $address "\\")
3859 do_nodes $(comma_list $(osts_nodes)) \
3860 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3861 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3862 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3863 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3868 do_nodes $(comma_list $(osts_nodes)) \
3869 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3870 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3871 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3873 nrs_write_read "$RUNAS"
3874 tbf_verify 20 20 "$RUNAS"
3876 do_nodes $(comma_list $(osts_nodes)) \
3877 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3878 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3879 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3881 nrs_write_read "$RUNAS"
3882 # with parameter "RUNAS", it will match the latest rule
3883 # "ext_b" first, so the limited write rate is 10.
3884 tbf_verify 10 10 "$RUNAS"
3887 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3889 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3890 { skip "Need OST version at least 2.10.58"; return 0; }
3892 do_nodes $(comma_list $(osts_nodes)) \
3893 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3894 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3895 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3896 nrs_write_read "runas -u 500 -g 1000"
3897 tbf_verify 5 5 "runas -u 500 -g 1000"
3899 do_nodes $(comma_list $(osts_nodes)) \
3900 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3901 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3902 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3904 nrs_write_read "runas -u 500"
3905 tbf_verify 20 10 "runas -u 500"
3907 do_nodes $(comma_list $(osts_nodes)) \
3908 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3909 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3910 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3911 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3912 nrs_write_read "runas -u 500"
3913 tbf_verify 10 10 "runas -u 500"
3914 tbf_verify 20 10 "runas -u 500"
3915 cleanup_77k "ext_a ext_b" "fifo"
3917 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3920 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3921 { skip "Need OST version at least 2.10.56"; return 0; }
3923 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3924 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3926 local output=$(do_facet ost1 lctl get_param \
3927 ost.OSS.ost_io.nrs_policies | \
3928 awk '/name: tbf/ {print;exit}' | \
3929 awk -F ': ' '{print $2}')
3931 if [ "$output" != "tbf" ]; then
3932 error "The generic TBF output is '$output', not 'tbf'"
3935 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3937 run_test 77l "check the output of NRS policies for generic TBF"
3940 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3941 skip "Need OST version at least 2.9.54"
3945 local dir=$DIR/$tdir
3947 mkdir $dir || error "mkdir $dir failed"
3948 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3951 local nodes=$(comma_list $(osts_nodes))
3952 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3953 ost.OSS.ost_io.nrs_delay_min=4 \
3954 ost.OSS.ost_io.nrs_delay_max=4 \
3955 ost.OSS.ost_io.nrs_delay_pct=100
3956 [ $? -ne 0 ] && error "Failed to set delay policy"
3958 local start=$SECONDS
3959 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3960 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3961 oflag=direct conv=fdatasync ||
3962 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3963 error "dd on client failed (1)"; }
3964 local elapsed=$((SECONDS - start))
3966 # NRS delay doesn't do sub-second timing, so a request enqueued at
3967 # 0.9 seconds can be dequeued at 4.0
3968 [ $elapsed -lt 3 ] &&
3969 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3970 error "Single 1M write should take at least 3 seconds"; }
3973 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3974 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3975 oflag=direct conv=fdatasync ||
3976 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3977 error "dd on client failed (2)"; }
3978 elapsed=$((SECONDS - start))
3980 [ $elapsed -lt 30 ] &&
3981 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3982 error "Ten 1M writes should take at least 30 seconds"; }
3984 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3985 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3989 run_test 77m "check NRS Delay slows write RPC processing"
3991 test_77n() { #LU-10802
3992 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3993 skip "Need OST version at least 2.10.58"
3997 # Configure jobid_var
3998 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3999 if [ $saved_jobid_var != procname_uid ]; then
4000 set_persistent_param_and_check client \
4001 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4004 do_nodes $(comma_list $(osts_nodes)) \
4005 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4006 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4007 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4010 tbf_verify 20 20 "$RUNAS"
4012 do_nodes $(comma_list $(osts_nodes)) \
4013 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4014 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4019 do_nodes $(comma_list $(osts_nodes)) \
4020 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4021 ost.OSS.ost_io.nrs_policies="fifo"
4025 local current_jobid_var=$($LCTL get_param -n jobid_var)
4026 if [ $saved_jobid_var != $current_jobid_var ]; then
4027 set_persistent_param_and_check client \
4028 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4031 run_test 77n "check wildcard support for TBF JobID NRS policy"
4033 test_78() { #LU-6673
4036 oss=$(comma_list $(osts_nodes))
4037 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4038 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4040 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4041 # Valid return codes are:
4042 # 0: Tuning succeeded
4043 # ENODEV: Policy is still stopped
4044 # EAGAIN: Policy is being initialized
4045 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4046 error "Expected set_param to return 0|ENODEV|EAGAIN"
4048 # Cleanup the ORR policy
4049 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4050 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4053 run_test 78 "Enable policy and specify tunings right away"
4056 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4057 test_mkdir $DIR/$tdir
4059 # Prevent interference from layout intent RPCs due to
4060 # asynchronous writeback. These will be tested in 130c below.
4061 do_nodes ${CLIENTS:-$HOSTNAME} sync
4063 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4064 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4066 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4067 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4068 local facet=mds$((mdtidx + 1))
4070 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4071 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4075 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4076 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4081 run_test 79 "xattr: intent error"
4084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4091 mkdir -p $DIR1/$tdir/dir
4092 createmany -o $DIR1/$tdir/dir/f 10 ||
4093 error "create files under remote dir failed $i"
4095 cp /etc/passwd $DIR1/$tdir/$tfile
4097 #migrate open file should fails
4098 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4100 # give multiop a chance to open
4103 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4104 error "migrate open files should failed with open files"
4108 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4109 error "migrate remote dir error"
4111 echo "Finish migration, then checking.."
4112 for file in $(find $DIR1/$tdir); do
4113 mdt_index=$($LFS getstripe -m $file)
4114 [ $mdt_index == $MDTIDX ] ||
4115 error "$file is not on MDT${MDTIDX}"
4118 diff /etc/passwd $DIR1/$tdir/$tfile ||
4119 error "file different after migration"
4121 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4123 run_test 80a "migrate directory when some children is being opened"
4127 kill -9 $migrate_pid
4131 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4132 local migrate_dir1=$DIR1/$tdir/migrate_dir
4133 local migrate_dir2=$DIR2/$tdir/migrate_dir
4134 local migrate_run=$LUSTRE/tests/migrate.sh
4142 trap cleanup_80b EXIT
4143 #prepare migrate directory
4144 mkdir -p $migrate_dir1
4145 for F in {1,2,3,4,5}; do
4146 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4147 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4150 #migrate the directories among MDTs
4153 mdt_idx=$((RANDOM % MDSCOUNT))
4154 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4156 [ $rc -ne 0 -o $rc -ne 16 ] || break
4161 echo "start migration thread $migrate_pid"
4162 #Access the files at the same time
4163 start_time=$(date +%s)
4164 echo "accessing the migrating directory for 5 minutes..."
4166 ls $migrate_dir2 > /dev/null || {
4167 echo "read dir fails"
4170 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4171 echo "access file1 fails"
4175 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4176 echo "access file2/3 fails"
4180 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4181 echo "access file4 fails"
4185 stat $migrate_dir2/file5 > /dev/null || {
4186 echo "stat file5 fails"
4190 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4191 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4192 echo "touch file failed with $rc1"
4196 if [ -e $migrate_dir2/source_file ]; then
4197 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4198 &>/dev/null || rc1=$?
4199 if [ -e $migrate_dir2/link_file ]; then
4200 rm -rf $migrate_dir2/link_file
4203 mrename $migrate_dir2/source_file \
4204 $migrate_dir2/target_file &>/dev/null || rc1=$?
4205 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4206 echo "rename failed with $rc1"
4210 if [ -e $migrate_dir2/target_file ]; then
4211 rm -rf $migrate_dir2/target_file &>/dev/null ||
4214 rm -rf $migrate_dir2/source_file &>/dev/null ||
4217 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4218 echo "unlink failed with $rc1"
4223 end_time=$(date +%s)
4224 duration=$((end_time - start_time))
4225 if [ $((duration % 10)) -eq 0 ]; then
4226 if [ $show_time -eq 1 ]; then
4227 echo "...$duration seconds"
4234 kill -0 $migrate_pid || {
4235 echo "migration stopped 1"
4239 [ $duration -ge 300 ] && break
4242 #check migration are still there
4243 kill -0 $migrate_pid || error "migration stopped 2"
4246 run_test 80b "Accessing directory during migration"
4249 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4253 mkdir -p $DIR1/$tdir
4255 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4256 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4259 touch d0/0 || error "create 0 failed"
4260 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4261 stat d0/0 && error "stat mv filed succeed"
4262 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4263 stat d0/0 || error "stat failed"
4265 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4267 if [ $t -ne 3 ]; then
4268 ls -ai $DIR1/$tdir/d0
4269 error "expect 3 get $t"
4274 run_test 81a "rename and stat under striped directory"
4277 [ $MDSCOUNT -lt 2 ] &&
4278 skip "We need at least 2 MDTs for this test"
4285 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4286 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4295 for i in $(seq $total); do
4296 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4300 kill -9 $setattr_pid
4302 run_test 81b "rename under striped directory doesn't deadlock"
4305 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4306 { skip "Need MDS version at least 2.6.92"; return 0; }
4308 # Client 1 creates a file.
4309 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4311 # Client 2 opens the file.
4312 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4314 # Client 1 makes the file an orphan.
4315 rm $DIR1/$tfile || error "rm"
4316 # Client 2 sets EA "user.multiop".
4318 wait $pid2 || error "multiop 2"
4319 # Client 1 gets EA "user.multiop". This used to fail because the EA
4320 # cache refill would get "trusted.link" from mdd_xattr_list() but
4321 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4324 wait $pid1 || error "multiop 1"
4326 run_test 82 "fsetxattr and fgetxattr on orphan files"
4329 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4336 $LFS mkdir -i1 -c2 $tdir
4341 echo "start pid $pid1 to create/unlink striped directory"
4343 # Access the directory at the same time
4347 stat $tdir > /dev/null 2>&1
4351 echo "start pid $pid2 to stat striped directory"
4359 run_test 83 "access striped directory while it is being created/unlinked"
4362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4367 [ "$SLOW" = "yes" ] && duration=600
4368 # Open/Create under striped directory
4372 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4373 touch $tdir/f{0..3} > /dev/null 2>&1
4377 echo "start pid $pid1 to open/create under striped directory"
4379 # unlink the striped directory at the same time
4383 rm -rf $tdir > /dev/null 2>&1
4387 echo "start pid $pid2 to unlink striped directory"
4396 run_test 90 "open/create and unlink striped directory"
4399 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4404 [ "$SLOW" = "yes" ] && duration=600
4405 # chmod striped directory
4409 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4410 chmod go+w $tdir > /dev/null 2>&1
4414 echo "start pid $pid1 to chmod striped directory"
4416 # unlink the striped directory at the same time
4420 rm -rf $tdir > /dev/null 2>&1
4424 echo "start pid $pid2 to unlink striped directory"
4433 run_test 91 "chmod and unlink striped directory"
4436 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4439 local cmd="exec $fd<$DIR1/$tdir"
4440 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4443 trap "eval $cmd" EXIT
4444 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4445 rmdir ../$tdir || error "rmdir ../$tdir fails"
4447 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4448 $LCTL set_param fail_loc=0x1408
4449 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4450 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4451 error "create remote dir succeeds"
4452 $LCTL set_param fail_loc=0
4456 run_test 92 "create remote directory under orphan directory"
4463 mkdir -p $DIR1/$tfile-1/
4464 mkdir -p $DIR2/$tfile-2/
4465 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4466 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4467 do_facet $SINGLEMDS lctl set_param -n \
4468 'lod.lustre-MDT*/qos_threshold_rr' 100
4469 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4470 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4472 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4475 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4479 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4480 do_facet $SINGLEMDS "lctl set_param -n \
4481 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4483 $LFS getstripe $DIR1/$tfile-1/file1
4484 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4485 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4486 $LFS getstripe $DIR2/$tfile-2/file2
4487 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4488 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4489 echo "rc1=$rc1 and rc2=$rc2 "
4490 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4491 error "object allocate on same ost detected"
4493 run_test 93 "alloc_rr should not allocate on same ost"
4497 skip "Reserved for glimpse-ahead" && return
4498 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4499 skip "Need MDS version at least 2.10.55"
4503 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4505 lctl set_param -n mdc.*.stats=clear
4506 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4508 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4509 # first stat from server should return size data and save glimpse
4510 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4511 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4512 # second stat to check size is NOT cached on client without IO lock
4513 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4515 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4516 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4519 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4522 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4523 skip "Need MDS version at least 2.10.55"
4527 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4529 lctl set_param -n mdc.*.stats=clear
4530 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4531 cancel_lru_locks mdc
4532 # first stat data from server should have size
4533 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4534 # second stat to check size is cached on client
4535 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4537 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4538 # both stats should cause no glimpse requests
4539 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4542 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4545 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4546 skip "Need MDS version at least 2.10.55"
4550 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4552 lctl set_param -n mdc.*.stats=clear
4553 lctl set_param -n osc.*.stats=clear
4554 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4556 # check that size is merged from MDT and OST correctly
4557 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4558 error "Wrong size from stat #1"
4560 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4561 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4565 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4568 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4569 skip "Need MDS version at least 2.10.55"
4573 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4576 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4577 lctl set_param -n mdc.*.stats=clear
4578 $TRUNCATE $DIR2/$tdir/dom 4096
4580 # check that reported size is valid after file grows to OST and
4581 # is truncated back to MDT stripe size
4582 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4583 error "Wrong size from stat #1"
4585 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4586 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4590 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4593 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
4594 skip "Need MDS version at least 2.11.50"
4596 local dom=$DIR/$tdir/dom
4597 local dom2=$DIR2/$tdir/dom
4600 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4602 cancel_lru_locks mdc
4603 dd if=/dev/urandom of=$dom bs=12000 count=1
4604 $TRUNCATE $dom2 6000
4605 cancel_lru_locks mdc
4606 lctl set_param -n mdc.*.stats=clear
4607 # expect read-on-open to return all data before write
4608 cat /etc/hosts >> $dom
4609 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4610 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4612 run_test 100e "DoM: read on open and file size"
4615 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4616 skip "Need MDS version at least 2.10.55" && return
4618 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4620 $CHECKSTAT -t file $DIR1/$tfile
4622 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4623 sysctl -wq vm.dirty_writeback_centisecs=0
4625 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4628 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4629 error_noexit "Write fails"
4630 # must discard pages
4631 lctl set_param -n mdc.*.stats=clear
4632 rm $DIR2/$tfile || error "Unlink fails"
4634 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4635 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4637 run_test 101a "Discard DoM data on unlink"
4640 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4641 skip "Need MDS version at least 2.10.55" && return
4643 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4644 touch $DIR1/${tfile}_2
4646 $CHECKSTAT -t file $DIR1/$tfile
4648 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4649 sysctl -wq vm.dirty_writeback_centisecs=0
4651 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4654 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4655 # must discard pages
4656 lctl set_param -n mdc.*.stats=clear
4657 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4659 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4660 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4662 run_test 101b "Discard DoM data on rename"
4665 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4666 skip "Need MDS version at least 2.10.55" && return
4668 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4670 $CHECKSTAT -t file $DIR1/$tfile
4672 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4673 sysctl -wq vm.dirty_writeback_centisecs=0
4675 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4678 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4679 $MULTIOP $DIR1/$tfile O_c &
4682 lctl set_param -n mdc.*.stats=clear
4683 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4684 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4686 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4687 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4689 run_test 101c "Discard DoM data on close-unlink"
4691 # test to verify file handle related system calls
4692 # (name_to_handle_at/open_by_handle_at)
4693 # The new system calls are supported in glibc >= 2.14.
4695 # test to verify we can open by handle an unlinked file from > 1 client
4696 # This test opens the file normally on $DIR1, which is on one mount, and then
4697 # opens it by handle on $DIR2, which is on a different mount.
4699 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
4700 skip "Needs MDS version 2.11.57 or later"
4702 echo "Test file_handle syscalls" > $DIR/$tfile ||
4703 error "write failed"
4704 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4705 error "check_fhandle_syscalls failed"
4708 run_test 102 "Test open by handle of unlinked file"
4710 log "cleanup: ======================================================"
4712 # kill and wait in each test only guarentee script finish, but command in script
4713 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4714 # otherwise umount below will fail
4715 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4720 check_and_cleanup_lustre