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 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
170 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
172 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
173 echo "$DIR1/$tfile has $block1 blocks"
174 echo "$DIR2/$tfile has $block2 blocks"
175 [ $block1 -eq $block2 ] || error
177 run_test 2g "check blocks update on sync write"
180 local target="this/is/good"
181 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
182 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
183 error "link $DIR2/$tfile not as expected"
185 run_test 3 "symlink on one mtpt, readlink on another ==========="
188 multifstat $DIR1/f4 $DIR2/f4
190 run_test 4 "fstat validation on multiple mount points =========="
194 $TRUNCATE $DIR2/f5 100
195 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
198 run_test 5 "create a file on one mount, truncate it on the other"
201 openunlink $DIR1/$tfile $DIR2/$tfile || \
202 error "openunlink $DIR1/$tfile $DIR2/$tfile"
204 run_test 6 "remove of open file on other node =================="
208 opendirunlink $DIR1/$dir $DIR2/$dir || \
209 error "opendirunlink $DIR1/$dir $DIR2/$dir"
211 run_test 7 "remove of open directory on other node ============="
214 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
215 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
217 run_test 8 "remove of open special file on other node =========="
223 for C in a b c d e f g h i j k l; do
224 dir=`eval echo \\$DIR$MTPT`
225 echo -n $C >> $dir/f9
226 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
228 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
229 error "`od -a $DIR1/f9` != abcdefghijkl"
231 run_test 9 "append of file with sub-page size on multiple mounts"
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
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
285 test_mkdir $DIR1/d13 || error
286 cd $DIR1/d13 || error
288 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
290 rm -f $DIR2/d13/f13 || error
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
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 -p $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
308 wait $MULTIPID || return 2
310 run_test 14 "execution of file open for write returns -ETXTBSY ="
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 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
318 kill -USR1 $MULTIOP_PID || return 2
319 wait $MULTIOP_PID || return 3
320 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
322 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
324 test_14b() { # bug 3192, 7040
325 test_mkdir -p $DIR1/d14
326 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
327 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
329 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
330 error "expected truncate error, got success"
331 kill -USR1 $MULTIOP_PID || return 2
332 wait $MULTIOP_PID || return 3
333 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
334 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
336 run_test 14b "truncate of executing file returns -ETXTBSY ======"
338 test_14c() { # bug 3430, 7040
339 test_mkdir -p $DIR1/d14
340 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
341 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
343 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
344 kill -USR1 $MULTIOP_PID || return 2
345 wait $MULTIOP_PID || return 3
346 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
347 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
349 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
351 test_14d() { # bug 10921
352 test_mkdir -p $DIR1/d14
353 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
354 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
357 chmod 600 $DIR1/d14/multiop || error "chmod failed"
358 kill -USR1 $MULTIOP_PID || return 2
359 wait $MULTIOP_PID || return 3
360 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
361 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
363 run_test 14d "chmod of executing file is still possible ========"
365 test_15() { # bug 974 - ENOSPC
367 sh oos2.sh $MOUNT1 $MOUNT2
368 wait_delete_completed
369 grant_error=`dmesg | grep "> available"`
370 [ -z "$grant_error" ] || error "$grant_error"
372 run_test 15 "test out-of-space with multiple writers ==========="
375 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
376 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
377 # pass a 2500 operation dual-mount run within the time limit.
378 if [ "$(facet_fstype ost1)" = "zfs" ]; then
379 FSXNUM=$((COUNT / 5))
381 elif [ "$SLOW" = "yes" ]; then
382 FSXNUM=$((COUNT * 5))
390 local file1=$DIR1/$tfile
391 local file2=$DIR2/$tfile
393 # to allocate grant because it may run out due to test_15.
394 lfs setstripe -c -1 $file1
395 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
396 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
399 lfs setstripe -c -1 $file1 # b=10919
400 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
402 run_test 16 "$FSXNUM iterations of dual-mount fsx"
404 test_17() { # bug 3513, 3667
405 remote_ost_nodsh && skip "remote OST with nodsh" && return
407 lfs setstripe $DIR1/$tfile -i 0 -c 1
408 cp $SAMPLE_FILE $DIR1/$tfile
409 cancel_lru_locks osc > /dev/null
410 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
411 do_facet ost1 lctl set_param fail_loc=0x8000030a
412 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
413 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
415 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
417 run_test 17 "resource creation/LVB creation race ==============="
420 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
423 for idx in {a..z}; do
424 local ptr=EXCEPT_ALWAYS_18$idx
425 [ x${!ptr} = xtrue ] || continue
427 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
430 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
433 run_test 18 "mmap sanity check ================================="
435 test_19() { # bug3811
436 local node=$(facet_active_host ost1)
438 # check whether obdfilter is cache capable at all
439 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
440 echo "not cache-capable obdfilter"
444 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
446 set_osd_param $node '' readcache_max_filesize 4096
447 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
448 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
449 cp $TMP/$tfile $DIR1/$tfile
450 for i in `seq 1 20`; do
451 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
452 cancel_lru_locks osc > /dev/null
453 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
454 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
456 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
457 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
458 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
459 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
461 set_osd_param $node '' readcache_max_filesize $MAX
464 run_test 19 "test concurrent uncached read races ==============="
469 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
470 $MULTIOP $DIR1/f20 Ow8190c
471 $MULTIOP $DIR2/f20 Oz8194w8190c
472 $MULTIOP $DIR1/f20 Oz0r8190c
474 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
476 error $CNTD" page left in cache after lock cancel" || true
478 run_test 20 "test extra readahead page left in cache ===="
485 test_21() { # Bug 5907
486 test_mkdir $DIR1/$tdir
487 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
489 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
490 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
491 test -d $DIR1/$tdir || error "Mounted directory disappeared"
493 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
496 run_test 21 " Try to remove mountpoint on another dir ===="
498 test_23() { # Bug 5972
499 local at_diff=$(do_facet $SINGLEMDS \
500 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
501 echo "atime should be updated while another read" > $DIR1/$tfile
503 # clear the lock(mode: LCK_PW) gotten from creating operation
507 sleep $((at_diff + 1))
509 echo "starting reads"
510 multiop_bg_pause $DIR1/$tfile or20_c || return 1
511 # with SOM and opencache enabled, we need to close a file and cancel
512 # open lock to get atime propogated to MDS
513 kill -USR1 $! || return 2
516 time2=$(stat -c "%X" $DIR/$tfile)
517 echo "new atime is $time2"
519 [ $time2 -gt $time1 ] || error "atime was not updated"
520 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
523 run_test 23 " others should see updated atime while another read===="
527 lfs df || error "lfs df failed"
528 lfs df -ih || error "lfs df -ih failed"
529 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
530 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
531 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
532 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
534 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
535 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
536 lctl --device %$OSC deactivate
537 lfs df -i || error "lfs df -i with deactivated OSC failed"
538 lctl --device %$OSC activate
539 lfs df || error "lfs df with reactivated OSC failed"
541 run_test 24a "lfs df [-ih] [path] test ========================="
545 fsnum=$(lfs_df | grep -c "summary")
546 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
548 run_test 24b "lfs df should show both filesystems ==============="
551 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
553 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
556 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
557 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
559 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
560 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
561 error "setfacl $DIR2/$tdir #1"
562 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
563 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
564 error "setfacl $DIR2/$tdir #2"
565 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
566 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
567 error "setfacl $DIR2/$tdir #3"
568 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
569 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
570 error "setfacl $DIR2/$tdir #4"
571 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
575 run_test 25a "change ACL on one mountpoint be seen on another ==="
578 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
580 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
582 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
585 $LFS mkdir -i 1 $DIR1/$tdir
586 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
587 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
589 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
590 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
591 error "setfacl $DIR2/$tdir #1"
592 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
593 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
594 error "setfacl $DIR2/$tdir #2"
595 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
596 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
597 error "setfacl $DIR2/$tdir #3"
598 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
599 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
600 error "setfacl $DIR2/$tdir #4"
601 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
605 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
608 utime $DIR1/f26a -s $DIR2/f26a || error
610 run_test 26a "allow mtime to get older"
615 echo "aaa" >> $DIR1/$tfile
617 chmod a+x $DIR2/$tfile
618 mt1=`stat -c %Y $DIR1/$tfile`
619 mt2=`stat -c %Y $DIR2/$tfile`
621 if [ x"$mt1" != x"$mt2" ]; then
622 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
625 run_test 26b "sync mtime between ost and mds"
630 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
635 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
640 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
642 lctl set_param -n ldlm.dump_namespaces ""
643 wait $DD1_PID $DD2_PID
644 [ $? -ne 0 ] && lctl dk $TMP/debug || true
646 run_test 27 "align non-overlapping extent locks from request ==="
648 test_28() { # bug 9977
649 ECHO_UUID="ECHO_osc1_UUID"
650 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
652 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
653 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
654 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
658 attach echo_client ECHO_osc1 $ECHO_UUID
662 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
663 $LCTL --device $tECHOID destroy "${tOBJID}:0"
671 # reading of 1st stripe should pass
672 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
673 # reading of 2nd stripe should fail (this stripe was destroyed)
674 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
676 # now, recreating test file
677 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
678 # reading of 1st stripe should pass
679 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
680 # reading of 2nd stripe should pass
681 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
683 run_test 28 "read/write/truncate file with lost stripes"
685 test_29() { # bug 10999
687 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
688 lctl set_param fail_loc=0x8000030f
691 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
694 #bug 11549 - permanently turn test off in b1_5
695 run_test 29 "lock put race between glimpse and enqueue ========="
697 test_30() { #bug #11110, LU-2523
698 test_mkdir -p $DIR1/$tdir
699 cp -f /bin/bash $DIR1/$tdir/bash
700 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
701 cp /bin/bash $DIR2/$tdir' &
702 $DIR1/$tdir/bash -c 'sleep 2;
703 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
708 run_test 30 "recreate file race"
711 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
712 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
713 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
714 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
715 lctl set_param fail_loc=0x314
716 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
717 awk 'BEGIN { FS="+" } /in/ {print $1}')
718 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
720 run_test 31a "voluntary cancel / blocking ast race=============="
723 remote_ost || { skip "local OST" && return 0; }
724 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
726 # make sure there is no local locks due to destroy
727 wait_mds_ost_sync || error "wait_mds_ost_sync()"
728 wait_delete_completed || error "wait_delete_completed()"
730 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
731 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
732 cp /etc/hosts $DIR/$tdir/$tfile
733 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
734 lctl set_param fail_loc=0x314
735 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
736 do_facet ost1 lctl set_param fail_loc=0x316
738 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
739 lctl set_param fail_loc=0
740 do_facet ost1 lctl set_param fail_loc=0
741 # cleanup: reconnect the client back
744 run_test 31b "voluntary OST cancel / blocking ast race=============="
746 # enable/disable lockless truncate feature, depending on the arg 0/1
747 enable_lockless_truncate() {
748 lctl set_param -n osc.*.lockless_truncate $1
751 test_32a() { # bug 11270
752 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
753 save_lustre_params client "osc.*.lockless_truncate" > $p
755 enable_lockless_truncate 1
757 lfs setstripe -c -1 $DIR1/$tfile
758 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
762 log "checking cached lockless truncate"
763 $TRUNCATE $DIR1/$tfile 8000000
764 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
765 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
766 error "cached truncate isn't lockless"
768 log "checking not cached lockless truncate"
769 $TRUNCATE $DIR2/$tfile 5000000
770 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
771 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
772 error "not cached truncate isn't lockless"
774 log "disabled lockless truncate"
775 enable_lockless_truncate 0
777 $TRUNCATE $DIR2/$tfile 3000000
778 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
779 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
780 error "lockless truncate disabling failed"
782 # restore lockless_truncate default values
783 restore_lustre_params < $p
786 run_test 32a "lockless truncate"
788 test_32b() { # bug 11270
789 remote_ost_nodsh && skip "remote OST with nodsh" && return
792 local facets=$(get_facets OST)
793 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
795 save_lustre_params client "osc.*.contention_seconds" > $p
796 save_lustre_params $facets \
797 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
798 save_lustre_params $facets \
799 "ldlm.namespaces.filter-*.contended_locks" >> $p
800 save_lustre_params $facets \
801 "ldlm.namespaces.filter-*.contention_seconds" >> $p
804 # agressive lockless i/o settings
805 for node in $(osts_nodes); do
806 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'
808 lctl set_param -n osc.*.contention_seconds 60
809 for i in $(seq 5); do
810 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
811 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
813 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
814 # disable lockless i/o (it is disabled by default)
815 for node in $(osts_nodes); do
816 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'
818 # set contention_seconds to 0 at client too, otherwise Lustre still
819 # remembers lock contention
820 lctl set_param -n osc.*.contention_seconds 0
822 for i in $(seq 1); do
823 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
824 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
826 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
827 error "lockless i/o works when disabled"
829 restore_lustre_params <$p
832 run_test 32b "lockless i/o"
836 local mdts=$(get_facets MDS)
841 for mds in ${mdts//,/ }; do
843 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
844 xargs readlink -f" ))
845 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
848 stat=$(( stat + val))
853 # commit on sharing tests
855 remote_mds_nodsh && skip "remote MDS with nodsh" && return
857 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
858 [ $CLIENTCOUNT -lt 2 ] &&
859 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
861 local nfiles=${TEST33_NFILES:-10000}
862 local param_file=$TMP/$tfile-params
863 local fstype=$(facet_fstype $SINGLEMDS)
865 save_lustre_params $(get_facets MDS) \
866 "mdt.*.commit_on_sharing" > $param_file
874 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
878 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
880 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
881 echo "=== START createmany old: $jbdold transaction"
882 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")
883 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
884 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
885 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
886 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
887 avgtime=$(( avgtime + elapsed ))
889 eval cos${COS}_jbd=$((avgjbd / 3))
890 eval cos${COS}_time=$((avgtime / 3))
893 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
894 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
895 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
896 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
898 restore_lustre_params < $param_file
902 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
904 # commit on sharing tests
906 remote_mds_nodsh && skip "remote MDS with nodsh" && return
908 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
909 [ $CLIENTCOUNT -ge 2 ] ||
910 { skip "Need two or more clients, have $CLIENTCOUNT" &&
912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
914 local nfiles=${TEST33_NFILES:-10000}
915 local param_file=$TMP/$tfile-params
917 save_lustre_params $(get_facets MDS) \
918 "mdt.*.commit_on_sharing" > $param_file
927 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
931 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \
932 $DIR1/$tdir-\\\$(hostname)-$i"
934 jbdold=$(print_jbd_stat)
935 echo "=== START createmany old: $jbdold transaction"
936 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
937 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
938 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
940 jbdnew=$(print_jbd_stat)
941 jbd=$(( jbdnew - jbdold ))
942 echo "=== END createmany new: $jbdnew transaction : \
943 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
944 avgjbd=$(( avgjbd + jbd ))
945 avgtime=$(( avgtime + elapsed ))
947 eval cos${COS}_jbd=$((avgjbd / 3))
948 eval cos${COS}_time=$((avgtime / 3))
951 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
952 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
953 [ "$cos0_jbd" != 0 ] &&
954 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
955 [ "$cos0_time" != 0 ] &&
956 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
958 restore_lustre_params < $param_file
962 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
964 # End commit on sharing tests
966 get_ost_lock_timeouts() {
967 local nodes=${1:-$(comma_list $(osts_nodes))}
969 local locks=$(do_nodes $nodes \
970 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
978 do_nodes $(comma_list $(osts_nodes)) \
979 "lctl set_param -n fail_loc=0 2>/dev/null || true"
980 for i in $(seq $OSTCOUNT); do
981 wait_osc_import_state client ost$i FULL
989 trap cleanup_34 EXIT RETURN
990 for OPER in notimeout timeout ; do
991 rm $DIR1/$tfile 2>/dev/null
992 lock_in=$(get_ost_lock_timeouts)
993 if [ $OPER == "timeout" ] ; then
994 for j in `seq $OSTCOUNT`; do
995 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
996 do_facet ost$j lctl set_param fail_loc=0x511
998 echo lock should expire
1000 for j in `seq $OSTCOUNT`; do
1001 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1002 do_facet ost$j lctl set_param fail_loc=0x512
1004 echo lock should not expire
1006 echo writing on client1
1007 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1009 echo reading on client2
1010 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1011 # wait for a lock timeout
1013 lock_out=$(get_ost_lock_timeouts)
1014 if [ $OPER == "timeout" ] ; then
1015 if [ $lock_in == $lock_out ]; then
1016 error "no lock timeout happened"
1021 if [ $lock_in != $lock_out ]; then
1022 error "lock timeout happened"
1030 run_test 34 "no lock timeout under IO"
1032 test_35() { # bug 17645
1035 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1036 awk '/generation/{print $2}')
1038 generation[count]=$g
1042 test_mkdir -p $MOUNT1/$tfile
1043 cancel_lru_locks mdc
1045 # Let's initiate -EINTR situation by setting fail_loc and take
1046 # write lock on same file from same client. This will not cause
1047 # bl_ast yet as lock is already in local cache.
1048 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1049 do_facet client "lctl set_param fail_loc=0x80000317"
1050 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1051 let timeout=timeout*3
1053 while test $nr -lt 10; do
1054 log "Race attempt $nr"
1055 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1056 test "x$blk1" = "x" && blk1=0
1057 createmany -o $MOUNT2/$tfile/a 4000 &
1061 # Let's make conflict and bl_ast
1062 ls -la $MOUNT1/$tfile > /dev/null &
1065 log "Wait for $pid1 $pid2 for $timeout sec..."
1067 kill -9 $pid1 $pid2 > /dev/null 2>&1
1069 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1070 test "x$blk2" = "x" && blk2=0
1071 test $blk2 -gt $blk1 && break
1072 rm -fr $MOUNT1/$tfile/*
1073 cancel_lru_locks mdc
1076 do_facet client "lctl set_param fail_loc=0x0"
1077 df -h $MOUNT1 $MOUNT2
1079 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1080 awk '/generation/{print $2}')
1082 if ! test "$g" -eq "${generation[count]}"; then
1083 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1085 for imp in $list; do
1086 if [ $c = $count ]; then
1091 imp=$(echo "$imp" | awk -F"." '{print $2}')
1092 error "Eviction happened on import $imp"
1097 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1099 test_36() { #bug 16417
1104 test_mkdir -p $DIR1/$tdir
1105 $LFS setstripe -c -1 $DIR1/$tdir
1108 let SIZE_B=SIZE*1024*1024
1109 sync; sleep 5; sync # wait for delete thread
1111 while [ $i -le 10 ]; do
1112 lctl mark "start test"
1113 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1114 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1115 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1116 sync # sync data from client cache
1117 sync_all_data # sync data from server cache (delayed allocation)
1119 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1120 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1122 rm -f $DIR1/$tdir/$tfile
1123 kill -USR1 $read_pid
1125 wait_delete_completed
1126 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1127 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1129 # this free space! not used
1130 (( $after_dd <= $after)) ||
1131 error "space leaked after_dd:$after_dd > after:$after"
1135 run_test 36 "handle ESTALE/open-unlink correctly"
1137 test_37() { # bug 18695
1138 test_mkdir -p $DIR1/$tdir
1139 multiop_bg_pause $DIR1/$tdir D_c || return 1
1141 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1142 createmany -m $DIR2/$tdir/f 10000
1143 # set mtime/atime backward
1144 touch -t 198001010000 $DIR2/$tdir
1145 kill -USR1 $MULTIPID
1146 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1147 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1150 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1152 # this should be set to past
1153 TEST_39_MTIME=`date -d "1 year ago" +%s`
1157 local client1=${CLIENT1:-`hostname`}
1158 local client2=${CLIENT2:-`hostname`}
1160 do_node $client1 "touch $DIR1/$tfile"
1162 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1163 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1164 [ "$mtime1" = $TEST_39_MTIME ] || \
1165 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1167 local d1=`do_node $client1 date +%s`
1168 do_node $client1 'echo hello >> '$DIR1/$tfile
1169 local d2=`do_node $client1 date +%s`
1171 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1172 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1173 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1175 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1177 for (( i=0; i < 2; i++ )) ; do
1178 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1179 [ "$mtime2" = "$mtime3" ] || \
1180 error "mtime ($mtime2) changed (to $mtime3) on rename"
1182 cancel_lru_locks osc
1183 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1186 run_test 39a "test from 11063 =================================="
1189 local client1=${CLIENT1:-`hostname`}
1190 local client2=${CLIENT2:-`hostname`}
1194 local mtime1=`stat -c %Y $DIR1/$tfile`
1195 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1198 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1200 for (( i=0; i < 2; i++ )) ; do
1201 local mtime3=`stat -c %Y $DIR1/$tfile`
1202 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1204 [ "$mtime3" = "$mtime4" ] || \
1205 error "different mtime on clients: $mtime3, $mtime4"
1206 [ "$mtime3" = $TEST_39_MTIME ] || \
1207 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1209 cancel_lru_locks osc
1210 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1213 run_test 39b "11063 problem 1 =================================="
1216 local client1=${CLIENT1:-`hostname`}
1217 local client2=${CLIENT2:-`hostname`}
1219 echo hello > $DIR1/$tfile
1221 local mtime1=`stat -c %Y $DIR1/$tfile`
1222 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1223 [ "$mtime1" = "$mtime2" ] || \
1224 error "create: different mtime on clients: $mtime1, $mtime2"
1227 $TRUNCATE $DIR1/$tfile 1
1229 for (( i=0; i < 2; i++ )) ; do
1230 local mtime3=`stat -c %Y $DIR1/$tfile`
1231 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1233 [ "$mtime3" = "$mtime4" ] || \
1234 error "different mtime on clients: $mtime3, $mtime4"
1235 [ "$mtime3" -gt $mtime2 ] || \
1236 error "truncate did not update mtime: $mtime2, $mtime3"
1238 cancel_lru_locks osc
1239 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1242 run_test 39c "check truncate mtime update ======================"
1244 # check that pid exists hence second operation wasn't blocked by first one
1245 # if it is so then there is no conflict, return 0
1246 # else second operation is conflicting with first one, return 1
1247 check_pdo_conflict() {
1250 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1251 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1261 # test 40: check non-blocking operations
1263 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1264 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1265 mkdir $DIR1/$tfile &
1268 touch $DIR2/$tfile-2
1269 check_pdo_conflict $PID1 || error "create is blocked"
1270 mkdir $DIR2/$tfile-3
1271 check_pdo_conflict $PID1 || error "mkdir is blocked"
1272 link $DIR2/$tfile-2 $DIR2/$tfile-4
1273 check_pdo_conflict $PID1 || error "link is blocked"
1274 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1275 check_pdo_conflict $PID1 || error "rename is blocked"
1276 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1277 check_pdo_conflict $PID1 || error "getattr is blocked"
1278 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1279 rmdir $DIR2/$tfile-3
1280 check_pdo_conflict $PID1 || error "unlink is blocked"
1282 # all operations above shouldn't wait the first one
1283 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1288 run_test 40a "pdirops: create vs others =============="
1291 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1292 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1293 touch $DIR1/$tfile &
1297 touch $DIR2/$tfile-2
1298 check_pdo_conflict $PID1 || error "create is blocked"
1299 mkdir $DIR2/$tfile-3
1300 check_pdo_conflict $PID1 || error "mkdir is blocked"
1301 link $DIR2/$tfile-2 $DIR2/$tfile-4
1302 check_pdo_conflict $PID1 || error "link is blocked"
1303 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1304 check_pdo_conflict $PID1 || error "rename is blocked"
1305 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1306 check_pdo_conflict $PID1 || error "getattr is blocked"
1307 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1308 rmdir $DIR2/$tfile-3
1309 check_pdo_conflict $PID1 || error "unlink is blocked"
1310 # all operations above shouldn't wait the first one
1312 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1317 run_test 40b "pdirops: open|create and others =============="
1321 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1322 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1323 link $DIR1/$tfile $DIR1/$tfile-0 &
1327 touch $DIR2/$tfile-2
1328 check_pdo_conflict $PID1 || error "create is blocked"
1329 mkdir $DIR2/$tfile-3
1330 check_pdo_conflict $PID1 || error "mkdir is blocked"
1331 link $DIR2/$tfile-2 $DIR2/$tfile-4
1332 check_pdo_conflict $PID1 || error "link is blocked"
1333 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1334 check_pdo_conflict $PID1 || error "rename is blocked"
1335 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1336 check_pdo_conflict $PID1 || error "getattr is blocked"
1337 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1338 rmdir $DIR2/$tfile-3
1339 check_pdo_conflict $PID1 || error "unlink is blocked"
1341 # all operations above shouldn't wait the first one
1342 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1347 run_test 40c "pdirops: link and others =============="
1351 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1352 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1357 touch $DIR2/$tfile-2
1358 check_pdo_conflict $PID1 || error "create is blocked"
1359 mkdir $DIR2/$tfile-3
1360 check_pdo_conflict $PID1 || error "mkdir is blocked"
1361 link $DIR2/$tfile-2 $DIR2/$tfile-4
1362 check_pdo_conflict $PID1 || error "link is blocked"
1363 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1364 check_pdo_conflict $PID1 || error "rename is blocked"
1365 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1366 check_pdo_conflict $PID1 || error "getattr is blocked"
1367 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1368 rmdir $DIR2/$tfile-3
1369 check_pdo_conflict $PID1 || error "unlink is blocked"
1371 # all operations above shouldn't wait the first one
1372 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1376 run_test 40d "pdirops: unlink and others =============="
1380 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1381 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1382 mv $DIR1/$tfile $DIR1/$tfile-0 &
1386 touch $DIR2/$tfile-2
1387 check_pdo_conflict $PID1 || error "create is blocked"
1388 mkdir $DIR2/$tfile-3
1389 check_pdo_conflict $PID1 || error "mkdir is blocked"
1390 link $DIR2/$tfile-2 $DIR2/$tfile-4
1391 check_pdo_conflict $PID1 || error "link is blocked"
1392 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1393 check_pdo_conflict $PID1 || error "getattr is blocked"
1394 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1395 rmdir $DIR2/$tfile-3
1396 check_pdo_conflict $PID1 || error "unlink is blocked"
1398 # all operations above shouldn't wait the first one
1399 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1404 run_test 40e "pdirops: rename and others =============="
1406 # test 41: create blocking operations
1408 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1409 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1410 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1413 mkdir $DIR2/$tfile && error "mkdir must fail"
1414 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1418 run_test 41a "pdirops: create vs mkdir =============="
1421 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1422 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1423 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1426 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1427 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1431 run_test 41b "pdirops: create vs create =============="
1434 touch $DIR1/$tfile-2
1435 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1436 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1437 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1440 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1441 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1445 run_test 41c "pdirops: create vs link =============="
1448 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1449 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1450 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1453 rm $DIR2/$tfile || error "unlink must succeed"
1454 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1458 run_test 41d "pdirops: create vs unlink =============="
1461 touch $DIR1/$tfile-2
1462 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1463 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1464 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1467 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1468 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1472 run_test 41e "pdirops: create and rename (tgt) =============="
1475 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1476 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1477 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1480 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1481 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1485 run_test 41f "pdirops: create and rename (src) =============="
1488 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1489 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1490 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1493 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1494 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1498 run_test 41g "pdirops: create vs getattr =============="
1501 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1502 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1503 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1506 ls -lia $DIR2/ > /dev/null
1507 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1511 run_test 41h "pdirops: create vs readdir =============="
1513 # test 42: unlink and blocking operations
1515 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1516 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1517 mkdir $DIR1/$tfile &
1520 mkdir $DIR2/$tfile && error "mkdir must fail"
1521 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1525 run_test 42a "pdirops: mkdir vs mkdir =============="
1528 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1529 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1530 mkdir $DIR1/$tfile &
1533 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1534 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1538 run_test 42b "pdirops: mkdir vs create =============="
1541 touch $DIR1/$tfile-2
1542 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1543 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1544 mkdir $DIR1/$tfile &
1547 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1548 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1552 run_test 42c "pdirops: mkdir vs link =============="
1555 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1556 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1557 mkdir $DIR1/$tfile &
1560 rmdir $DIR2/$tfile || error "unlink must succeed"
1561 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1565 run_test 42d "pdirops: mkdir vs unlink =============="
1568 touch $DIR1/$tfile-2
1569 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1570 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1571 mkdir $DIR1/$tfile &
1574 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1575 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1579 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1582 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1583 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1584 mkdir $DIR1/$tfile &
1587 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1588 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1592 run_test 42f "pdirops: mkdir and rename (src) =============="
1595 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1596 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1597 mkdir $DIR1/$tfile &
1600 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1601 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1605 run_test 42g "pdirops: mkdir vs getattr =============="
1608 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1609 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1610 mkdir $DIR1/$tfile &
1613 ls -lia $DIR2/ > /dev/null
1614 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1618 run_test 42h "pdirops: mkdir vs readdir =============="
1620 # test 43: unlink and blocking operations
1623 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1624 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1628 mkdir $DIR2/$tfile || error "mkdir must succeed"
1629 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1633 run_test 43a "pdirops: unlink vs mkdir =============="
1637 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1638 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1642 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1643 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1647 run_test 43b "pdirops: unlink vs create =============="
1651 touch $DIR1/$tfile-2
1652 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1653 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1657 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1658 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1662 run_test 43c "pdirops: unlink vs link =============="
1666 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1667 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1671 rm $DIR2/$tfile && error "unlink must fail"
1672 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1676 run_test 43d "pdirops: unlink vs unlink =============="
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
1686 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1687 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1691 run_test 43e "pdirops: unlink and rename (tgt) =============="
1695 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1696 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1700 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1701 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1705 run_test 43f "pdirops: unlink and rename (src) =============="
1709 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1710 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1714 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1715 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1719 run_test 43g "pdirops: unlink vs getattr =============="
1723 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1724 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1728 ls -lia $DIR2/ > /dev/null
1729 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1733 run_test 43h "pdirops: unlink vs readdir =============="
1736 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1738 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1739 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1743 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1744 check_pdo_conflict $PID1 &&
1745 { wait $PID1; error "remote mkdir isn't blocked"; }
1749 run_test 43i "pdirops: unlink vs remote mkdir"
1751 # test 44: rename tgt and blocking operations
1753 touch $DIR1/$tfile-2
1754 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1755 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1756 mv $DIR1/$tfile-2 $DIR1/$tfile &
1759 mkdir $DIR2/$tfile && error "mkdir must fail"
1760 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1764 run_test 44a "pdirops: rename tgt vs mkdir =============="
1767 touch $DIR1/$tfile-2
1768 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1769 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1770 mv $DIR1/$tfile-2 $DIR1/$tfile &
1773 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1774 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1778 run_test 44b "pdirops: rename tgt vs create =============="
1781 touch $DIR1/$tfile-2
1782 touch $DIR1/$tfile-3
1783 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1784 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1785 mv $DIR1/$tfile-2 $DIR1/$tfile &
1788 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1789 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1793 run_test 44c "pdirops: rename tgt vs link =============="
1796 touch $DIR1/$tfile-2
1797 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1798 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1799 mv $DIR1/$tfile-2 $DIR1/$tfile &
1802 rm $DIR2/$tfile || error "unlink must succeed"
1803 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1807 run_test 44d "pdirops: rename tgt vs unlink =============="
1811 touch $DIR1/$tfile-2
1812 touch $DIR1/$tfile-3
1813 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1814 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1815 mv $DIR1/$tfile-2 $DIR1/$tfile &
1818 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1819 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1823 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1826 touch $DIR1/$tfile-2
1827 touch $DIR1/$tfile-3
1828 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1829 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1830 mv $DIR1/$tfile-2 $DIR1/$tfile &
1833 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1834 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1838 run_test 44f "pdirops: rename tgt and rename (src) =============="
1841 touch $DIR1/$tfile-2
1842 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1843 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1844 mv $DIR1/$tfile-2 $DIR1/$tfile &
1847 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1848 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1852 run_test 44g "pdirops: rename tgt vs getattr =============="
1855 touch $DIR1/$tfile-2
1856 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1857 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1858 mv $DIR1/$tfile-2 $DIR1/$tfile &
1861 ls -lia $DIR2/ > /dev/null
1862 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1866 run_test 44h "pdirops: rename tgt vs readdir =============="
1868 # test 44: rename tgt and blocking operations
1870 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1871 touch $DIR1/$tfile-2
1872 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1873 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1874 mv $DIR1/$tfile-2 $DIR1/$tfile &
1877 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1878 check_pdo_conflict $PID1 && { wait $PID1;
1879 error "remote mkdir isn't blocked"; }
1883 run_test 44i "pdirops: rename tgt vs remote mkdir"
1885 # test 45: rename src and blocking operations
1888 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1889 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1890 mv $DIR1/$tfile $DIR1/$tfile-2 &
1893 mkdir $DIR2/$tfile || error "mkdir must succeed"
1894 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1898 run_test 45a "pdirops: rename src vs mkdir =============="
1902 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1903 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1904 mv $DIR1/$tfile $DIR1/$tfile-2 &
1907 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1908 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1912 run_test 45b "pdirops: rename src vs create =============="
1916 touch $DIR1/$tfile-3
1917 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1918 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1919 mv $DIR1/$tfile $DIR1/$tfile-2 &
1922 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1923 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1927 run_test 45c "pdirops: rename src vs link =============="
1931 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1932 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1933 mv $DIR1/$tfile $DIR1/$tfile-2 &
1936 rm $DIR2/$tfile && error "unlink must fail"
1937 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1941 run_test 45d "pdirops: rename src vs unlink =============="
1945 touch $DIR1/$tfile-3
1946 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1947 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1948 mv $DIR1/$tfile $DIR1/$tfile-2 &
1951 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1952 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1956 run_test 45e "pdirops: rename src and rename (tgt) =============="
1960 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1961 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1962 mv $DIR1/$tfile $DIR1/$tfile-2 &
1965 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1966 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1970 run_test 45f "pdirops: rename src and rename (src) =============="
1974 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1975 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1976 mv $DIR1/$tfile $DIR1/$tfile-2 &
1979 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1980 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1984 run_test 45g "pdirops: rename src vs getattr =============="
1988 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1990 mv $DIR1/$tfile $DIR1/$tfile-2 &
1993 ls -lia $DIR2/ > /dev/null
1994 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1998 run_test 45h "pdirops: unlink vs readdir =============="
2001 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2003 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2004 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2005 mv $DIR1/$tfile $DIR1/$tfile-2 &
2008 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2009 check_pdo_conflict $PID1 && { wait $PID1;
2010 error "create remote dir isn't blocked"; }
2014 run_test 45i "pdirops: rename src vs remote mkdir"
2016 # test 46: link and blocking operations
2018 touch $DIR1/$tfile-2
2019 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2020 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2021 link $DIR1/$tfile-2 $DIR1/$tfile &
2024 mkdir $DIR2/$tfile && error "mkdir must fail"
2025 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2029 run_test 46a "pdirops: link vs mkdir =============="
2032 touch $DIR1/$tfile-2
2033 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2034 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2035 link $DIR1/$tfile-2 $DIR1/$tfile &
2038 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2039 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2043 run_test 46b "pdirops: link vs create =============="
2046 touch $DIR1/$tfile-2
2047 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2048 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2049 link $DIR1/$tfile-2 $DIR1/$tfile &
2052 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2053 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2057 run_test 46c "pdirops: link vs link =============="
2060 touch $DIR1/$tfile-2
2061 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2062 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2063 link $DIR1/$tfile-2 $DIR1/$tfile &
2066 rm $DIR2/$tfile || error "unlink must succeed"
2067 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2071 run_test 46d "pdirops: link vs unlink =============="
2074 touch $DIR1/$tfile-2
2075 touch $DIR1/$tfile-3
2076 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2077 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2078 link $DIR1/$tfile-2 $DIR1/$tfile &
2081 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2082 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2086 run_test 46e "pdirops: link and rename (tgt) =============="
2089 touch $DIR1/$tfile-2
2090 touch $DIR1/$tfile-3
2091 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2092 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2093 link $DIR1/$tfile-2 $DIR1/$tfile &
2096 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2097 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2101 run_test 46f "pdirops: link and rename (src) =============="
2104 touch $DIR1/$tfile-2
2105 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2106 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2107 link $DIR1/$tfile-2 $DIR1/$tfile &
2110 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2111 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2115 run_test 46g "pdirops: link vs getattr =============="
2118 touch $DIR1/$tfile-2
2119 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2120 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2121 link $DIR1/$tfile-2 $DIR1/$tfile &
2124 ls -lia $DIR2/ > /dev/null
2125 check_pdo_conflict $PID1 && { wait $PID1;
2126 error "readdir isn't blocked"; }
2130 run_test 46h "pdirops: link vs readdir =============="
2133 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2134 touch $DIR1/$tfile-2
2135 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2136 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2137 link $DIR1/$tfile-2 $DIR1/$tfile &
2140 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2141 check_pdo_conflict $PID1 && { wait $PID1;
2142 error "remote mkdir isn't blocked"; }
2146 run_test 46i "pdirops: link vs remote mkdir"
2148 # test 47: remote mkdir and blocking operations
2150 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2151 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2152 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2153 $LFS mkdir -i 1 $DIR1/$tfile &
2156 mkdir $DIR2/$tfile && error "mkdir must fail"
2157 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2161 run_test 47a "pdirops: remote mkdir vs mkdir"
2164 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2165 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2166 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2167 $LFS mkdir -i 1 $DIR1/$tfile &
2170 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2171 check_pdo_conflict $PID1 && { wait $PID1;
2172 error "create isn't blocked"; }
2176 run_test 47b "pdirops: remote mkdir vs create"
2179 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2180 touch $DIR1/$tfile-2
2181 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2182 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2183 $LFS mkdir -i 1 $DIR1/$tfile &
2186 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2187 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2191 run_test 47c "pdirops: remote mkdir vs link"
2194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2195 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2196 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2197 $LFS mkdir -i 1 $DIR1/$tfile &
2200 rmdir $DIR2/$tfile || error "unlink must succeed"
2201 check_pdo_conflict $PID1 && { wait $PID1;
2202 error "unlink isn't blocked"; }
2206 run_test 47d "pdirops: remote mkdir vs unlink"
2209 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2210 touch $DIR1/$tfile-2
2211 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2212 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2213 $LFS mkdir -i 1 $DIR1/$tfile &
2216 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2217 check_pdo_conflict $PID1 && { wait $PID1;
2218 error "rename isn't blocked"; }
2222 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2226 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2227 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2228 $LFS mkdir -i 1 $DIR1/$tfile &
2231 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2232 check_pdo_conflict $PID1 && { wait $PID1;
2233 error "rename isn't blocked"; }
2237 run_test 47f "pdirops: remote mkdir and rename (src)"
2240 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2241 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2242 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2243 $LFS mkdir -i 1 $DIR1/$tfile &
2246 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2247 check_pdo_conflict $PID1 && { wait $PID1;
2248 error "getattr isn't blocked"; }
2252 run_test 47g "pdirops: remote mkdir vs getattr"
2256 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2257 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2258 do_facet client "lctl set_param fail_loc=0x410"
2259 $TRUNCATE $DIR2/$tfile $trunc_size
2260 do_facet client "lctl set_param fail_loc=0x0"
2262 size=`stat -c %s $DIR2/$tfile`
2263 [ $size -eq $trunc_size ] || error "wrong size"
2265 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2269 local origfile=/etc/hosts
2271 filesize=`stat -c %s $origfile`
2273 # create an empty file
2274 $MCREATE $DIR1/$tfile
2275 # cache layout lock on both mount point
2276 stat $DIR1/$tfile > /dev/null
2277 stat $DIR2/$tfile > /dev/null
2279 # open and sleep 2 seconds then read
2280 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2284 # create the layout of testing file
2285 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2287 # MULTIOP proc should be able to read enough bytes and exit
2289 kill -0 $pid && error "multiop is still there"
2290 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2294 run_test 51a "layout lock: refresh layout should work"
2297 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2298 { skip "Need MDS version at least 2.3.59"; return 0; }
2300 local tmpfile=`mktemp`
2302 # create an empty file
2303 $MCREATE $DIR1/$tfile
2305 # delay glimpse so that layout has changed when glimpse finish
2306 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2307 $LCTL set_param fail_loc=0x1404
2308 stat -c %s $DIR2/$tfile |tee $tmpfile &
2312 # create layout of testing file
2313 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2316 local fsize=`cat $tmpfile`
2318 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2320 rm -f $DIR1/$tfile $tmpfile
2322 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2325 [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; }
2327 # set default layout to have 1 stripe
2328 mkdir -p $DIR1/$tdir
2329 $LFS setstripe -c 1 $DIR1/$tdir
2331 # create a file with empty layout
2332 $MCREATE $DIR1/$tdir/$tfile
2334 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2335 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2337 # change the layout of testing file
2338 echo "Setting layout to have $OSTCOUNT stripes ..."
2339 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2343 # write something to the file, it should be blocked on fetching layout
2344 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2345 local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2346 [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT"
2350 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2353 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2354 cancel_lru_locks mdc
2356 # open should grant LAYOUT lock, mmap and read will install pages
2357 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2361 # rss before revoking
2362 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2363 echo "Before revoking layout lock: $br KB mapped"
2365 # delete the file will revoke layout lock
2368 # rss after revoking
2369 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2374 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2376 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2380 echo "==> rename vs getattr vs setxattr should not deadlock"
2381 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2383 do_facet mds $LCTL set_param fail_loc=$1
2385 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2393 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2394 wait $PID1 || error "(3) mv failed"
2395 wait $PID2 || error "(4) stat failed"
2402 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2403 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2405 do_facet mds $LCTL set_param fail_loc=$1
2407 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2415 $MULTIOP $DIR2/d1/d2 Oc &
2419 stat $DIR/d1 || error "(2) stat failed"
2421 wait $PID1 || error "(3) mv failed"
2422 wait $PID2 || error "(4) stat failed"
2423 wait $PID3 && error "(5) multiop failed"
2429 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2430 save_lustre_params client "llite.*.xattr_cache" > $p
2431 lctl set_param llite.*.xattr_cache 1 ||
2432 { skip "xattr cache is not supported"; return 0; }
2434 #define OBD_FAIL_MDS_RENAME 0x153
2435 #define OBD_FAIL_MDS_RENAME2 0x154
2436 test_54_part1 0x80000153 || error 10
2437 test_54_part1 0x80000154 || error 11
2438 test_54_part2 0x80000153 || error 12
2439 test_54_part2 0x80000154 || error 13
2441 restore_lustre_params < $p
2444 run_test 54 "rename locking"
2447 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2449 #define OBD_FAIL_MDS_RENAME4 0x156
2450 do_facet mds $LCTL set_param fail_loc=0x80000156
2452 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2457 wait $PID1 && error "(2) mv succeeded"
2461 run_test 55a "rename vs unlink target dir"
2465 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2467 #define OBD_FAIL_MDS_RENAME4 0x156
2468 do_facet mds $LCTL set_param fail_loc=0x80000156
2470 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2475 wait $PID1 && error "(2) mv succeeded"
2479 run_test 55b "rename vs unlink source dir"
2483 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2485 #define OBD_FAIL_MDS_RENAME4 0x156
2486 do_facet mds $LCTL set_param fail_loc=0x156
2488 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2492 # while rename is sleeping, open and remove d3
2493 $MULTIOP $DIR2/d3 D_c &
2499 # while rename is sleeping 2nd time, close d3
2501 wait $PID2 || error "(3) multiop failed"
2503 wait $PID1 && error "(2) mv succeeded"
2507 run_test 55c "rename vs unlink orphan target dir"
2513 #define OBD_FAIL_MDS_RENAME3 0x155
2514 do_facet mds $LCTL set_param fail_loc=0x155
2515 mv $DIR/f1 $DIR/$tdir &
2519 # while rename is sleeping, create $tdir, but as a directory
2520 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2522 # link in reverse locking order
2523 ln $DIR2/f1 $DIR2/$tdir/
2525 wait $PID1 && error "(2) mv succeeded"
2528 run_test 55d "rename file vs link"
2531 local MDSVER=$(lustre_build_version $SINGLEMDS)
2532 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2533 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2536 test_mkdir -p $DIR1/$tdir
2537 file1=$DIR1/$tdir/file
2538 file2=$DIR2/$tdir/file
2540 echo orig > $file2 || error "Could not create $file2"
2541 version=$($LFS data_version $file1)
2544 echo append >> $file2 || error "Could not append to $file2"
2545 version2=$($LFS data_version $file1)
2546 [ "$version" != "$version2" ] ||
2547 error "append did not change data version: $version"
2550 echo overwrite > $file2 || error "Could not overwrite $file2"
2551 version3=$($LFS data_version $file1)
2552 [ "$version2" != "$version3" ] ||
2553 error "overwrite did not change data version: $version2"
2555 # Truncate before EOF
2556 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2557 version4=$($LFS data_version $file1)
2558 [ "$version3" != "$version4" ] ||
2559 error "truncate did not change data version: $version3"
2561 # Truncate after EOF
2562 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2563 version5=$($LFS data_version $file1)
2564 [ "$version4" != "$version5" ] ||
2565 error "truncate did not change data version: $version4"
2567 # Chmod do not change version
2568 chmod 400 $file2 || error "Could not chmod 400 $file2"
2569 version6=$($LFS data_version $file1)
2570 [ "$version5" == "$version6" ] ||
2571 error "chmod should not change data version: $version5 != $version6"
2573 # Chown do not change version
2574 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2575 version7=$($LFS data_version $file1)
2576 [ "$version5" == "$version7" ] ||
2577 error "chown should not change data version: $version5 != $version7"
2579 run_test 60 "Verify data_version behaviour"
2582 local test_dir=$tdir/test_dir
2584 mkdir -p $DIR1/$tdir
2585 if [ $MDSCOUNT -ge 2 ]; then
2587 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2588 error "Create remote directory failed"
2590 mkdir -p $DIR1/$test_dir
2592 cd $DIR2/$test_dir || error "cd directory failed"
2593 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2595 cd $DIR2/$tdir || error "exit directory"
2597 run_test 70a "cd directory && rm directory"
2599 test_70b() { # LU-2781
2601 mkdir -p $DIR1/$tdir
2603 touch $DIR1/$tdir/file
2604 for ((i = 0; i < 32; i++)); do
2605 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2607 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2609 touch $DIR1/$tdir/file
2610 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2611 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2612 rm -rf $DIR1/$tdir/test_dir ||
2613 error "cannot remove directory after rm_entry"
2614 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2616 run_test 70b "remove files after calling rm_entry"
2619 local server_version=$(lustre_version_code $SINGLEMDS)
2621 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2622 skip "Need MDS version at least 2.1.6" && return
2624 # Patch not applied to 2.2 and 2.3 branches
2625 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2626 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2627 skip "Need MDS version at least 2.4.0" && return
2629 checkfiemap --test ||
2630 { skip "checkfiemap not runnable: $?" && return; }
2631 # write data this way: hole - data - hole - data
2632 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2633 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2635 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2636 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2637 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2639 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2641 checkfiemap $DIR2/$tfile 81920 ||
2642 error "data is not flushed from client"
2643 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2646 # common case of "create file, copy file" on a single node
2647 # should not flush data from ost
2648 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2649 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2651 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2653 checkfiemap $DIR1/$tfile 81920 ||
2655 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2657 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2659 run_test 71 "correct file map just after write operation is finished"
2662 local p="$TMP/sanityN-$TESTNAME.parameters"
2665 save_lustre_params client "llite.*.xattr_cache" > $p
2666 lctl set_param llite.*.xattr_cache 1 ||
2667 { skip "xattr cache is not supported"; return 0; }
2670 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2671 error "setfattr1 failed"
2672 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2673 error "getfattr1 failed"
2674 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2675 error "setfattr2 failed"
2676 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2677 error "getfattr2 failed"
2679 # check that trusted.link is consistent
2680 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2681 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2682 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2683 echo "$tlink1 $tlink2"
2684 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2688 restore_lustre_params < $p
2691 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2694 local p="$TMP/sanityN-$TESTNAME.parameters"
2695 save_lustre_params client "llite.*.xattr_cache" > $p
2696 lctl set_param llite.*.xattr_cache 1 ||
2697 { skip "xattr cache is not supported"; return 0; }
2700 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2701 error "setfattr1 failed"
2702 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2703 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2705 # PR lock should be cached by now on both clients
2706 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2707 # 2 hits for getfattr(0)+getfattr(size)
2708 [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1"
2709 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2710 # 4 hits for more getfattr(0)+getfattr(size)
2711 [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2"
2714 restore_lustre_params < $p
2717 run_test 73 "getxattr should not cause xattr lock cancellation"
2720 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2721 skip "Need MDS version at least 2.4.93" && return
2723 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2724 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2725 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2727 run_test 74 "flock deadlock: different mounts =============="
2731 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2732 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2733 cancel_lru_locks osc
2735 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2738 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2739 $LCTL set_param fail_loc=0x31d
2740 stat -c %s $DIR1/$tfile &
2745 # For bad lock error handler we should ASSERT and got kernel panic here
2747 $LCTL set_param fail_loc=0
2749 run_test 75 "osc: upcall after unuse lock==================="
2752 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2753 skip "Need MDS version at least 2.5.53" && return
2755 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2761 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2767 test_mkdir -p $DIR/$tdir
2769 # drop all open locks and close any cached "open" files on the client
2770 cancel_lru_locks mdc
2772 echo -n "open files "
2774 for ((i = 0; i < $fcount; i++)); do
2775 touch $DIR/$tdir/f_$i
2777 local cmd="exec $fd<$DIR/$tdir/f_$i"
2784 local get_open_fids="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2785 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $get_open_fids))
2787 # Possible errors in openfiles FID list.
2788 # 1. Missing FIDs. Check 1
2789 # 2. Extra FIDs. Check 1
2790 # 3. Duplicated FID. Check 2
2791 # 4. Invalid FIDs. Check 2
2792 # 5. Valid FID, points to some other file. Check 3
2795 [ ${#fid_list[@]} -ne $fcount ] &&
2796 error "${#fid_list[@]} != $fcount open files"
2798 for (( i = 0; i < $fcount; i++ )) ; do
2799 cmd="exec ${fd_list[i]}</dev/null"
2801 filename=$($LFS fid2path $DIR2 ${fid_list[i]})
2804 rm --interactive=no $filename
2806 error "Nonexisting fid ${fid_list[i]} listed."
2810 ls_op=$(ls $DIR2/$tdir | wc -l)
2812 error "Some openfiles are missing in lproc output"
2816 run_test 76 "Verify open file for 2048 files"
2820 local dir=$DIR/$tdir
2822 mkdir $dir || error "mkdir $dir failed"
2823 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
2825 do_nodes $CLIENTS dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME"\
2826 bs=1M count=$n > /dev/null 2>&1
2828 for ((i = 0; i < $n; i++)); do
2829 do_nodes $CLIENTS dd if=/dev/zero of="$dir/nrs_w_$HOSTNAME"\
2830 bs=1M seek=$i count=1 > /dev/null 2>&1 &
2833 do_nodes $CLIENTS sync;
2834 cancel_lru_locks osc
2836 for ((i = 0; i < $n; i++)); do
2837 do_nodes $CLIENTS dd if="$dir/nrs_w_$HOSTNAME" of=/dev/zero\
2838 bs=1M seek=$i count=1 > /dev/null 2>&1 &
2841 cancel_lru_locks osc
2843 for ((i = 0; i < $n; i++)); do
2847 rm -rf $dir || error "rm -rf $dir failed"
2850 test_77a() { #LU-3266
2851 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_policies="fifo"
2856 run_test 77a "check FIFO NRS policy"
2859 test_77b() { #LU-3266
2860 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_policies="crrn"
2861 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_crrn_quantum=1
2863 echo "policy: crr-n, crrn_quantum 1"
2866 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_crrn_quantum=64
2868 echo "policy: crr-n, crrn_quantum 64"
2873 run_test 77b "check CRR-N NRS policy"
2878 for i in $(seq 1 $OSTCOUNT)
2880 do_facet ost"$i" lctl set_param \
2881 ost.OSS.ost_io.nrs_policies=$policy
2882 do_facet ost"$i" lctl set_param \
2883 ost.OSS.*.nrs_"$policy"_quantum=1
2884 do_facet ost"$i" lctl set_param \
2885 ost.OSS.*.nrs_"$policy"_offset_type="physical"
2886 do_facet ost"$i" lctl set_param \
2887 ost.OSS.*.nrs_"$policy"_supported="reads"
2890 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type \
2891 physical, ${policy}_supported reads"
2894 for i in $(seq 1 $OSTCOUNT)
2896 do_facet ost"$i" lctl set_param \
2897 ost.OSS.*.nrs_${policy}_supported="writes"
2898 do_facet ost"$i" lctl set_param \
2899 ost.OSS.*.nrs_${policy}_quantum=64
2901 echo "policy: $policy, ${policy}_quantum 64, \
2902 ${policy}_offset_type physical, ${policy}_supported writes"
2905 for i in $(seq 1 $OSTCOUNT)
2907 do_facet ost"$i" lctl set_param \
2908 ost.OSS.*.nrs_${policy}_supported="reads_and_writes"
2909 do_facet ost"$i" lctl set_param \
2910 ost.OSS.*.nrs_${policy}_offset_type="logical"
2912 echo "policy: $policy, ${policy}_quantum 64, \
2913 ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
2919 test_77c() { #LU-3266
2923 run_test 77c "check ORR NRS policy"
2925 test_77d() { #LU-3266
2929 run_test 77d "check TRR nrs policy"
2932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2939 mkdir -p $DIR1/$tdir/dir
2940 createmany -o $DIR1/$tdir/dir/f 10 ||
2941 error "create files under remote dir failed $i"
2943 cp /etc/passwd $DIR1/$tdir/$tfile
2945 #migrate open file should fails
2946 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
2948 # give multiop a chance to open
2951 $LFS mv -M $MDTIDX $DIR1/$tdir &&
2952 error "migrate open files should failed with open files"
2956 $LFS mv -M $MDTIDX $DIR1/$tdir ||
2957 error "migrate remote dir error"
2959 echo "Finish migration, then checking.."
2960 for file in $(find $DIR1/$tdir); do
2961 mdt_index=$($LFS getstripe -M $file)
2962 [ $mdt_index == $MDTIDX ] ||
2963 error "$file is not on MDT${MDTIDX}"
2966 diff /etc/passwd $DIR1/$tdir/$tfile ||
2967 error "file different after migration"
2969 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
2971 run_test 80 "migrate directory when some children is being opened"
2974 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2978 mkdir -p $DIR1/$tdir
2980 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
2981 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
2984 touch d0/0 || error "create 0 failed"
2985 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
2986 stat d0/0 && error "stat mv filed succeed"
2987 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || "rename d1/0 d0/0 failed"
2988 stat d0/0 || error "stat failed"
2990 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
2992 if [ $t -ne 3 ]; then
2993 ls -ai $DIR1/$tdir/d0
2994 error "expect 3 get $t"
2999 run_test 81 "rename and stat under striped directory"
3002 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3003 { skip "Need MDS version at least 2.6.92"; return 0; }
3005 # Client 1 creates a file.
3006 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3008 # Client 2 opens the file.
3009 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3011 # Client 1 makes the file an orphan.
3012 rm $DIR1/$tfile || error "rm"
3013 # Client 2 sets EA "user.multiop".
3015 wait $pid2 || error "multiop 2"
3016 # Client 1 gets EA "user.multiop". This used to fail because the EA
3017 # cache refill would get "trusted.link" from mdd_xattr_list() but
3018 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3021 wait $pid1 || error "multiop 1"
3023 run_test 82 "fsetxattr and fgetxattr on orphan files"
3025 log "cleanup: ======================================================"
3027 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
3031 check_and_cleanup_lustre