6 # bug number for skipped test: 3192 LU-1205 15528/3811 9977 15528/11549 18080
7 ALWAYS_EXCEPT=" 14b 18c 19 28 29 35 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
14 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
15 OPENFILE=${OPENFILE:-openfile}
16 OPENUNLINK=${OPENUNLINK:-openunlink}
17 export MULTIOP=${MULTIOP:-multiop}
18 export TMP=${TMP:-/tmp}
19 MOUNT_2=${MOUNT_2:-"yes"}
20 CHECK_GRANT=${CHECK_GRANT:-"yes"}
21 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
25 export NAME=${NAME:-local}
27 LUSTRE=${LUSTRE:-`dirname $0`/..}
28 . $LUSTRE/tests/test-framework.sh
32 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
35 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
36 # bug number for skipped test: LU-2189 LU-2776
37 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 36 51a"
38 # LU-2829 / LU-2887 - make allowances for ZFS slowness
39 TEST33_NFILES=${TEST33_NFILES:-1000}
42 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
49 check_and_setup_lustre
51 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
52 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
55 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
57 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
58 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
60 # $RUNAS_ID may get set incorrectly somewhere else
61 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
63 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
72 [ -f $DIR2/f1 ] || error
74 run_test 1a "check create on 2 mtpt's =========================="
78 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
81 run_test 1b "check attribute updates on 2 mtpt's ==============="
84 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
86 run_test 1c "check after remount attribute updates on 2 mtpt's ="
90 $CHECKSTAT -a $DIR1/f1 || error
92 run_test 1d "unlink on one mountpoint removes file on other ===="
98 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
100 run_test 2a "check cached attribute updates on 2 mtpt's ========"
106 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
108 run_test 2b "check cached attribute updates on 2 mtpt's ========"
110 # NEED TO SAVE ROOT DIR MODE
113 $CHECKSTAT -t dir -p 0777 $DIR2 || error
115 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
119 $CHECKSTAT -t dir -p 0755 $DIR2 || error
121 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
128 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
130 run_test 2e "check chmod on root is propagated to others"
133 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
135 local remote_dir=$tdir/remote_dir
138 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
139 error "Create remote directory failed"
141 touch $DIR1/$remote_dir/$tfile ||
142 error "Create file under remote directory failed"
143 chmod 777 $DIR1/$remote_dir/$tfile ||
144 error "Chmod file under remote directory failed"
146 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
147 error "Check attr of file under remote directory failed"
149 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
150 error "Chown file under remote directory failed"
152 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
153 error "Check owner of file under remote directory failed"
155 cd $DIR2/$remote_dir || error "enter remote dir"
156 rm -rf $DIR1/$remote_dir/$tfile ||
157 error "Unlink remote directory failed"
159 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
160 error "unlink file still exists!"
162 cd $DIR2/$tdir || error "exit remote dir"
163 rm -rf $DIR1/$tdir || error "unlink directory failed"
165 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
168 local target="this/is/good"
169 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
170 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
171 error "link $DIR2/$tfile not as expected"
173 run_test 3 "symlink on one mtpt, readlink on another ==========="
176 multifstat $DIR1/f4 $DIR2/f4
178 run_test 4 "fstat validation on multiple mount points =========="
182 $TRUNCATE $DIR2/f5 100
183 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
186 run_test 5 "create a file on one mount, truncate it on the other"
189 openunlink $DIR1/$tfile $DIR2/$tfile || \
190 error "openunlink $DIR1/$tfile $DIR2/$tfile"
192 run_test 6 "remove of open file on other node =================="
196 opendirunlink $DIR1/$dir $DIR2/$dir || \
197 error "opendirunlink $DIR1/$dir $DIR2/$dir"
199 run_test 7 "remove of open directory on other node ============="
202 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
203 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
205 run_test 8 "remove of open special file on other node =========="
211 for C in a b c d e f g h i j k l; do
212 dir=`eval echo \\$DIR$MTPT`
213 echo -n $C >> $dir/f9
214 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
216 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
217 error "`od -a $DIR1/f9` != abcdefghijkl"
219 run_test 9 "append of file with sub-page size on multiple mounts"
226 for C in a b c d e f g h i j k l; do
227 dir=`eval echo \\$DIR$MTPT`
228 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
229 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
230 OFFSET=`expr $OFFSET + 1`
232 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
233 error "`od -a $DIR1/f10` != abcdefghijkl"
235 run_test 10a "write of file with sub-page size on multiple mounts "
239 yes "R" | head -c 4000 >$TMP/f10b-seed
240 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
242 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
244 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
246 # create a test file locally to compare
247 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
248 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
249 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
250 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
252 run_test 10b "write of file with sub-page size on multiple mounts "
256 multiop_bg_pause $DIR1/d11/f O_c || return 1
258 cp -p /bin/ls $DIR1/d11/f
262 wait $MULTIPID || error
263 [ $RC -eq 0 ] && error || true
265 run_test 11 "execution of file opened for write should return error ===="
268 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
270 run_test 12 "test lock ordering (link, stat, unlink) ==========="
272 test_13() { # bug 2451 - directory coherency
273 test_mkdir $DIR1/d13 || error
274 cd $DIR1/d13 || error
276 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
278 rm -f $DIR2/d13/f13 || error
279 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
280 # need to run it twice
281 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
283 rm -f $DIR2/d13/f13 || error
284 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
286 run_test 13 "test directory page revocation ===================="
289 test_mkdir -p $DIR1/$tdir
290 cp -p /bin/ls $DIR1/$tdir/$tfile
291 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
294 $DIR2/$tdir/$tfile && error || true
296 wait $MULTIPID || return 2
298 run_test 14 "execution of file open for write returns -ETXTBSY ="
301 test_mkdir -p $DIR1/d14
302 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
303 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
305 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
306 kill -USR1 $MULTIOP_PID || return 2
307 wait $MULTIOP_PID || return 3
308 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
310 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
312 test_14b() { # bug 3192, 7040
313 test_mkdir -p $DIR1/d14
314 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
315 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
317 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
318 error "expected truncate error, got success"
319 kill -USR1 $MULTIOP_PID || return 2
320 wait $MULTIOP_PID || return 3
321 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
322 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
324 run_test 14b "truncate of executing file returns -ETXTBSY ======"
326 test_14c() { # bug 3430, 7040
327 test_mkdir -p $DIR1/d14
328 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
329 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
331 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
332 kill -USR1 $MULTIOP_PID || return 2
333 wait $MULTIOP_PID || return 3
334 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
335 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
337 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
339 test_14d() { # bug 10921
340 test_mkdir -p $DIR1/d14
341 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
342 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
345 chmod 600 $DIR1/d14/multiop || error "chmod failed"
346 kill -USR1 $MULTIOP_PID || return 2
347 wait $MULTIOP_PID || return 3
348 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
349 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
351 run_test 14d "chmod of executing file is still possible ========"
353 test_15() { # bug 974 - ENOSPC
355 sh oos2.sh $MOUNT1 $MOUNT2
356 wait_delete_completed
357 grant_error=`dmesg | grep "> available"`
358 [ -z "$grant_error" ] || error "$grant_error"
360 run_test 15 "test out-of-space with multiple writers ==========="
363 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
364 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
365 # pass a 2500 operation dual-mount run within the time limit.
366 if [ "$(facet_fstype ost1)" = "zfs" ]; then
367 FSXNUM=$((COUNT / 5))
369 elif [ "$SLOW" = "yes" ]; then
370 FSXNUM=$((COUNT * 5))
378 local file1=$DIR1/$tfile
379 local file2=$DIR2/$tfile
381 # to allocate grant because it may run out due to test_15.
382 lfs setstripe -c -1 $file1
383 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
384 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
387 lfs setstripe -c -1 $file1 # b=10919
388 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
390 run_test 16 "$FSXNUM iterations of dual-mount fsx"
392 test_17() { # bug 3513, 3667
393 remote_ost_nodsh && skip "remote OST with nodsh" && return
395 lfs setstripe $DIR1/$tfile -i 0 -c 1
396 cp $SAMPLE_FILE $DIR1/$tfile
397 cancel_lru_locks osc > /dev/null
398 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
399 do_facet ost1 lctl set_param fail_loc=0x8000030a
400 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
401 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
403 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
405 run_test 17 "resource creation/LVB creation race ==============="
408 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
411 for idx in {a..z}; do
412 local ptr=EXCEPT_ALWAYS_18$idx
413 [ x${!ptr} = xtrue ] || continue
415 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
418 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
421 run_test 18 "mmap sanity check ================================="
423 test_19() { # bug3811
424 local node=$(facet_active_host ost1)
426 # check whether obdfilter is cache capable at all
427 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
428 echo "not cache-capable obdfilter"
432 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
434 set_osd_param $node '' readcache_max_filesize 4096
435 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
436 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
437 cp $TMP/$tfile $DIR1/$tfile
438 for i in `seq 1 20`; do
439 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
440 cancel_lru_locks osc > /dev/null
441 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
442 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
444 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
445 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
446 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
447 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
449 set_osd_param $node '' readcache_max_filesize $MAX
452 run_test 19 "test concurrent uncached read races ==============="
457 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
458 $MULTIOP $DIR1/f20 Ow8190c
459 $MULTIOP $DIR2/f20 Oz8194w8190c
460 $MULTIOP $DIR1/f20 Oz0r8190c
462 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
464 error $CNTD" page left in cache after lock cancel" || true
466 run_test 20 "test extra readahead page left in cache ===="
473 test_21() { # Bug 5907
474 test_mkdir $DIR1/$tdir
475 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
477 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
478 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
479 test -d $DIR1/$tdir || error "Mounted directory disappeared"
481 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
484 run_test 21 " Try to remove mountpoint on another dir ===="
486 test_23() { # Bug 5972
487 local at_diff=$(do_facet $SINGLEMDS \
488 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
489 echo "atime should be updated while another read" > $DIR1/$tfile
491 # clear the lock(mode: LCK_PW) gotten from creating operation
495 sleep $((at_diff + 1))
497 echo "starting reads"
498 multiop_bg_pause $DIR1/$tfile or20_c || return 1
499 # with SOM and opencache enabled, we need to close a file and cancel
500 # open lock to get atime propogated to MDS
501 kill -USR1 $! || return 2
504 time2=$(stat -c "%X" $DIR/$tfile)
505 echo "new atime is $time2"
507 [ $time2 -gt $time1 ] || error "atime was not updated"
508 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
511 run_test 23 " others should see updated atime while another read===="
515 lfs df || error "lfs df failed"
516 lfs df -ih || error "lfs df -ih failed"
517 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
518 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
519 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
520 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
522 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
523 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
524 lctl --device %$OSC deactivate
525 lfs df -i || error "lfs df -i with deactivated OSC failed"
526 lctl --device %$OSC activate
527 lfs df || error "lfs df with reactivated OSC failed"
529 run_test 24a "lfs df [-ih] [path] test ========================="
533 fsnum=$(lfs_df | grep -c "summary")
534 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
536 run_test 24b "lfs df should show both filesystems ==============="
539 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
541 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
544 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
545 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
547 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
548 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
549 error "setfacl $DIR2/$tdir #1"
550 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
551 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
552 error "setfacl $DIR2/$tdir #2"
553 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
554 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
555 error "setfacl $DIR2/$tdir #3"
556 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
557 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
558 error "setfacl $DIR2/$tdir #4"
559 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
563 run_test 25a "change ACL on one mountpoint be seen on another ==="
566 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
568 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
570 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
573 $LFS mkdir -i 1 $DIR1/$tdir
574 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
575 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
577 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
578 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
579 error "setfacl $DIR2/$tdir #1"
580 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
581 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
582 error "setfacl $DIR2/$tdir #2"
583 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
584 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
585 error "setfacl $DIR2/$tdir #3"
586 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
587 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
588 error "setfacl $DIR2/$tdir #4"
589 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
593 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
596 utime $DIR1/f26a -s $DIR2/f26a || error
598 run_test 26a "allow mtime to get older"
603 echo "aaa" >> $DIR1/$tfile
605 chmod a+x $DIR2/$tfile
606 mt1=`stat -c %Y $DIR1/$tfile`
607 mt2=`stat -c %Y $DIR2/$tfile`
609 if [ x"$mt1" != x"$mt2" ]; then
610 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
613 run_test 26b "sync mtime between ost and mds"
618 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
623 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
628 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
630 lctl set_param -n ldlm.dump_namespaces ""
631 wait $DD1_PID $DD2_PID
632 [ $? -ne 0 ] && lctl dk $TMP/debug || true
634 run_test 27 "align non-overlapping extent locks from request ==="
636 test_28() { # bug 9977
637 ECHO_UUID="ECHO_osc1_UUID"
638 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
640 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
641 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
642 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
646 attach echo_client ECHO_osc1 $ECHO_UUID
650 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
651 $LCTL --device $tECHOID destroy "${tOBJID}:0"
659 # reading of 1st stripe should pass
660 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
661 # reading of 2nd stripe should fail (this stripe was destroyed)
662 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
664 # now, recreating test file
665 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
666 # reading of 1st stripe should pass
667 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
668 # reading of 2nd stripe should pass
669 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
671 run_test 28 "read/write/truncate file with lost stripes"
673 test_29() { # bug 10999
675 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
676 lctl set_param fail_loc=0x8000030f
679 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
682 #bug 11549 - permanently turn test off in b1_5
683 run_test 29 "lock put race between glimpse and enqueue ========="
685 test_30() { #bug #11110, LU-2523
686 test_mkdir -p $DIR1/$tdir
687 cp -f /bin/bash $DIR1/$tdir/bash
688 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
689 cp /bin/bash $DIR2/$tdir' &
690 $DIR1/$tdir/bash -c 'sleep 2;
691 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
696 run_test 30 "recreate file race"
699 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
700 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
701 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
702 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
703 lctl set_param fail_loc=0x314
704 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
705 awk 'BEGIN { FS="+" } /in/ {print $1}')
706 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
708 run_test 31a "voluntary cancel / blocking ast race=============="
711 remote_ost || { skip "local OST" && return 0; }
712 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
714 # make sure there is no local locks due to destroy
715 wait_mds_ost_sync || error "wait_mds_ost_sync()"
716 wait_delete_completed || error "wait_delete_completed()"
718 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
719 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
720 cp /etc/hosts $DIR/$tdir/$tfile
721 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
722 lctl set_param fail_loc=0x314
723 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
724 do_facet ost1 lctl set_param fail_loc=0x316
726 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
727 lctl set_param fail_loc=0
728 do_facet ost1 lctl set_param fail_loc=0
729 # cleanup: reconnect the client back
732 run_test 31b "voluntary OST cancel / blocking ast race=============="
734 # enable/disable lockless truncate feature, depending on the arg 0/1
735 enable_lockless_truncate() {
736 lctl set_param -n osc.*.lockless_truncate $1
739 test_32a() { # bug 11270
740 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
741 save_lustre_params client "osc.*.lockless_truncate" > $p
743 enable_lockless_truncate 1
745 lfs setstripe -c -1 $DIR1/$tfile
746 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
750 log "checking cached lockless truncate"
751 $TRUNCATE $DIR1/$tfile 8000000
752 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
753 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
754 error "cached truncate isn't lockless"
756 log "checking not cached lockless truncate"
757 $TRUNCATE $DIR2/$tfile 5000000
758 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
759 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
760 error "not cached truncate isn't lockless"
762 log "disabled lockless truncate"
763 enable_lockless_truncate 0
765 $TRUNCATE $DIR2/$tfile 3000000
766 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
767 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
768 error "lockless truncate disabling failed"
770 # restore lockless_truncate default values
771 restore_lustre_params < $p
774 run_test 32a "lockless truncate"
776 test_32b() { # bug 11270
777 remote_ost_nodsh && skip "remote OST with nodsh" && return
780 local facets=$(get_facets OST)
781 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
783 save_lustre_params client "osc.*.contention_seconds" > $p
784 save_lustre_params $facets \
785 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
786 save_lustre_params $facets \
787 "ldlm.namespaces.filter-*.contended_locks" >> $p
788 save_lustre_params $facets \
789 "ldlm.namespaces.filter-*.contention_seconds" >> $p
792 # agressive lockless i/o settings
793 for node in $(osts_nodes); do
794 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
796 lctl set_param -n osc.*.contention_seconds 60
797 for i in $(seq 5); do
798 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
799 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
801 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
802 # disable lockless i/o (it is disabled by default)
803 for node in $(osts_nodes); do
804 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
806 # set contention_seconds to 0 at client too, otherwise Lustre still
807 # remembers lock contention
808 lctl set_param -n osc.*.contention_seconds 0
810 for i in $(seq 1); do
811 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
812 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
814 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
815 error "lockless i/o works when disabled"
817 restore_lustre_params <$p
820 run_test 32b "lockless i/o"
824 local mdts=$(get_facets MDS)
829 for mds in ${mdts//,/ }; do
831 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
832 xargs readlink -f" ))
833 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
836 stat=$(( stat + val))
841 # commit on sharing tests
843 remote_mds_nodsh && skip "remote MDS with nodsh" && return
845 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
846 [ $CLIENTCOUNT -lt 2 ] &&
847 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
849 local nfiles=${TEST33_NFILES:-10000}
850 local param_file=$TMP/$tfile-params
851 local fstype=$(facet_fstype $SINGLEMDS)
853 save_lustre_params $(get_facets MDS) \
854 "mdt.*.commit_on_sharing" > $param_file
862 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
866 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
868 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
869 echo "=== START createmany old: $jbdold transaction"
870 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")
871 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
872 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
873 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
874 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
875 avgtime=$(( avgtime + elapsed ))
877 eval cos${COS}_jbd=$((avgjbd / 3))
878 eval cos${COS}_time=$((avgtime / 3))
881 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
882 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
883 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
884 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
886 restore_lustre_params < $param_file
890 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
892 # commit on sharing tests
894 remote_mds_nodsh && skip "remote MDS with nodsh" && return
896 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
897 [ $CLIENTCOUNT -ge 2 ] ||
898 { skip "Need two or more clients, have $CLIENTCOUNT" &&
900 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
902 local nfiles=${TEST33_NFILES:-10000}
903 local param_file=$TMP/$tfile-params
905 save_lustre_params $(get_facets MDS) \
906 "mdt.*.commit_on_sharing" > $param_file
915 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
919 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \
920 $DIR1/$tdir-\\\$(hostname)-$i"
922 jbdold=$(print_jbd_stat)
923 echo "=== START createmany old: $jbdold transaction"
924 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
925 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
926 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
928 jbdnew=$(print_jbd_stat)
929 jbd=$(( jbdnew - jbdold ))
930 echo "=== END createmany new: $jbdnew transaction : \
931 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
932 avgjbd=$(( avgjbd + jbd ))
933 avgtime=$(( avgtime + elapsed ))
935 eval cos${COS}_jbd=$((avgjbd / 3))
936 eval cos${COS}_time=$((avgtime / 3))
939 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
940 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
941 [ "$cos0_jbd" != 0 ] &&
942 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
943 [ "$cos0_time" != 0 ] &&
944 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
946 restore_lustre_params < $param_file
950 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
952 # End commit on sharing tests
954 get_ost_lock_timeouts() {
955 local nodes=${1:-$(comma_list $(osts_nodes))}
957 local locks=$(do_nodes $nodes \
958 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
966 do_nodes $(comma_list $(osts_nodes)) \
967 "lctl set_param -n fail_loc=0 2>/dev/null || true"
968 for i in $(seq $OSTCOUNT); do
969 wait_osc_import_state client ost$i FULL
977 trap cleanup_34 EXIT RETURN
978 for OPER in notimeout timeout ; do
979 rm $DIR1/$tfile 2>/dev/null
980 lock_in=$(get_ost_lock_timeouts)
981 if [ $OPER == "timeout" ] ; then
982 for j in `seq $OSTCOUNT`; do
983 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
984 do_facet ost$j lctl set_param fail_loc=0x511
986 echo lock should expire
988 for j in `seq $OSTCOUNT`; do
989 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
990 do_facet ost$j lctl set_param fail_loc=0x512
992 echo lock should not expire
994 echo writing on client1
995 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
997 echo reading on client2
998 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
999 # wait for a lock timeout
1001 lock_out=$(get_ost_lock_timeouts)
1002 if [ $OPER == "timeout" ] ; then
1003 if [ $lock_in == $lock_out ]; then
1004 error "no lock timeout happened"
1009 if [ $lock_in != $lock_out ]; then
1010 error "lock timeout happened"
1018 run_test 34 "no lock timeout under IO"
1020 test_35() { # bug 17645
1023 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1024 awk '/generation/{print $2}')
1026 generation[count]=$g
1030 test_mkdir -p $MOUNT1/$tfile
1031 cancel_lru_locks mdc
1033 # Let's initiate -EINTR situation by setting fail_loc and take
1034 # write lock on same file from same client. This will not cause
1035 # bl_ast yet as lock is already in local cache.
1036 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1037 do_facet client "lctl set_param fail_loc=0x80000317"
1038 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1039 let timeout=timeout*3
1041 while test $nr -lt 10; do
1042 log "Race attempt $nr"
1043 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1044 test "x$blk1" = "x" && blk1=0
1045 createmany -o $MOUNT2/$tfile/a 4000 &
1049 # Let's make conflict and bl_ast
1050 ls -la $MOUNT1/$tfile > /dev/null &
1053 log "Wait for $pid1 $pid2 for $timeout sec..."
1055 kill -9 $pid1 $pid2 > /dev/null 2>&1
1057 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1058 test "x$blk2" = "x" && blk2=0
1059 test $blk2 -gt $blk1 && break
1060 rm -fr $MOUNT1/$tfile/*
1061 cancel_lru_locks mdc
1064 do_facet client "lctl set_param fail_loc=0x0"
1065 df -h $MOUNT1 $MOUNT2
1067 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1068 awk '/generation/{print $2}')
1070 if ! test "$g" -eq "${generation[count]}"; then
1071 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1073 for imp in $list; do
1074 if [ $c = $count ]; then
1079 imp=$(echo "$imp" | awk -F"." '{print $2}')
1080 error "Eviction happened on import $imp"
1085 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1087 test_36() { #bug 16417
1092 test_mkdir -p $DIR1/$tdir
1093 $LFS setstripe -c -1 $DIR1/$tdir
1096 let SIZE_B=SIZE*1024*1024
1097 sync; sleep 5; sync # wait for delete thread
1099 while [ $i -le 10 ]; do
1100 lctl mark "start test"
1101 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1102 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1103 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1104 sync # sync data from client cache
1105 sync_all_data # sync data from server cache (delayed allocation)
1107 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1108 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1110 rm -f $DIR1/$tdir/$tfile
1111 kill -USR1 $read_pid
1113 wait_delete_completed
1114 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1115 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1117 # this free space! not used
1118 (( $after_dd <= $after)) ||
1119 error "space leaked after_dd:$after_dd > after:$after"
1123 run_test 36 "handle ESTALE/open-unlink correctly"
1125 test_37() { # bug 18695
1126 test_mkdir -p $DIR1/$tdir
1127 multiop_bg_pause $DIR1/$tdir D_c || return 1
1129 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1130 createmany -m $DIR2/$tdir/f 10000
1131 # set mtime/atime backward
1132 touch -t 198001010000 $DIR2/$tdir
1133 kill -USR1 $MULTIPID
1134 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1135 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1138 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1140 # this should be set to past
1141 TEST_39_MTIME=`date -d "1 year ago" +%s`
1145 local client1=${CLIENT1:-`hostname`}
1146 local client2=${CLIENT2:-`hostname`}
1148 do_node $client1 "touch $DIR1/$tfile"
1150 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1151 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1152 [ "$mtime1" = $TEST_39_MTIME ] || \
1153 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1155 local d1=`do_node $client1 date +%s`
1156 do_node $client1 'echo hello >> '$DIR1/$tfile
1157 local d2=`do_node $client1 date +%s`
1159 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1160 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1161 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1163 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1165 for (( i=0; i < 2; i++ )) ; do
1166 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1167 [ "$mtime2" = "$mtime3" ] || \
1168 error "mtime ($mtime2) changed (to $mtime3) on rename"
1170 cancel_lru_locks osc
1171 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1174 run_test 39a "test from 11063 =================================="
1177 local client1=${CLIENT1:-`hostname`}
1178 local client2=${CLIENT2:-`hostname`}
1182 local mtime1=`stat -c %Y $DIR1/$tfile`
1183 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1186 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1188 for (( i=0; i < 2; i++ )) ; do
1189 local mtime3=`stat -c %Y $DIR1/$tfile`
1190 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1192 [ "$mtime3" = "$mtime4" ] || \
1193 error "different mtime on clients: $mtime3, $mtime4"
1194 [ "$mtime3" = $TEST_39_MTIME ] || \
1195 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1197 cancel_lru_locks osc
1198 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1201 run_test 39b "11063 problem 1 =================================="
1204 local client1=${CLIENT1:-`hostname`}
1205 local client2=${CLIENT2:-`hostname`}
1207 echo hello > $DIR1/$tfile
1209 local mtime1=`stat -c %Y $DIR1/$tfile`
1210 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1211 [ "$mtime1" = "$mtime2" ] || \
1212 error "create: different mtime on clients: $mtime1, $mtime2"
1215 $TRUNCATE $DIR1/$tfile 1
1217 for (( i=0; i < 2; i++ )) ; do
1218 local mtime3=`stat -c %Y $DIR1/$tfile`
1219 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1221 [ "$mtime3" = "$mtime4" ] || \
1222 error "different mtime on clients: $mtime3, $mtime4"
1223 [ "$mtime3" -gt $mtime2 ] || \
1224 error "truncate did not update mtime: $mtime2, $mtime3"
1226 cancel_lru_locks osc
1227 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1230 run_test 39c "check truncate mtime update ======================"
1232 # check that pid exists hence second operation wasn't blocked by first one
1233 # if it is so then there is no conflict, return 0
1234 # else second operation is conflicting with first one, return 1
1235 check_pdo_conflict() {
1238 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1239 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1249 # test 40: check non-blocking operations
1251 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1252 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1253 mkdir $DIR1/$tfile &
1256 touch $DIR2/$tfile-2
1257 check_pdo_conflict $PID1 || error "create is blocked"
1258 mkdir $DIR2/$tfile-3
1259 check_pdo_conflict $PID1 || error "mkdir is blocked"
1260 link $DIR2/$tfile-2 $DIR2/$tfile-4
1261 check_pdo_conflict $PID1 || error "link is blocked"
1262 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1263 check_pdo_conflict $PID1 || error "rename is blocked"
1264 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1265 check_pdo_conflict $PID1 || error "getattr is blocked"
1266 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1267 rmdir $DIR2/$tfile-3
1268 check_pdo_conflict $PID1 || error "unlink is blocked"
1270 # all operations above shouldn't wait the first one
1271 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1276 run_test 40a "pdirops: create vs others =============="
1279 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1280 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1281 touch $DIR1/$tfile &
1285 touch $DIR2/$tfile-2
1286 check_pdo_conflict $PID1 || error "create is blocked"
1287 mkdir $DIR2/$tfile-3
1288 check_pdo_conflict $PID1 || error "mkdir is blocked"
1289 link $DIR2/$tfile-2 $DIR2/$tfile-4
1290 check_pdo_conflict $PID1 || error "link is blocked"
1291 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1292 check_pdo_conflict $PID1 || error "rename is blocked"
1293 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1294 check_pdo_conflict $PID1 || error "getattr is blocked"
1295 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1296 rmdir $DIR2/$tfile-3
1297 check_pdo_conflict $PID1 || error "unlink is blocked"
1298 # all operations above shouldn't wait the first one
1300 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1305 run_test 40b "pdirops: open|create and others =============="
1309 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1310 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1311 link $DIR1/$tfile $DIR1/$tfile-0 &
1315 touch $DIR2/$tfile-2
1316 check_pdo_conflict $PID1 || error "create is blocked"
1317 mkdir $DIR2/$tfile-3
1318 check_pdo_conflict $PID1 || error "mkdir is blocked"
1319 link $DIR2/$tfile-2 $DIR2/$tfile-4
1320 check_pdo_conflict $PID1 || error "link is blocked"
1321 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1322 check_pdo_conflict $PID1 || error "rename is blocked"
1323 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1324 check_pdo_conflict $PID1 || error "getattr is blocked"
1325 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1326 rmdir $DIR2/$tfile-3
1327 check_pdo_conflict $PID1 || error "unlink is blocked"
1329 # all operations above shouldn't wait the first one
1330 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1335 run_test 40c "pdirops: link and others =============="
1339 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1340 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1345 touch $DIR2/$tfile-2
1346 check_pdo_conflict $PID1 || error "create is blocked"
1347 mkdir $DIR2/$tfile-3
1348 check_pdo_conflict $PID1 || error "mkdir is blocked"
1349 link $DIR2/$tfile-2 $DIR2/$tfile-4
1350 check_pdo_conflict $PID1 || error "link is blocked"
1351 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1352 check_pdo_conflict $PID1 || error "rename is blocked"
1353 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1354 check_pdo_conflict $PID1 || error "getattr is blocked"
1355 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1356 rmdir $DIR2/$tfile-3
1357 check_pdo_conflict $PID1 || error "unlink is blocked"
1359 # all operations above shouldn't wait the first one
1360 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1364 run_test 40d "pdirops: unlink and others =============="
1368 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1369 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1370 mv $DIR1/$tfile $DIR1/$tfile-0 &
1374 touch $DIR2/$tfile-2
1375 check_pdo_conflict $PID1 || error "create is blocked"
1376 mkdir $DIR2/$tfile-3
1377 check_pdo_conflict $PID1 || error "mkdir is blocked"
1378 link $DIR2/$tfile-2 $DIR2/$tfile-4
1379 check_pdo_conflict $PID1 || error "link is blocked"
1380 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1381 check_pdo_conflict $PID1 || error "getattr is blocked"
1382 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1383 rmdir $DIR2/$tfile-3
1384 check_pdo_conflict $PID1 || error "unlink is blocked"
1386 # all operations above shouldn't wait the first one
1387 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1392 run_test 40e "pdirops: rename and others =============="
1394 # test 41: create blocking operations
1396 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1397 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1398 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1401 mkdir $DIR2/$tfile && error "mkdir must fail"
1402 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1406 run_test 41a "pdirops: create vs mkdir =============="
1409 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1410 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1411 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1414 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1415 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1419 run_test 41b "pdirops: create vs create =============="
1422 touch $DIR1/$tfile-2
1423 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1424 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1425 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1428 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1429 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1433 run_test 41c "pdirops: create vs link =============="
1436 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1437 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1438 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1441 rm $DIR2/$tfile || error "unlink must succeed"
1442 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1446 run_test 41d "pdirops: create vs unlink =============="
1449 touch $DIR1/$tfile-2
1450 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1451 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1452 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1455 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1456 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1460 run_test 41e "pdirops: create and rename (tgt) =============="
1463 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1464 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1465 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1468 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1469 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1473 run_test 41f "pdirops: create and rename (src) =============="
1476 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1477 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1478 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1481 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1482 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1486 run_test 41g "pdirops: create vs getattr =============="
1489 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1490 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1491 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1494 ls -lia $DIR2/ > /dev/null
1495 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1499 run_test 41h "pdirops: create vs readdir =============="
1501 # test 42: unlink and blocking operations
1503 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1504 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1505 mkdir $DIR1/$tfile &
1508 mkdir $DIR2/$tfile && error "mkdir must fail"
1509 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1513 run_test 42a "pdirops: mkdir vs mkdir =============="
1516 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1517 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1518 mkdir $DIR1/$tfile &
1521 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1522 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1526 run_test 42b "pdirops: mkdir vs create =============="
1529 touch $DIR1/$tfile-2
1530 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1531 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1532 mkdir $DIR1/$tfile &
1535 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1536 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1540 run_test 42c "pdirops: mkdir vs link =============="
1543 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1544 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1545 mkdir $DIR1/$tfile &
1548 rmdir $DIR2/$tfile || error "unlink must succeed"
1549 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1553 run_test 42d "pdirops: mkdir vs unlink =============="
1556 touch $DIR1/$tfile-2
1557 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1558 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1559 mkdir $DIR1/$tfile &
1562 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1563 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1567 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1570 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1571 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1572 mkdir $DIR1/$tfile &
1575 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1576 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1580 run_test 42f "pdirops: mkdir and rename (src) =============="
1583 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1584 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1585 mkdir $DIR1/$tfile &
1588 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1589 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1593 run_test 42g "pdirops: mkdir vs getattr =============="
1596 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1597 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1598 mkdir $DIR1/$tfile &
1601 ls -lia $DIR2/ > /dev/null
1602 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1606 run_test 42h "pdirops: mkdir vs readdir =============="
1608 # test 43: unlink and blocking operations
1611 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1612 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1616 mkdir $DIR2/$tfile || error "mkdir must succeed"
1617 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1621 run_test 43a "pdirops: unlink vs mkdir =============="
1625 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1626 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1630 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1631 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1635 run_test 43b "pdirops: unlink vs create =============="
1639 touch $DIR1/$tfile-2
1640 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1641 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1645 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1646 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1650 run_test 43c "pdirops: unlink vs link =============="
1654 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1655 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1659 rm $DIR2/$tfile && error "unlink must fail"
1660 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1664 run_test 43d "pdirops: unlink vs unlink =============="
1668 touch $DIR1/$tfile-2
1669 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1670 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1674 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1675 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1679 run_test 43e "pdirops: unlink and rename (tgt) =============="
1683 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1684 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1688 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1689 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1693 run_test 43f "pdirops: unlink and rename (src) =============="
1697 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1698 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1702 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1703 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1707 run_test 43g "pdirops: unlink vs getattr =============="
1711 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1712 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1716 ls -lia $DIR2/ > /dev/null
1717 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1721 run_test 43h "pdirops: unlink vs readdir =============="
1724 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1726 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1727 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1731 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1732 check_pdo_conflict $PID1 &&
1733 { wait $PID1; error "remote mkdir isn't blocked"; }
1737 run_test 43i "pdirops: unlink vs remote mkdir"
1739 # test 44: rename tgt and blocking operations
1741 touch $DIR1/$tfile-2
1742 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1743 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1744 mv $DIR1/$tfile-2 $DIR1/$tfile &
1747 mkdir $DIR2/$tfile && error "mkdir must fail"
1748 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1752 run_test 44a "pdirops: rename tgt vs mkdir =============="
1755 touch $DIR1/$tfile-2
1756 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1757 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1758 mv $DIR1/$tfile-2 $DIR1/$tfile &
1761 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1762 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1766 run_test 44b "pdirops: rename tgt vs create =============="
1769 touch $DIR1/$tfile-2
1770 touch $DIR1/$tfile-3
1771 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1772 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1773 mv $DIR1/$tfile-2 $DIR1/$tfile &
1776 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1777 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1781 run_test 44c "pdirops: rename tgt vs link =============="
1784 touch $DIR1/$tfile-2
1785 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1786 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1787 mv $DIR1/$tfile-2 $DIR1/$tfile &
1790 rm $DIR2/$tfile || error "unlink must succeed"
1791 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1795 run_test 44d "pdirops: rename tgt vs unlink =============="
1799 touch $DIR1/$tfile-2
1800 touch $DIR1/$tfile-3
1801 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1802 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1803 mv $DIR1/$tfile-2 $DIR1/$tfile &
1806 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1807 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1811 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1814 touch $DIR1/$tfile-2
1815 touch $DIR1/$tfile-3
1816 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1817 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1818 mv $DIR1/$tfile-2 $DIR1/$tfile &
1821 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1822 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1826 run_test 44f "pdirops: rename tgt and rename (src) =============="
1829 touch $DIR1/$tfile-2
1830 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1831 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1832 mv $DIR1/$tfile-2 $DIR1/$tfile &
1835 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1836 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1840 run_test 44g "pdirops: rename tgt vs getattr =============="
1843 touch $DIR1/$tfile-2
1844 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1845 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1846 mv $DIR1/$tfile-2 $DIR1/$tfile &
1849 ls -lia $DIR2/ > /dev/null
1850 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1854 run_test 44h "pdirops: rename tgt vs readdir =============="
1856 # test 44: rename tgt and blocking operations
1858 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1859 touch $DIR1/$tfile-2
1860 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1861 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1862 mv $DIR1/$tfile-2 $DIR1/$tfile &
1865 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1866 check_pdo_conflict $PID1 && { wait $PID1;
1867 error "remote mkdir isn't blocked"; }
1871 run_test 44i "pdirops: rename tgt vs remote mkdir"
1873 # test 45: rename src and blocking operations
1876 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1877 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1878 mv $DIR1/$tfile $DIR1/$tfile-2 &
1881 mkdir $DIR2/$tfile || error "mkdir must succeed"
1882 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1886 run_test 45a "pdirops: rename src vs mkdir =============="
1890 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1891 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1892 mv $DIR1/$tfile $DIR1/$tfile-2 &
1895 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1896 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1900 run_test 45b "pdirops: rename src vs create =============="
1904 touch $DIR1/$tfile-3
1905 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1906 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1907 mv $DIR1/$tfile $DIR1/$tfile-2 &
1910 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1911 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1915 run_test 45c "pdirops: rename src vs link =============="
1919 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1920 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1921 mv $DIR1/$tfile $DIR1/$tfile-2 &
1924 rm $DIR2/$tfile && error "unlink must fail"
1925 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1929 run_test 45d "pdirops: rename src vs unlink =============="
1933 touch $DIR1/$tfile-3
1934 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1935 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1936 mv $DIR1/$tfile $DIR1/$tfile-2 &
1939 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1940 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1944 run_test 45e "pdirops: rename src and rename (tgt) =============="
1948 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1949 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1950 mv $DIR1/$tfile $DIR1/$tfile-2 &
1953 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1954 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1958 run_test 45f "pdirops: rename src and rename (src) =============="
1962 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1963 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1964 mv $DIR1/$tfile $DIR1/$tfile-2 &
1967 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1968 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1972 run_test 45g "pdirops: rename src vs getattr =============="
1976 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1977 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1978 mv $DIR1/$tfile $DIR1/$tfile-2 &
1981 ls -lia $DIR2/ > /dev/null
1982 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1986 run_test 45h "pdirops: unlink vs readdir =============="
1989 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1991 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1992 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1993 mv $DIR1/$tfile $DIR1/$tfile-2 &
1996 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
1997 check_pdo_conflict $PID1 && { wait $PID1;
1998 error "create remote dir isn't blocked"; }
2002 run_test 45i "pdirops: rename src vs remote mkdir"
2004 # test 46: link and blocking operations
2006 touch $DIR1/$tfile-2
2007 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2008 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2009 link $DIR1/$tfile-2 $DIR1/$tfile &
2012 mkdir $DIR2/$tfile && error "mkdir must fail"
2013 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2017 run_test 46a "pdirops: link vs mkdir =============="
2020 touch $DIR1/$tfile-2
2021 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2022 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2023 link $DIR1/$tfile-2 $DIR1/$tfile &
2026 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2027 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2031 run_test 46b "pdirops: link vs create =============="
2034 touch $DIR1/$tfile-2
2035 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2036 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2037 link $DIR1/$tfile-2 $DIR1/$tfile &
2040 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2041 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2045 run_test 46c "pdirops: link vs link =============="
2048 touch $DIR1/$tfile-2
2049 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2050 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2051 link $DIR1/$tfile-2 $DIR1/$tfile &
2054 rm $DIR2/$tfile || error "unlink must succeed"
2055 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2059 run_test 46d "pdirops: link vs unlink =============="
2062 touch $DIR1/$tfile-2
2063 touch $DIR1/$tfile-3
2064 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2065 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2066 link $DIR1/$tfile-2 $DIR1/$tfile &
2069 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2070 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2074 run_test 46e "pdirops: link and rename (tgt) =============="
2077 touch $DIR1/$tfile-2
2078 touch $DIR1/$tfile-3
2079 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2080 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2081 link $DIR1/$tfile-2 $DIR1/$tfile &
2084 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2085 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2089 run_test 46f "pdirops: link and rename (src) =============="
2092 touch $DIR1/$tfile-2
2093 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2094 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2095 link $DIR1/$tfile-2 $DIR1/$tfile &
2098 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2099 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2103 run_test 46g "pdirops: link vs getattr =============="
2106 touch $DIR1/$tfile-2
2107 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2108 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2109 link $DIR1/$tfile-2 $DIR1/$tfile &
2112 ls -lia $DIR2/ > /dev/null
2113 check_pdo_conflict $PID1 && { wait $PID1;
2114 error "readdir isn't blocked"; }
2118 run_test 46h "pdirops: link vs readdir =============="
2121 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2122 touch $DIR1/$tfile-2
2123 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2124 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2125 link $DIR1/$tfile-2 $DIR1/$tfile &
2128 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2129 check_pdo_conflict $PID1 && { wait $PID1;
2130 error "remote mkdir isn't blocked"; }
2134 run_test 46i "pdirops: link vs remote mkdir"
2136 # test 47: remote mkdir and blocking operations
2138 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2139 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2140 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2141 $LFS mkdir -i 1 $DIR1/$tfile &
2144 mkdir $DIR2/$tfile && error "mkdir must fail"
2145 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2149 run_test 47a "pdirops: remote mkdir vs mkdir"
2152 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2153 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2154 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2155 $LFS mkdir -i 1 $DIR1/$tfile &
2158 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2159 check_pdo_conflict $PID1 && { wait $PID1;
2160 error "create isn't blocked"; }
2164 run_test 47b "pdirops: remote mkdir vs create"
2167 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2168 touch $DIR1/$tfile-2
2169 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2170 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2171 $LFS mkdir -i 1 $DIR1/$tfile &
2174 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2175 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2179 run_test 47c "pdirops: remote mkdir vs link"
2182 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2183 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2184 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2185 $LFS mkdir -i 1 $DIR1/$tfile &
2188 rmdir $DIR2/$tfile || error "unlink must succeed"
2189 check_pdo_conflict $PID1 && { wait $PID1;
2190 error "unlink isn't blocked"; }
2194 run_test 47d "pdirops: remote mkdir vs unlink"
2197 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2198 touch $DIR1/$tfile-2
2199 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2200 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2201 $LFS mkdir -i 1 $DIR1/$tfile &
2204 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2205 check_pdo_conflict $PID1 && { wait $PID1;
2206 error "rename isn't blocked"; }
2210 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2213 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2214 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2215 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2216 $LFS mkdir -i 1 $DIR1/$tfile &
2219 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2220 check_pdo_conflict $PID1 && { wait $PID1;
2221 error "rename isn't blocked"; }
2225 run_test 47f "pdirops: remote mkdir and rename (src)"
2228 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2229 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2230 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2231 $LFS mkdir -i 1 $DIR1/$tfile &
2234 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2235 check_pdo_conflict $PID1 && { wait $PID1;
2236 error "getattr isn't blocked"; }
2240 run_test 47g "pdirops: remote mkdir vs getattr"
2244 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2245 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2246 do_facet client "lctl set_param fail_loc=0x410"
2247 $TRUNCATE $DIR2/$tfile $trunc_size
2248 do_facet client "lctl set_param fail_loc=0x0"
2250 size=`stat -c %s $DIR2/$tfile`
2251 [ $size -eq $trunc_size ] || error "wrong size"
2253 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2257 local origfile=/etc/hosts
2259 filesize=`stat -c %s $origfile`
2261 # create an empty file
2262 $MCREATE $DIR1/$tfile
2263 # cache layout lock on both mount point
2264 stat $DIR1/$tfile > /dev/null
2265 stat $DIR2/$tfile > /dev/null
2267 # open and sleep 2 seconds then read
2268 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2272 # create the layout of testing file
2273 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2275 # MULTIOP proc should be able to read enough bytes and exit
2277 kill -0 $pid && error "multiop is still there"
2278 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2282 run_test 51a "layout lock: refresh layout should work"
2285 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2286 { skip "Need MDS version at least 2.3.59"; return 0; }
2288 local tmpfile=`mktemp`
2290 # create an empty file
2291 $MCREATE $DIR1/$tfile
2293 # delay glimpse so that layout has changed when glimpse finish
2294 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2295 $LCTL set_param fail_loc=0x1404
2296 stat -c %s $DIR2/$tfile |tee $tmpfile &
2300 # create layout of testing file
2301 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2304 local fsize=`cat $tmpfile`
2306 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2308 rm -f $DIR1/$tfile $tmpfile
2310 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2313 [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; }
2315 # set default layout to have 1 stripe
2316 mkdir -p $DIR1/$tdir
2317 $LFS setstripe -c 1 $DIR1/$tdir
2319 # create a file with empty layout
2320 $MCREATE $DIR1/$tdir/$tfile
2322 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2323 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2325 # change the layout of testing file
2326 echo "Setting layout to have $OSTCOUNT stripes ..."
2327 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2331 # write something to the file, it should be blocked on fetching layout
2332 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2333 local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2334 [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT"
2338 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2341 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2342 cancel_lru_locks mdc
2344 # open should grant LAYOUT lock, mmap and read will install pages
2345 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2349 # rss before revoking
2350 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2351 echo "Before revoking layout lock: $br KB mapped"
2353 # delete the file will revoke layout lock
2356 # rss after revoking
2357 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2362 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2364 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2368 echo "==> rename vs getattr vs setxattr should not deadlock"
2369 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2371 do_facet mds $LCTL set_param fail_loc=$1
2373 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2381 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2382 wait $PID1 || error "(3) mv failed"
2383 wait $PID2 || error "(4) stat failed"
2390 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2391 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2393 do_facet mds $LCTL set_param fail_loc=$1
2395 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2403 $MULTIOP $DIR2/d1/d2 Oc &
2407 stat $DIR/d1 || error "(2) stat failed"
2409 wait $PID1 || error "(3) mv failed"
2410 wait $PID2 || error "(4) stat failed"
2411 wait $PID3 && error "(5) multiop failed"
2417 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2418 save_lustre_params client "llite.*.xattr_cache" > $p
2419 lctl set_param llite.*.xattr_cache 1 ||
2420 { skip "xattr cache is not supported"; return 0; }
2422 #define OBD_FAIL_MDS_RENAME 0x153
2423 #define OBD_FAIL_MDS_RENAME2 0x154
2424 test_54_part1 0x80000153 || error 10
2425 test_54_part1 0x80000154 || error 11
2426 test_54_part2 0x80000153 || error 12
2427 test_54_part2 0x80000154 || error 13
2429 restore_lustre_params < $p
2432 run_test 54 "rename locking"
2435 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2437 #define OBD_FAIL_MDS_RENAME4 0x156
2438 do_facet mds $LCTL set_param fail_loc=0x80000156
2440 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2445 wait $PID1 && error "(2) mv succeeded"
2449 run_test 55a "rename vs unlink target dir"
2453 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2455 #define OBD_FAIL_MDS_RENAME4 0x156
2456 do_facet mds $LCTL set_param fail_loc=0x80000156
2458 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2463 wait $PID1 && error "(2) mv succeeded"
2467 run_test 55b "rename vs unlink source dir"
2471 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2473 #define OBD_FAIL_MDS_RENAME4 0x156
2474 do_facet mds $LCTL set_param fail_loc=0x156
2476 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2480 # while rename is sleeping, open and remove d3
2481 $MULTIOP $DIR2/d3 D_c &
2487 # while rename is sleeping 2nd time, close d3
2489 wait $PID2 || error "(3) multiop failed"
2491 wait $PID1 && error "(2) mv succeeded"
2495 run_test 55c "rename vs unlink orphan target dir"
2501 #define OBD_FAIL_MDS_RENAME3 0x155
2502 do_facet mds $LCTL set_param fail_loc=0x155
2503 mv $DIR/f1 $DIR/$tdir &
2507 # while rename is sleeping, create $tdir, but as a directory
2508 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2510 # link in reverse locking order
2511 ln $DIR2/f1 $DIR2/$tdir/
2513 wait $PID1 && error "(2) mv succeeded"
2516 run_test 55d "rename file vs link"
2519 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
2520 { skip "Need MDS version at least 2.3.0"; return; }
2522 test_mkdir -p $DIR1/$tdir
2523 file1=$DIR1/$tdir/file
2524 file2=$DIR2/$tdir/file
2526 echo orig > $file2 || error "Could not create $file2"
2527 version=$($LFS data_version $file1)
2530 echo append >> $file2 || error "Could not append to $file2"
2531 version2=$($LFS data_version $file1)
2532 [ "$version" != "$version2" ] ||
2533 error "append did not change data version: $version"
2536 echo overwrite > $file2 || error "Could not overwrite $file2"
2537 version3=$($LFS data_version $file1)
2538 [ "$version2" != "$version3" ] ||
2539 error "overwrite did not change data version: $version2"
2541 # Truncate before EOF
2542 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2543 version4=$($LFS data_version $file1)
2544 [ "$version3" != "$version4" ] ||
2545 error "truncate did not change data version: $version3"
2547 # Truncate after EOF
2548 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2549 version5=$($LFS data_version $file1)
2550 [ "$version4" != "$version5" ] ||
2551 error "truncate did not change data version: $version4"
2553 # Chmod do not change version
2554 chmod 400 $file2 || error "Could not chmod 400 $file2"
2555 version6=$($LFS data_version $file1)
2556 [ "$version5" == "$version6" ] ||
2557 error "chmod should not change data version: $version5 != $version6"
2559 # Chown do not change version
2560 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2561 version7=$($LFS data_version $file1)
2562 [ "$version5" == "$version7" ] ||
2563 error "chown should not change data version: $version5 != $version7"
2565 run_test 60 "Verify data_version behaviour"
2568 local test_dir=$tdir/test_dir
2570 mkdir -p $DIR1/$tdir
2571 if [ $MDSCOUNT -ge 2 ]; then
2573 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2574 error "Create remote directory failed"
2576 mkdir -p $DIR1/$test_dir
2578 cd $DIR2/$test_dir || error "cd directory failed"
2579 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2581 cd $DIR2/$tdir || error "exit directory"
2583 run_test 70a "cd directory && rm directory"
2585 test_70b() { # LU-2781
2587 mkdir -p $DIR1/$tdir
2589 touch $DIR1/$tdir/file
2590 for ((i = 0; i < 32; i++)); do
2591 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2593 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2595 touch $DIR1/$tdir/file
2596 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2597 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2598 rm -rf $DIR1/$tdir/test_dir ||
2599 error "cannot remove directory after rm_entry"
2600 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2602 run_test 70b "remove files after calling rm_entry"
2605 local server_version=$(lustre_version_code $SINGLEMDS)
2607 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2608 skip "Need MDS version at least 2.1.6" && return
2610 # Patch not applied to 2.2 and 2.3 branches
2611 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2612 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2613 skip "Need MDS version at least 2.4.0" && return
2615 checkfiemap --test ||
2616 { skip "checkfiemap not runnable: $?" && return; }
2617 # write data this way: hole - data - hole - data
2618 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2619 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2621 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2622 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2623 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2625 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2627 checkfiemap $DIR2/$tfile 81920 ||
2628 error "data is not flushed from client"
2629 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2632 # common case of "create file, copy file" on a single node
2633 # should not flush data from ost
2634 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2635 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2637 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2639 checkfiemap $DIR1/$tfile 81920 ||
2641 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2643 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2645 run_test 71 "correct file map just after write operation is finished"
2648 local p="$TMP/sanityN-$TESTNAME.parameters"
2651 save_lustre_params client "llite.*.xattr_cache" > $p
2652 lctl set_param llite.*.xattr_cache 1 ||
2653 { skip "xattr cache is not supported"; return 0; }
2656 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2657 error "setfattr1 failed"
2658 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2659 error "getfattr1 failed"
2660 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2661 error "setfattr2 failed"
2662 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2663 error "getfattr2 failed"
2665 # check that trusted.link is consistent
2666 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2667 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2668 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2669 echo "$tlink1 $tlink2"
2670 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2674 restore_lustre_params < $p
2677 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2680 local p="$TMP/sanityN-$TESTNAME.parameters"
2681 save_lustre_params client "llite.*.xattr_cache" > $p
2682 lctl set_param llite.*.xattr_cache 1 ||
2683 { skip "xattr cache is not supported"; return 0; }
2686 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2687 error "setfattr1 failed"
2688 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2689 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2691 # PR lock should be cached by now on both clients
2692 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2693 # 2 hits for getfattr(0)+getfattr(size)
2694 [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1"
2695 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2696 # 4 hits for more getfattr(0)+getfattr(size)
2697 [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2"
2700 restore_lustre_params < $p
2703 run_test 73 "getxattr should not cause xattr lock cancellation"
2706 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2707 skip "Need MDS version at least 2.4.93" && return
2709 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2710 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2711 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2713 run_test 74 "flock deadlock: different mounts =============="
2717 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2718 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2719 cancel_lru_locks osc
2721 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2724 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2725 $LCTL set_param fail_loc=0x31d
2726 stat -c %s $DIR1/$tfile &
2731 # For bad lock error handler we should ASSERT and got kernel panic here
2733 $LCTL set_param fail_loc=0
2735 run_test 75 "osc: upcall after unuse lock==================="
2738 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2739 skip "Need MDS version at least 2.5.53" && return
2741 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2747 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2753 test_mkdir -p $DIR/$tdir
2755 # drop all open locks and close any cached "open" files on the client
2756 cancel_lru_locks mdc
2758 echo -n "open files "
2760 for ((i = 0; i < $fcount; i++)); do
2761 touch $DIR/$tdir/f_$i
2763 local cmd="exec $fd<$DIR/$tdir/f_$i"
2770 local get_open_fids="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2771 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $get_open_fids))
2773 # Possible errors in openfiles FID list.
2774 # 1. Missing FIDs. Check 1
2775 # 2. Extra FIDs. Check 1
2776 # 3. Duplicated FID. Check 2
2777 # 4. Invalid FIDs. Check 2
2778 # 5. Valid FID, points to some other file. Check 3
2781 [ ${#fid_list[@]} -ne $fcount ] &&
2782 error "${#fid_list[@]} != $fcount open files"
2784 for (( i = 0; i < $fcount; i++ )) ; do
2785 cmd="exec ${fd_list[i]}</dev/null"
2787 filename=$($LFS fid2path $DIR2 ${fid_list[i]})
2790 rm --interactive=no $filename
2792 error "Nonexisting fid ${fid_list[i]} listed."
2796 ls_op=$(ls $DIR2/$tdir | wc -l)
2798 error "Some openfiles are missing in lproc output"
2802 run_test 76 "Verify open file for 2048 files"
2805 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2812 mkdir -p $DIR1/$tdir/dir
2813 createmany -o $DIR1/$tdir/dir/f 10 ||
2814 error "create files under remote dir failed $i"
2816 cp /etc/passwd $DIR1/$tdir/$tfile
2818 #migrate open file should fails
2819 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
2821 # give multiop a chance to open
2824 $LFS mv -M $MDTIDX $DIR1/$tdir &&
2825 error "migrate open files should failed with open files"
2829 $LFS mv -M $MDTIDX $DIR1/$tdir ||
2830 error "migrate remote dir error"
2832 echo "Finish migration, then checking.."
2833 for file in $(find $DIR1/$tdir); do
2834 mdt_index=$($LFS getstripe -M $file)
2835 [ $mdt_index == $MDTIDX ] ||
2836 error "$file is not on MDT${MDTIDX}"
2839 diff /etc/passwd $DIR1/$tdir/$tfile ||
2840 error "file different after migration"
2842 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
2844 run_test 80 "migrate directory when some children is being opened"
2847 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2851 mkdir -p $DIR1/$tdir
2853 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
2854 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
2857 touch d0/0 || error "create 0 failed"
2858 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
2859 stat d0/0 && error "stat mv filed succeed"
2860 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || "rename d1/0 d0/0 failed"
2861 stat d0/0 || error "stat failed"
2863 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
2865 if [ $t -ne 3 ]; then
2866 ls -ai $DIR1/$tdir/d0
2867 error "expect 3 get $t"
2872 run_test 81 "rename and stat under striped directory"
2875 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
2876 { skip "Need MDS version at least 2.6.92"; return 0; }
2878 # Client 1 creates a file.
2879 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
2881 # Client 2 opens the file.
2882 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
2884 # Client 1 makes the file an orphan.
2885 rm $DIR1/$tfile || error "rm"
2886 # Client 2 sets EA "user.multiop".
2888 wait $pid2 || error "multiop 2"
2889 # Client 1 gets EA "user.multiop". This used to fail because the EA
2890 # cache refill would get "trusted.link" from mdd_xattr_list() but
2891 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
2894 wait $pid1 || error "multiop 1"
2896 run_test 82 "fsetxattr and fgetxattr on orphan files"
2898 log "cleanup: ======================================================"
2900 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
2904 check_and_cleanup_lustre