6 # bug number for skipped test: 9977/LU-7105
7 ALWAYS_EXCEPT=" 28 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
14 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
15 OPENFILE=${OPENFILE:-openfile}
16 OPENUNLINK=${OPENUNLINK:-openunlink}
17 export MULTIOP=${MULTIOP:-multiop}
18 export TMP=${TMP:-/tmp}
19 MOUNT_2=${MOUNT_2:-"yes"}
20 CHECK_GRANT=${CHECK_GRANT:-"yes"}
21 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
25 export NAME=${NAME:-local}
27 LUSTRE=${LUSTRE:-`dirname $0`/..}
28 . $LUSTRE/tests/test-framework.sh
32 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
35 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
36 # bug number for skipped test:
37 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
38 # LU-2829 / LU-2887 - make allowances for ZFS slowness
39 TEST33_NFILES=${TEST33_NFILES:-1000}
42 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
49 check_and_setup_lustre
54 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
56 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
57 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
59 # $RUNAS_ID may get set incorrectly somewhere else
60 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
62 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
68 [ -f $DIR2/$tfile ] || error "Check create"
69 chmod 777 $DIR2/$tfile
70 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
71 error "Check attribute update for 0777"
73 chmod a-x $DIR2/$tfile
74 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
75 error "Check attribute update for 0666"
78 $CHECKSTAT -a $DIR1/$tfile ||
79 error "Check unlink - removes file on other mountpoint"
81 run_test 1 "Check attribute updates on 2 mount points"
87 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
88 error "Either not file type or perms not 0777"
90 run_test 2a "check cached attribute updates on 2 mtpt's ========"
96 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
97 error "Either not file type or perms not 0777"
99 run_test 2b "check cached attribute updates on 2 mtpt's ========"
101 # NEED TO SAVE ROOT DIR MODE
104 $CHECKSTAT -t dir -p 0777 $DIR2 ||
105 error "Either not dir type or perms not 0777"
107 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
111 $CHECKSTAT -t dir -p 0755 $DIR2 ||
112 error "Either not file type or perms not 0775"
114 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
121 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
124 run_test 2e "check chmod on root is propagated to others"
127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
129 local remote_dir=$tdir/remote_dir
132 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
133 error "Create remote directory failed"
135 touch $DIR1/$remote_dir/$tfile ||
136 error "Create file under remote directory failed"
137 chmod 777 $DIR1/$remote_dir/$tfile ||
138 error "Chmod file under remote directory failed"
140 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
141 error "Check attr of file under remote directory failed"
143 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
144 error "Chown file under remote directory failed"
146 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
147 error "Check owner of file under remote directory failed"
149 cd $DIR2/$remote_dir || error "enter remote dir"
150 rm -rf $DIR1/$remote_dir/$tfile ||
151 error "Unlink remote directory failed"
153 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
154 error "unlink file still exists!"
156 cd $DIR2/$tdir || error "exit remote dir"
157 rm -rf $DIR1/$tdir || error "unlink directory failed"
159 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
162 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
164 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
166 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
167 echo "$DIR1/$tfile has $block1 blocks"
168 echo "$DIR2/$tfile has $block2 blocks"
169 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
171 run_test 2g "check blocks update on sync write"
174 local target="this/is/good"
175 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
176 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
177 error "link $DIR2/$tfile not as expected"
179 run_test 3 "symlink on one mtpt, readlink on another ==========="
182 multifstat $DIR1/f4 $DIR2/f4
184 run_test 4 "fstat validation on multiple mount points =========="
188 $TRUNCATE $DIR2/f5 100
189 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
190 error "Either not file type or size not equal to 100 bytes"
193 run_test 5 "create a file on one mount, truncate it on the other"
196 openunlink $DIR1/$tfile $DIR2/$tfile || \
197 error "openunlink $DIR1/$tfile $DIR2/$tfile"
199 run_test 6 "remove of open file on other node =================="
203 opendirunlink $DIR1/$dir $DIR2/$dir || \
204 error "opendirunlink $DIR1/$dir $DIR2/$dir"
206 run_test 7 "remove of open directory on other node ============="
209 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
210 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
212 run_test 8 "remove of open special file on other node =========="
218 for C in a b c d e f g h i j k l; do
219 dir=`eval echo \\$DIR$MTPT`
220 echo -n $C >> $dir/f9
221 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
223 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
224 error "`od -a $DIR1/f9` != abcdefghijkl"
226 run_test 9 "append of file with sub-page size on multiple mounts"
233 for C in a b c d e f g h i j k l; do
234 dir=`eval echo \\$DIR$MTPT`
235 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
236 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
237 OFFSET=`expr $OFFSET + 1`
239 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
240 error "`od -a $DIR1/f10` != abcdefghijkl"
242 run_test 10a "write of file with sub-page size on multiple mounts "
246 yes "R" | head -c 4000 >$TMP/f10b-seed
247 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
249 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
251 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
253 # create a test file locally to compare
254 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
255 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
256 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
257 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
259 run_test 10b "write of file with sub-page size on multiple mounts "
263 multiop_bg_pause $DIR1/d11/f O_c || return 1
265 cp -p /bin/ls $DIR1/d11/f
269 wait $MULTIPID || error "wait for PID $MULTIPID failed"
270 [ $RC -eq 0 ] && error || true
272 run_test 11 "execution of file opened for write should return error ===="
275 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
277 run_test 12 "test lock ordering (link, stat, unlink)"
279 test_13() { # bug 2451 - directory coherency
281 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
283 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
285 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
286 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
287 # need to run it twice
288 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
290 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
291 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
293 run_test 13 "test directory page revocation"
296 test_mkdir $DIR1/$tdir
297 cp -p /bin/ls $DIR1/$tdir/$tfile
298 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
301 $DIR2/$tdir/$tfile && error || true
303 wait $MULTIPID || return 2
305 run_test 14aa "execution of file open for write returns -ETXTBSY"
308 test_mkdir $DIR1/$tdir
309 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
310 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
313 $MULTIOP $DIR2/$tdir/multiop Oc && error "expected error, got success"
314 kill -USR1 $MULTIOP_PID || return 2
315 wait $MULTIOP_PID || return 3
316 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
318 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
320 test_14b() { # bug 3192, 7040
321 test_mkdir $DIR1/$tdir
322 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
323 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
326 $TRUNCATE $DIR2/$tdir/multiop 0 && kill -9 $MULTIOP_PID && \
327 error "expected truncate error, got success"
328 kill -USR1 $MULTIOP_PID || return 2
329 wait $MULTIOP_PID || return 3
330 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
331 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
333 run_test 14b "truncate of executing file returns -ETXTBSY ======"
335 test_14c() { # bug 3430, 7040
336 test_mkdir $DIR1/$tdir
337 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
338 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
341 cp /etc/hosts $DIR2/$tdir/multiop && error "expected error, got success"
342 kill -USR1 $MULTIOP_PID || return 2
343 wait $MULTIOP_PID || return 3
344 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
345 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
347 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
349 test_14d() { # bug 10921
350 test_mkdir $DIR1/$tdir
351 cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed"
352 MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c ||
356 chmod 600 $DIR1/$tdir/multiop || error "chmod failed"
357 kill -USR1 $MULTIOP_PID || return 2
358 wait $MULTIOP_PID || return 3
359 cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed"
360 rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
362 run_test 14d "chmod of executing file is still possible ========"
364 test_15() { # bug 974 - ENOSPC
366 sh oos2.sh $MOUNT1 $MOUNT2
367 wait_delete_completed
368 grant_error=`dmesg | grep "> available"`
369 [ -z "$grant_error" ] || error "$grant_error"
371 run_test 15 "test out-of-space with multiple writers ==========="
374 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
375 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
376 # pass a 2500 operation dual-mount run within the time limit.
377 if [ "$(facet_fstype ost1)" = "zfs" ]; then
378 FSXNUM=$((COUNT / 5))
380 elif [ "$SLOW" = "yes" ]; then
381 FSXNUM=$((COUNT * 5))
389 local file1=$DIR1/$tfile
390 local file2=$DIR2/$tfile
391 local stripe_size=$(do_facet $SINGLEMDS \
392 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
394 # to allocate grant because it may run out due to test_15.
395 $LFS setstripe -c -1 $file1
396 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
397 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
400 $LFS setstripe -c -1 $file1 # b=10919
401 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
402 || error "fsx failed"
405 # O_DIRECT reads and writes must be aligned to the device block size.
406 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
407 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
409 run_test 16a "$FSXNUM iterations of dual-mount fsx"
411 # Consistency check for tiny writes, LU-9409
413 local file1=$DIR1/$tfile
414 local file2=$DIR2/$tfile
416 # to allocate grant because it may run out due to test_15.
417 lfs setstripe -c -1 $file1
418 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
419 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
422 lfs setstripe -c -1 $file1 # b=10919
423 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
424 # create a mix of tiny writes & normal writes
425 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
428 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
430 test_17() { # bug 3513, 3667
431 remote_ost_nodsh && skip "remote OST with nodsh" && return
433 lfs setstripe $DIR1/$tfile -i 0 -c 1
434 cp $SAMPLE_FILE $DIR1/$tfile
435 cancel_lru_locks osc > /dev/null
436 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
437 do_facet ost1 lctl set_param fail_loc=0x8000030a
438 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
439 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
441 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
443 run_test 17 "resource creation/LVB creation race ==============="
446 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
449 for idx in {a..z}; do
450 local ptr=EXCEPT_ALWAYS_18$idx
451 [ x${!ptr} = xtrue ] || continue
453 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
456 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
459 run_test 18 "mmap sanity check ================================="
461 test_19() { # bug3811
462 local node=$(facet_active_host ost1)
464 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
466 # check whether obdfilter is cache capable at all
467 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
468 echo "not cache-capable obdfilter"
472 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
474 set_osd_param $node '' readcache_max_filesize 4096
475 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
476 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
477 cp $TMP/$tfile $DIR1/$tfile
478 for i in `seq 1 20`; do
479 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
480 cancel_lru_locks $OSC > /dev/null
481 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
482 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
484 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
485 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
486 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
487 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
489 set_osd_param $node '' readcache_max_filesize $MAX
492 run_test 19 "test concurrent uncached read races ==============="
496 cancel_lru_locks $OSC
497 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
498 $MULTIOP $DIR1/f20 Ow8190c
499 $MULTIOP $DIR2/f20 Oz8194w8190c
500 $MULTIOP $DIR1/f20 Oz0r8190c
501 cancel_lru_locks $OSC
502 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
504 error $CNTD" page left in cache after lock cancel" || true
506 run_test 20 "test extra readahead page left in cache ===="
513 test_21() { # Bug 5907
514 test_mkdir $DIR1/$tdir
515 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
517 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
518 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
519 test -d $DIR1/$tdir || error "Mounted directory disappeared"
521 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
524 run_test 21 " Try to remove mountpoint on another dir ===="
526 test_23() { # Bug 5972
527 local at_diff=$(do_facet $SINGLEMDS \
528 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
529 echo "atime should be updated while another read" > $DIR1/$tfile
531 # clear the lock(mode: LCK_PW) gotten from creating operation
532 cancel_lru_locks $OSC
535 sleep $((at_diff + 1))
537 echo "starting reads"
538 multiop_bg_pause $DIR1/$tfile or20_c || return 1
539 # with SOM and opencache enabled, we need to close a file and cancel
540 # open lock to get atime propogated to MDS
541 kill -USR1 $! || return 2
544 time2=$(stat -c "%X" $DIR/$tfile)
545 echo "new atime is $time2"
547 [ $time2 -gt $time1 ] || error "atime was not updated"
548 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
551 run_test 23 " others should see updated atime while another read===="
555 lfs df || error "lfs df failed"
556 lfs df -ih || error "lfs df -ih failed"
557 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
558 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
559 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
560 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
562 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
563 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
564 lctl --device %osc deactivate
565 lfs df -i || error "lfs df -i with deactivated OSC failed"
566 lctl --device %osc activate
567 lfs df || error "lfs df with reactivated OSC failed"
569 run_test 24a "lfs df [-ih] [path] test ========================="
573 fsnum=$(lfs_df | grep -c "summary")
574 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
576 run_test 24b "lfs df should show both filesystems ==============="
579 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
581 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
584 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
585 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
587 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
588 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
589 error "setfacl $DIR2/$tdir #1"
590 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
591 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
592 error "setfacl $DIR2/$tdir #2"
593 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
594 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
595 error "setfacl $DIR2/$tdir #3"
596 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
597 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
598 error "setfacl $DIR2/$tdir #4"
599 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
603 run_test 25a "change ACL on one mountpoint be seen on another ==="
606 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
608 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
610 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
613 $LFS mkdir -i 1 $DIR1/$tdir
614 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
615 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
617 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
618 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
619 error "setfacl $DIR2/$tdir #1"
620 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
621 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
622 error "setfacl $DIR2/$tdir #2"
623 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
624 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
625 error "setfacl $DIR2/$tdir #3"
626 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
627 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
628 error "setfacl $DIR2/$tdir #4"
629 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
633 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
636 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
638 run_test 26a "allow mtime to get older"
643 echo "aaa" >> $DIR1/$tfile
645 chmod a+x $DIR2/$tfile
646 mt1=`stat -c %Y $DIR1/$tfile`
647 mt2=`stat -c %Y $DIR2/$tfile`
649 if [ x"$mt1" != x"$mt2" ]; then
650 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
653 run_test 26b "sync mtime between ost and mds"
656 cancel_lru_locks $OSC
658 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
663 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
668 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
670 lctl set_param -n ldlm.dump_namespaces ""
671 wait $DD1_PID $DD2_PID
672 [ $? -ne 0 ] && lctl dk $TMP/debug || true
674 run_test 27 "align non-overlapping extent locks from request ==="
676 test_28() { # bug 9977
677 ECHO_UUID="ECHO_osc1_UUID"
678 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
680 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
681 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
682 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
686 attach echo_client ECHO_osc1 $ECHO_UUID
690 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
691 $LCTL --device $tECHOID destroy "${tOBJID}:0"
699 # reading of 1st stripe should pass
700 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
701 # reading of 2nd stripe should fail (this stripe was destroyed)
702 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
704 # now, recreating test file
705 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
706 # reading of 1st stripe should pass
707 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
708 # reading of 2nd stripe should pass
709 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
712 run_test 28 "read/write/truncate file with lost stripes"
714 test_30() { #b=11110, LU-2523
715 test_mkdir $DIR1/$tdir
716 cp -f /bin/bash $DIR1/$tdir/bash
717 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
718 $DIR1/$tdir/bash -c 'sleep 2;
719 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
723 run_test 30 "recreate file race"
726 test_mkdir $DIR1/$tdir
727 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
728 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
729 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
730 lctl set_param fail_loc=0x314
731 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
732 awk 'BEGIN { FS="+" } /in/ {print $1}')
733 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
735 run_test 31a "voluntary cancel / blocking ast race=============="
738 remote_ost || { skip "local OST" && return 0; }
739 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
741 # make sure there is no local locks due to destroy
742 wait_mds_ost_sync || error "wait_mds_ost_sync()"
743 wait_delete_completed || error "wait_delete_completed()"
745 test_mkdir $DIR1/$tdir
746 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
747 cp /etc/hosts $DIR/$tdir/$tfile
748 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
749 lctl set_param fail_loc=0x314
750 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
751 do_facet ost1 lctl set_param fail_loc=0x316
753 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
754 lctl set_param fail_loc=0
755 do_facet ost1 lctl set_param fail_loc=0
756 # cleanup: reconnect the client back
759 run_test 31b "voluntary OST cancel / blocking ast race=============="
761 # enable/disable lockless truncate feature, depending on the arg 0/1
762 enable_lockless_truncate() {
763 lctl set_param -n $OSC.*.lockless_truncate $1
766 test_32a() { # bug 11270
767 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
768 local stripe_size=$(do_facet $SINGLEMDS \
769 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
771 save_lustre_params client "$OSC.*.lockless_truncate" > $p
772 cancel_lru_locks $OSC
773 enable_lockless_truncate 1
775 lfs setstripe -c -1 $DIR1/$tfile
776 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
778 clear_stats $OSC.*.${OSC}_stats
780 log "checking cached lockless truncate"
781 $TRUNCATE $DIR1/$tfile 8000000
782 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
783 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
784 error "cached truncate isn't lockless"
786 log "checking not cached lockless truncate"
787 $TRUNCATE $DIR2/$tfile 5000000
788 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
789 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
790 error "not cached truncate isn't lockless"
792 log "disabled lockless truncate"
793 enable_lockless_truncate 0
794 clear_stats $OSC.*.${OSC}_stats
795 $TRUNCATE $DIR2/$tfile 3000000
796 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
797 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
798 error "lockless truncate disabling failed"
800 # restore lockless_truncate default values
801 restore_lustre_params < $p
804 run_test 32a "lockless truncate"
806 test_32b() { # bug 11270
807 remote_ost_nodsh && skip "remote OST with nodsh" && return
810 local facets=$(get_facets OST)
811 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
813 save_lustre_params client "osc.*.contention_seconds" > $p
814 save_lustre_params $facets \
815 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
816 save_lustre_params $facets \
817 "ldlm.namespaces.filter-*.contended_locks" >> $p
818 save_lustre_params $facets \
819 "ldlm.namespaces.filter-*.contention_seconds" >> $p
820 clear_stats $OSC.*.${OSC}_stats
822 # agressive lockless i/o settings
823 do_nodes $(comma_list $(osts_nodes)) \
824 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
825 ldlm.namespaces.filter-*.contended_locks=0 \
826 ldlm.namespaces.filter-*.contention_seconds=60"
827 lctl set_param -n $OSC.*.contention_seconds=60
829 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
831 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
834 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
835 error "lockless i/o was not triggered"
836 # disable lockless i/o (it is disabled by default)
837 do_nodes $(comma_list $(osts_nodes)) \
838 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
839 ldlm.namespaces.filter-*.contended_locks=32 \
840 ldlm.namespaces.filter-*.contention_seconds=0"
841 # set contention_seconds to 0 at client too, otherwise Lustre still
842 # remembers lock contention
843 lctl set_param -n $OSC.*.contention_seconds=0
844 clear_stats $OSC.*.${OSC}_stats
846 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
848 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
851 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
852 error "lockless i/o works when disabled"
854 restore_lustre_params <$p
857 run_test 32b "lockless i/o"
861 local mdts=$(get_facets MDS)
866 for mds in ${mdts//,/ }; do
868 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
869 xargs readlink -f" ))
870 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
873 stat=$(( stat + val))
878 # commit on sharing tests
880 remote_mds_nodsh && skip "remote MDS with nodsh" && return
882 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
883 [ $CLIENTCOUNT -lt 2 ] &&
884 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
886 local nfiles=${TEST33_NFILES:-10000}
887 local param_file=$TMP/$tfile-params
888 local fstype=$(facet_fstype $SINGLEMDS)
890 save_lustre_params $(get_facets MDS) \
891 "mdt.*.commit_on_sharing" > $param_file
899 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
903 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
905 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
906 echo "=== START createmany old: $jbdold transaction"
907 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")
908 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
909 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
910 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
911 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
912 avgtime=$(( avgtime + elapsed ))
914 eval cos${COS}_jbd=$((avgjbd / 3))
915 eval cos${COS}_time=$((avgtime / 3))
918 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
919 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
920 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
921 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
923 restore_lustre_params < $param_file
927 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
929 # commit on sharing tests
931 remote_mds_nodsh && skip "remote MDS with nodsh" && return
933 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
934 [ $CLIENTCOUNT -ge 2 ] ||
935 { skip "Need two or more clients, have $CLIENTCOUNT" &&
937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
939 local nfiles=${TEST33_NFILES:-10000}
940 local param_file=$TMP/$tfile-params
942 save_lustre_params $(get_facets MDS) \
943 "mdt.*.commit_on_sharing" > $param_file
952 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
956 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
957 $DIR1/$tdir-\\\$(hostname)-$i"
959 jbdold=$(print_jbd_stat)
960 echo "=== START createmany old: $jbdold transaction"
961 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
962 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
963 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
965 jbdnew=$(print_jbd_stat)
966 jbd=$(( jbdnew - jbdold ))
967 echo "=== END createmany new: $jbdnew transaction : \
968 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
969 avgjbd=$(( avgjbd + jbd ))
970 avgtime=$(( avgtime + elapsed ))
972 eval cos${COS}_jbd=$((avgjbd / 3))
973 eval cos${COS}_time=$((avgtime / 3))
976 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
977 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
978 [ "$cos0_jbd" != 0 ] &&
979 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
980 [ "$cos0_time" != 0 ] &&
981 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
983 restore_lustre_params < $param_file
987 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
990 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
991 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
992 skip "DNE CoS not supported" && return
997 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
998 $LFS mkdir -i 1 $DIR/$tdir/d1
999 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1001 local sync_count=$(do_facet mds1 \
1002 "lctl get_param -n mdt.*MDT0000.sync_count")
1003 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
1005 $LFS mkdir -i 1 $DIR/$tdir/d3
1006 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1007 # during sleep remote mkdir should have been committed and canceled
1008 # remote lock spontaneously, which shouldn't trigger sync
1011 local sync_count=$(do_facet mds1 \
1012 "lctl get_param -n mdt.*MDT0000.sync_count")
1013 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1015 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1018 local nodes=$(comma_list $(mdts_nodes))
1019 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1021 local async_commit_count=$(do_nodes $nodes \
1022 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1023 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
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
1035 # remote directory create
1037 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1038 # remote directory unlink
1039 $LFS mkdir -i 1 $DIR/$tdir
1040 ops_do_cos "rmdir $DIR/$tdir"
1041 # striped directory create
1043 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1044 # striped directory setattr
1045 $LFS mkdir -c 2 $DIR/$tdir
1047 ops_do_cos "chmod 713 $DIR/$tdir"
1048 # striped directory unlink
1049 $LFS mkdir -c 2 $DIR/$tdir
1051 ops_do_cos "rmdir $DIR/$tdir"
1053 $LFS mkdir -c 2 $DIR/$tdir
1054 $LFS mkdir -i 0 $DIR/$tdir/d1
1055 $LFS mkdir -i 1 $DIR/$tdir/d2
1056 touch $DIR/$tdir/d1/tgt
1057 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1059 $LFS mkdir -c 2 $DIR/$tdir
1060 $LFS mkdir -i 0 $DIR/$tdir/d1
1061 $LFS mkdir -i 1 $DIR/$tdir/d2
1062 touch $DIR/$tdir/d1/src
1063 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1065 $LFS mkdir -i 0 $DIR/$tdir
1066 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1069 run_test 33d "DNE distributed operation should trigger COS"
1072 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1073 [ $CLIENTCOUNT -ge 2 ] ||
1074 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1076 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1077 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1078 skip "DNE CoS not supported" && return
1080 local client2=${CLIENT2:-$(hostname)}
1084 local nodes=$(comma_list $(mdts_nodes))
1085 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1087 $LFS mkdir -c 2 $DIR/$tdir
1088 mkdir $DIR/$tdir/subdir
1089 echo abc > $DIR/$tdir/$tfile
1090 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1091 do_node $client2 touch $DIR/$tdir/subdir
1093 local async_commit_count=$(do_nodes $nodes \
1094 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1095 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1099 run_test 33e "DNE local operation shouldn't trigger COS"
1101 # End commit on sharing tests
1103 get_ost_lock_timeouts() {
1104 local nodes=${1:-$(comma_list $(osts_nodes))}
1106 local locks=$(do_nodes $nodes \
1107 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1115 do_nodes $(comma_list $(osts_nodes)) \
1116 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1117 for i in $(seq $OSTCOUNT); do
1118 wait_osc_import_state client ost$i FULL
1123 remote_ost_nodsh && skip "remote OST with nodsh" && return
1127 trap cleanup_34 EXIT RETURN
1128 for OPER in notimeout timeout ; do
1129 rm $DIR1/$tfile 2>/dev/null
1130 lock_in=$(get_ost_lock_timeouts)
1131 if [ $OPER == "timeout" ] ; then
1132 for j in `seq $OSTCOUNT`; do
1133 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1134 do_facet ost$j lctl set_param fail_loc=0x511
1136 echo lock should expire
1138 for j in `seq $OSTCOUNT`; do
1139 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1140 do_facet ost$j lctl set_param fail_loc=0x512
1142 echo lock should not expire
1144 echo writing on client1
1145 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1147 echo reading on client2
1148 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1149 # wait for a lock timeout
1151 lock_out=$(get_ost_lock_timeouts)
1152 if [ $OPER == "timeout" ] ; then
1153 if [ $lock_in == $lock_out ]; then
1154 error "no lock timeout happened"
1159 if [ $lock_in != $lock_out ]; then
1160 error "lock timeout happened"
1168 run_test 34 "no lock timeout under IO"
1170 test_35() { # bug 17645
1173 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1174 awk '/generation/{print $2}')
1176 generation[count]=$g
1180 test_mkdir $MOUNT1/$tdir
1181 cancel_lru_locks mdc
1183 # Let's initiate -EINTR situation by setting fail_loc and take
1184 # write lock on same file from same client. This will not cause
1185 # bl_ast yet as lock is already in local cache.
1186 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1187 do_facet client "lctl set_param fail_loc=0x80000317"
1188 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1189 let timeout=timeout*3
1191 while test $nr -lt 10; do
1192 log "Race attempt $nr"
1193 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1194 awk '/ldlm_bl_callback/ { print $2 }')
1195 test "x$blk1" = "x" && blk1=0
1196 createmany -o $MOUNT2/$tdir/a 4000 &
1200 # Let's make conflict and bl_ast
1201 ls -la $MOUNT1/$tdir > /dev/null &
1204 log "Wait for $pid1 $pid2 for $timeout sec..."
1206 kill -9 $pid1 $pid2 > /dev/null 2>&1
1208 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1209 awk '/ldlm_bl_callback/ { print $2 }')
1210 test "x$blk2" = "x" && blk2=0
1211 test $blk2 -gt $blk1 && break
1212 rm -fr $MOUNT1/$tdir
1213 cancel_lru_locks mdc
1216 do_facet client "lctl set_param fail_loc=0x0"
1217 df -h $MOUNT1 $MOUNT2
1219 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1220 awk '/generation/{print $2}')
1222 if ! test "$g" -eq "${generation[count]}"; then
1223 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1225 for imp in $list; do
1226 if [ $c = $count ]; then
1231 imp=$(echo "$imp" | awk -F"." '{print $2}')
1232 error "Eviction happened on import $imp"
1237 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1239 test_36() { #bug 16417
1244 test_mkdir $DIR1/$tdir
1245 $LFS setstripe -c -1 $DIR1/$tdir
1248 let SIZE_B=SIZE*1024*1024
1249 sync; sleep 2; sync # wait for delete thread
1250 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1251 wait_destroy_complete || error "wait_destroy_complete failed"
1253 while [ $i -le 10 ]; do
1254 lctl mark "start test - cycle ($i)"
1255 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1256 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1257 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1258 sync # sync data from client cache
1259 sync_all_data # sync data from server cache (delayed allocation)
1261 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1262 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1264 rm -f $DIR1/$tdir/$tfile
1265 kill -USR1 $read_pid
1267 sync; sleep 2; sync # Ensure new statfs
1268 wait_delete_completed
1269 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1270 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1272 # this free space! not used
1273 (( $after_dd <= $after)) ||
1274 error "space leaked after_dd:$after_dd > after:$after"
1278 run_test 36 "handle ESTALE/open-unlink correctly"
1280 test_37() { # bug 18695
1281 test_mkdir $DIR1/$tdir
1282 multiop_bg_pause $DIR1/$tdir D_c || return 1
1284 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1285 createmany -m $DIR2/$tdir/f 10000
1286 # set mtime/atime backward
1287 touch -t 198001010000 $DIR2/$tdir
1288 kill -USR1 $MULTIPID
1289 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1290 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1293 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1295 # this should be set to past
1296 TEST_39_MTIME=`date -d "1 year ago" +%s`
1300 local client1=${CLIENT1:-`hostname`}
1301 local client2=${CLIENT2:-`hostname`}
1303 do_node $client1 "touch $DIR1/$tfile"
1305 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1306 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1307 [ "$mtime1" = $TEST_39_MTIME ] || \
1308 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1310 local d1=`do_node $client1 date +%s`
1311 do_node $client1 'echo hello >> '$DIR1/$tfile
1312 local d2=`do_node $client1 date +%s`
1314 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1315 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1316 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1318 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1320 for (( i=0; i < 2; i++ )) ; do
1321 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1322 [ "$mtime2" = "$mtime3" ] || \
1323 error "mtime ($mtime2) changed (to $mtime3) on rename"
1325 cancel_lru_locks osc
1326 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1329 run_test 39a "test from 11063 =================================="
1332 local client1=${CLIENT1:-`hostname`}
1333 local client2=${CLIENT2:-`hostname`}
1337 local mtime1=`stat -c %Y $DIR1/$tfile`
1338 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1341 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1343 for (( i=0; i < 2; i++ )) ; do
1344 local mtime3=`stat -c %Y $DIR1/$tfile`
1345 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1347 [ "$mtime3" = "$mtime4" ] || \
1348 error "different mtime on clients: $mtime3, $mtime4"
1349 [ "$mtime3" = $TEST_39_MTIME ] || \
1350 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1352 cancel_lru_locks osc
1353 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1356 run_test 39b "11063 problem 1 =================================="
1359 local client1=${CLIENT1:-`hostname`}
1360 local client2=${CLIENT2:-`hostname`}
1362 echo hello > $DIR1/$tfile
1364 local mtime1=`stat -c %Y $DIR1/$tfile`
1365 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1366 [ "$mtime1" = "$mtime2" ] || \
1367 error "create: different mtime on clients: $mtime1, $mtime2"
1370 $TRUNCATE $DIR1/$tfile 1
1372 for (( i=0; i < 2; i++ )) ; do
1373 local mtime3=`stat -c %Y $DIR1/$tfile`
1374 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1376 [ "$mtime3" = "$mtime4" ] || \
1377 error "different mtime on clients: $mtime3, $mtime4"
1378 [ "$mtime3" -gt $mtime2 ] || \
1379 error "truncate did not update mtime: $mtime2, $mtime3"
1381 cancel_lru_locks osc
1382 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1385 run_test 39c "check truncate mtime update ======================"
1387 test_39d() { # LU-7310
1389 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1391 local mtime1=$(stat -c %Y $DIR2/$tfile)
1392 [ "$mtime1" = $TEST_39_MTIME ] ||
1393 error "mtime: $mtime1, should be $TEST_39_MTIME"
1396 # define OBD_FAIL_OSC_NO_GRANT 0x411
1397 $LCTL set_param fail_loc=0x411
1399 local d1=$(date +%s)
1400 echo hello >> $DIR1/$tfile
1401 local d2=$(date +%s)
1403 $LCTL set_param fail_loc=0
1405 cancel_lru_locks $OSC
1407 local mtime2=$(stat -c %Y $DIR2/$tfile)
1408 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1409 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1411 run_test 39d "sync write should update mtime"
1413 # check that pid exists hence second operation wasn't blocked by first one
1414 # if it is so then there is no conflict, return 0
1415 # else second operation is conflicting with first one, return 1
1416 check_pdo_conflict() {
1419 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1420 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1430 # test 40: check non-blocking operations
1432 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1433 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1434 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1436 mkdir $DIR1/$tfile &
1439 touch $DIR2/$tfile-2
1440 check_pdo_conflict $PID1 || error "create is blocked"
1441 mkdir $DIR2/$tfile-3
1442 check_pdo_conflict $PID1 || error "mkdir is blocked"
1443 link $DIR2/$tfile-2 $DIR2/$tfile-4
1444 check_pdo_conflict $PID1 || error "link is blocked"
1445 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1446 check_pdo_conflict $PID1 || error "rename is blocked"
1447 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1448 check_pdo_conflict $PID1 || error "getattr is blocked"
1449 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1450 rmdir $DIR2/$tfile-3
1451 check_pdo_conflict $PID1 || error "unlink is blocked"
1453 # all operations above shouldn't wait the first one
1454 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1459 run_test 40a "pdirops: create vs others =============="
1462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1463 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1464 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1465 touch $DIR1/$tfile &
1469 touch $DIR2/$tfile-2
1470 check_pdo_conflict $PID1 || error "create is blocked"
1471 mkdir $DIR2/$tfile-3
1472 check_pdo_conflict $PID1 || error "mkdir is blocked"
1473 link $DIR2/$tfile-2 $DIR2/$tfile-4
1474 check_pdo_conflict $PID1 || error "link is blocked"
1475 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1476 check_pdo_conflict $PID1 || error "rename is blocked"
1477 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1478 check_pdo_conflict $PID1 || error "getattr is blocked"
1479 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1480 rmdir $DIR2/$tfile-3
1481 check_pdo_conflict $PID1 || error "unlink is blocked"
1482 # all operations above shouldn't wait the first one
1484 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1489 run_test 40b "pdirops: open|create and others =============="
1492 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1494 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1495 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1496 link $DIR1/$tfile $DIR1/$tfile-0 &
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"
1520 run_test 40c "pdirops: link and others =============="
1523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1526 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
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"
1545 # all operations above shouldn't wait the first one
1546 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1550 run_test 40d "pdirops: unlink and others =============="
1553 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1555 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1556 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1557 mv $DIR1/$tfile $DIR1/$tfile-0 &
1561 touch $DIR2/$tfile-2
1562 check_pdo_conflict $PID1 || error "create is blocked"
1563 mkdir $DIR2/$tfile-3
1564 check_pdo_conflict $PID1 || error "mkdir is blocked"
1565 link $DIR2/$tfile-2 $DIR2/$tfile-4
1566 check_pdo_conflict $PID1 || error "link is blocked"
1567 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1568 check_pdo_conflict $PID1 || error "getattr is blocked"
1569 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1570 rmdir $DIR2/$tfile-3
1571 check_pdo_conflict $PID1 || error "unlink is blocked"
1573 # all operations above shouldn't wait the first one
1574 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1579 run_test 40e "pdirops: rename and others =============="
1581 # test 41: create blocking operations
1583 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1584 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1585 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1588 mkdir $DIR2/$tfile && error "mkdir must fail"
1589 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1593 run_test 41a "pdirops: create vs mkdir =============="
1596 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1597 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1598 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1601 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1602 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1606 run_test 41b "pdirops: create vs create =============="
1609 touch $DIR1/$tfile-2
1610 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1611 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1612 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1615 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1616 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1620 run_test 41c "pdirops: create vs link =============="
1623 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1624 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1625 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1628 rm $DIR2/$tfile || error "unlink must succeed"
1629 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1633 run_test 41d "pdirops: create vs unlink =============="
1636 touch $DIR1/$tfile-2
1637 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1638 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1639 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1642 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1643 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1647 run_test 41e "pdirops: create and rename (tgt) =============="
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 &
1655 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1656 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1660 run_test 41f "pdirops: create and rename (src) =============="
1663 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1664 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1665 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1668 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1669 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1673 run_test 41g "pdirops: create vs getattr =============="
1676 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1677 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1678 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1681 ls -lia $DIR2/ > /dev/null
1682 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1686 run_test 41h "pdirops: create vs readdir =============="
1688 # test 42: unlink and blocking operations
1690 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1691 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1692 mkdir $DIR1/$tfile &
1695 mkdir $DIR2/$tfile && error "mkdir must fail"
1696 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1700 run_test 42a "pdirops: mkdir vs mkdir =============="
1703 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1704 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1705 mkdir $DIR1/$tfile &
1708 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1709 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1713 run_test 42b "pdirops: mkdir vs create =============="
1716 touch $DIR1/$tfile-2
1717 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1718 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1719 mkdir $DIR1/$tfile &
1722 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1723 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1727 run_test 42c "pdirops: mkdir vs link =============="
1730 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1731 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1732 mkdir $DIR1/$tfile &
1735 rmdir $DIR2/$tfile || error "unlink must succeed"
1736 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1740 run_test 42d "pdirops: mkdir vs unlink =============="
1743 touch $DIR1/$tfile-2
1744 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1745 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1746 mkdir $DIR1/$tfile &
1749 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1750 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1754 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1757 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1758 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1759 mkdir $DIR1/$tfile &
1762 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1763 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1767 run_test 42f "pdirops: mkdir and rename (src) =============="
1770 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1771 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1772 mkdir $DIR1/$tfile &
1775 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1776 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1780 run_test 42g "pdirops: mkdir vs getattr =============="
1783 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1784 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1785 mkdir $DIR1/$tfile &
1788 ls -lia $DIR2/ > /dev/null
1789 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1793 run_test 42h "pdirops: mkdir vs readdir =============="
1795 # test 43: unlink and blocking operations
1798 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1799 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1803 mkdir $DIR2/$tfile || error "mkdir must succeed"
1804 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1808 run_test 43a "pdirops: unlink vs mkdir =============="
1812 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1813 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1817 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1818 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1822 run_test 43b "pdirops: unlink vs create =============="
1826 touch $DIR1/$tfile-2
1827 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1828 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1832 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1833 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1837 run_test 43c "pdirops: unlink vs link =============="
1841 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1842 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1846 rm $DIR2/$tfile && error "unlink must fail"
1847 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1851 run_test 43d "pdirops: unlink vs unlink =============="
1855 touch $DIR1/$tfile-2
1856 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1857 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1861 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1862 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1866 run_test 43e "pdirops: unlink and rename (tgt) =============="
1870 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1871 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1875 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1876 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1880 run_test 43f "pdirops: unlink and rename (src) =============="
1884 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1885 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1889 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1890 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1894 run_test 43g "pdirops: unlink vs getattr =============="
1898 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1899 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1903 ls -lia $DIR2/ > /dev/null
1904 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1908 run_test 43h "pdirops: unlink vs readdir =============="
1911 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1913 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1914 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1918 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1919 check_pdo_conflict $PID1 &&
1920 { wait $PID1; error "remote mkdir isn't blocked"; }
1924 run_test 43i "pdirops: unlink vs remote mkdir"
1926 # test 44: rename tgt and blocking operations
1928 touch $DIR1/$tfile-2
1929 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1930 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1931 mv $DIR1/$tfile-2 $DIR1/$tfile &
1934 mkdir $DIR2/$tfile && error "mkdir must fail"
1935 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1939 run_test 44a "pdirops: rename tgt vs mkdir =============="
1942 touch $DIR1/$tfile-2
1943 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1944 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1945 mv $DIR1/$tfile-2 $DIR1/$tfile &
1948 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1949 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1953 run_test 44b "pdirops: rename tgt vs create =============="
1956 touch $DIR1/$tfile-2
1957 touch $DIR1/$tfile-3
1958 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1959 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1960 mv $DIR1/$tfile-2 $DIR1/$tfile &
1963 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1964 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1968 run_test 44c "pdirops: rename tgt vs link =============="
1971 touch $DIR1/$tfile-2
1972 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1973 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1974 mv $DIR1/$tfile-2 $DIR1/$tfile &
1977 rm $DIR2/$tfile || error "unlink must succeed"
1978 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1982 run_test 44d "pdirops: rename tgt vs unlink =============="
1986 touch $DIR1/$tfile-2
1987 touch $DIR1/$tfile-3
1988 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1990 mv $DIR1/$tfile-2 $DIR1/$tfile &
1993 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1994 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1998 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2001 touch $DIR1/$tfile-2
2002 touch $DIR1/$tfile-3
2003 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2004 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2005 mv $DIR1/$tfile-2 $DIR1/$tfile &
2008 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2009 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2013 run_test 44f "pdirops: rename tgt and rename (src) =============="
2016 touch $DIR1/$tfile-2
2017 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2018 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2019 mv $DIR1/$tfile-2 $DIR1/$tfile &
2022 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2023 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2027 run_test 44g "pdirops: rename tgt vs getattr =============="
2030 touch $DIR1/$tfile-2
2031 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2032 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2033 mv $DIR1/$tfile-2 $DIR1/$tfile &
2036 ls -lia $DIR2/ > /dev/null
2037 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2041 run_test 44h "pdirops: rename tgt vs readdir =============="
2043 # test 44: rename tgt and blocking operations
2045 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2046 touch $DIR1/$tfile-2
2047 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2048 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2049 mv $DIR1/$tfile-2 $DIR1/$tfile &
2052 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2053 check_pdo_conflict $PID1 && { wait $PID1;
2054 error "remote mkdir isn't blocked"; }
2058 run_test 44i "pdirops: rename tgt vs remote mkdir"
2060 # test 45: rename src and blocking operations
2063 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2064 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2065 mv $DIR1/$tfile $DIR1/$tfile-2 &
2068 mkdir $DIR2/$tfile || error "mkdir must succeed"
2069 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2073 run_test 45a "pdirops: rename src vs mkdir =============="
2077 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2078 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2079 mv $DIR1/$tfile $DIR1/$tfile-2 &
2082 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2083 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2087 run_test 45b "pdirops: rename src vs create =============="
2091 touch $DIR1/$tfile-3
2092 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2093 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2094 mv $DIR1/$tfile $DIR1/$tfile-2 &
2097 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2098 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2102 run_test 45c "pdirops: rename src vs link =============="
2106 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2107 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2108 mv $DIR1/$tfile $DIR1/$tfile-2 &
2111 rm $DIR2/$tfile && error "unlink must fail"
2112 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2116 run_test 45d "pdirops: rename src vs unlink =============="
2120 touch $DIR1/$tfile-3
2121 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2122 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2123 mv $DIR1/$tfile $DIR1/$tfile-2 &
2126 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2127 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2131 run_test 45e "pdirops: rename src and rename (tgt) =============="
2135 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2136 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2137 mv $DIR1/$tfile $DIR1/$tfile-2 &
2140 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2141 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2145 run_test 45f "pdirops: rename src and rename (src) =============="
2149 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2150 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2151 mv $DIR1/$tfile $DIR1/$tfile-2 &
2154 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2155 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2159 run_test 45g "pdirops: rename src vs getattr =============="
2163 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2164 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2165 mv $DIR1/$tfile $DIR1/$tfile-2 &
2168 ls -lia $DIR2/ > /dev/null
2169 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2173 run_test 45h "pdirops: unlink vs readdir =============="
2176 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2178 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2179 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2180 mv $DIR1/$tfile $DIR1/$tfile-2 &
2183 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2184 check_pdo_conflict $PID1 && { wait $PID1;
2185 error "create remote dir isn't blocked"; }
2189 run_test 45i "pdirops: rename src vs remote mkdir"
2191 # test 46: link and blocking operations
2193 touch $DIR1/$tfile-2
2194 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2195 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2196 link $DIR1/$tfile-2 $DIR1/$tfile &
2199 mkdir $DIR2/$tfile && error "mkdir must fail"
2200 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2204 run_test 46a "pdirops: link vs mkdir =============="
2207 touch $DIR1/$tfile-2
2208 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2209 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2210 link $DIR1/$tfile-2 $DIR1/$tfile &
2213 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2214 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2218 run_test 46b "pdirops: link vs create =============="
2221 touch $DIR1/$tfile-2
2222 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2223 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2224 link $DIR1/$tfile-2 $DIR1/$tfile &
2227 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2228 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2232 run_test 46c "pdirops: link vs link =============="
2235 touch $DIR1/$tfile-2
2236 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2237 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2238 link $DIR1/$tfile-2 $DIR1/$tfile &
2241 rm $DIR2/$tfile || error "unlink must succeed"
2242 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2246 run_test 46d "pdirops: link vs unlink =============="
2249 touch $DIR1/$tfile-2
2250 touch $DIR1/$tfile-3
2251 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2252 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2253 link $DIR1/$tfile-2 $DIR1/$tfile &
2256 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2257 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2261 run_test 46e "pdirops: link and rename (tgt) =============="
2264 touch $DIR1/$tfile-2
2265 touch $DIR1/$tfile-3
2266 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2267 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2268 link $DIR1/$tfile-2 $DIR1/$tfile &
2271 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2272 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2276 run_test 46f "pdirops: link and rename (src) =============="
2279 touch $DIR1/$tfile-2
2280 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2281 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2282 link $DIR1/$tfile-2 $DIR1/$tfile &
2285 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2286 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2290 run_test 46g "pdirops: link vs getattr =============="
2293 touch $DIR1/$tfile-2
2294 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2295 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2296 link $DIR1/$tfile-2 $DIR1/$tfile &
2299 ls -lia $DIR2/ > /dev/null
2300 check_pdo_conflict $PID1 && { wait $PID1;
2301 error "readdir isn't blocked"; }
2305 run_test 46h "pdirops: link vs readdir =============="
2308 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2309 touch $DIR1/$tfile-2
2310 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2311 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2312 link $DIR1/$tfile-2 $DIR1/$tfile &
2315 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2316 check_pdo_conflict $PID1 && { wait $PID1;
2317 error "remote mkdir isn't blocked"; }
2321 run_test 46i "pdirops: link vs remote mkdir"
2323 # test 47: remote mkdir and blocking operations
2325 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2326 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2327 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2328 $LFS mkdir -i 1 $DIR1/$tfile &
2331 mkdir $DIR2/$tfile && error "mkdir must fail"
2332 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2336 run_test 47a "pdirops: remote mkdir vs mkdir"
2339 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2340 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2341 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2342 $LFS mkdir -i 1 $DIR1/$tfile &
2345 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2346 check_pdo_conflict $PID1 && { wait $PID1;
2347 error "create isn't blocked"; }
2351 run_test 47b "pdirops: remote mkdir vs create"
2354 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2355 touch $DIR1/$tfile-2
2356 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2357 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2358 $LFS mkdir -i 1 $DIR1/$tfile &
2361 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2362 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2366 run_test 47c "pdirops: remote mkdir vs link"
2369 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2370 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2371 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2372 $LFS mkdir -i 1 $DIR1/$tfile &
2375 rmdir $DIR2/$tfile || error "unlink must succeed"
2376 check_pdo_conflict $PID1 && { wait $PID1;
2377 error "unlink isn't blocked"; }
2381 run_test 47d "pdirops: remote mkdir vs unlink"
2384 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2385 touch $DIR1/$tfile-2
2386 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2387 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2388 $LFS mkdir -i 1 $DIR1/$tfile &
2391 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2392 check_pdo_conflict $PID1 && { wait $PID1;
2393 error "rename isn't blocked"; }
2397 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2400 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2401 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2402 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2403 $LFS mkdir -i 1 $DIR1/$tfile &
2406 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2407 check_pdo_conflict $PID1 && { wait $PID1;
2408 error "rename isn't blocked"; }
2412 run_test 47f "pdirops: remote mkdir and rename (src)"
2415 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2417 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2418 $LFS mkdir -i 1 $DIR1/$tfile &
2421 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2422 check_pdo_conflict $PID1 && { wait $PID1;
2423 error "getattr isn't blocked"; }
2427 run_test 47g "pdirops: remote mkdir vs getattr"
2431 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2432 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2433 do_facet client "lctl set_param fail_loc=0x410"
2434 $TRUNCATE $DIR2/$tfile $trunc_size
2435 do_facet client "lctl set_param fail_loc=0x0"
2437 size=`stat -c %s $DIR2/$tfile`
2438 [ $size -eq $trunc_size ] || error "wrong size"
2440 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2444 local origfile=/etc/hosts
2446 filesize=$(stat -c %s $origfile)
2448 # create an empty file
2449 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2450 # cache layout lock on both mount point
2451 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2452 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2454 # open and sleep 2 seconds then read
2455 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2459 # create the layout of testing file
2460 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2461 error "dd $DIR1/$tfile failed"
2463 # MULTIOP proc should be able to read enough bytes and exit
2464 for ((i = 0; i < 6; i++)); do
2466 kill -0 $pid || break
2468 kill -0 $pid 2> /dev/null && error "multiop is still there"
2469 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2473 run_test 51a "layout lock: refresh layout should work"
2476 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2477 { skip "Need MDS version at least 2.3.59"; return 0; }
2479 local tmpfile=`mktemp`
2481 # create an empty file
2482 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2484 # delay glimpse so that layout has changed when glimpse finish
2485 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2486 $LCTL set_param fail_loc=0x1404
2487 stat -c %s $DIR2/$tfile |tee $tmpfile &
2491 # create layout of testing file
2492 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2493 error "dd $DIR1/$tfile failed"
2496 local fsize=$(cat $tmpfile)
2498 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2500 rm -f $DIR1/$tfile $tmpfile
2502 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2505 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2507 # set default layout to have 1 stripe
2509 $LFS setstripe -c 1 $DIR1/$tdir
2511 # create a file with empty layout
2512 $MCREATE $DIR1/$tdir/$tfile ||
2513 error "$MCREATE $DIR1/$tdir/$tfile failed"
2515 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2516 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2518 # change the layout of testing file
2519 echo "Setting layout to have $OSTCOUNT stripes ..."
2520 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2524 # write something to the file, it should be blocked on fetching layout
2525 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2526 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2529 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2530 # count to succeed with only 3/4 of the number of stripes (rounded up),
2531 # so creating striped files does not fail if an OST is offline or full
2532 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2533 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2537 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2540 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2541 cancel_lru_locks mdc
2543 # open should grant LAYOUT lock, mmap and read will install pages
2544 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2548 # rss before revoking
2549 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2550 echo "Before revoking layout lock: $br KB mapped"
2552 # cancel layout lock manually
2553 cancel_lru_locks mdc
2555 # rss after revoking
2556 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2559 wait $PID || error "wait PID $PID failed"
2561 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2563 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2567 echo "==> rename vs getattr vs setxattr should not deadlock"
2568 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2570 do_facet mds1 $LCTL set_param fail_loc=$1
2572 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2580 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2581 wait $PID1 || error "(3) mv failed"
2582 wait $PID2 || error "(4) stat failed"
2589 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2590 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2592 do_facet mds1 $LCTL set_param fail_loc=$1
2594 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2602 $MULTIOP $DIR2/d1/d2 Oc &
2606 stat $DIR/d1 || error "(2) stat failed"
2608 wait $PID1 || error "(3) mv failed"
2609 wait $PID2 || error "(4) stat failed"
2610 wait $PID3 && error "(5) multiop failed"
2616 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2617 save_lustre_params client "llite.*.xattr_cache" > $p
2618 lctl set_param llite.*.xattr_cache 1 ||
2619 { skip "xattr cache is not supported"; return 0; }
2621 #define OBD_FAIL_MDS_RENAME 0x153
2622 #define OBD_FAIL_MDS_RENAME2 0x154
2623 test_54_part1 0x80000153 || error 10
2624 test_54_part1 0x80000154 || error 11
2625 test_54_part2 0x80000153 || error 12
2626 test_54_part2 0x80000154 || error 13
2628 restore_lustre_params < $p
2631 run_test 54 "rename locking"
2634 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2636 #define OBD_FAIL_MDS_RENAME4 0x156
2637 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2639 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2644 wait $PID1 && error "(2) mv succeeded"
2648 run_test 55a "rename vs unlink target dir"
2652 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2654 #define OBD_FAIL_MDS_RENAME4 0x156
2655 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2657 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2662 wait $PID1 && error "(2) mv succeeded"
2666 run_test 55b "rename vs unlink source dir"
2670 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2672 #define OBD_FAIL_MDS_RENAME4 0x156
2673 do_facet mds1 $LCTL set_param fail_loc=0x156
2675 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2679 # while rename is sleeping, open and remove d3
2680 $MULTIOP $DIR2/d3 D_c &
2686 # while rename is sleeping 2nd time, close d3
2688 wait $PID2 || error "(3) multiop failed"
2690 wait $PID1 && error "(2) mv succeeded"
2694 run_test 55c "rename vs unlink orphan target dir"
2700 #define OBD_FAIL_MDS_RENAME3 0x155
2701 do_facet mds1 $LCTL set_param fail_loc=0x155
2702 mv $DIR/f1 $DIR/$tdir &
2706 # while rename is sleeping, create $tdir, but as a directory
2707 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2709 # link in reverse locking order
2710 ln $DIR2/f1 $DIR2/$tdir/
2712 wait $PID1 && error "(2) mv succeeded"
2715 run_test 55d "rename file vs link"
2718 local MDSVER=$(lustre_build_version $SINGLEMDS)
2719 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2720 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2723 test_mkdir $DIR1/$tdir
2724 file1=$DIR1/$tdir/file
2725 file2=$DIR2/$tdir/file
2727 echo orig > $file2 || error "Could not create $file2"
2728 version=$($LFS data_version $file1)
2731 echo append >> $file2 || error "Could not append to $file2"
2732 version2=$($LFS data_version $file1)
2733 [ "$version" != "$version2" ] ||
2734 error "append did not change data version: $version"
2737 echo overwrite > $file2 || error "Could not overwrite $file2"
2738 version3=$($LFS data_version $file1)
2739 [ "$version2" != "$version3" ] ||
2740 error "overwrite did not change data version: $version2"
2742 # Truncate before EOF
2743 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2744 version4=$($LFS data_version $file1)
2745 [ "$version3" != "$version4" ] ||
2746 error "truncate did not change data version: $version3"
2748 # Truncate after EOF
2749 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2750 version5=$($LFS data_version $file1)
2751 [ "$version4" != "$version5" ] ||
2752 error "truncate did not change data version: $version4"
2754 # Chmod do not change version
2755 chmod 400 $file2 || error "Could not chmod 400 $file2"
2756 version6=$($LFS data_version $file1)
2757 [ "$version5" == "$version6" ] ||
2758 error "chmod should not change data version: $version5 != $version6"
2760 # Chown do not change version
2761 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2762 version7=$($LFS data_version $file1)
2763 [ "$version5" == "$version7" ] ||
2764 error "chown should not change data version: $version5 != $version7"
2766 run_test 60 "Verify data_version behaviour"
2769 local test_dir=$tdir/test_dir
2771 mkdir -p $DIR1/$tdir
2772 if [ $MDSCOUNT -ge 2 ]; then
2774 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2775 error "Create remote directory failed"
2777 mkdir -p $DIR1/$test_dir
2779 cd $DIR2/$test_dir || error "cd directory failed"
2780 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2782 cd $DIR2/$tdir || error "exit directory"
2784 run_test 70a "cd directory && rm directory"
2786 test_70b() { # LU-2781
2788 mkdir -p $DIR1/$tdir
2790 touch $DIR1/$tdir/file
2791 for ((i = 0; i < 32; i++)); do
2792 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2794 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2796 touch $DIR1/$tdir/file
2797 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2798 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2799 rm -rf $DIR1/$tdir/test_dir ||
2800 error "cannot remove directory after rm_entry"
2801 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2803 run_test 70b "remove files after calling rm_entry"
2806 local server_version=$(lustre_version_code $SINGLEMDS)
2808 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2809 skip "Need MDS version at least 2.1.6" && return
2811 # Patch not applied to 2.2 and 2.3 branches
2812 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2813 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2814 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2817 checkfiemap --test ||
2818 { skip "checkfiemap not runnable: $?" && return; }
2819 # write data this way: hole - data - hole - data
2820 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2821 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2823 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2824 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2825 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2827 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2829 checkfiemap $DIR2/$tfile 81920 ||
2830 error "data is not flushed from client"
2831 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2834 # common case of "create file, copy file" on a single node
2835 # should not flush data from ost
2836 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2837 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2839 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2841 checkfiemap $DIR1/$tfile 81920 ||
2843 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2845 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2847 run_test 71a "correct file map just after write operation is finished"
2850 local server_version=$(lustre_version_code $SINGLEMDS)
2852 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2853 skip "Need MDS version at least 2.1.6" && return
2855 # Patch not applied to 2.2 and 2.3 branches
2856 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2857 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2858 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
2860 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
2862 checkfiemap --test ||
2863 { skip "error $?: checkfiemap failed" && return; }
2865 mkdir -p $DIR1/$tdir
2867 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
2868 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
2869 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \
2871 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2872 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
2874 run_test 71b "check fiemap support for stripecount > 1"
2877 local p="$TMP/sanityN-$TESTNAME.parameters"
2880 save_lustre_params client "llite.*.xattr_cache" > $p
2881 lctl set_param llite.*.xattr_cache 1 ||
2882 { skip "xattr cache is not supported"; return 0; }
2885 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2886 error "setfattr1 failed"
2887 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2888 error "getfattr1 failed"
2889 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2890 error "setfattr2 failed"
2891 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2892 error "getfattr2 failed"
2894 # check that trusted.link is consistent
2895 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2896 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2897 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2898 echo "$tlink1 $tlink2"
2899 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2903 restore_lustre_params < $p
2906 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2909 local p="$TMP/sanityN-$TESTNAME.parameters"
2910 save_lustre_params client "llite.*.xattr_cache" > $p
2911 lctl set_param llite.*.xattr_cache 1 ||
2912 { skip "xattr cache is not supported"; return 0; }
2915 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2916 error "setfattr1 failed"
2917 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2918 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2919 clear_stats llite.*.stats
2920 # PR lock should be cached by now on both clients
2921 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2922 # 2 hits for getfattr(0)+getfattr(size)
2923 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
2924 error "not cached in $DIR1"
2925 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2926 # 4 hits for more getfattr(0)+getfattr(size)
2927 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
2928 error "not cached in $DIR2"
2931 restore_lustre_params < $p
2934 run_test 73 "getxattr should not cause xattr lock cancellation"
2937 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2938 skip "Need MDS version at least 2.4.93" && return
2940 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2941 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2942 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2944 run_test 74 "flock deadlock: different mounts =============="
2948 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2949 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2950 cancel_lru_locks osc
2952 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2955 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2956 $LCTL set_param fail_loc=0x31d
2957 stat -c %s $DIR1/$tfile &
2962 # For bad lock error handler we should ASSERT and got kernel panic here
2964 $LCTL set_param fail_loc=0
2966 run_test 75 "osc: upcall after unuse lock==================="
2969 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2970 skip "Need MDS version at least 2.5.53" && return
2972 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2973 local fcount=$((MDSCOUNT * 256))
2978 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2984 test_mkdir $DIR/$tdir
2986 # drop all open locks and close any cached "open" files on the client
2987 cancel_lru_locks mdc
2989 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2990 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
2991 local already=${#fid_list[@]}
2992 for (( i = 0; i < $already; i++ )) ; do
2993 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
2996 echo -n "opening files: "
2997 ulimit -n $((fcount + 50))
2998 for ((i = 0; i < $fcount; i++)); do
2999 touch $DIR/$tdir/f_$i
3000 local fd=$(free_fd ${fd_list[i]})
3001 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3006 (( $i % 32 == 0 )) && echo -n "."
3010 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3012 # Possible errors in openfiles FID list.
3013 # 1. Missing FIDs. Check 1
3014 # 2. Extra FIDs. Check 1
3015 # 3. Duplicated FID. Check 2
3016 # 4. Invalid FIDs. Check 2
3017 # 5. Valid FID, points to some other file. Check 3
3020 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3021 error "${#fid_list[@]} != $fcount (+$already old) open files"
3023 echo -n "closing files: "
3024 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3025 local close_cmd="exec ${fd_list[fd]}<&-"
3027 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3029 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3030 echo "skip old open file $filename"
3032 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3036 rm --interactive=no $filename
3038 error "Nonexisting fid ${fid_list[fid]} listed."
3039 (( $fd % 32 == 0 )) && echo -n "."
3044 ls_op=$(ls $DIR2/$tdir | wc -l)
3046 error "Some openfiles are missing in lproc output"
3050 run_test 76 "Verify MDT open_files listing"
3054 local dir=$DIR/$tdir
3057 mkdir $dir || error "mkdir $dir failed"
3058 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3061 do_nodes $CLIENTS $myRUNAS \
3062 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
3063 error "dd at 0 on client failed (1)"
3065 for ((i = 0; i < $n; i++)); do
3066 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
3067 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
3068 error "dd at ${i}MB on client failed (2)" &
3071 do_nodes $CLIENTS sync;
3072 cancel_lru_locks osc
3074 for ((i = 0; i < $n; i++)); do
3075 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
3076 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
3077 error "dd at ${i}MB on client failed (3)" &
3080 cancel_lru_locks osc
3082 for ((i = 0; i < $n; i++)); do
3086 rm -rf $dir || error "rm -rf $dir failed"
3089 test_77a() { #LU-3266
3092 oss=$(comma_list $(osts_nodes))
3093 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3095 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3096 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3101 run_test 77a "check FIFO NRS policy"
3103 test_77b() { #LU-3266
3106 oss=$(comma_list $(osts_nodes))
3108 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3109 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3110 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3111 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3113 echo "policy: crr-n, crrn_quantum 1"
3116 do_nodes $oss lctl set_param \
3117 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3118 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3120 echo "policy: crr-n, crrn_quantum 64"
3124 do_nodes $oss lctl set_param \
3125 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3126 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3129 run_test 77b "check CRR-N NRS policy"
3134 oss=$(comma_list $(osts_nodes))
3136 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3137 ost.OSS.*.nrs_"$policy"_quantum=1 \
3138 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3139 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3141 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3142 "physical, ${policy}_supported reads"
3145 do_nodes $oss lctl set_param \
3146 ost.OSS.*.nrs_${policy}_supported="writes" \
3147 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3149 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3150 "physical, ${policy}_supported writes"
3153 do_nodes $oss lctl set_param \
3154 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3155 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3156 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3157 "logical, ${policy}_supported reads_and_writes"
3161 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3166 test_77c() { #LU-3266
3168 orr_trr "orr" || rc=$?
3169 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3170 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3173 run_test 77c "check ORR NRS policy"
3175 test_77d() { #LU-3266
3177 orr_trr "trr" || rc=$?
3178 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3179 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3182 run_test 77d "check TRR nrs policy"
3189 do_facet $facet lctl set_param \
3190 ost.OSS.ost_io.nrs_tbf_rule="$*"
3192 error "failed to run operate '$*' on TBF rules"
3195 cleanup_tbf_verify()
3199 echo "cleanup_tbf $DIR/$tdir"
3202 wait_delete_completed
3207 local dir=$DIR/$tdir
3208 local client1=${CLIENT1:-$(hostname)}
3211 local np=$(check_cpt_number ost1)
3212 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3213 echo "cpu_npartitions on ost1 is $np"
3215 mkdir $dir || error "mkdir $dir failed"
3216 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3219 trap cleanup_tbf_verify EXIT
3220 echo "Limited write rate: $1, read rate: $2"
3221 echo "Verify the write rate is under TBF control"
3222 local start=$SECONDS
3223 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3224 bs=1M count=100 oflag=direct 2>&1
3225 local runtime=$((SECONDS - start + 1))
3226 local rate=$(bc <<< "scale=6; 100 / $runtime")
3227 echo "Write runtime is $runtime s, speed is $rate IOPS"
3229 # verify the write rate does not exceed TBF rate limit
3230 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3231 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3233 cancel_lru_locks osc
3235 echo "Verify the read rate is under TBF control"
3237 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3238 bs=1M count=100 iflag=direct 2>&1
3239 runtime=$((SECONDS - start + 1))
3240 rate=$(bc <<< "scale=6; 100 / $runtime")
3241 echo "Read runtime is $runtime s, speed is $rate IOPS"
3243 # verify the read rate does not exceed TBF rate limit
3244 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3245 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3247 cancel_lru_locks osc
3248 cleanup_tbf_verify || error "rm -rf $dir failed"
3254 oss=$(comma_list $(osts_nodes))
3256 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3258 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3259 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3263 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3268 # Only operate rules on ost1 since OSTs might run on the same OSS
3270 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3271 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3272 local client_nids=$(nids_list $address "\\")
3273 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3274 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3278 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3279 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3280 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3284 tbf_rule_operate ost1 "stop\ localhost"
3285 tbf_rule_operate ost1 "stop\ clients"
3286 tbf_rule_operate ost1 "stop\ others"
3289 # Cleanup the TBF policy
3290 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3291 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3295 run_test 77e "check TBF NID nrs policy"
3300 oss=$(comma_list $(osts_nodes))
3302 do_nodes $oss $LCTL set_param \
3303 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3304 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3305 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3307 # Configure jobid_var
3308 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3310 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3311 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3312 if [ $saved_jobid_var != procname_uid ]; then
3313 set_conf_param_and_check client \
3314 "$LCTL get_param -n jobid_var" \
3315 "$FSNAME.sys.jobid_var" procname_uid
3320 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3325 # Only operate rules on ost1 since OSTs might run on the same OSS
3327 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3328 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3329 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3330 nrs_write_read "$RUNAS"
3333 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3334 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3335 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3336 nrs_write_read "$RUNAS"
3339 tbf_rule_operate ost1 "stop\ runas"
3340 tbf_rule_operate ost1 "stop\ iozone_runas"
3341 tbf_rule_operate ost1 "stop\ dd_runas"
3342 nrs_write_read "$RUNAS"
3344 # Cleanup the TBF policy
3345 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3346 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3347 nrs_write_read "$RUNAS"
3349 local current_jobid_var=$($LCTL get_param -n jobid_var)
3350 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3351 if [ $saved_jobid_var != $current_jobid_var ]; then
3352 set_conf_param_and_check client \
3353 "$LCTL get_param -n jobid_var" \
3354 "$FSNAME.sys.jobid_var" $saved_jobid_var
3358 run_test 77f "check TBF JobID nrs policy"
3363 oss=$(comma_list $(osts_nodes))
3365 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3367 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3368 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3370 do_nodes $oss lctl set_param \
3371 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3372 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3376 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3381 # Add a rule that only valid for Jobid TBF. If direct change between
3382 # TBF types is not supported, this operation will fail.
3383 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3385 # Cleanup the TBF policy
3386 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3387 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3390 run_test 77g "Change TBF type directly"
3393 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3394 { skip "Need OST version at least 2.8.55"; return 0; }
3396 local old_policy=$(do_facet ost1 \
3397 lctl get_param ost.OSS.ost_io.nrs_policies)
3400 do_facet ost1 lctl set_param \
3401 ost.OSS.ost_io.nrs_policies="abc"
3402 [ $? -eq 0 ] && error "should return error"
3404 do_facet ost1 lctl set_param \
3405 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3406 [ $? -eq 0 ] && error "should return error"
3408 do_facet ost1 lctl set_param \
3409 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3410 [ $? -eq 0 ] && error "should return error"
3412 do_facet ost1 lctl set_param \
3413 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3414 [ $? -eq 0 ] && error "should return error"
3416 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3417 [ $? -eq 0 ] || error "shouldn't LBUG"
3419 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3423 run_test 77h "Wrong policy name should report error, not LBUG"
3429 local error_message=$3
3431 for rule in $expected; do
3432 rule_number=$((rule_number + 1))
3434 local stop_line=$(($rule_number + 3))
3435 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3437 local output=$(do_facet $facet lctl get_param \
3438 ost.OSS.ost_io.nrs_tbf_rule |
3442 if [ "$output" != "$expected" ]; then
3443 error "$error_message, expected '$expected', got '$output'"
3448 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3449 { skip "Need OST version at least 2.8.55"; return 0; }
3451 for i in $(seq 1 $OSTCOUNT)
3453 do_facet ost"$i" lctl set_param \
3454 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3456 error "failed to set TBF policy"
3459 tbf_rule_check ost1 "default" "error before inserting any rule"
3461 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3462 tbf_rule_check ost1 "before default" \
3463 "error when inserting rule 'before'"
3465 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3466 tbf_rule_check ost1 "before after default" \
3467 "error when inserting rule 'after'"
3469 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3470 tbf_rule_check ost1 "before target after default" \
3471 "error when inserting rule 'target'"
3473 echo "Move before itself"
3474 tbf_rule_operate ost1 "change\ target\ rank=target"
3475 tbf_rule_check ost1 "before target after default" \
3476 "error when moving before itself"
3478 echo "Move to higher rank"
3479 tbf_rule_operate ost1 "change\ target\ rank=before"
3480 tbf_rule_check ost1 "target before after default" \
3481 "error when moving to higher rank"
3483 echo "Move to lower rank"
3484 tbf_rule_operate ost1 "change\ target\ rank=after"
3485 tbf_rule_check ost1 "before target after default" \
3486 "error when moving to lower rank"
3488 echo "Move before default"
3489 tbf_rule_operate ost1 "change\ target\ rank=default"
3490 tbf_rule_check ost1 "before after target default" \
3491 error "error when moving before default"
3493 # Cleanup the TBF policy
3494 do_nodes $(comma_list $(osts_nodes)) \
3495 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3498 run_test 77i "Change rank of TBF rule"
3503 local ost_version=$(lustre_version_code ost1)
3505 [ $ost_version -ge $(version_code 2.9.53) ] ||
3506 { skip "Need OST version at least 2.9.53"; return 0; }
3507 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3512 do_nodes $(comma_list $(osts_nodes)) \
3513 lctl set_param jobid_var=procname_uid \
3514 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3515 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3516 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3517 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3522 do_nodes $(comma_list $(osts_nodes)) \
3523 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3524 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3525 ost.OSS.ost_io.nrs_policies="fifo"
3527 # sleep 3 seconds to wait the tbf policy stop completely,
3528 # or the next test case is possible get -EAGAIN when
3529 # setting the tbf policy
3532 run_test 77j "check TBF-OPCode NRS policy"
3535 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3536 { skip "Need OST version at least 2.9.53"; return 0; }
3538 do_nodes $(comma_list $(osts_nodes)) \
3539 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3540 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3541 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3543 nrs_write_read "$RUNAS"
3544 tbf_verify 20 10 "$RUNAS"
3546 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3547 local client_nids=$(nids_list $address "\\")
3548 do_nodes $(comma_list $(osts_nodes)) \
3549 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3550 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3551 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3552 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3557 do_nodes $(comma_list $(osts_nodes)) \
3558 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3559 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3560 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3562 nrs_write_read "$RUNAS"
3563 tbf_verify 20 20 "$RUNAS"
3565 do_nodes $(comma_list $(osts_nodes)) \
3566 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3567 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3568 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3570 nrs_write_read "$RUNAS"
3571 # with parameter "RUNAS", it will match the latest rule
3572 # "ext_b" first, so the limited write rate is 10.
3573 tbf_verify 10 10 "$RUNAS"
3576 do_nodes $(comma_list $(osts_nodes)) \
3577 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3578 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3579 ost.OSS.ost_io.nrs_policies="fifo"
3583 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
3586 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3587 { skip "Need OST version at least 2.10.56"; return 0; }
3589 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3590 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3592 local output=$(do_facet ost1 lctl get_param \
3593 ost.OSS.ost_io.nrs_policies | \
3594 awk '/name: tbf/ {print;exit}' | \
3595 awk -F ': ' '{print $2}')
3597 if [ "$output" != "tbf" ]; then
3598 error "The generic TBF output is '$output', not 'tbf'"
3601 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3603 run_test 77l "check the output of NRS policies for generic TBF"
3606 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3607 skip "Need OST version at least 2.9.54"
3611 local dir=$DIR/$tdir
3613 mkdir $dir || error "mkdir $dir failed"
3614 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3617 local nodes=$(comma_list $(osts_nodes))
3618 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3619 ost.OSS.ost_io.nrs_delay_min=4 \
3620 ost.OSS.ost_io.nrs_delay_max=4 \
3621 ost.OSS.ost_io.nrs_delay_pct=100
3622 [ $? -ne 0 ] && error "Failed to set delay policy"
3624 local start=$SECONDS
3625 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3626 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3627 oflag=direct conv=fdatasync ||
3628 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3629 error "dd on client failed (1)"; }
3630 local elapsed=$((SECONDS - start))
3632 # NRS delay doesn't do sub-second timing, so a request enqueued at
3633 # 0.9 seconds can be dequeued at 4.0
3634 [ $elapsed -lt 3 ] &&
3635 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3636 error "Single 1M write should take at least 3 seconds"; }
3639 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3640 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3641 oflag=direct conv=fdatasync ||
3642 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3643 error "dd on client failed (2)"; }
3644 elapsed=$((SECONDS - start))
3646 [ $elapsed -lt 30 ] &&
3647 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3648 error "Ten 1M writes should take at least 30 seconds"; }
3650 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3651 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3655 run_test 77m "check NRS Delay slows write RPC processing"
3657 test_78() { #LU-6673
3660 oss=$(comma_list $(osts_nodes))
3661 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3662 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3664 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3665 # Valid return codes are:
3666 # 0: Tuning succeeded
3667 # ENODEV: Policy is still stopped
3668 # EAGAIN: Policy is being initialized
3669 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3670 error "Expected set_param to return 0|ENODEV|EAGAIN"
3672 # Cleanup the ORR policy
3673 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3674 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3677 run_test 78 "Enable policy and specify tunings right away"
3680 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3681 test_mkdir $DIR/$tdir
3683 # Prevent interference from layout intent RPCs due to
3684 # asynchronous writeback. These will be tested in 130c below.
3685 do_nodes ${CLIENTS:-$HOSTNAME} sync
3687 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3688 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3690 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3691 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3692 local facet=mds$((mdtidx + 1))
3694 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3695 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3699 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3700 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3705 run_test 79 "xattr: intent error"
3708 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3715 mkdir -p $DIR1/$tdir/dir
3716 createmany -o $DIR1/$tdir/dir/f 10 ||
3717 error "create files under remote dir failed $i"
3719 cp /etc/passwd $DIR1/$tdir/$tfile
3721 #migrate open file should fails
3722 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3724 # give multiop a chance to open
3727 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3728 error "migrate open files should failed with open files"
3732 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3733 error "migrate remote dir error"
3735 echo "Finish migration, then checking.."
3736 for file in $(find $DIR1/$tdir); do
3737 mdt_index=$($LFS getstripe -M $file)
3738 [ $mdt_index == $MDTIDX ] ||
3739 error "$file is not on MDT${MDTIDX}"
3742 diff /etc/passwd $DIR1/$tdir/$tfile ||
3743 error "file different after migration"
3745 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3747 run_test 80a "migrate directory when some children is being opened"
3751 kill -9 $migrate_pid
3755 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3756 local migrate_dir1=$DIR1/$tdir/migrate_dir
3757 local migrate_dir2=$DIR2/$tdir/migrate_dir
3758 local migrate_run=$LUSTRE/tests/migrate.sh
3766 trap cleanup_80b EXIT
3767 #prepare migrate directory
3768 mkdir -p $migrate_dir1
3769 for F in {1,2,3,4,5}; do
3770 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3771 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3774 #migrate the directories among MDTs
3777 mdt_idx=$((RANDOM % MDSCOUNT))
3778 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
3780 [ $rc -ne 0 -o $rc -ne 16 ] || break
3785 echo "start migration thread $migrate_pid"
3786 #Access the files at the same time
3787 start_time=$(date +%s)
3788 echo "accessing the migrating directory for 5 minutes..."
3790 ls $migrate_dir2 > /dev/null || {
3791 echo "read dir fails"
3794 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3795 echo "access file1 fails"
3799 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3800 echo "access file2/3 fails"
3804 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3805 echo "access file4 fails"
3809 stat $migrate_dir2/file5 > /dev/null || {
3810 echo "stat file5 fails"
3814 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3815 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3816 echo "touch file failed with $rc1"
3820 if [ -e $migrate_dir2/source_file ]; then
3821 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3822 &>/dev/null || rc1=$?
3823 if [ -e $migrate_dir2/link_file ]; then
3824 rm -rf $migrate_dir2/link_file
3827 mrename $migrate_dir2/source_file \
3828 $migrate_dir2/target_file &>/dev/null || rc1=$?
3829 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3830 echo "rename failed with $rc1"
3834 if [ -e $migrate_dir2/target_file ]; then
3835 rm -rf $migrate_dir2/target_file &>/dev/null ||
3838 rm -rf $migrate_dir2/source_file &>/dev/null ||
3841 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3842 echo "unlink failed with $rc1"
3847 end_time=$(date +%s)
3848 duration=$((end_time - start_time))
3849 if [ $((duration % 10)) -eq 0 ]; then
3850 if [ $show_time -eq 1 ]; then
3851 echo "...$duration seconds"
3858 kill -0 $migrate_pid || {
3859 echo "migration stopped 1"
3863 [ $duration -ge 300 ] && break
3866 #check migration are still there
3867 kill -0 $migrate_pid || error "migration stopped 2"
3870 run_test 80b "Accessing directory during migration"
3873 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3877 mkdir -p $DIR1/$tdir
3879 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3880 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3883 touch d0/0 || error "create 0 failed"
3884 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3885 stat d0/0 && error "stat mv filed succeed"
3886 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3887 stat d0/0 || error "stat failed"
3889 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3891 if [ $t -ne 3 ]; then
3892 ls -ai $DIR1/$tdir/d0
3893 error "expect 3 get $t"
3898 run_test 81 "rename and stat under striped directory"
3901 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3902 { skip "Need MDS version at least 2.6.92"; return 0; }
3904 # Client 1 creates a file.
3905 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3907 # Client 2 opens the file.
3908 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3910 # Client 1 makes the file an orphan.
3911 rm $DIR1/$tfile || error "rm"
3912 # Client 2 sets EA "user.multiop".
3914 wait $pid2 || error "multiop 2"
3915 # Client 1 gets EA "user.multiop". This used to fail because the EA
3916 # cache refill would get "trusted.link" from mdd_xattr_list() but
3917 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3920 wait $pid1 || error "multiop 1"
3922 run_test 82 "fsetxattr and fgetxattr on orphan files"
3925 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3932 $LFS mkdir -i1 -c2 $tdir
3937 echo "start pid $pid1 to create/unlink striped directory"
3939 # Access the directory at the same time
3943 stat $tdir > /dev/null 2>&1
3947 echo "start pid $pid2 to stat striped directory"
3955 run_test 83 "access striped directory while it is being created/unlinked"
3958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3963 [ "$SLOW" = "yes" ] && duration=600
3964 # Open/Create under striped directory
3968 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3969 touch $tdir/f{0..3} > /dev/null 2>&1
3973 echo "start pid $pid1 to open/create under striped directory"
3975 # unlink the striped directory at the same time
3979 rm -rf $tdir > /dev/null 2>&1
3983 echo "start pid $pid2 to unlink striped directory"
3992 run_test 90 "open/create and unlink striped directory"
3995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4000 [ "$SLOW" = "yes" ] && duration=600
4001 # chmod striped directory
4005 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4006 chmod go+w $tdir > /dev/null 2>&1
4010 echo "start pid $pid1 to chmod striped directory"
4012 # unlink the striped directory at the same time
4016 rm -rf $tdir > /dev/null 2>&1
4020 echo "start pid $pid2 to unlink striped directory"
4029 run_test 91 "chmod and unlink striped directory"
4032 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4035 local cmd="exec $fd<$DIR1/$tdir"
4036 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4039 trap "eval $cmd" EXIT
4040 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4041 rmdir ../$tdir || error "rmdir ../$tdir fails"
4043 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4044 $LCTL set_param fail_loc=0x1408
4045 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4046 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4047 error "create remote dir succeeds"
4048 $LCTL set_param fail_loc=0
4052 run_test 92 "create remote directory under orphan directory"
4059 mkdir -p $DIR1/$tfile-1/
4060 mkdir -p $DIR2/$tfile-2/
4061 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
4062 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
4063 do_facet $SINGLEMDS lctl set_param -n \
4064 'lod.lustre-MDT*/qos_threshold_rr' 100
4065 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4066 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
4068 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
4071 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
4075 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4076 do_facet $SINGLEMDS "lctl set_param -n \
4077 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
4079 $GETSTRIPE $DIR1/$tfile-1/file1
4080 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
4081 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4082 $GETSTRIPE $DIR2/$tfile-2/file2
4083 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
4084 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4085 echo "rc1=$rc1 and rc2=$rc2 "
4086 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4087 error "object allocate on same ost detected"
4089 run_test 93 "alloc_rr should not allocate on same ost"
4093 skip "Reserved for glimpse-ahead" && return
4094 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4095 skip "Need MDS version at least 2.10.55" && return
4099 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4101 lctl set_param -n mdc.*.stats=clear
4102 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4104 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4105 # first stat from server should return size data and save glimpse
4106 local gls=$(lctl get_param -n mdc.*.stats | \
4107 awk '/ldlm_glimpse/ {print $2}')
4108 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4109 # second stat to check size is NOT cached on client without IO lock
4110 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4112 local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l)
4113 [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls"
4116 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4119 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4120 skip "Need MDS version at least 2.10.55" && return
4124 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4126 lctl set_param -n mdc.*.stats=clear
4127 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4128 cancel_lru_locks mdc
4129 # first stat data from server should have size
4130 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4131 # second stat to check size is cached on client
4132 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4134 local gls=$(lctl get_param -n mdc.*.stats |
4135 awk '/ldlm_glimpse/ {print $2}')
4136 # both stats should cause no glimpse requests
4137 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
4140 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4143 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4144 skip "Need MDS version at least 2.10.55" && return
4148 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4150 lctl set_param -n mdc.*.stats=clear
4151 lctl set_param -n osc.*.stats=clear
4152 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4154 # check that size is merged from MDT and OST correctly
4155 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4156 error "Wrong size from stat #1"
4158 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4159 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4163 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4166 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4167 skip "Need MDS version at least 2.10.55" && return
4171 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4174 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4175 lctl set_param -n mdc.*.stats=clear
4176 $TRUNCATE $DIR2/$tdir/dom 4096
4178 # check that reported size is valid after file grows to OST and
4179 # is truncated back to MDT stripe size
4180 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4181 error "Wrong size from stat #1"
4183 local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
4184 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4188 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4191 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4192 skip "Need MDS version at least 2.10.55" && return
4194 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4196 $CHECKSTAT -t file $DIR1/$tfile
4198 OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
4199 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
4203 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4204 error_noexit "Write fails"
4205 # must discard pages
4206 lctl set_param -n mdc.*.stats=clear
4207 rm $DIR2/$tfile || error_noexit "Unlink fails"
4208 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4209 echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
4211 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4213 run_test 101a "Discard DoM data on unlink"
4216 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4217 skip "Need MDS version at least 2.10.55" && return
4219 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4220 touch $DIR1/${tfile}_2
4222 $CHECKSTAT -t file $DIR1/$tfile
4224 OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
4225 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
4229 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4230 error_noexit "Write fails"
4231 # must discard pages
4232 lctl set_param -n mdc.*.stats=clear
4233 mv $DIR2/${tfile}_2 $DIR2/$tfile || error_noexit "Rename fails"
4234 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4235 echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
4236 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4238 run_test 101b "Discard DoM data on rename"
4241 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4242 skip "Need MDS version at least 2.10.55" && return
4244 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4246 $CHECKSTAT -t file $DIR1/$tfile
4248 OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
4249 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
4253 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4254 error_noexit "Write fails"
4255 $MULTIOP $DIR1/$tfile O_c &
4258 lctl set_param -n mdc.*.stats=clear
4259 rm $DIR2/$tfile > /dev/null || error_noexit "Unlink fails"
4260 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID ||
4261 error_noexit "multiop failure"
4262 local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
4263 echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
4264 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4266 run_test 101c "Discard DoM data on close-unlink"
4268 log "cleanup: ======================================================"
4270 # kill and wait in each test only guarentee script finish, but command in script
4271 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4272 # otherwise umount below will fail
4273 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4278 check_and_cleanup_lustre