8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
26 # LU-2829 / LU-2887 - make allowances for ZFS slowness
27 TEST33_NFILES=${TEST33_NFILES:-1000}
31 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
40 check_and_setup_lustre
45 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
47 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
48 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
50 # $RUNAS_ID may get set incorrectly somewhere else
51 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
53 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
57 [ -f $DIR2/$tfile ] || error "Check create"
58 chmod 777 $DIR2/$tfile
59 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
60 error "Check attribute update for 0777"
62 chmod a-x $DIR2/$tfile
63 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
64 error "Check attribute update for 0666"
67 $CHECKSTAT -a $DIR1/$tfile ||
68 error "Check unlink - removes file on other mountpoint"
70 run_test 1 "Check attribute updates on 2 mount points"
76 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
77 error "Either not file type or perms not 0777"
79 run_test 2a "check cached attribute updates on 2 mtpt's ========"
85 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
86 error "Either not file type or perms not 0777"
88 run_test 2b "check cached attribute updates on 2 mtpt's ========"
90 # NEED TO SAVE ROOT DIR MODE
93 $CHECKSTAT -t dir -p 0777 $DIR2 ||
94 error "Either not dir type or perms not 0777"
96 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
100 $CHECKSTAT -t dir -p 0755 $DIR2 ||
101 error "Either not file type or perms not 0775"
103 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
110 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
113 run_test 2e "check chmod on root is propagated to others"
116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
118 local remote_dir=$tdir/remote_dir
121 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
122 error "Create remote directory failed"
124 touch $DIR1/$remote_dir/$tfile ||
125 error "Create file under remote directory failed"
126 chmod 777 $DIR1/$remote_dir/$tfile ||
127 error "Chmod file under remote directory failed"
129 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
130 error "Check attr of file under remote directory failed"
132 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
133 error "Chown file under remote directory failed"
135 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
136 error "Check owner of file under remote directory failed"
138 cd $DIR2/$remote_dir || error "enter remote dir"
139 rm -rf $DIR1/$remote_dir/$tfile ||
140 error "Unlink remote directory failed"
142 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
143 error "unlink file still exists!"
145 cd $DIR2/$tdir || error "exit remote dir"
146 rm -rf $DIR1/$tdir || error "unlink directory failed"
148 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
151 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
153 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
155 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
156 echo "$DIR1/$tfile has $block1 blocks"
157 echo "$DIR2/$tfile has $block2 blocks"
158 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
160 run_test 2g "check blocks update on sync write"
163 local target="this/is/good"
164 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
165 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
166 error "link $DIR2/$tfile not as expected"
168 run_test 3 "symlink on one mtpt, readlink on another ==========="
171 multifstat $DIR1/f4 $DIR2/f4
173 run_test 4 "fstat validation on multiple mount points =========="
177 $TRUNCATE $DIR2/f5 100
178 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
179 error "Either not file type or size not equal to 100 bytes"
182 run_test 5 "create a file on one mount, truncate it on the other"
185 openunlink $DIR1/$tfile $DIR2/$tfile || \
186 error "openunlink $DIR1/$tfile $DIR2/$tfile"
188 run_test 6 "remove of open file on other node =================="
192 opendirunlink $DIR1/$dir $DIR2/$dir || \
193 error "opendirunlink $DIR1/$dir $DIR2/$dir"
195 run_test 7 "remove of open directory on other node ============="
198 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
199 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
201 run_test 8 "remove of open special file on other node =========="
207 for C in a b c d e f g h i j k l; do
208 dir=`eval echo \\$DIR$MTPT`
209 echo -n $C >> $dir/f9
210 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
212 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
213 error "`od -a $DIR1/f9` != abcdefghijkl"
215 run_test 9a "append of file with sub-page size on multiple mounts"
217 #LU-10681 - tiny writes & appending to sparse striped file
219 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
221 $LFS setstripe -c 2 -S 1M $DIR/$tfile
222 echo "foo" >> $DIR/$tfile
223 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
224 error "sparse dd $DIR2/$tfile failed"
225 echo "foo" >> $DIR/$tfile
227 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
228 echo "Data read (expecting 'foo')": $data
229 [ "$data" = "foo" ] || error "append to sparse striped file failed"
231 run_test 9b "append to striped sparse file"
238 for C in a b c d e f g h i j k l; do
239 dir=`eval echo \\$DIR$MTPT`
240 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
241 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
242 OFFSET=`expr $OFFSET + 1`
244 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
245 error "`od -a $DIR1/f10` != abcdefghijkl"
247 run_test 10a "write of file with sub-page size on multiple mounts "
251 yes "R" | head -c 4000 >$TMP/f10b-seed
252 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
254 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
256 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
258 # create a test file locally to compare
259 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
260 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
261 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
262 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
264 run_test 10b "write of file with sub-page size on multiple mounts "
268 multiop_bg_pause $DIR1/d11/f O_c || return 1
270 cp -p /bin/ls $DIR1/d11/f
274 wait $MULTIPID || error "wait for PID $MULTIPID failed"
275 [ $RC -eq 0 ] && error || true
277 run_test 11 "execution of file opened for write should return error ===="
280 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
282 run_test 12 "test lock ordering (link, stat, unlink)"
284 test_13() { # bug 2451 - directory coherency
286 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
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 (1)" || true
292 # need to run it twice
293 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
295 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
296 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
298 run_test 13 "test directory page revocation"
301 test_mkdir $DIR1/$tdir
302 cp -p /bin/ls $DIR1/$tdir/$tfile
303 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
306 $DIR2/$tdir/$tfile && error || true
309 run_test 14aa "execution of file open for write returns -ETXTBSY"
312 test_mkdir $DIR1/$tdir
313 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
314 $DIR1/$tdir/sleep 60 &
316 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
319 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
321 test_14b() { # bug 3192, 7040
322 test_mkdir $DIR1/$tdir
323 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
324 $DIR1/$tdir/sleep 60 &
326 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
327 error "expected truncate error, got success"
329 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
331 run_test 14b "truncate of executing file returns -ETXTBSY ======"
333 test_14c() { # bug 3430, 7040
334 test_mkdir $DIR1/$tdir
335 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
336 $DIR1/$tdir/sleep 60 &
338 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
340 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
342 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
344 test_14d() { # bug 10921
345 test_mkdir $DIR1/$tdir
346 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
347 $DIR1/$tdir/sleep 60 &
350 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
352 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
354 run_test 14d "chmod of executing file is still possible ========"
356 test_15() { # bug 974 - ENOSPC
358 sh oos2.sh $MOUNT1 $MOUNT2
359 wait_delete_completed
360 grant_error=$(dmesg | grep "< tot_grant")
361 [ -z "$grant_error" ] || error "$grant_error"
363 run_test 15 "test out-of-space with multiple writers ==========="
366 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
367 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
368 # pass a 2500 operation dual-mount run within the time limit.
369 if [ "$(facet_fstype ost1)" = "zfs" ]; then
370 FSXNUM=$((COUNT / 5))
372 elif [ "$SLOW" = "yes" ]; then
373 FSXNUM=$((COUNT * 5))
381 local file1=$DIR1/$tfile
382 local file2=$DIR2/$tfile
383 local stripe_size=$(do_facet $SINGLEMDS \
384 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
386 # to allocate grant because it may run out due to test_15.
387 $LFS setstripe -c -1 $file1
388 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
389 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
392 $LFS setstripe -c -1 $file1 # b=10919
393 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
394 || error "fsx failed"
397 # O_DIRECT reads and writes must be aligned to the device block size.
398 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
399 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
401 run_test 16a "$FSXNUM iterations of dual-mount fsx"
403 # Consistency check for tiny writes, LU-9409
405 local file1=$DIR1/$tfile
406 local file2=$DIR2/$tfile
407 local stripe_size=($($LFS getstripe -S $DIR))
409 # to allocate grant because it may run out due to test_15.
410 lfs setstripe -c -1 $file1
411 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
412 error "dd failed writing to file=$file1"
413 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
414 error "dd failed writing to file=$file2"
417 lfs setstripe -c -1 $file1 # b=10919
418 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
419 # create a mix of tiny writes & normal writes
420 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
421 $file2 || error "fsx with tiny write failed."
423 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
426 local file1=$DIR1/$tfile
427 local file2=$DIR2/$tfile
428 local stripe_size=$(do_facet $SINGLEMDS \
429 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
431 [ $(facet_fstype ost1) != ldiskfs ] && skip "dio on ldiskfs only"
433 # to allocate grant because it may run out due to test_15.
434 $LFS setstripe -c -1 $file1
435 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
436 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
438 wait_delete_completed
440 local list=$(comma_list $(osts_nodes))
441 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
442 skip "not cache-capable obdfilter"
445 set_osd_param $list '' read_cache_enable 0
446 set_osd_param $list '' writethrough_cache_enable 0
448 $LFS setstripe -c -1 $file1 # b=10919
449 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \
450 || error "fsx failed"
453 set_osd_param $list '' read_cache_enable 1
454 set_osd_param $list '' writethrough_cache_enable 1
458 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
461 test_17() { # bug 3513, 3667
462 remote_ost_nodsh && skip "remote OST with nodsh" && return
464 lfs setstripe $DIR1/$tfile -i 0 -c 1
465 cp $SAMPLE_FILE $DIR1/$tfile
466 cancel_lru_locks osc > /dev/null
467 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
468 do_facet ost1 lctl set_param fail_loc=0x8000030a
469 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
470 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
472 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
474 run_test 17 "resource creation/LVB creation race ==============="
477 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
480 for idx in {a..z}; do
481 local ptr=EXCEPT_ALWAYS_18$idx
482 [ x${!ptr} = xtrue ] || continue
484 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
487 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
490 run_test 18 "mmap sanity check ================================="
492 test_19() { # bug3811
493 local node=$(facet_active_host ost1)
495 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
497 # check whether obdfilter is cache capable at all
498 get_osd_param $node '' read_cache_enable >/dev/null ||
499 skip "not cache-capable obdfilter"
501 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
502 set_osd_param $node '' readcache_max_filesize 4096
503 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
504 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
505 cp $TMP/$tfile $DIR1/$tfile
506 for i in `seq 1 20`; do
507 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
508 cancel_lru_locks $OSC > /dev/null
509 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
510 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
512 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
513 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
514 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
515 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
517 set_osd_param $node '' readcache_max_filesize $MAX
520 run_test 19 "test concurrent uncached read races ==============="
524 cancel_lru_locks $OSC
525 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
526 $MULTIOP $DIR1/f20 Ow8190c
527 $MULTIOP $DIR2/f20 Oz8194w8190c
528 $MULTIOP $DIR1/f20 Oz0r8190c
529 cancel_lru_locks $OSC
530 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
532 error $CNTD" page left in cache after lock cancel" || true
534 run_test 20 "test extra readahead page left in cache ===="
541 test_21() { # Bug 5907
542 test_mkdir $DIR1/$tdir
543 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
545 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
546 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
547 test -d $DIR1/$tdir || error "Mounted directory disappeared"
549 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
552 run_test 21 " Try to remove mountpoint on another dir ===="
554 test_23() { # Bug 5972
555 local at_diff=$(do_facet $SINGLEMDS \
556 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
557 echo "atime should be updated while another read" > $DIR1/$tfile
559 # clear the lock(mode: LCK_PW) gotten from creating operation
560 cancel_lru_locks $OSC
563 sleep $((at_diff + 1))
565 echo "starting reads"
566 multiop_bg_pause $DIR1/$tfile or20_c || return 1
567 # with SOM and opencache enabled, we need to close a file and cancel
568 # open lock to get atime propogated to MDS
569 kill -USR1 $! || return 2
572 time2=$(stat -c "%X" $DIR/$tfile)
573 echo "new atime is $time2"
575 [ $time2 -gt $time1 ] || error "atime was not updated"
576 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
579 run_test 23 " others should see updated atime while another read===="
583 lfs df || error "lfs df failed"
584 lfs df -ih || error "lfs df -ih failed"
585 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
586 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
587 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
588 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
590 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
591 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
592 lctl --device %osc deactivate
593 lfs df -i || error "lfs df -i with deactivated OSC failed"
594 lctl --device %osc activate
595 lfs df || error "lfs df with reactivated OSC failed"
597 run_test 24a "lfs df [-ih] [path] test ========================="
601 fsnum=$(lfs_df | grep -c "summary")
602 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
604 run_test 24b "lfs df should show both filesystems ==============="
607 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
609 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
612 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
613 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
615 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
616 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
617 error "setfacl $DIR2/$tdir #1"
618 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
619 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
620 error "setfacl $DIR2/$tdir #2"
621 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
622 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
623 error "setfacl $DIR2/$tdir #3"
624 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
625 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
626 error "setfacl $DIR2/$tdir #4"
627 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
631 run_test 25a "change ACL on one mountpoint be seen on another ==="
634 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
636 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
638 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
641 $LFS mkdir -i 1 $DIR1/$tdir
642 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
643 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
645 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
646 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
647 error "setfacl $DIR2/$tdir #1"
648 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
649 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
650 error "setfacl $DIR2/$tdir #2"
651 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
652 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
653 error "setfacl $DIR2/$tdir #3"
654 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
655 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
656 error "setfacl $DIR2/$tdir #4"
657 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
661 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
664 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
666 run_test 26a "allow mtime to get older"
671 echo "aaa" >> $DIR1/$tfile
673 chmod a+x $DIR2/$tfile
674 mt1=`stat -c %Y $DIR1/$tfile`
675 mt2=`stat -c %Y $DIR2/$tfile`
677 if [ x"$mt1" != x"$mt2" ]; then
678 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
681 run_test 26b "sync mtime between ost and mds"
684 cancel_lru_locks $OSC
686 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
691 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
696 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
698 lctl set_param -n ldlm.dump_namespaces ""
699 wait $DD1_PID $DD2_PID
700 [ $? -ne 0 ] && lctl dk $TMP/debug || true
702 run_test 27 "align non-overlapping extent locks from request ==="
704 test_28() { # bug 9977
705 ECHO_UUID="ECHO_osc1_UUID"
706 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
708 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
709 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
710 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
714 attach echo_client ECHO_osc1 $ECHO_UUID
718 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
719 $LCTL --device $tECHOID destroy "${tOBJID}:0"
727 # reading of 1st stripe should pass
728 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
729 # reading of 2nd stripe should fail (this stripe was destroyed)
730 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
732 # now, recreating test file
733 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
734 # reading of 1st stripe should pass
735 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
736 # reading of 2nd stripe should pass
737 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
740 run_test 28 "read/write/truncate file with lost stripes"
742 test_30() { #b=11110, LU-2523
743 test_mkdir $DIR1/$tdir
744 cp -f /bin/bash $DIR1/$tdir/bash
745 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
746 $DIR1/$tdir/bash -c 'sleep 2;
747 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
751 run_test 30 "recreate file race"
754 test_mkdir $DIR1/$tdir
755 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
756 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
757 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
758 lctl set_param fail_loc=0x314
759 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
760 awk 'BEGIN { FS="+" } /in/ {print $1}')
761 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
763 run_test 31a "voluntary cancel / blocking ast race=============="
766 remote_ost || { skip "local OST" && return 0; }
767 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
769 # make sure there is no local locks due to destroy
770 wait_mds_ost_sync || error "wait_mds_ost_sync()"
771 wait_delete_completed || error "wait_delete_completed()"
773 test_mkdir $DIR1/$tdir
774 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
775 cp /etc/hosts $DIR/$tdir/$tfile
776 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
777 lctl set_param fail_loc=0x314
778 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
779 do_facet ost1 lctl set_param fail_loc=0x316
781 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
782 lctl set_param fail_loc=0
783 do_facet ost1 lctl set_param fail_loc=0
784 # cleanup: reconnect the client back
787 run_test 31b "voluntary OST cancel / blocking ast race=============="
789 # enable/disable lockless truncate feature, depending on the arg 0/1
790 enable_lockless_truncate() {
791 lctl set_param -n $OSC.*.lockless_truncate $1
794 test_32a() { # bug 11270
795 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
796 local stripe_size=$(do_facet $SINGLEMDS \
797 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
799 save_lustre_params client "$OSC.*.lockless_truncate" > $save
800 # restore lockless_truncate default values on exit
801 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
802 cancel_lru_locks $OSC
803 enable_lockless_truncate 1
805 lfs setstripe -c -1 $DIR1/$tfile
806 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
808 clear_stats $OSC.*.${OSC}_stats
810 log "checking cached lockless truncate"
811 $TRUNCATE $DIR1/$tfile 8000000
812 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
813 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
814 error "cached truncate isn't lockless"
816 log "checking not cached lockless truncate"
817 $TRUNCATE $DIR2/$tfile 5000000
818 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
819 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
820 error "not cached truncate isn't lockless"
822 log "disabled lockless truncate"
823 enable_lockless_truncate 0
824 clear_stats $OSC.*.${OSC}_stats
825 $TRUNCATE $DIR2/$tfile 3000000
826 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
827 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
828 error "lockless truncate disabling failed"
831 run_test 32a "lockless truncate"
833 test_32b() { # bug 11270
834 remote_ost_nodsh && skip "remote OST with nodsh" && return
837 local facets=$(get_facets OST)
838 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
840 save_lustre_params client "osc.*.contention_seconds" > $p
841 save_lustre_params $facets \
842 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
843 save_lustre_params $facets \
844 "ldlm.namespaces.filter-*.contended_locks" >> $p
845 save_lustre_params $facets \
846 "ldlm.namespaces.filter-*.contention_seconds" >> $p
847 clear_stats $OSC.*.${OSC}_stats
849 # agressive lockless i/o settings
850 do_nodes $(comma_list $(osts_nodes)) \
851 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
852 ldlm.namespaces.filter-*.contended_locks=0 \
853 ldlm.namespaces.filter-*.contention_seconds=60"
854 lctl set_param -n $OSC.*.contention_seconds=60
856 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
858 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
861 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
862 error "lockless i/o was not triggered"
863 # disable lockless i/o (it is disabled by default)
864 do_nodes $(comma_list $(osts_nodes)) \
865 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
866 ldlm.namespaces.filter-*.contended_locks=32 \
867 ldlm.namespaces.filter-*.contention_seconds=0"
868 # set contention_seconds to 0 at client too, otherwise Lustre still
869 # remembers lock contention
870 lctl set_param -n $OSC.*.contention_seconds=0
871 clear_stats $OSC.*.${OSC}_stats
873 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
875 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
878 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
879 error "lockless i/o works when disabled"
881 restore_lustre_params <$p
884 run_test 32b "lockless i/o"
888 local mdts=$(get_facets MDS)
893 for mds in ${mdts//,/ }; do
895 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
896 xargs readlink -f" ))
897 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
900 stat=$(( stat + val))
905 # commit on sharing tests
907 remote_mds_nodsh && skip "remote MDS with nodsh" && return
909 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
910 [ $CLIENTCOUNT -lt 2 ] &&
911 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
913 local nfiles=${TEST33_NFILES:-10000}
914 local param_file=$TMP/$tfile-params
915 local fstype=$(facet_fstype $SINGLEMDS)
917 save_lustre_params $(get_facets MDS) \
918 "mdt.*.commit_on_sharing" > $param_file
926 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
930 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
932 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
933 echo "=== START createmany old: $jbdold transaction"
934 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")
935 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
936 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
937 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
938 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
939 avgtime=$(( avgtime + elapsed ))
941 eval cos${COS}_jbd=$((avgjbd / 3))
942 eval cos${COS}_time=$((avgtime / 3))
945 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
946 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
947 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
948 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
950 restore_lustre_params < $param_file
954 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
956 # commit on sharing tests
958 remote_mds_nodsh && skip "remote MDS with nodsh" && return
960 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
961 [ $CLIENTCOUNT -ge 2 ] ||
962 { skip "Need two or more clients, have $CLIENTCOUNT" &&
964 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
966 local nfiles=${TEST33_NFILES:-10000}
967 local param_file=$TMP/$tfile-params
969 save_lustre_params $(get_facets MDS) \
970 "mdt.*.commit_on_sharing" > $param_file
979 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
983 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
984 $DIR1/$tdir-\\\$(hostname)-$i"
986 jbdold=$(print_jbd_stat)
987 echo "=== START createmany old: $jbdold transaction"
988 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
989 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
990 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
992 jbdnew=$(print_jbd_stat)
993 jbd=$(( jbdnew - jbdold ))
994 echo "=== END createmany new: $jbdnew transaction : \
995 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
996 avgjbd=$(( avgjbd + jbd ))
997 avgtime=$(( avgtime + elapsed ))
999 eval cos${COS}_jbd=$((avgjbd / 3))
1000 eval cos${COS}_time=$((avgtime / 3))
1003 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1004 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1005 [ "$cos0_jbd" != 0 ] &&
1006 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1007 [ "$cos0_time" != 0 ] &&
1008 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1010 restore_lustre_params < $param_file
1014 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1017 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1018 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1019 skip "DNE CoS not supported" && return
1025 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1026 # do twice in case transaction is committed before unlock, see LU-8200
1028 # remote dir is created on MDT1, which enqueued lock of $tdir on
1030 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1031 mkdir $DIR/$tdir/local.$i
1033 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1034 echo "sync_count $sync_count"
1035 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1038 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1039 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1040 # during sleep remote mkdir should have been committed and canceled
1041 # remote lock spontaneously, which shouldn't trigger sync
1043 mkdir $DIR/$tdir/local.3
1044 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1045 echo "sync_count $sync_count"
1046 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1048 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1050 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1054 local nodes=$(comma_list $(mdts_nodes))
1058 # trigger CoS twice in case transaction commit before unlock
1061 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1063 commit_nr=$(do_nodes $nodes \
1064 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1065 total=$((total + commit_nr));
1070 echo "CoS count $total"
1071 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1075 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1076 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1077 skip "DNE CoS not supported" && return
1079 # remote directory create
1080 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1081 # remote directory unlink
1082 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1083 # striped directory create
1084 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1085 # striped directory setattr
1086 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1087 "chmod 713 $DIR/$tdir"
1088 # striped directory unlink
1089 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1092 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1093 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1094 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1095 touch $DIR/$tdir/d1/tgt" \
1096 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1098 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1099 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1100 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1101 touch $DIR/$tdir/d1/src" \
1102 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1104 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1105 "$LFS migrate -m 1 $DIR/$tdir"
1109 run_test 33d "DNE distributed operation should trigger COS"
1112 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1113 [ $CLIENTCOUNT -ge 2 ] ||
1114 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1117 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1118 skip "DNE CoS not supported" && return
1120 local client2=${CLIENT2:-$(hostname)}
1124 local nodes=$(comma_list $(mdts_nodes))
1125 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1127 $LFS mkdir -c 2 $DIR/$tdir
1128 mkdir $DIR/$tdir/subdir
1129 echo abc > $DIR/$tdir/$tfile
1130 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1131 do_node $client2 touch $DIR/$tdir/subdir
1133 local async_commit_count=$(do_nodes $nodes \
1134 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1135 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1139 run_test 33e "DNE local operation shouldn't trigger COS"
1141 # End commit on sharing tests
1143 get_ost_lock_timeouts() {
1144 local nodes=${1:-$(comma_list $(osts_nodes))}
1146 local locks=$(do_nodes $nodes \
1147 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1155 do_nodes $(comma_list $(osts_nodes)) \
1156 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1157 for i in $(seq $OSTCOUNT); do
1158 wait_osc_import_ready client ost$i
1163 remote_ost_nodsh && skip "remote OST with nodsh" && return
1167 trap cleanup_34 EXIT RETURN
1168 for OPER in notimeout timeout ; do
1169 rm $DIR1/$tfile 2>/dev/null
1170 lock_in=$(get_ost_lock_timeouts)
1171 if [ $OPER == "timeout" ] ; then
1172 for j in `seq $OSTCOUNT`; do
1173 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1174 do_facet ost$j lctl set_param fail_loc=0x511
1176 echo lock should expire
1178 for j in `seq $OSTCOUNT`; do
1179 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1180 do_facet ost$j lctl set_param fail_loc=0x512
1182 echo lock should not expire
1184 echo writing on client1
1185 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1187 echo reading on client2
1188 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1189 # wait for a lock timeout
1191 lock_out=$(get_ost_lock_timeouts)
1192 if [ $OPER == "timeout" ] ; then
1193 if [ $lock_in == $lock_out ]; then
1194 error "no lock timeout happened"
1199 if [ $lock_in != $lock_out ]; then
1200 error "lock timeout happened"
1208 run_test 34 "no lock timeout under IO"
1210 test_35() { # bug 17645
1213 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1214 awk '/generation/{print $2}')
1216 generation[count]=$g
1220 test_mkdir $MOUNT1/$tdir
1221 cancel_lru_locks mdc
1223 # Let's initiate -EINTR situation by setting fail_loc and take
1224 # write lock on same file from same client. This will not cause
1225 # bl_ast yet as lock is already in local cache.
1226 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1227 do_facet client "lctl set_param fail_loc=0x80000317"
1228 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1229 let timeout=timeout*3
1231 while test $nr -lt 10; do
1232 log "Race attempt $nr"
1233 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1234 awk '/ldlm_bl_callback/ { print $2 }')
1235 test "x$blk1" = "x" && blk1=0
1236 createmany -o $MOUNT2/$tdir/a 4000 &
1240 # Let's make conflict and bl_ast
1241 ls -la $MOUNT1/$tdir > /dev/null &
1244 log "Wait for $pid1 $pid2 for $timeout sec..."
1246 kill -9 $pid1 $pid2 > /dev/null 2>&1
1248 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1249 awk '/ldlm_bl_callback/ { print $2 }')
1250 test "x$blk2" = "x" && blk2=0
1251 test $blk2 -gt $blk1 && break
1252 rm -fr $MOUNT1/$tdir
1253 cancel_lru_locks mdc
1256 do_facet client "lctl set_param fail_loc=0x0"
1257 df -h $MOUNT1 $MOUNT2
1259 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1260 awk '/generation/{print $2}')
1262 if ! test "$g" -eq "${generation[count]}"; then
1263 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1265 for imp in $list; do
1266 if [ $c = $count ]; then
1271 imp=$(echo "$imp" | awk -F"." '{print $2}')
1272 error "Eviction happened on import $imp"
1277 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1279 test_36() { #bug 16417
1284 test_mkdir $DIR1/$tdir
1285 $LFS setstripe -c -1 $DIR1/$tdir
1288 let SIZE_B=SIZE*1024*1024
1289 sync; sleep 2; sync # wait for delete thread
1290 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1291 wait_destroy_complete || error "wait_destroy_complete failed"
1293 while [ $i -le 10 ]; do
1294 lctl mark "start test - cycle ($i)"
1295 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1296 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1297 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1298 sync # sync data from client cache
1299 sync_all_data # sync data from server cache (delayed allocation)
1301 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1302 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1304 rm -f $DIR1/$tdir/$tfile
1305 kill -USR1 $read_pid
1307 sync; sleep 2; sync # Ensure new statfs
1308 wait_delete_completed
1309 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1310 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1312 # this free space! not used
1313 (( $after_dd <= $after)) ||
1314 error "space leaked after_dd:$after_dd > after:$after"
1318 run_test 36 "handle ESTALE/open-unlink correctly"
1320 test_37() { # bug 18695
1321 test_mkdir $DIR1/$tdir
1322 multiop_bg_pause $DIR1/$tdir D_c || return 1
1324 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1325 createmany -m $DIR2/$tdir/f 10000
1326 # set mtime/atime backward
1327 touch -t 198001010000 $DIR2/$tdir
1328 kill -USR1 $MULTIPID
1329 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1330 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1333 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1335 # this should be set to past
1336 TEST_39_MTIME=`date -d "1 year ago" +%s`
1340 local client1=${CLIENT1:-`hostname`}
1341 local client2=${CLIENT2:-`hostname`}
1343 do_node $client1 "touch $DIR1/$tfile"
1345 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1346 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1347 [ "$mtime1" = $TEST_39_MTIME ] || \
1348 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1350 local d1=`do_node $client1 date +%s`
1351 do_node $client1 'echo hello >> '$DIR1/$tfile
1352 local d2=`do_node $client1 date +%s`
1354 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1355 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1356 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1358 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1360 for (( i=0; i < 2; i++ )) ; do
1361 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1362 [ "$mtime2" = "$mtime3" ] || \
1363 error "mtime ($mtime2) changed (to $mtime3) on rename"
1365 cancel_lru_locks osc
1366 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1369 run_test 39a "test from 11063 =================================="
1372 local client1=${CLIENT1:-`hostname`}
1373 local client2=${CLIENT2:-`hostname`}
1377 local mtime1=`stat -c %Y $DIR1/$tfile`
1378 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1381 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1383 for (( i=0; i < 2; i++ )) ; do
1384 local mtime3=`stat -c %Y $DIR1/$tfile`
1385 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1387 [ "$mtime3" = "$mtime4" ] || \
1388 error "different mtime on clients: $mtime3, $mtime4"
1389 [ "$mtime3" = $TEST_39_MTIME ] || \
1390 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1392 cancel_lru_locks osc
1393 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1396 run_test 39b "11063 problem 1 =================================="
1399 local client1=${CLIENT1:-`hostname`}
1400 local client2=${CLIENT2:-`hostname`}
1402 echo hello > $DIR1/$tfile
1404 local mtime1=`stat -c %Y $DIR1/$tfile`
1405 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1406 [ "$mtime1" = "$mtime2" ] || \
1407 error "create: different mtime on clients: $mtime1, $mtime2"
1410 $TRUNCATE $DIR1/$tfile 1
1412 for (( i=0; i < 2; i++ )) ; do
1413 local mtime3=`stat -c %Y $DIR1/$tfile`
1414 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1416 [ "$mtime3" = "$mtime4" ] || \
1417 error "different mtime on clients: $mtime3, $mtime4"
1418 [ "$mtime3" -gt $mtime2 ] || \
1419 error "truncate did not update mtime: $mtime2, $mtime3"
1421 cancel_lru_locks osc
1422 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1425 run_test 39c "check truncate mtime update ======================"
1427 test_39d() { # LU-7310
1429 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1431 local mtime1=$(stat -c %Y $DIR2/$tfile)
1432 [ "$mtime1" = $TEST_39_MTIME ] ||
1433 error "mtime: $mtime1, should be $TEST_39_MTIME"
1436 # define OBD_FAIL_OSC_NO_GRANT 0x411
1437 $LCTL set_param fail_loc=0x411
1439 local d1=$(date +%s)
1440 echo hello >> $DIR1/$tfile
1441 local d2=$(date +%s)
1443 $LCTL set_param fail_loc=0
1445 cancel_lru_locks $OSC
1447 local mtime2=$(stat -c %Y $DIR2/$tfile)
1448 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1449 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1451 run_test 39d "sync write should update mtime"
1454 # how long 40-47 take with specific delay
1461 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1462 # avoid unexpected delays due to previous tests
1464 cancel_lru_locks mdc
1465 do_nodes $(comma_list $(mdts_nodes)) \
1466 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1467 do_nodes $(comma_list $(mdts_nodes)) \
1468 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1469 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1472 # check that pid exists hence second operation wasn't blocked by first one
1473 # if it is so then there is no conflict, return 0
1474 # else second operation is conflicting with first one, return 1
1475 check_pdo_conflict() {
1478 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1479 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1489 # test 40: check non-blocking operations
1491 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1493 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1494 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1496 mkdir $DIR1/$tfile &
1498 touch $DIR2/$tfile-2
1499 check_pdo_conflict $PID1 || error "create is blocked"
1500 mkdir $DIR2/$tfile-3
1501 check_pdo_conflict $PID1 || error "mkdir is blocked"
1502 link $DIR2/$tfile-2 $DIR2/$tfile-4
1503 check_pdo_conflict $PID1 || error "link is blocked"
1504 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1505 check_pdo_conflict $PID1 || error "rename is blocked"
1506 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1507 check_pdo_conflict $PID1 || error "getattr is blocked"
1508 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1509 rmdir $DIR2/$tfile-3
1510 check_pdo_conflict $PID1 || error "unlink is blocked"
1512 # all operations above shouldn't wait the first one
1513 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1514 do_facet $SINGLEMDS lctl set_param fail_loc=0
1519 run_test 40a "pdirops: create vs others =============="
1522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1524 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1525 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1526 touch $DIR1/$tfile &
1529 touch $DIR2/$tfile-2
1530 check_pdo_conflict $PID1 || error "create is blocked"
1531 mkdir $DIR2/$tfile-3
1532 check_pdo_conflict $PID1 || error "mkdir is blocked"
1533 link $DIR2/$tfile-2 $DIR2/$tfile-4
1534 check_pdo_conflict $PID1 || error "link is blocked"
1535 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1536 check_pdo_conflict $PID1 || error "rename is blocked"
1537 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1538 check_pdo_conflict $PID1 || error "getattr is blocked"
1539 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1540 rmdir $DIR2/$tfile-3
1541 check_pdo_conflict $PID1 || error "unlink is blocked"
1542 # all operations above shouldn't wait the first one
1544 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1545 do_facet $SINGLEMDS lctl set_param fail_loc=0
1550 run_test 40b "pdirops: open|create and others =============="
1553 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1556 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1557 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1558 link $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 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1568 check_pdo_conflict $PID1 || error "rename is blocked"
1569 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1570 check_pdo_conflict $PID1 || error "getattr is blocked"
1571 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1572 rmdir $DIR2/$tfile-3
1573 check_pdo_conflict $PID1 || error "unlink is blocked"
1575 # all operations above shouldn't wait the first one
1576 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1577 do_facet $SINGLEMDS lctl set_param fail_loc=0
1582 run_test 40c "pdirops: link and others =============="
1585 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1588 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1589 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1593 touch $DIR2/$tfile-2
1594 check_pdo_conflict $PID1 || error "create is blocked"
1595 mkdir $DIR2/$tfile-3
1596 check_pdo_conflict $PID1 || error "mkdir is blocked"
1597 link $DIR2/$tfile-2 $DIR2/$tfile-4
1598 check_pdo_conflict $PID1 || error "link is blocked"
1599 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1600 check_pdo_conflict $PID1 || error "rename is blocked"
1601 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1602 check_pdo_conflict $PID1 || error "getattr is blocked"
1603 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1604 rmdir $DIR2/$tfile-3
1605 check_pdo_conflict $PID1 || error "unlink is blocked"
1607 # all operations above shouldn't wait the first one
1608 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1609 do_facet $SINGLEMDS lctl set_param fail_loc=0
1613 run_test 40d "pdirops: unlink and others =============="
1616 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1619 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1620 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1621 mv $DIR1/$tfile $DIR1/$tfile-0 &
1624 touch $DIR2/$tfile-2
1625 check_pdo_conflict $PID1 || error "create is blocked"
1626 mkdir $DIR2/$tfile-3
1627 check_pdo_conflict $PID1 || error "mkdir is blocked"
1628 link $DIR2/$tfile-2 $DIR2/$tfile-4
1629 check_pdo_conflict $PID1 || error "link is blocked"
1630 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1631 check_pdo_conflict $PID1 || error "getattr is blocked"
1632 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1633 rmdir $DIR2/$tfile-3
1634 check_pdo_conflict $PID1 || error "unlink is blocked"
1636 # all operations above shouldn't wait the first one
1637 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1638 do_facet $SINGLEMDS lctl set_param fail_loc=0
1643 run_test 40e "pdirops: rename and others =============="
1645 # test 41: create blocking operations
1648 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1649 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1650 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1652 mkdir $DIR2/$tfile &
1654 do_facet $SINGLEMDS lctl set_param fail_loc=0
1655 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1656 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1660 run_test 41a "pdirops: create vs mkdir =============="
1664 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1665 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1666 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1668 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1670 do_facet $SINGLEMDS lctl set_param fail_loc=0
1671 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1672 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1676 run_test 41b "pdirops: create vs create =============="
1680 touch $DIR1/$tfile-2
1681 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1682 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1683 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1685 link $DIR2/$tfile-2 $DIR2/$tfile &
1687 do_facet $SINGLEMDS lctl set_param fail_loc=0
1688 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1689 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1693 run_test 41c "pdirops: create vs link =============="
1697 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1698 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1699 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1703 do_facet $SINGLEMDS lctl set_param fail_loc=0
1704 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1705 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1709 run_test 41d "pdirops: create vs unlink =============="
1713 touch $DIR1/$tfile-2
1714 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1715 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1716 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1718 mv $DIR2/$tfile-2 $DIR2/$tfile &
1720 do_facet $SINGLEMDS lctl set_param fail_loc=0
1721 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1722 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1726 run_test 41e "pdirops: create and rename (tgt) =============="
1730 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1731 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1732 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1734 mv $DIR2/$tfile $DIR2/$tfile-2 &
1736 do_facet $SINGLEMDS lctl set_param fail_loc=0
1737 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1738 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1742 run_test 41f "pdirops: create and rename (src) =============="
1746 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1747 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1748 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1750 stat $DIR2/$tfile > /dev/null &
1752 do_facet $SINGLEMDS lctl set_param fail_loc=0
1753 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1754 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1758 run_test 41g "pdirops: create vs getattr =============="
1762 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1763 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1764 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1766 ls -lia $DIR2/ > /dev/null &
1768 do_facet $SINGLEMDS lctl set_param fail_loc=0
1769 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1774 run_test 41h "pdirops: create vs readdir =============="
1776 # test 42: unlink and blocking operations
1779 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1780 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1781 mkdir $DIR1/$tfile &
1783 mkdir $DIR2/$tfile &
1785 do_facet $SINGLEMDS lctl set_param fail_loc=0
1786 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1787 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1791 run_test 42a "pdirops: mkdir vs mkdir =============="
1795 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1796 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1797 mkdir $DIR1/$tfile &
1799 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1801 do_facet $SINGLEMDS lctl set_param fail_loc=0
1802 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1803 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1807 run_test 42b "pdirops: mkdir vs create =============="
1811 touch $DIR1/$tfile-2
1812 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1813 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1814 mkdir $DIR1/$tfile &
1816 link $DIR2/$tfile-2 $DIR2/$tfile &
1818 do_facet $SINGLEMDS lctl set_param fail_loc=0
1819 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1820 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1824 run_test 42c "pdirops: mkdir vs link =============="
1828 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1829 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1830 mkdir $DIR1/$tfile &
1832 rmdir $DIR2/$tfile &
1834 do_facet $SINGLEMDS lctl set_param fail_loc=0
1835 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1836 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1840 run_test 42d "pdirops: mkdir vs unlink =============="
1844 touch $DIR1/$tfile-2
1845 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1846 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1847 mkdir $DIR1/$tfile &
1849 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
1851 do_facet $SINGLEMDS lctl set_param fail_loc=0
1852 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1853 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
1857 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1861 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1862 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1863 mkdir $DIR1/$tfile &
1865 mv $DIR2/$tfile $DIR2/$tfile-2 &
1867 do_facet $SINGLEMDS lctl set_param fail_loc=0
1868 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1869 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1873 run_test 42f "pdirops: mkdir and rename (src) =============="
1877 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1878 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1879 mkdir $DIR1/$tfile &
1881 stat $DIR2/$tfile > /dev/null &
1883 do_facet $SINGLEMDS lctl set_param fail_loc=0
1884 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1885 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1889 run_test 42g "pdirops: mkdir vs getattr =============="
1893 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1894 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1895 mkdir $DIR1/$tfile &
1897 ls -lia $DIR2/ > /dev/null &
1899 do_facet $SINGLEMDS lctl set_param fail_loc=0
1900 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1905 run_test 42h "pdirops: mkdir vs readdir =============="
1907 # test 43: unlink and blocking operations
1911 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1912 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1915 mkdir $DIR2/$tfile &
1917 do_facet $SINGLEMDS lctl set_param fail_loc=0
1918 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1919 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
1923 run_test 43a "pdirops: unlink vs mkdir =============="
1928 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1929 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1932 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1934 do_facet $SINGLEMDS lctl set_param fail_loc=0
1935 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1936 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
1940 run_test 43b "pdirops: unlink vs create =============="
1945 touch $DIR1/$tfile-2
1946 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1947 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1950 link $DIR2/$tfile-2 $DIR2/$tfile &
1952 do_facet $SINGLEMDS lctl set_param fail_loc=0
1953 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1954 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
1958 run_test 43c "pdirops: unlink vs link =============="
1963 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1964 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1969 do_facet $SINGLEMDS lctl set_param fail_loc=0
1970 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1971 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
1975 run_test 43d "pdirops: unlink vs unlink =============="
1980 touch $DIR1/$tfile-2
1981 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1982 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1985 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
1987 do_facet $SINGLEMDS lctl set_param fail_loc=0
1988 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1989 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1993 run_test 43e "pdirops: unlink and rename (tgt) =============="
1998 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1999 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2002 mv $DIR2/$tfile $DIR2/$tfile-2 &
2004 do_facet $SINGLEMDS lctl set_param fail_loc=0
2005 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2006 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2010 run_test 43f "pdirops: unlink and rename (src) =============="
2015 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2016 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2019 stat $DIR2/$tfile > /dev/null &
2021 do_facet $SINGLEMDS lctl set_param fail_loc=0
2022 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2023 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2027 run_test 43g "pdirops: unlink vs getattr =============="
2032 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2033 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2036 ls -lia $DIR2/ > /dev/null &
2038 do_facet $SINGLEMDS lctl set_param fail_loc=0
2039 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2044 run_test 43h "pdirops: unlink vs readdir =============="
2047 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2050 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2051 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2054 $LFS mkdir -i 1 $DIR2/$tfile &
2056 do_facet $SINGLEMDS lctl set_param fail_loc=0
2057 check_pdo_conflict $PID1 &&
2058 { wait $PID1; error "remote mkdir isn't blocked"; }
2059 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2063 run_test 43i "pdirops: unlink vs remote mkdir"
2065 # test 44: rename tgt and blocking operations
2068 touch $DIR1/$tfile-2
2069 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2070 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2071 mv $DIR1/$tfile-2 $DIR1/$tfile &
2073 mkdir $DIR2/$tfile &
2075 do_facet $SINGLEMDS lctl set_param fail_loc=0
2076 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2077 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2082 run_test 44a "pdirops: rename tgt vs mkdir =============="
2086 touch $DIR1/$tfile-2
2087 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2088 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2089 mv $DIR1/$tfile-2 $DIR1/$tfile &
2091 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2093 do_facet $SINGLEMDS lctl set_param fail_loc=0
2094 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2095 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2099 run_test 44b "pdirops: rename tgt vs create =============="
2103 touch $DIR1/$tfile-2
2104 touch $DIR1/$tfile-3
2105 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2106 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2107 mv $DIR1/$tfile-2 $DIR1/$tfile &
2109 link $DIR2/$tfile-3 $DIR2/$tfile &
2111 do_facet $SINGLEMDS lctl set_param fail_loc=0
2112 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2113 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2117 run_test 44c "pdirops: rename tgt vs link =============="
2121 touch $DIR1/$tfile-2
2122 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2123 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2124 mv $DIR1/$tfile-2 $DIR1/$tfile &
2128 do_facet $SINGLEMDS lctl set_param fail_loc=0
2129 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2130 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2134 run_test 44d "pdirops: rename tgt vs unlink =============="
2139 touch $DIR1/$tfile-2
2140 touch $DIR1/$tfile-3
2141 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2142 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2143 mv $DIR1/$tfile-2 $DIR1/$tfile &
2145 mv $DIR2/$tfile-3 $DIR2/$tfile &
2147 do_facet $SINGLEMDS lctl set_param fail_loc=0
2148 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2149 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2153 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2157 touch $DIR1/$tfile-2
2158 touch $DIR1/$tfile-3
2159 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2160 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2161 mv $DIR1/$tfile-2 $DIR1/$tfile &
2163 mv $DIR2/$tfile $DIR2/$tfile-3 &
2165 do_facet $SINGLEMDS lctl set_param fail_loc=0
2166 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2167 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2171 run_test 44f "pdirops: rename tgt and rename (src) =============="
2175 touch $DIR1/$tfile-2
2176 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2177 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2178 mv $DIR1/$tfile-2 $DIR1/$tfile &
2180 stat $DIR2/$tfile > /dev/null &
2182 do_facet $SINGLEMDS lctl set_param fail_loc=0
2183 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2184 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2188 run_test 44g "pdirops: rename tgt vs getattr =============="
2192 touch $DIR1/$tfile-2
2193 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2194 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2195 mv $DIR1/$tfile-2 $DIR1/$tfile &
2197 ls -lia $DIR2/ > /dev/null &
2199 do_facet $SINGLEMDS lctl set_param fail_loc=0
2200 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2205 run_test 44h "pdirops: rename tgt vs readdir =============="
2207 # test 44: rename tgt and blocking operations
2209 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2211 touch $DIR1/$tfile-2
2212 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2213 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2214 mv $DIR1/$tfile-2 $DIR1/$tfile &
2216 $LFS mkdir -i 1 $DIR2/$tfile &
2218 do_facet $SINGLEMDS lctl set_param fail_loc=0
2219 check_pdo_conflict $PID1 && { wait $PID1;
2220 error "remote mkdir isn't blocked"; }
2221 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2225 run_test 44i "pdirops: rename tgt vs remote mkdir"
2227 # test 45: rename src and blocking operations
2231 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2232 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2233 mv $DIR1/$tfile $DIR1/$tfile-2 &
2235 mkdir $DIR2/$tfile &
2237 do_facet $SINGLEMDS lctl set_param fail_loc=0
2238 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2239 wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
2243 run_test 45a "pdirops: rename src vs mkdir =============="
2248 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2249 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2250 mv $DIR1/$tfile $DIR1/$tfile-2 &
2252 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2254 do_facet $SINGLEMDS lctl set_param fail_loc=0
2255 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2256 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2260 run_test 45b "pdirops: rename src vs create =============="
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 mv $DIR1/$tfile $DIR1/$tfile-2 &
2270 link $DIR2/$tfile-3 $DIR2/$tfile &
2272 do_facet $SINGLEMDS lctl set_param fail_loc=0
2273 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2274 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2278 run_test 45c "pdirops: rename src vs link =============="
2283 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2284 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2285 mv $DIR1/$tfile $DIR1/$tfile-2 &
2289 do_facet $SINGLEMDS lctl set_param fail_loc=0
2290 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2291 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2295 run_test 45d "pdirops: rename src vs unlink =============="
2300 touch $DIR1/$tfile-3
2301 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2302 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2303 mv $DIR1/$tfile $DIR1/$tfile-2 &
2305 mv $DIR2/$tfile-3 $DIR2/$tfile &
2307 do_facet $SINGLEMDS lctl set_param fail_loc=0
2308 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2309 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2313 run_test 45e "pdirops: rename src and rename (tgt) =============="
2318 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2319 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2320 mv $DIR1/$tfile $DIR1/$tfile-2 &
2322 mv $DIR2/$tfile $DIR2/$tfile-3 &
2324 do_facet $SINGLEMDS lctl set_param fail_loc=0
2325 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2326 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2330 run_test 45f "pdirops: rename src and rename (src) =============="
2335 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2336 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2337 mv $DIR1/$tfile $DIR1/$tfile-2 &
2339 stat $DIR2/$tfile > /dev/null &
2341 do_facet $SINGLEMDS lctl set_param fail_loc=0
2342 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2343 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2347 run_test 45g "pdirops: rename src vs getattr =============="
2352 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2353 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2354 mv $DIR1/$tfile $DIR1/$tfile-2 &
2356 ls -lia $DIR2/ > /dev/null &
2357 do_facet $SINGLEMDS lctl set_param fail_loc=0
2358 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2363 run_test 45h "pdirops: unlink vs readdir =============="
2366 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2369 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2370 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2371 mv $DIR1/$tfile $DIR1/$tfile-2 &
2373 $LFS mkdir -i 1 $DIR2/$tfile &
2375 do_facet $SINGLEMDS lctl set_param fail_loc=0
2376 check_pdo_conflict $PID1 && { wait $PID1;
2377 error "create remote dir isn't blocked"; }
2378 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2382 run_test 45i "pdirops: rename src vs remote mkdir"
2384 # test 46: link and blocking operations
2387 touch $DIR1/$tfile-2
2388 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2389 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2390 link $DIR1/$tfile-2 $DIR1/$tfile &
2392 mkdir $DIR2/$tfile &
2394 do_facet $SINGLEMDS lctl set_param fail_loc=0
2395 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2396 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2400 run_test 46a "pdirops: link vs mkdir =============="
2404 touch $DIR1/$tfile-2
2405 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2406 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2407 link $DIR1/$tfile-2 $DIR1/$tfile &
2409 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2411 do_facet $SINGLEMDS lctl set_param fail_loc=0
2412 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2413 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2417 run_test 46b "pdirops: link vs create =============="
2421 touch $DIR1/$tfile-2
2422 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2423 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2424 link $DIR1/$tfile-2 $DIR1/$tfile &
2426 link $DIR2/$tfile $DIR2/$tfile &
2428 do_facet $SINGLEMDS lctl set_param fail_loc=0
2429 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2430 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2434 run_test 46c "pdirops: link vs link =============="
2438 touch $DIR1/$tfile-2
2439 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2440 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2441 link $DIR1/$tfile-2 $DIR1/$tfile &
2445 do_facet $SINGLEMDS lctl set_param fail_loc=0
2446 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2447 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2451 run_test 46d "pdirops: link vs unlink =============="
2455 touch $DIR1/$tfile-2
2456 touch $DIR1/$tfile-3
2457 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2458 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2459 link $DIR1/$tfile-2 $DIR1/$tfile &
2461 mv $DIR2/$tfile-3 $DIR2/$tfile &
2463 do_facet $SINGLEMDS lctl set_param fail_loc=0
2464 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2465 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2469 run_test 46e "pdirops: link and rename (tgt) =============="
2473 touch $DIR1/$tfile-2
2474 touch $DIR1/$tfile-3
2475 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2476 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2477 link $DIR1/$tfile-2 $DIR1/$tfile &
2479 mv $DIR2/$tfile $DIR2/$tfile-3 &
2481 do_facet $SINGLEMDS lctl set_param fail_loc=0
2482 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2483 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2487 run_test 46f "pdirops: link and rename (src) =============="
2491 touch $DIR1/$tfile-2
2492 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2493 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2494 link $DIR1/$tfile-2 $DIR1/$tfile &
2496 stat $DIR2/$tfile > /dev/null &
2498 do_facet $SINGLEMDS lctl set_param fail_loc=0
2499 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2500 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2504 run_test 46g "pdirops: link vs getattr =============="
2508 touch $DIR1/$tfile-2
2509 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2510 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2511 link $DIR1/$tfile-2 $DIR1/$tfile &
2513 ls -lia $DIR2/ > /dev/null &
2515 do_facet $SINGLEMDS lctl set_param fail_loc=0
2516 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2521 run_test 46h "pdirops: link vs readdir =============="
2524 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2526 touch $DIR1/$tfile-2
2527 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2528 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2529 link $DIR1/$tfile-2 $DIR1/$tfile &
2531 $LFS mkdir -i 1 $DIR2/$tfile &
2533 do_facet $SINGLEMDS lctl set_param fail_loc=0
2534 check_pdo_conflict $PID1 && { wait $PID1;
2535 error "remote mkdir isn't blocked"; }
2536 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2540 run_test 46i "pdirops: link vs remote mkdir"
2542 # test 47: remote mkdir and blocking operations
2544 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2545 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2547 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2548 $LFS mkdir -i 1 $DIR1/$tfile &
2550 mkdir $DIR2/$tfile &
2552 do_facet $SINGLEMDS lctl set_param fail_loc=0
2553 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2554 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2558 run_test 47a "pdirops: remote mkdir vs mkdir"
2561 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2562 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2564 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2565 $LFS mkdir -i 1 $DIR1/$tfile &
2567 sleep 1 # please do not remove this sleep, see LU-10754
2568 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2570 do_facet $SINGLEMDS lctl set_param fail_loc=0
2571 check_pdo_conflict $PID1 && { wait $PID1;
2572 error "create isn't blocked"; }
2573 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2577 run_test 47b "pdirops: remote mkdir vs create"
2580 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2582 touch $DIR1/$tfile-2
2583 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2584 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2585 $LFS mkdir -i 1 $DIR1/$tfile &
2587 link $DIR2/$tfile-2 $DIR2/$tfile &
2589 do_facet $SINGLEMDS lctl set_param fail_loc=0
2590 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2591 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2595 run_test 47c "pdirops: remote mkdir vs link"
2598 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2600 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2601 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2602 $LFS mkdir -i 1 $DIR1/$tfile &
2604 rmdir $DIR2/$tfile &
2606 do_facet $SINGLEMDS lctl set_param fail_loc=0
2607 check_pdo_conflict $PID1 && { wait $PID1;
2608 error "unlink isn't blocked"; }
2609 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2613 run_test 47d "pdirops: remote mkdir vs unlink"
2616 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2618 touch $DIR1/$tfile-2
2619 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2620 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2621 $LFS mkdir -i 1 $DIR1/$tfile &
2623 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2625 do_facet $SINGLEMDS lctl set_param fail_loc=0
2626 check_pdo_conflict $PID1 && { wait $PID1;
2627 error "rename isn't blocked"; }
2628 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2632 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2635 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2637 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2638 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2639 $LFS mkdir -i 1 $DIR1/$tfile &
2641 mv $DIR2/$tfile $DIR2/$tfile-2 &
2643 do_facet $SINGLEMDS lctl set_param fail_loc=0
2644 check_pdo_conflict $PID1 && { wait $PID1;
2645 error "rename isn't blocked"; }
2646 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2650 run_test 47f "pdirops: remote mkdir and rename (src)"
2653 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2657 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2658 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2659 $LFS mkdir -i 1 $DIR1/$tfile &
2661 stat $DIR2/$tfile > /dev/null &
2663 do_facet $SINGLEMDS lctl set_param fail_loc=0
2664 check_pdo_conflict $PID1 && { wait $PID1;
2665 error "getattr isn't blocked"; }
2666 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2670 run_test 47g "pdirops: remote mkdir vs getattr"
2674 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2675 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2676 do_facet client "lctl set_param fail_loc=0x410"
2677 $TRUNCATE $DIR2/$tfile $trunc_size
2678 do_facet client "lctl set_param fail_loc=0x0"
2680 size=`stat -c %s $DIR2/$tfile`
2681 [ $size -eq $trunc_size ] || error "wrong size"
2683 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2687 local origfile=/etc/hosts
2689 filesize=$(stat -c %s $origfile)
2691 # create an empty file
2692 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
2693 # cache layout lock on both mount point
2694 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
2695 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
2697 # open and sleep 2 seconds then read
2698 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2702 # create the layout of testing file
2703 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
2704 error "dd $DIR1/$tfile failed"
2706 # MULTIOP proc should be able to read enough bytes and exit
2707 for ((i = 0; i < 6; i++)); do
2709 kill -0 $pid || break
2711 kill -0 $pid 2> /dev/null && error "multiop is still there"
2712 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
2716 run_test 51a "layout lock: refresh layout should work"
2719 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2720 { skip "Need MDS version at least 2.3.59"; return 0; }
2722 local tmpfile=`mktemp`
2724 # create an empty file
2725 $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
2727 # delay glimpse so that layout has changed when glimpse finish
2728 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2729 $LCTL set_param fail_loc=0x1404
2730 stat -c %s $DIR2/$tfile |tee $tmpfile &
2734 # create layout of testing file
2735 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
2736 error "dd $DIR1/$tfile failed"
2739 local fsize=$(cat $tmpfile)
2741 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2743 rm -f $DIR1/$tfile $tmpfile
2745 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2748 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
2750 # set default layout to have 1 stripe
2752 $LFS setstripe -c 1 $DIR1/$tdir
2754 # create a file with empty layout
2755 $MCREATE $DIR1/$tdir/$tfile ||
2756 error "$MCREATE $DIR1/$tdir/$tfile failed"
2758 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2759 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2761 # change the layout of testing file
2762 echo "Setting layout to have $OSTCOUNT stripes ..."
2763 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2767 # write something to the file, it should be blocked on fetching layout
2768 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2769 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2772 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
2773 # count to succeed with only 3/4 of the number of stripes (rounded up),
2774 # so creating striped files does not fail if an OST is offline or full
2775 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
2776 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
2780 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2783 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2784 cancel_lru_locks mdc
2786 # open should grant LAYOUT lock, mmap and read will install pages
2787 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2791 # rss before revoking
2792 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2793 echo "Before revoking layout lock: $br KB mapped"
2795 # cancel layout lock manually
2796 cancel_lru_locks mdc
2798 # rss after revoking
2799 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2802 wait $PID || error "wait PID $PID failed"
2804 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2806 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2810 echo "==> rename vs getattr vs setxattr should not deadlock"
2811 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2813 do_facet mds1 $LCTL set_param fail_loc=$1
2815 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2823 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2824 wait $PID1 || error "(3) mv failed"
2825 wait $PID2 || error "(4) stat failed"
2832 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2833 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2835 do_facet mds1 $LCTL set_param fail_loc=$1
2837 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2845 $MULTIOP $DIR2/d1/d2 Oc &
2849 stat $DIR/d1 || error "(2) stat failed"
2851 wait $PID1 || error "(3) mv failed"
2852 wait $PID2 || error "(4) stat failed"
2853 wait $PID3 && error "(5) multiop failed"
2859 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2860 save_lustre_params client "llite.*.xattr_cache" > $p
2861 lctl set_param llite.*.xattr_cache 1 ||
2862 { skip "xattr cache is not supported"; return 0; }
2864 #define OBD_FAIL_MDS_RENAME 0x153
2865 #define OBD_FAIL_MDS_RENAME2 0x154
2866 test_54_part1 0x80000153 || error 10
2867 test_54_part1 0x80000154 || error 11
2868 test_54_part2 0x80000153 || error 12
2869 test_54_part2 0x80000154 || error 13
2871 restore_lustre_params < $p
2874 run_test 54 "rename locking"
2877 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2879 #define OBD_FAIL_MDS_RENAME4 0x156
2880 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2882 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2887 wait $PID1 && error "(2) mv succeeded"
2891 run_test 55a "rename vs unlink target dir"
2895 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2897 #define OBD_FAIL_MDS_RENAME4 0x156
2898 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2900 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2905 wait $PID1 && error "(2) mv succeeded"
2909 run_test 55b "rename vs unlink source dir"
2913 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2915 #define OBD_FAIL_MDS_RENAME4 0x156
2916 do_facet mds1 $LCTL set_param fail_loc=0x156
2918 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2922 # while rename is sleeping, open and remove d3
2923 $MULTIOP $DIR2/d3 D_c &
2929 # while rename is sleeping 2nd time, close d3
2931 wait $PID2 || error "(3) multiop failed"
2933 wait $PID1 && error "(2) mv succeeded"
2937 run_test 55c "rename vs unlink orphan target dir"
2943 #define OBD_FAIL_MDS_RENAME3 0x155
2944 do_facet mds1 $LCTL set_param fail_loc=0x155
2945 mv $DIR/f1 $DIR/$tdir &
2949 # while rename is sleeping, create $tdir, but as a directory
2950 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2952 # link in reverse locking order
2953 ln $DIR2/f1 $DIR2/$tdir/
2955 wait $PID1 && error "(2) mv succeeded"
2958 run_test 55d "rename file vs link"
2961 local MDSVER=$(lustre_build_version $SINGLEMDS)
2962 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2963 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2966 test_mkdir $DIR1/$tdir
2967 file1=$DIR1/$tdir/file
2968 file2=$DIR2/$tdir/file
2970 echo orig > $file2 || error "Could not create $file2"
2971 version=$($LFS data_version $file1)
2974 echo append >> $file2 || error "Could not append to $file2"
2975 version2=$($LFS data_version $file1)
2976 [ "$version" != "$version2" ] ||
2977 error "append did not change data version: $version"
2980 echo overwrite > $file2 || error "Could not overwrite $file2"
2981 version3=$($LFS data_version $file1)
2982 [ "$version2" != "$version3" ] ||
2983 error "overwrite did not change data version: $version2"
2985 # Truncate before EOF
2986 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2987 version4=$($LFS data_version $file1)
2988 [ "$version3" != "$version4" ] ||
2989 error "truncate did not change data version: $version3"
2991 # Truncate after EOF
2992 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2993 version5=$($LFS data_version $file1)
2994 [ "$version4" != "$version5" ] ||
2995 error "truncate did not change data version: $version4"
2997 # Chmod do not change version
2998 chmod 400 $file2 || error "Could not chmod 400 $file2"
2999 version6=$($LFS data_version $file1)
3000 [ "$version5" == "$version6" ] ||
3001 error "chmod should not change data version: $version5 != $version6"
3003 # Chown do not change version
3004 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3005 version7=$($LFS data_version $file1)
3006 [ "$version5" == "$version7" ] ||
3007 error "chown should not change data version: $version5 != $version7"
3009 run_test 60 "Verify data_version behaviour"
3012 local test_dir=$tdir/test_dir
3014 mkdir -p $DIR1/$tdir
3015 if [ $MDSCOUNT -ge 2 ]; then
3017 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3018 error "Create remote directory failed"
3020 mkdir -p $DIR1/$test_dir
3022 cd $DIR2/$test_dir || error "cd directory failed"
3023 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3025 cd $DIR2/$tdir || error "exit directory"
3027 run_test 70a "cd directory && rm directory"
3029 test_70b() { # LU-2781
3031 mkdir -p $DIR1/$tdir
3033 touch $DIR1/$tdir/file
3034 for ((i = 0; i < 32; i++)); do
3035 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3037 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3039 touch $DIR1/$tdir/file
3040 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3041 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3042 rm -rf $DIR1/$tdir/test_dir ||
3043 error "cannot remove directory after rm_entry"
3044 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3046 run_test 70b "remove files after calling rm_entry"
3049 local server_version=$(lustre_version_code $SINGLEMDS)
3051 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3052 skip "Need MDS version at least 2.1.6" && return
3054 # Patch not applied to 2.2 and 2.3 branches
3055 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3056 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3057 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3060 checkfiemap --test ||
3061 { skip "checkfiemap not runnable: $?" && return; }
3062 # write data this way: hole - data - hole - data
3063 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3064 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3066 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3067 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3068 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3070 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3072 checkfiemap $DIR2/$tfile 81920 ||
3073 error "data is not flushed from client"
3074 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3077 # common case of "create file, copy file" on a single node
3078 # should not flush data from ost
3079 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3080 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3082 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3084 checkfiemap $DIR1/$tfile 81920 ||
3086 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3088 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3090 run_test 71a "correct file map just after write operation is finished"
3093 local server_version=$(lustre_version_code $SINGLEMDS)
3095 [[ $server_version -lt $(version_code 2.1.6) ]] &&
3096 skip "Need MDS version at least 2.1.6" && return
3098 # Patch not applied to 2.2 and 2.3 branches
3099 [[ $server_version -ge $(version_code 2.2.0) ]] &&
3100 [[ $server_version -lt $(version_code 2.4.0) ]] &&
3101 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" &&
3103 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
3105 checkfiemap --test ||
3106 { skip "error $?: checkfiemap failed" && return; }
3108 mkdir -p $DIR1/$tdir
3110 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3111 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3112 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3114 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3115 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3117 run_test 71b "check fiemap support for stripecount > 1"
3120 local p="$TMP/sanityN-$TESTNAME.parameters"
3123 save_lustre_params client "llite.*.xattr_cache" > $p
3124 lctl set_param llite.*.xattr_cache 1 ||
3125 { skip "xattr cache is not supported"; return 0; }
3128 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3129 error "setfattr1 failed"
3130 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3131 error "getfattr1 failed"
3132 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3133 error "setfattr2 failed"
3134 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3135 error "getfattr2 failed"
3137 # check that trusted.link is consistent
3138 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3139 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3140 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3141 echo "$tlink1 $tlink2"
3142 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3146 restore_lustre_params < $p
3149 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3152 local p="$TMP/sanityN-$TESTNAME.parameters"
3153 save_lustre_params client "llite.*.xattr_cache" > $p
3154 lctl set_param llite.*.xattr_cache 1 ||
3155 { skip "xattr cache is not supported"; return 0; }
3158 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3159 error "setfattr1 failed"
3160 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3161 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3162 clear_stats llite.*.stats
3163 # PR lock should be cached by now on both clients
3164 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3165 # 2 hits for getfattr(0)+getfattr(size)
3166 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3167 error "not cached in $DIR1"
3168 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3169 # 4 hits for more getfattr(0)+getfattr(size)
3170 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3171 error "not cached in $DIR2"
3174 restore_lustre_params < $p
3177 run_test 73 "getxattr should not cause xattr lock cancellation"
3180 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
3181 skip "Need MDS version at least 2.4.93" && return
3183 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3184 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3185 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3187 run_test 74 "flock deadlock: different mounts =============="
3191 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3192 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3193 cancel_lru_locks osc
3195 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3198 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3199 $LCTL set_param fail_loc=0x31d
3200 stat -c %s $DIR1/$tfile &
3205 # For bad lock error handler we should ASSERT and got kernel panic here
3207 $LCTL set_param fail_loc=0
3209 run_test 75 "osc: upcall after unuse lock==================="
3212 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
3213 skip "Need MDS version at least 2.5.53" && return
3215 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3216 local fcount=$((MDSCOUNT * 256))
3221 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3227 test_mkdir $DIR/$tdir
3229 # drop all open locks and close any cached "open" files on the client
3230 cancel_lru_locks mdc
3232 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3233 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3234 local already=${#fid_list[@]}
3235 for (( i = 0; i < $already; i++ )) ; do
3236 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3239 echo -n "opening files: "
3240 ulimit -n $((fcount + 50))
3241 for ((i = 0; i < $fcount; i++)); do
3242 touch $DIR/$tdir/f_$i
3243 local fd=$(free_fd ${fd_list[i]})
3244 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3249 (( $i % 32 == 0 )) && echo -n "."
3253 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3255 # Possible errors in openfiles FID list.
3256 # 1. Missing FIDs. Check 1
3257 # 2. Extra FIDs. Check 1
3258 # 3. Duplicated FID. Check 2
3259 # 4. Invalid FIDs. Check 2
3260 # 5. Valid FID, points to some other file. Check 3
3263 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3264 error "${#fid_list[@]} != $fcount (+$already old) open files"
3266 echo -n "closing files: "
3267 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3268 local close_cmd="exec ${fd_list[fd]}<&-"
3270 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3272 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3273 echo "skip old open file $filename"
3275 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3279 rm --interactive=no $filename
3281 error "Nonexisting fid ${fid_list[fid]} listed."
3282 (( $fd % 32 == 0 )) && echo -n "."
3287 ls_op=$(ls $DIR2/$tdir | wc -l)
3289 error "Some openfiles are missing in lproc output"
3293 run_test 76 "Verify MDT open_files listing"
3297 local dir=$DIR/$tdir
3300 mkdir $dir || error "mkdir $dir failed"
3301 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3304 do_nodes $CLIENTS $myRUNAS \
3305 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3306 error "dd at 0 on client failed (1)"
3308 do_nodes $CLIENTS $myRUNAS \
3310 for ((i = 0; i < $n; i++)); do
3311 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3312 seek=\\\$i count=1 conv=notrunc &
3313 pids_w[\\\$i]=\\\$!;
3316 for ((i = 0; i < $n; i++)); do
3317 wait \\\${pids_w[\\\$i]};
3319 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3323 do_nodes $CLIENTS sync;
3324 cancel_lru_locks osc
3326 do_nodes $CLIENTS $myRUNAS \
3328 for ((i = 0; i < $n; i++)); do
3329 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3330 seek=\\\$i count=1 &
3331 pids_r[\\\$i]=\\\$!;
3334 for ((i = 0; i < $n; i++)); do
3335 wait \\\${pids_r[\\\$i]};
3337 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3341 cancel_lru_locks osc
3343 wait $pid_w || error "dd (write) failed (2)"
3344 wait $pid_r || error "dd (read) failed (3)"
3345 rm -rvf $dir || error "rm -rf $dir failed"
3348 test_77a() { #LU-3266
3351 oss=$(comma_list $(osts_nodes))
3352 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3354 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3355 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3360 run_test 77a "check FIFO NRS policy"
3362 test_77b() { #LU-3266
3365 oss=$(comma_list $(osts_nodes))
3367 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3368 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3369 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3370 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3372 echo "policy: crr-n, crrn_quantum 1"
3375 do_nodes $oss lctl set_param \
3376 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3377 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3379 echo "policy: crr-n, crrn_quantum 64"
3383 do_nodes $oss lctl set_param \
3384 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3385 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3388 run_test 77b "check CRR-N NRS policy"
3393 oss=$(comma_list $(osts_nodes))
3395 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3396 ost.OSS.*.nrs_"$policy"_quantum=1 \
3397 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3398 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3400 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3401 "physical, ${policy}_supported reads"
3404 do_nodes $oss lctl set_param \
3405 ost.OSS.*.nrs_${policy}_supported="writes" \
3406 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3408 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3409 "physical, ${policy}_supported writes"
3412 do_nodes $oss lctl set_param \
3413 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3414 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3415 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3416 "logical, ${policy}_supported reads_and_writes"
3420 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3425 test_77c() { #LU-3266
3427 orr_trr "orr" || rc=$?
3428 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3429 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3432 run_test 77c "check ORR NRS policy"
3434 test_77d() { #LU-3266
3436 orr_trr "trr" || rc=$?
3437 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3438 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3441 run_test 77d "check TRR nrs policy"
3448 do_facet $facet lctl set_param \
3449 ost.OSS.ost_io.nrs_tbf_rule="$*"
3451 error "failed to run operate '$*' on TBF rules"
3454 cleanup_tbf_verify()
3458 echo "cleanup_tbf $DIR/$tdir"
3461 wait_delete_completed
3466 local dir=$DIR/$tdir
3467 local client1=${CLIENT1:-$(hostname)}
3470 local np=$(check_cpt_number ost1)
3471 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3472 echo "cpu_npartitions on ost1 is $np"
3474 mkdir $dir || error "mkdir $dir failed"
3475 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3478 trap cleanup_tbf_verify EXIT
3479 echo "Limited write rate: $1, read rate: $2"
3480 echo "Verify the write rate is under TBF control"
3481 local start=$SECONDS
3482 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3483 bs=1M count=100 oflag=direct 2>&1
3484 local runtime=$((SECONDS - start + 1))
3485 local rate=$(bc <<< "scale=6; 100 / $runtime")
3486 echo "Write runtime is $runtime s, speed is $rate IOPS"
3488 # verify the write rate does not exceed TBF rate limit
3489 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3490 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3492 cancel_lru_locks osc
3494 echo "Verify the read rate is under TBF control"
3496 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3497 bs=1M count=100 iflag=direct 2>&1
3498 runtime=$((SECONDS - start + 1))
3499 rate=$(bc <<< "scale=6; 100 / $runtime")
3500 echo "Read runtime is $runtime s, speed is $rate IOPS"
3502 # verify the read rate does not exceed TBF rate limit
3503 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3504 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3506 cancel_lru_locks osc
3507 cleanup_tbf_verify || error "rm -rf $dir failed"
3513 oss=$(comma_list $(osts_nodes))
3515 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3517 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3518 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3522 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3527 # Only operate rules on ost1 since OSTs might run on the same OSS
3529 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3530 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3531 local client_nids=$(nids_list $address "\\")
3532 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3533 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3537 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3538 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3539 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3543 tbf_rule_operate ost1 "stop\ localhost"
3544 tbf_rule_operate ost1 "stop\ clients"
3545 tbf_rule_operate ost1 "stop\ others"
3548 # Cleanup the TBF policy
3549 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3550 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3554 run_test 77e "check TBF NID nrs policy"
3559 oss=$(comma_list $(osts_nodes))
3561 do_nodes $oss $LCTL set_param \
3562 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3563 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3564 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3566 # Configure jobid_var
3567 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3569 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3570 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3571 if [ $saved_jobid_var != procname_uid ]; then
3572 set_persistent_param_and_check client \
3573 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3578 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3583 # Only operate rules on ost1 since OSTs might run on the same OSS
3585 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3586 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3587 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3588 nrs_write_read "$RUNAS"
3591 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3592 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3593 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3594 nrs_write_read "$RUNAS"
3597 tbf_rule_operate ost1 "stop\ runas"
3598 tbf_rule_operate ost1 "stop\ iozone_runas"
3599 tbf_rule_operate ost1 "stop\ dd_runas"
3600 nrs_write_read "$RUNAS"
3602 # Cleanup the TBF policy
3603 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3604 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3605 nrs_write_read "$RUNAS"
3607 local current_jobid_var=$($LCTL get_param -n jobid_var)
3608 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
3609 if [ $saved_jobid_var != $current_jobid_var ]; then
3610 set_persistent_param_and_check client \
3611 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
3615 run_test 77f "check TBF JobID nrs policy"
3620 oss=$(comma_list $(osts_nodes))
3622 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3624 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3625 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3627 do_nodes $oss lctl set_param \
3628 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3629 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3633 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3638 # Add a rule that only valid for Jobid TBF. If direct change between
3639 # TBF types is not supported, this operation will fail.
3640 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3642 # Cleanup the TBF policy
3643 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3644 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3647 run_test 77g "Change TBF type directly"
3650 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3651 { skip "Need OST version at least 2.8.55"; return 0; }
3653 local old_policy=$(do_facet ost1 \
3654 lctl get_param ost.OSS.ost_io.nrs_policies)
3657 do_facet ost1 lctl set_param \
3658 ost.OSS.ost_io.nrs_policies="abc"
3659 [ $? -eq 0 ] && error "should return error"
3661 do_facet ost1 lctl set_param \
3662 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3663 [ $? -eq 0 ] && error "should return error"
3665 do_facet ost1 lctl set_param \
3666 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3667 [ $? -eq 0 ] && error "should return error"
3669 do_facet ost1 lctl set_param \
3670 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3671 [ $? -eq 0 ] && error "should return error"
3673 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3674 [ $? -eq 0 ] || error "shouldn't LBUG"
3676 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3680 run_test 77h "Wrong policy name should report error, not LBUG"
3686 local error_message=$3
3688 for rule in $expected; do
3689 rule_number=$((rule_number + 1))
3691 local stop_line=$(($rule_number + 3))
3692 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3694 local output=$(do_facet $facet lctl get_param \
3695 ost.OSS.ost_io.nrs_tbf_rule |
3699 if [ "$output" != "$expected" ]; then
3700 error "$error_message, expected '$expected', got '$output'"
3705 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3706 { skip "Need OST version at least 2.8.55"; return 0; }
3708 for i in $(seq 1 $OSTCOUNT)
3710 do_facet ost"$i" lctl set_param \
3711 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3713 error "failed to set TBF policy"
3716 tbf_rule_check ost1 "default" "error before inserting any rule"
3718 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3719 tbf_rule_check ost1 "before default" \
3720 "error when inserting rule 'before'"
3722 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3723 tbf_rule_check ost1 "before after default" \
3724 "error when inserting rule 'after'"
3726 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3727 tbf_rule_check ost1 "before target after default" \
3728 "error when inserting rule 'target'"
3730 echo "Move before itself"
3731 tbf_rule_operate ost1 "change\ target\ rank=target"
3732 tbf_rule_check ost1 "before target after default" \
3733 "error when moving before itself"
3735 echo "Move to higher rank"
3736 tbf_rule_operate ost1 "change\ target\ rank=before"
3737 tbf_rule_check ost1 "target before after default" \
3738 "error when moving to higher rank"
3740 echo "Move to lower rank"
3741 tbf_rule_operate ost1 "change\ target\ rank=after"
3742 tbf_rule_check ost1 "before target after default" \
3743 "error when moving to lower rank"
3745 echo "Move before default"
3746 tbf_rule_operate ost1 "change\ target\ rank=default"
3747 tbf_rule_check ost1 "before after target default" \
3748 error "error when moving before default"
3750 # Cleanup the TBF policy
3751 do_nodes $(comma_list $(osts_nodes)) \
3752 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3755 run_test 77i "Change rank of TBF rule"
3760 local ost_version=$(lustre_version_code ost1)
3762 [ $ost_version -ge $(version_code 2.9.53) ] ||
3763 { skip "Need OST version at least 2.9.53"; return 0; }
3764 if [ $ost_version -ge $(version_code 2.8.60) ]; then
3769 do_nodes $(comma_list $(osts_nodes)) \
3770 lctl set_param jobid_var=procname_uid \
3771 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
3772 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
3773 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
3774 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
3779 do_nodes $(comma_list $(osts_nodes)) \
3780 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
3781 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
3782 ost.OSS.ost_io.nrs_policies="fifo"
3784 # sleep 3 seconds to wait the tbf policy stop completely,
3785 # or the next test case is possible get -EAGAIN when
3786 # setting the tbf policy
3789 run_test 77j "check TBF-OPCode NRS policy"
3792 local idstr="${1}id"
3793 local policy="${idstr}={$2}"
3794 local rate="rate=$3"
3796 do_nodes $(comma_list $(osts_nodes)) \
3797 lctl set_param jobid_var=procname_uid \
3798 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
3799 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
3800 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
3802 nrs_write_read "runas $4"
3803 tbf_verify $3 $3 "runas $4"
3805 do_nodes $(comma_list $(osts_nodes)) \
3806 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
3807 ost.OSS.ost_io.nrs_policies="fifo"
3809 # sleep 3 seconds to wait the tbf policy stop completely,
3810 # or the next test case is possible get -eagain when
3811 # setting the tbf policy
3816 if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
3817 skip "Need OST version at least 2.11.50"
3820 test_id "u" "500" "5" "-u 500"
3821 test_id "g" "500" "5" "-u 500 -g 500"
3823 run_test 77ja "check TBF-UID/GID NRS policy"
3831 for rule in $rule_lists; do
3832 do_nodes $(comma_list $(osts_nodes)) \
3833 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
3836 do_nodes $(comma_list $(osts_nodes)) \
3837 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
3843 [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] ||
3844 { skip "Need OST version at least 2.9.53"; return 0; }
3846 do_nodes $(comma_list $(osts_nodes)) \
3847 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
3848 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
3849 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
3851 nrs_write_read "$RUNAS"
3852 tbf_verify 20 10 "$RUNAS"
3854 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3855 local client_nids=$(nids_list $address "\\")
3856 do_nodes $(comma_list $(osts_nodes)) \
3857 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3858 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3859 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
3860 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
3865 do_nodes $(comma_list $(osts_nodes)) \
3866 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
3867 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
3868 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
3870 nrs_write_read "$RUNAS"
3871 tbf_verify 20 20 "$RUNAS"
3873 do_nodes $(comma_list $(osts_nodes)) \
3874 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
3875 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
3876 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
3878 nrs_write_read "$RUNAS"
3879 # with parameter "RUNAS", it will match the latest rule
3880 # "ext_b" first, so the limited write rate is 10.
3881 tbf_verify 10 10 "$RUNAS"
3884 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
3886 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] ||
3887 { skip "Need OST version at least 2.10.58"; return 0; }
3889 do_nodes $(comma_list $(osts_nodes)) \
3890 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
3891 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
3892 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
3893 nrs_write_read "runas -u 500 -g 1000"
3894 tbf_verify 5 5 "runas -u 500 -g 1000"
3896 do_nodes $(comma_list $(osts_nodes)) \
3897 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
3898 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
3899 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
3901 nrs_write_read "runas -u 500"
3902 tbf_verify 20 10 "runas -u 500"
3904 do_nodes $(comma_list $(osts_nodes)) \
3905 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
3906 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
3907 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
3908 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
3909 nrs_write_read "runas -u 500"
3910 tbf_verify 10 10 "runas -u 500"
3911 tbf_verify 20 10 "runas -u 500"
3912 cleanup_77k "ext_a ext_b" "fifo"
3914 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
3917 [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
3918 { skip "Need OST version at least 2.10.56"; return 0; }
3920 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3921 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
3923 local output=$(do_facet ost1 lctl get_param \
3924 ost.OSS.ost_io.nrs_policies | \
3925 awk '/name: tbf/ {print;exit}' | \
3926 awk -F ': ' '{print $2}')
3928 if [ "$output" != "tbf" ]; then
3929 error "The generic TBF output is '$output', not 'tbf'"
3932 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3934 run_test 77l "check the output of NRS policies for generic TBF"
3937 if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
3938 skip "Need OST version at least 2.9.54"
3942 local dir=$DIR/$tdir
3944 mkdir $dir || error "mkdir $dir failed"
3945 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3948 local nodes=$(comma_list $(osts_nodes))
3949 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
3950 ost.OSS.ost_io.nrs_delay_min=4 \
3951 ost.OSS.ost_io.nrs_delay_max=4 \
3952 ost.OSS.ost_io.nrs_delay_pct=100
3953 [ $? -ne 0 ] && error "Failed to set delay policy"
3955 local start=$SECONDS
3956 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3957 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
3958 oflag=direct conv=fdatasync ||
3959 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3960 error "dd on client failed (1)"; }
3961 local elapsed=$((SECONDS - start))
3963 # NRS delay doesn't do sub-second timing, so a request enqueued at
3964 # 0.9 seconds can be dequeued at 4.0
3965 [ $elapsed -lt 3 ] &&
3966 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3967 error "Single 1M write should take at least 3 seconds"; }
3970 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
3971 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
3972 oflag=direct conv=fdatasync ||
3973 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3974 error "dd on client failed (2)"; }
3975 elapsed=$((SECONDS - start))
3977 [ $elapsed -lt 30 ] &&
3978 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
3979 error "Ten 1M writes should take at least 30 seconds"; }
3981 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3982 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3986 run_test 77m "check NRS Delay slows write RPC processing"
3988 test_77n() { #LU-10802
3989 if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then
3990 skip "Need OST version at least 2.10.58"
3994 # Configure jobid_var
3995 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3996 if [ $saved_jobid_var != procname_uid ]; then
3997 set_persistent_param_and_check client \
3998 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4001 do_nodes $(comma_list $(osts_nodes)) \
4002 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4003 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4004 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4007 tbf_verify 20 20 "$RUNAS"
4009 do_nodes $(comma_list $(osts_nodes)) \
4010 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4011 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4016 do_nodes $(comma_list $(osts_nodes)) \
4017 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4018 ost.OSS.ost_io.nrs_policies="fifo"
4022 local current_jobid_var=$($LCTL get_param -n jobid_var)
4023 if [ $saved_jobid_var != $current_jobid_var ]; then
4024 set_persistent_param_and_check client \
4025 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4028 run_test 77n "check wildcard support for TBF JobID NRS policy"
4030 test_78() { #LU-6673
4033 oss=$(comma_list $(osts_nodes))
4034 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4035 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4037 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4038 # Valid return codes are:
4039 # 0: Tuning succeeded
4040 # ENODEV: Policy is still stopped
4041 # EAGAIN: Policy is being initialized
4042 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4043 error "Expected set_param to return 0|ENODEV|EAGAIN"
4045 # Cleanup the ORR policy
4046 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4047 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4050 run_test 78 "Enable policy and specify tunings right away"
4053 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4054 test_mkdir $DIR/$tdir
4056 # Prevent interference from layout intent RPCs due to
4057 # asynchronous writeback. These will be tested in 130c below.
4058 do_nodes ${CLIENTS:-$HOSTNAME} sync
4060 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4061 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4063 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4064 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4065 local facet=mds$((mdtidx + 1))
4067 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4068 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4072 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4073 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4078 run_test 79 "xattr: intent error"
4081 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4088 mkdir -p $DIR1/$tdir/dir
4089 createmany -o $DIR1/$tdir/dir/f 10 ||
4090 error "create files under remote dir failed $i"
4092 cp /etc/passwd $DIR1/$tdir/$tfile
4094 #migrate open file should fails
4095 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4097 # give multiop a chance to open
4100 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4101 error "migrate open files should failed with open files"
4105 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4106 error "migrate remote dir error"
4108 echo "Finish migration, then checking.."
4109 for file in $(find $DIR1/$tdir); do
4110 mdt_index=$($LFS getstripe -m $file)
4111 [ $mdt_index == $MDTIDX ] ||
4112 error "$file is not on MDT${MDTIDX}"
4115 diff /etc/passwd $DIR1/$tdir/$tfile ||
4116 error "file different after migration"
4118 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4120 run_test 80a "migrate directory when some children is being opened"
4124 kill -9 $migrate_pid
4128 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4129 local migrate_dir1=$DIR1/$tdir/migrate_dir
4130 local migrate_dir2=$DIR2/$tdir/migrate_dir
4131 local migrate_run=$LUSTRE/tests/migrate.sh
4139 trap cleanup_80b EXIT
4140 #prepare migrate directory
4141 mkdir -p $migrate_dir1
4142 for F in {1,2,3,4,5}; do
4143 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4144 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4147 #migrate the directories among MDTs
4150 mdt_idx=$((RANDOM % MDSCOUNT))
4151 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4153 [ $rc -ne 0 -o $rc -ne 16 ] || break
4158 echo "start migration thread $migrate_pid"
4159 #Access the files at the same time
4160 start_time=$(date +%s)
4161 echo "accessing the migrating directory for 5 minutes..."
4163 ls $migrate_dir2 > /dev/null || {
4164 echo "read dir fails"
4167 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4168 echo "access file1 fails"
4172 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4173 echo "access file2/3 fails"
4177 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4178 echo "access file4 fails"
4182 stat $migrate_dir2/file5 > /dev/null || {
4183 echo "stat file5 fails"
4187 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4188 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4189 echo "touch file failed with $rc1"
4193 if [ -e $migrate_dir2/source_file ]; then
4194 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4195 &>/dev/null || rc1=$?
4196 if [ -e $migrate_dir2/link_file ]; then
4197 rm -rf $migrate_dir2/link_file
4200 mrename $migrate_dir2/source_file \
4201 $migrate_dir2/target_file &>/dev/null || rc1=$?
4202 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4203 echo "rename failed with $rc1"
4207 if [ -e $migrate_dir2/target_file ]; then
4208 rm -rf $migrate_dir2/target_file &>/dev/null ||
4211 rm -rf $migrate_dir2/source_file &>/dev/null ||
4214 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4215 echo "unlink failed with $rc1"
4220 end_time=$(date +%s)
4221 duration=$((end_time - start_time))
4222 if [ $((duration % 10)) -eq 0 ]; then
4223 if [ $show_time -eq 1 ]; then
4224 echo "...$duration seconds"
4231 kill -0 $migrate_pid || {
4232 echo "migration stopped 1"
4236 [ $duration -ge 300 ] && break
4239 #check migration are still there
4240 kill -0 $migrate_pid || error "migration stopped 2"
4243 run_test 80b "Accessing directory during migration"
4246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4250 mkdir -p $DIR1/$tdir
4252 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4253 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4256 touch d0/0 || error "create 0 failed"
4257 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4258 stat d0/0 && error "stat mv filed succeed"
4259 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4260 stat d0/0 || error "stat failed"
4262 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4264 if [ $t -ne 3 ]; then
4265 ls -ai $DIR1/$tdir/d0
4266 error "expect 3 get $t"
4271 run_test 81a "rename and stat under striped directory"
4274 [ $MDSCOUNT -lt 2 ] &&
4275 skip "We need at least 2 MDTs for this test"
4282 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4283 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4292 for i in $(seq $total); do
4293 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4297 kill -9 $setattr_pid
4299 run_test 81b "rename under striped directory doesn't deadlock"
4302 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
4303 { skip "Need MDS version at least 2.6.92"; return 0; }
4305 # Client 1 creates a file.
4306 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4308 # Client 2 opens the file.
4309 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4311 # Client 1 makes the file an orphan.
4312 rm $DIR1/$tfile || error "rm"
4313 # Client 2 sets EA "user.multiop".
4315 wait $pid2 || error "multiop 2"
4316 # Client 1 gets EA "user.multiop". This used to fail because the EA
4317 # cache refill would get "trusted.link" from mdd_xattr_list() but
4318 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4321 wait $pid1 || error "multiop 1"
4323 run_test 82 "fsetxattr and fgetxattr on orphan files"
4326 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4333 $LFS mkdir -i1 -c2 $tdir
4338 echo "start pid $pid1 to create/unlink striped directory"
4340 # Access the directory at the same time
4344 stat $tdir > /dev/null 2>&1
4348 echo "start pid $pid2 to stat striped directory"
4356 run_test 83 "access striped directory while it is being created/unlinked"
4359 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4360 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4364 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4365 error "create $tfile failed"
4366 mtime=$(stat -c%Y $DIR/$tfile)
4367 mtime=$((mtime + 200))
4369 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4370 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4372 touch -c -m $mtime $DIR/$tfile &
4374 # sleep a while to let 'touch' run first
4376 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4379 wait $setattr_pid || true
4381 run_test 84 "0-nlink race in lu_object_find()"
4384 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4389 [ "$SLOW" = "yes" ] && duration=600
4390 # Open/Create under striped directory
4394 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4395 touch $tdir/f{0..3} > /dev/null 2>&1
4399 echo "start pid $pid1 to open/create under striped directory"
4401 # unlink the striped directory at the same time
4405 rm -rf $tdir > /dev/null 2>&1
4409 echo "start pid $pid2 to unlink striped directory"
4418 run_test 90 "open/create and unlink striped directory"
4421 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4426 [ "$SLOW" = "yes" ] && duration=600
4427 # chmod striped directory
4431 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4432 chmod go+w $tdir > /dev/null 2>&1
4436 echo "start pid $pid1 to chmod striped directory"
4438 # unlink the striped directory at the same time
4442 rm -rf $tdir > /dev/null 2>&1
4446 echo "start pid $pid2 to unlink striped directory"
4455 run_test 91 "chmod and unlink striped directory"
4458 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4461 local cmd="exec $fd<$DIR1/$tdir"
4462 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4465 trap "eval $cmd" EXIT
4466 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4467 rmdir ../$tdir || error "rmdir ../$tdir fails"
4469 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4470 $LCTL set_param fail_loc=0x1408
4471 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4472 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4473 error "create remote dir succeeds"
4474 $LCTL set_param fail_loc=0
4478 run_test 92 "create remote directory under orphan directory"
4485 mkdir -p $DIR1/$tfile-1/
4486 mkdir -p $DIR2/$tfile-2/
4487 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4488 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4489 do_facet $SINGLEMDS "$LCTL set_param -n \
4490 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4491 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4492 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4494 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4497 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4501 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4502 do_facet $SINGLEMDS "$LCTL set_param -n \
4503 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4505 $LFS getstripe $DIR1/$tfile-1/file1
4506 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4507 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4508 $LFS getstripe $DIR2/$tfile-2/file2
4509 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4510 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4511 echo "rc1=$rc1 and rc2=$rc2 "
4512 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4513 error "object allocate on same ost detected"
4515 run_test 93 "alloc_rr should not allocate on same ost"
4518 $LCTL set_param osc.*.idle_timeout=0
4519 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4521 local before=$(date +%s)
4525 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4526 $LCTL set_param fail_val=5 fail_loc=0x80000312
4527 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4531 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4532 $LCTL set_param fail_val=6 fail_loc=0x80000329
4533 $LCTL mark kill $pid
4536 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4539 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4541 evict=$(do_facet client $LCTL get_param \
4542 osc.$FSNAME-OST*-osc-*/state |
4543 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4545 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4546 (do_facet client $LCTL get_param \
4547 osc.$FSNAME-OST*-osc-*/state;
4548 error "eviction happened: $evict before:$before")
4549 $LCTL set_param osc.*.idle_timeout=debug
4551 run_test 94 "signal vs CP callback race"
4555 skip "Reserved for glimpse-ahead" && return
4556 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4557 skip "Need MDS version at least 2.10.55"
4561 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4563 lctl set_param -n mdc.*.stats=clear
4564 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4566 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4567 # first stat from server should return size data and save glimpse
4568 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4569 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
4570 # second stat to check size is NOT cached on client without IO lock
4571 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4573 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4574 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
4577 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
4580 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4581 skip "Need MDS version at least 2.10.55"
4585 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4587 lctl set_param -n mdc.*.stats=clear
4588 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
4589 cancel_lru_locks mdc
4590 # first stat data from server should have size
4591 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
4592 # second stat to check size is cached on client
4593 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
4595 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
4596 # both stats should cause no glimpse requests
4597 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
4600 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
4603 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4604 skip "Need MDS version at least 2.10.55"
4608 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4610 lctl set_param -n mdc.*.stats=clear
4611 lctl set_param -n osc.*.stats=clear
4612 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4614 # check that size is merged from MDT and OST correctly
4615 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
4616 error "Wrong size from stat #1"
4618 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4619 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
4623 run_test 100c "DoM: write vs stat without IO lock (combined file)"
4626 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4627 skip "Need MDS version at least 2.10.55"
4631 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
4634 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
4635 lctl set_param -n mdc.*.stats=clear
4636 $TRUNCATE $DIR2/$tdir/dom 4096
4638 # check that reported size is valid after file grows to OST and
4639 # is truncated back to MDT stripe size
4640 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
4641 error "Wrong size from stat #1"
4643 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
4644 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
4648 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
4651 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
4652 skip "Need MDS version at least 2.11.50"
4654 local dom=$DIR/$tdir/dom
4655 local dom2=$DIR2/$tdir/dom
4658 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
4660 cancel_lru_locks mdc
4661 dd if=/dev/urandom of=$dom bs=12000 count=1
4662 $TRUNCATE $dom2 6000
4663 cancel_lru_locks mdc
4664 lctl set_param -n mdc.*.stats=clear
4665 # expect read-on-open to return all data before write
4666 cat /etc/hosts >> $dom
4667 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
4668 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
4670 run_test 100e "DoM: read on open and file size"
4673 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4674 skip "Need MDS version at least 2.10.55" && return
4676 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4678 $CHECKSTAT -t file $DIR1/$tfile
4680 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4681 sysctl -wq vm.dirty_writeback_centisecs=0
4683 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4686 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
4687 error_noexit "Write fails"
4688 # must discard pages
4689 lctl set_param -n mdc.*.stats=clear
4690 rm $DIR2/$tfile || error "Unlink fails"
4692 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4693 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4695 run_test 101a "Discard DoM data on unlink"
4698 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4699 skip "Need MDS version at least 2.10.55" && return
4701 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4702 touch $DIR1/${tfile}_2
4704 $CHECKSTAT -t file $DIR1/$tfile
4706 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4707 sysctl -wq vm.dirty_writeback_centisecs=0
4709 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4712 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4713 # must discard pages
4714 lctl set_param -n mdc.*.stats=clear
4715 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
4717 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4718 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4720 run_test 101b "Discard DoM data on rename"
4723 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
4724 skip "Need MDS version at least 2.10.55" && return
4726 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
4728 $CHECKSTAT -t file $DIR1/$tfile
4730 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
4731 sysctl -wq vm.dirty_writeback_centisecs=0
4733 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
4736 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
4737 $MULTIOP $DIR1/$tfile O_c &
4740 lctl set_param -n mdc.*.stats=clear
4741 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
4742 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
4744 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
4745 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
4747 run_test 101c "Discard DoM data on close-unlink"
4749 # test to verify file handle related system calls
4750 # (name_to_handle_at/open_by_handle_at)
4751 # The new system calls are supported in glibc >= 2.14.
4753 # test to verify we can open by handle an unlinked file from > 1 client
4754 # This test opens the file normally on $DIR1, which is on one mount, and then
4755 # opens it by handle on $DIR2, which is on a different mount.
4757 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
4758 skip "Needs MDS version 2.11.57 or later"
4760 echo "Test file_handle syscalls" > $DIR/$tfile ||
4761 error "write failed"
4762 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
4763 error "check_fhandle_syscalls failed"
4766 run_test 102 "Test open by handle of unlinked file"
4768 # Compare file size between first & second mount, ensuring the client correctly
4769 # glimpses even with unused speculative locks - LU-11670
4771 [ $(lustre_version_code $ost1) -lt $(version_code 2.10.50) ] &&
4772 skip "Lockahead needs OST version at least 2.10.50"
4776 test_mkdir -p $DIR/$tdir
4778 # Force file on to OST0
4779 $LFS setstripe -i 0 $DIR/$tdir
4781 # Do not check multiple locks on glimpse
4782 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
4783 $LCTL set_param fail_loc=0x415
4785 # Delay write commit by 2 seconds to guarantee glimpse wins race
4786 # The same fail_loc is used on client & server so it can work in the
4787 # single node sanity setup
4788 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
4790 echo "Incorrect size expected (no glimpse fix):"
4791 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
4793 if [ $rc -eq 0 ]; then
4794 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
4797 # guarantee write commit timeout has expired
4800 # Clear fail_loc on client
4801 $LCTL set_param fail_loc=0
4803 # Delay write commit by 2 seconds to guarantee glimpse wins race
4804 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4805 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
4807 # Write commit is still delayed by 2 seconds
4808 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
4810 [ $rc -eq 0 ] || error "Lockahead test${testnum} failed, ${rc}"
4812 # guarantee write commit timeout has expired
4815 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
4817 run_test 103 "Test size correctness with lockahead"
4823 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
4834 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
4835 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
4836 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
4837 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
4845 local xtimes=($(get_stat_xtimes))
4846 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4848 echo "STAT a|m|ctime ${xtimes[*]}"
4849 echo "MDT a|m|ctime ${xtimes[*]}"
4850 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
4851 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
4852 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4853 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4854 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4855 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4859 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
4862 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
4863 local atime_diff=$(do_facet $SINGLEMDS \
4864 lctl get_param -n mdd.*MDT0000*.atime_diff)
4866 do_facet $SINGLEMDS \
4867 lctl set_param -n mdd.*MDT0000*.atime_diff=0
4869 stack_trap "do_facet $SINGLEMDS \
4870 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
4872 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4873 check_mdt_xtimes $mdtdev
4876 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4877 check_mdt_xtimes $mdtdev
4879 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
4882 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
4884 kill -USR1 $pid && wait $pid || error "multiop failure"
4885 check_mdt_xtimes $mdtdev
4890 # Verify mtime/ctime is NOT upated on MDS when there is no modification
4891 # on the client side
4892 xtimes=($(get_stat_xtimes))
4893 $MULTIOP $DIR/$tfile O_c &
4896 kill -USR1 $pid && wait $pid || error "multiop failure"
4897 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
4898 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
4899 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
4900 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
4901 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
4902 check_mdt_xtimes $mdtdev
4905 # Change ctime via chmod
4906 $MULTIOP $DIR/$tfile o_tc &
4909 kill -USR1 $pid && wait $pid || error "multiop failure"
4910 check_mdt_xtimes $mdtdev
4912 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
4914 log "cleanup: ======================================================"
4916 # kill and wait in each test only guarentee script finish, but command in script
4917 # like 'rm' 'chmod' may still be running, wait for all commands to finish
4918 # otherwise umount below will fail
4919 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
4924 check_and_cleanup_lustre