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
52 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
54 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
55 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
57 # $RUNAS_ID may get set incorrectly somewhere else
58 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
60 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
69 [ -f $DIR2/f1 ] || error
71 run_test 1a "check create on 2 mtpt's =========================="
75 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
78 run_test 1b "check attribute updates on 2 mtpt's ==============="
81 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
83 run_test 1c "check after remount attribute updates on 2 mtpt's ="
87 $CHECKSTAT -a $DIR1/f1 || error
89 run_test 1d "unlink on one mountpoint removes file on other ===="
95 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
97 run_test 2a "check cached attribute updates on 2 mtpt's ========"
103 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
105 run_test 2b "check cached attribute updates on 2 mtpt's ========"
107 # NEED TO SAVE ROOT DIR MODE
110 $CHECKSTAT -t dir -p 0777 $DIR2 || error
112 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
116 $CHECKSTAT -t dir -p 0755 $DIR2 || error
118 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
125 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
127 run_test 2e "check chmod on root is propagated to others"
130 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
132 local remote_dir=$tdir/remote_dir
135 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
136 error "Create remote directory failed"
138 touch $DIR1/$remote_dir/$tfile ||
139 error "Create file under remote directory failed"
140 chmod 777 $DIR1/$remote_dir/$tfile ||
141 error "Chmod file under remote directory failed"
143 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
144 error "Check attr of file under remote directory failed"
146 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
147 error "Chown file under remote directory failed"
149 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
150 error "Check owner of file under remote directory failed"
152 cd $DIR2/$remote_dir || error "enter remote dir"
153 rm -rf $DIR1/$remote_dir/$tfile ||
154 error "Unlink remote directory failed"
156 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
157 error "unlink file still exists!"
159 cd $DIR2/$tdir || error "exit remote dir"
160 rm -rf $DIR1/$tdir || error "unlink directory failed"
162 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
165 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
167 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
169 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
170 echo "$DIR1/$tfile has $block1 blocks"
171 echo "$DIR2/$tfile has $block2 blocks"
172 [ $block1 -eq $block2 ] || error
174 run_test 2g "check blocks update on sync write"
177 local target="this/is/good"
178 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
179 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
180 error "link $DIR2/$tfile not as expected"
182 run_test 3 "symlink on one mtpt, readlink on another ==========="
185 multifstat $DIR1/f4 $DIR2/f4
187 run_test 4 "fstat validation on multiple mount points =========="
191 $TRUNCATE $DIR2/f5 100
192 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
195 run_test 5 "create a file on one mount, truncate it on the other"
198 openunlink $DIR1/$tfile $DIR2/$tfile || \
199 error "openunlink $DIR1/$tfile $DIR2/$tfile"
201 run_test 6 "remove of open file on other node =================="
205 opendirunlink $DIR1/$dir $DIR2/$dir || \
206 error "opendirunlink $DIR1/$dir $DIR2/$dir"
208 run_test 7 "remove of open directory on other node ============="
211 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
212 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
214 run_test 8 "remove of open special file on other node =========="
220 for C in a b c d e f g h i j k l; do
221 dir=`eval echo \\$DIR$MTPT`
222 echo -n $C >> $dir/f9
223 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
225 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
226 error "`od -a $DIR1/f9` != abcdefghijkl"
228 run_test 9 "append of file with sub-page size on multiple mounts"
235 for C in a b c d e f g h i j k l; do
236 dir=`eval echo \\$DIR$MTPT`
237 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
238 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
239 OFFSET=`expr $OFFSET + 1`
241 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
242 error "`od -a $DIR1/f10` != abcdefghijkl"
244 run_test 10a "write of file with sub-page size on multiple mounts "
248 yes "R" | head -c 4000 >$TMP/f10b-seed
249 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
251 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
253 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
255 # create a test file locally to compare
256 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
257 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
258 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
259 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
261 run_test 10b "write of file with sub-page size on multiple mounts "
265 multiop_bg_pause $DIR1/d11/f O_c || return 1
267 cp -p /bin/ls $DIR1/d11/f
271 wait $MULTIPID || error
272 [ $RC -eq 0 ] && error || true
274 run_test 11 "execution of file opened for write should return error ===="
277 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
279 run_test 12 "test lock ordering (link, stat, unlink) ==========="
281 test_13() { # bug 2451 - directory coherency
282 test_mkdir $DIR1/d13 || error
283 cd $DIR1/d13 || error
285 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
287 rm -f $DIR2/d13/f13 || error
288 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
289 # need to run it twice
290 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
292 rm -f $DIR2/d13/f13 || error
293 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
295 run_test 13 "test directory page revocation ===================="
298 test_mkdir -p $DIR1/$tdir
299 cp -p /bin/ls $DIR1/$tdir/$tfile
300 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
303 $DIR2/$tdir/$tfile && error || true
305 wait $MULTIPID || return 2
307 run_test 14aa "execution of file open for write returns -ETXTBSY"
310 test_mkdir -p $DIR1/d14
311 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
312 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
314 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
315 kill -USR1 $MULTIOP_PID || return 2
316 wait $MULTIOP_PID || return 3
317 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
319 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
321 test_14b() { # bug 3192, 7040
322 test_mkdir -p $DIR1/d14
323 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
324 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
326 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
327 error "expected truncate error, got success"
328 kill -USR1 $MULTIOP_PID || return 2
329 wait $MULTIOP_PID || return 3
330 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
331 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
333 run_test 14b "truncate of executing file returns -ETXTBSY ======"
335 test_14c() { # bug 3430, 7040
336 test_mkdir -p $DIR1/d14
337 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
338 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
340 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
341 kill -USR1 $MULTIOP_PID || return 2
342 wait $MULTIOP_PID || return 3
343 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
344 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
346 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
348 test_14d() { # bug 10921
349 test_mkdir -p $DIR1/d14
350 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
351 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
354 chmod 600 $DIR1/d14/multiop || error "chmod failed"
355 kill -USR1 $MULTIOP_PID || return 2
356 wait $MULTIOP_PID || return 3
357 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
358 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
360 run_test 14d "chmod of executing file is still possible ========"
362 test_15() { # bug 974 - ENOSPC
364 sh oos2.sh $MOUNT1 $MOUNT2
365 wait_delete_completed
366 grant_error=`dmesg | grep "> available"`
367 [ -z "$grant_error" ] || error "$grant_error"
369 run_test 15 "test out-of-space with multiple writers ==========="
372 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
373 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
374 # pass a 2500 operation dual-mount run within the time limit.
375 if [ "$(facet_fstype ost1)" = "zfs" ]; then
376 FSXNUM=$((COUNT / 5))
378 elif [ "$SLOW" = "yes" ]; then
379 FSXNUM=$((COUNT * 5))
387 local file1=$DIR1/$tfile
388 local file2=$DIR2/$tfile
390 # to allocate grant because it may run out due to test_15.
391 lfs setstripe -c -1 $file1
392 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
393 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
396 lfs setstripe -c -1 $file1 # b=10919
397 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
399 run_test 16 "$FSXNUM iterations of dual-mount fsx"
401 test_17() { # bug 3513, 3667
402 remote_ost_nodsh && skip "remote OST with nodsh" && return
404 lfs setstripe $DIR1/$tfile -i 0 -c 1
405 cp $SAMPLE_FILE $DIR1/$tfile
406 cancel_lru_locks osc > /dev/null
407 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
408 do_facet ost1 lctl set_param fail_loc=0x8000030a
409 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
410 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
412 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
414 run_test 17 "resource creation/LVB creation race ==============="
417 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
420 for idx in {a..z}; do
421 local ptr=EXCEPT_ALWAYS_18$idx
422 [ x${!ptr} = xtrue ] || continue
424 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
427 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
430 run_test 18 "mmap sanity check ================================="
432 test_19() { # bug3811
433 local node=$(facet_active_host ost1)
435 # check whether obdfilter is cache capable at all
436 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
437 echo "not cache-capable obdfilter"
441 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
443 set_osd_param $node '' readcache_max_filesize 4096
444 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
445 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
446 cp $TMP/$tfile $DIR1/$tfile
447 for i in `seq 1 20`; do
448 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
449 cancel_lru_locks osc > /dev/null
450 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
451 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
453 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
454 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
455 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
456 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
458 set_osd_param $node '' readcache_max_filesize $MAX
461 run_test 19 "test concurrent uncached read races ==============="
466 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
467 $MULTIOP $DIR1/f20 Ow8190c
468 $MULTIOP $DIR2/f20 Oz8194w8190c
469 $MULTIOP $DIR1/f20 Oz0r8190c
471 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
473 error $CNTD" page left in cache after lock cancel" || true
475 run_test 20 "test extra readahead page left in cache ===="
482 test_21() { # Bug 5907
483 test_mkdir $DIR1/$tdir
484 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
486 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
487 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
488 test -d $DIR1/$tdir || error "Mounted directory disappeared"
490 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
493 run_test 21 " Try to remove mountpoint on another dir ===="
495 test_23() { # Bug 5972
496 local at_diff=$(do_facet $SINGLEMDS \
497 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
498 echo "atime should be updated while another read" > $DIR1/$tfile
500 # clear the lock(mode: LCK_PW) gotten from creating operation
504 sleep $((at_diff + 1))
506 echo "starting reads"
507 multiop_bg_pause $DIR1/$tfile or20_c || return 1
508 # with SOM and opencache enabled, we need to close a file and cancel
509 # open lock to get atime propogated to MDS
510 kill -USR1 $! || return 2
513 time2=$(stat -c "%X" $DIR/$tfile)
514 echo "new atime is $time2"
516 [ $time2 -gt $time1 ] || error "atime was not updated"
517 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
520 run_test 23 " others should see updated atime while another read===="
524 lfs df || error "lfs df failed"
525 lfs df -ih || error "lfs df -ih failed"
526 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
527 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
528 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
529 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
531 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
532 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
533 lctl --device %$OSC deactivate
534 lfs df -i || error "lfs df -i with deactivated OSC failed"
535 lctl --device %$OSC activate
536 lfs df || error "lfs df with reactivated OSC failed"
538 run_test 24a "lfs df [-ih] [path] test ========================="
542 fsnum=$(lfs_df | grep -c "summary")
543 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
545 run_test 24b "lfs df should show both filesystems ==============="
548 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
550 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
553 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
554 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
556 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
557 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
558 error "setfacl $DIR2/$tdir #1"
559 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
560 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
561 error "setfacl $DIR2/$tdir #2"
562 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
563 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
564 error "setfacl $DIR2/$tdir #3"
565 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
566 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
567 error "setfacl $DIR2/$tdir #4"
568 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
572 run_test 25a "change ACL on one mountpoint be seen on another ==="
575 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
577 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
579 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
582 $LFS mkdir -i 1 $DIR1/$tdir
583 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
584 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
586 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
587 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
588 error "setfacl $DIR2/$tdir #1"
589 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
590 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
591 error "setfacl $DIR2/$tdir #2"
592 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
593 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
594 error "setfacl $DIR2/$tdir #3"
595 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
596 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
597 error "setfacl $DIR2/$tdir #4"
598 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
602 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
605 utime $DIR1/f26a -s $DIR2/f26a || error
607 run_test 26a "allow mtime to get older"
612 echo "aaa" >> $DIR1/$tfile
614 chmod a+x $DIR2/$tfile
615 mt1=`stat -c %Y $DIR1/$tfile`
616 mt2=`stat -c %Y $DIR2/$tfile`
618 if [ x"$mt1" != x"$mt2" ]; then
619 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
622 run_test 26b "sync mtime between ost and mds"
627 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
632 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
637 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
639 lctl set_param -n ldlm.dump_namespaces ""
640 wait $DD1_PID $DD2_PID
641 [ $? -ne 0 ] && lctl dk $TMP/debug || true
643 run_test 27 "align non-overlapping extent locks from request ==="
645 test_28() { # bug 9977
646 ECHO_UUID="ECHO_osc1_UUID"
647 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
649 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
650 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
651 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
655 attach echo_client ECHO_osc1 $ECHO_UUID
659 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
660 $LCTL --device $tECHOID destroy "${tOBJID}:0"
668 # reading of 1st stripe should pass
669 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
670 # reading of 2nd stripe should fail (this stripe was destroyed)
671 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
673 # now, recreating test file
674 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
675 # reading of 1st stripe should pass
676 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
677 # reading of 2nd stripe should pass
678 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
680 run_test 28 "read/write/truncate file with lost stripes"
682 test_29() { # bug 10999
684 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
685 lctl set_param fail_loc=0x8000030f
688 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
691 #bug 11549 - permanently turn test off in b1_5
692 run_test 29 "lock put race between glimpse and enqueue ========="
694 test_30() { #bug #11110, LU-2523
695 test_mkdir -p $DIR1/$tdir
696 cp -f /bin/bash $DIR1/$tdir/bash
697 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
698 cp /bin/bash $DIR2/$tdir' &
699 $DIR1/$tdir/bash -c 'sleep 2;
700 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
705 run_test 30 "recreate file race"
708 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
709 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
710 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
711 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
712 lctl set_param fail_loc=0x314
713 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
714 awk 'BEGIN { FS="+" } /in/ {print $1}')
715 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
717 run_test 31a "voluntary cancel / blocking ast race=============="
720 remote_ost || { skip "local OST" && return 0; }
721 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
723 # make sure there is no local locks due to destroy
724 wait_mds_ost_sync || error "wait_mds_ost_sync()"
725 wait_delete_completed || error "wait_delete_completed()"
727 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
728 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
729 cp /etc/hosts $DIR/$tdir/$tfile
730 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
731 lctl set_param fail_loc=0x314
732 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
733 do_facet ost1 lctl set_param fail_loc=0x316
735 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
736 lctl set_param fail_loc=0
737 do_facet ost1 lctl set_param fail_loc=0
738 # cleanup: reconnect the client back
741 run_test 31b "voluntary OST cancel / blocking ast race=============="
743 # enable/disable lockless truncate feature, depending on the arg 0/1
744 enable_lockless_truncate() {
745 lctl set_param -n osc.*.lockless_truncate $1
748 test_32a() { # bug 11270
749 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
750 save_lustre_params client "osc.*.lockless_truncate" > $p
752 enable_lockless_truncate 1
754 lfs setstripe -c -1 $DIR1/$tfile
755 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
759 log "checking cached lockless truncate"
760 $TRUNCATE $DIR1/$tfile 8000000
761 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
762 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
763 error "cached truncate isn't lockless"
765 log "checking not cached lockless truncate"
766 $TRUNCATE $DIR2/$tfile 5000000
767 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
768 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
769 error "not cached truncate isn't lockless"
771 log "disabled lockless truncate"
772 enable_lockless_truncate 0
774 $TRUNCATE $DIR2/$tfile 3000000
775 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
776 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
777 error "lockless truncate disabling failed"
779 # restore lockless_truncate default values
780 restore_lustre_params < $p
783 run_test 32a "lockless truncate"
785 test_32b() { # bug 11270
786 remote_ost_nodsh && skip "remote OST with nodsh" && return
789 local facets=$(get_facets OST)
790 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
792 save_lustre_params client "osc.*.contention_seconds" > $p
793 save_lustre_params $facets \
794 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
795 save_lustre_params $facets \
796 "ldlm.namespaces.filter-*.contended_locks" >> $p
797 save_lustre_params $facets \
798 "ldlm.namespaces.filter-*.contention_seconds" >> $p
801 # agressive lockless i/o settings
802 for node in $(osts_nodes); do
803 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'
805 lctl set_param -n osc.*.contention_seconds 60
806 for i in $(seq 5); do
807 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
808 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
810 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
811 # disable lockless i/o (it is disabled by default)
812 for node in $(osts_nodes); do
813 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'
815 # set contention_seconds to 0 at client too, otherwise Lustre still
816 # remembers lock contention
817 lctl set_param -n osc.*.contention_seconds 0
819 for i in $(seq 1); do
820 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
821 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
823 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
824 error "lockless i/o works when disabled"
826 restore_lustre_params <$p
829 run_test 32b "lockless i/o"
833 local mdts=$(get_facets MDS)
838 for mds in ${mdts//,/ }; do
840 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
841 xargs readlink -f" ))
842 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
845 stat=$(( stat + val))
850 # commit on sharing tests
852 remote_mds_nodsh && skip "remote MDS with nodsh" && return
854 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
855 [ $CLIENTCOUNT -lt 2 ] &&
856 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
858 local nfiles=${TEST33_NFILES:-10000}
859 local param_file=$TMP/$tfile-params
860 local fstype=$(facet_fstype $SINGLEMDS)
862 save_lustre_params $(get_facets MDS) \
863 "mdt.*.commit_on_sharing" > $param_file
871 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
875 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
877 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
878 echo "=== START createmany old: $jbdold transaction"
879 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")
880 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
881 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
882 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
883 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
884 avgtime=$(( avgtime + elapsed ))
886 eval cos${COS}_jbd=$((avgjbd / 3))
887 eval cos${COS}_time=$((avgtime / 3))
890 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
891 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
892 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
893 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
895 restore_lustre_params < $param_file
899 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
901 # commit on sharing tests
903 remote_mds_nodsh && skip "remote MDS with nodsh" && return
905 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
906 [ $CLIENTCOUNT -ge 2 ] ||
907 { skip "Need two or more clients, have $CLIENTCOUNT" &&
909 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
911 local nfiles=${TEST33_NFILES:-10000}
912 local param_file=$TMP/$tfile-params
914 save_lustre_params $(get_facets MDS) \
915 "mdt.*.commit_on_sharing" > $param_file
924 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
928 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
929 $DIR1/$tdir-\\\$(hostname)-$i"
931 jbdold=$(print_jbd_stat)
932 echo "=== START createmany old: $jbdold transaction"
933 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
934 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
935 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
937 jbdnew=$(print_jbd_stat)
938 jbd=$(( jbdnew - jbdold ))
939 echo "=== END createmany new: $jbdnew transaction : \
940 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
941 avgjbd=$(( avgjbd + jbd ))
942 avgtime=$(( avgtime + elapsed ))
944 eval cos${COS}_jbd=$((avgjbd / 3))
945 eval cos${COS}_time=$((avgtime / 3))
948 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
949 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
950 [ "$cos0_jbd" != 0 ] &&
951 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
952 [ "$cos0_time" != 0 ] &&
953 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
955 restore_lustre_params < $param_file
959 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
962 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
963 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
964 skip "DNE CoS not supported" && return
969 # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
970 $LFS mkdir -i 1 $DIR/$tdir/d1
971 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
973 local sync_count=$(do_facet mds1 \
974 "lctl get_param -n mdt.*MDT0000.sync_count")
975 [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
977 $LFS mkdir -i 1 $DIR/$tdir/d3
978 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
979 # during sleep remote mkdir should have been committed and canceled
980 # remote lock spontaneously, which shouldn't trigger sync
983 local sync_count=$(do_facet mds1 \
984 "lctl get_param -n mdt.*MDT0000.sync_count")
985 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
987 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
990 local nodes=$(comma_list $(mdts_nodes))
991 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
993 local async_commit_count=$(do_nodes $nodes \
994 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
995 [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
1002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1003 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1004 skip "DNE CoS not supported" && return
1007 # remote directory create
1009 ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1010 # remote directory unlink
1011 $LFS mkdir -i 1 $DIR/$tdir
1012 ops_do_cos "rmdir $DIR/$tdir"
1013 # striped directory create
1015 ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1016 # striped directory setattr
1017 $LFS mkdir -c 2 $DIR/$tdir
1019 ops_do_cos "chmod 713 $DIR/$tdir"
1020 # striped directory unlink
1021 $LFS mkdir -c 2 $DIR/$tdir
1023 ops_do_cos "rmdir $DIR/$tdir"
1025 $LFS mkdir -c 2 $DIR/$tdir
1026 $LFS mkdir -i 0 $DIR/$tdir/d1
1027 $LFS mkdir -i 1 $DIR/$tdir/d2
1028 touch $DIR/$tdir/d1/tgt
1029 ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1031 $LFS mkdir -c 2 $DIR/$tdir
1032 $LFS mkdir -i 0 $DIR/$tdir/d1
1033 $LFS mkdir -i 1 $DIR/$tdir/d2
1034 touch $DIR/$tdir/d1/src
1035 ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1037 $LFS mkdir -i 0 $DIR/$tdir
1038 ops_do_cos "$LFS migrate -m 1 $DIR/$tdir"
1041 run_test 33d "DNE distributed operation should trigger COS"
1044 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1045 [ $CLIENTCOUNT -ge 2 ] ||
1046 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1048 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1049 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] &&
1050 skip "DNE CoS not supported" && return
1052 local client2=${CLIENT2:-$(hostname)}
1056 local nodes=$(comma_list $(mdts_nodes))
1057 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1059 $LFS mkdir -c 2 $DIR/$tdir
1060 mkdir $DIR/$tdir/subdir
1061 echo abc > $DIR/$tdir/$tfile
1062 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1063 do_node $client2 touch $DIR/$tdir/subdir
1065 local async_commit_count=$(do_nodes $nodes \
1066 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1067 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1071 run_test 33e "DNE local operation shouldn't trigger COS"
1073 # End commit on sharing tests
1075 get_ost_lock_timeouts() {
1076 local nodes=${1:-$(comma_list $(osts_nodes))}
1078 local locks=$(do_nodes $nodes \
1079 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1087 do_nodes $(comma_list $(osts_nodes)) \
1088 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1089 for i in $(seq $OSTCOUNT); do
1090 wait_osc_import_state client ost$i FULL
1095 remote_ost_nodsh && skip "remote OST with nodsh" && return
1099 trap cleanup_34 EXIT RETURN
1100 for OPER in notimeout timeout ; do
1101 rm $DIR1/$tfile 2>/dev/null
1102 lock_in=$(get_ost_lock_timeouts)
1103 if [ $OPER == "timeout" ] ; then
1104 for j in `seq $OSTCOUNT`; do
1105 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1106 do_facet ost$j lctl set_param fail_loc=0x511
1108 echo lock should expire
1110 for j in `seq $OSTCOUNT`; do
1111 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1112 do_facet ost$j lctl set_param fail_loc=0x512
1114 echo lock should not expire
1116 echo writing on client1
1117 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1119 echo reading on client2
1120 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1121 # wait for a lock timeout
1123 lock_out=$(get_ost_lock_timeouts)
1124 if [ $OPER == "timeout" ] ; then
1125 if [ $lock_in == $lock_out ]; then
1126 error "no lock timeout happened"
1131 if [ $lock_in != $lock_out ]; then
1132 error "lock timeout happened"
1140 run_test 34 "no lock timeout under IO"
1142 test_35() { # bug 17645
1145 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1146 awk '/generation/{print $2}')
1148 generation[count]=$g
1152 test_mkdir -p $MOUNT1/$tfile
1153 cancel_lru_locks mdc
1155 # Let's initiate -EINTR situation by setting fail_loc and take
1156 # write lock on same file from same client. This will not cause
1157 # bl_ast yet as lock is already in local cache.
1158 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1159 do_facet client "lctl set_param fail_loc=0x80000317"
1160 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1161 let timeout=timeout*3
1163 while test $nr -lt 10; do
1164 log "Race attempt $nr"
1165 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1166 test "x$blk1" = "x" && blk1=0
1167 createmany -o $MOUNT2/$tfile/a 4000 &
1171 # Let's make conflict and bl_ast
1172 ls -la $MOUNT1/$tfile > /dev/null &
1175 log "Wait for $pid1 $pid2 for $timeout sec..."
1177 kill -9 $pid1 $pid2 > /dev/null 2>&1
1179 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1180 test "x$blk2" = "x" && blk2=0
1181 test $blk2 -gt $blk1 && break
1182 rm -fr $MOUNT1/$tfile/*
1183 cancel_lru_locks mdc
1186 do_facet client "lctl set_param fail_loc=0x0"
1187 df -h $MOUNT1 $MOUNT2
1189 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1190 awk '/generation/{print $2}')
1192 if ! test "$g" -eq "${generation[count]}"; then
1193 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1195 for imp in $list; do
1196 if [ $c = $count ]; then
1201 imp=$(echo "$imp" | awk -F"." '{print $2}')
1202 error "Eviction happened on import $imp"
1207 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1209 test_36() { #bug 16417
1214 test_mkdir -p $DIR1/$tdir
1215 $LFS setstripe -c -1 $DIR1/$tdir
1218 let SIZE_B=SIZE*1024*1024
1219 sync; sleep 5; sync # wait for delete thread
1221 while [ $i -le 10 ]; do
1222 lctl mark "start test"
1223 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1224 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1225 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1226 sync # sync data from client cache
1227 sync_all_data # sync data from server cache (delayed allocation)
1229 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1230 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1232 rm -f $DIR1/$tdir/$tfile
1233 kill -USR1 $read_pid
1235 wait_delete_completed
1236 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1237 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1239 # this free space! not used
1240 (( $after_dd <= $after)) ||
1241 error "space leaked after_dd:$after_dd > after:$after"
1245 run_test 36 "handle ESTALE/open-unlink correctly"
1247 test_37() { # bug 18695
1248 test_mkdir -p $DIR1/$tdir
1249 multiop_bg_pause $DIR1/$tdir D_c || return 1
1251 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1252 createmany -m $DIR2/$tdir/f 10000
1253 # set mtime/atime backward
1254 touch -t 198001010000 $DIR2/$tdir
1255 kill -USR1 $MULTIPID
1256 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1257 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1260 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1262 # this should be set to past
1263 TEST_39_MTIME=`date -d "1 year ago" +%s`
1267 local client1=${CLIENT1:-`hostname`}
1268 local client2=${CLIENT2:-`hostname`}
1270 do_node $client1 "touch $DIR1/$tfile"
1272 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1273 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1274 [ "$mtime1" = $TEST_39_MTIME ] || \
1275 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1277 local d1=`do_node $client1 date +%s`
1278 do_node $client1 'echo hello >> '$DIR1/$tfile
1279 local d2=`do_node $client1 date +%s`
1281 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1282 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1283 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1285 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1287 for (( i=0; i < 2; i++ )) ; do
1288 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1289 [ "$mtime2" = "$mtime3" ] || \
1290 error "mtime ($mtime2) changed (to $mtime3) on rename"
1292 cancel_lru_locks osc
1293 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1296 run_test 39a "test from 11063 =================================="
1299 local client1=${CLIENT1:-`hostname`}
1300 local client2=${CLIENT2:-`hostname`}
1304 local mtime1=`stat -c %Y $DIR1/$tfile`
1305 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1308 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1310 for (( i=0; i < 2; i++ )) ; do
1311 local mtime3=`stat -c %Y $DIR1/$tfile`
1312 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1314 [ "$mtime3" = "$mtime4" ] || \
1315 error "different mtime on clients: $mtime3, $mtime4"
1316 [ "$mtime3" = $TEST_39_MTIME ] || \
1317 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1319 cancel_lru_locks osc
1320 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1323 run_test 39b "11063 problem 1 =================================="
1326 local client1=${CLIENT1:-`hostname`}
1327 local client2=${CLIENT2:-`hostname`}
1329 echo hello > $DIR1/$tfile
1331 local mtime1=`stat -c %Y $DIR1/$tfile`
1332 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1333 [ "$mtime1" = "$mtime2" ] || \
1334 error "create: different mtime on clients: $mtime1, $mtime2"
1337 $TRUNCATE $DIR1/$tfile 1
1339 for (( i=0; i < 2; i++ )) ; do
1340 local mtime3=`stat -c %Y $DIR1/$tfile`
1341 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1343 [ "$mtime3" = "$mtime4" ] || \
1344 error "different mtime on clients: $mtime3, $mtime4"
1345 [ "$mtime3" -gt $mtime2 ] || \
1346 error "truncate did not update mtime: $mtime2, $mtime3"
1348 cancel_lru_locks osc
1349 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1352 run_test 39c "check truncate mtime update ======================"
1354 # check that pid exists hence second operation wasn't blocked by first one
1355 # if it is so then there is no conflict, return 0
1356 # else second operation is conflicting with first one, return 1
1357 check_pdo_conflict() {
1360 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1361 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1371 # test 40: check non-blocking operations
1373 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1374 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1375 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1377 mkdir $DIR1/$tfile &
1380 touch $DIR2/$tfile-2
1381 check_pdo_conflict $PID1 || error "create is blocked"
1382 mkdir $DIR2/$tfile-3
1383 check_pdo_conflict $PID1 || error "mkdir is blocked"
1384 link $DIR2/$tfile-2 $DIR2/$tfile-4
1385 check_pdo_conflict $PID1 || error "link is blocked"
1386 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1387 check_pdo_conflict $PID1 || error "rename is blocked"
1388 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1389 check_pdo_conflict $PID1 || error "getattr is blocked"
1390 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1391 rmdir $DIR2/$tfile-3
1392 check_pdo_conflict $PID1 || error "unlink is blocked"
1394 # all operations above shouldn't wait the first one
1395 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1400 run_test 40a "pdirops: create vs others =============="
1403 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1404 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1405 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1406 touch $DIR1/$tfile &
1410 touch $DIR2/$tfile-2
1411 check_pdo_conflict $PID1 || error "create is blocked"
1412 mkdir $DIR2/$tfile-3
1413 check_pdo_conflict $PID1 || error "mkdir is blocked"
1414 link $DIR2/$tfile-2 $DIR2/$tfile-4
1415 check_pdo_conflict $PID1 || error "link is blocked"
1416 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1417 check_pdo_conflict $PID1 || error "rename is blocked"
1418 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1419 check_pdo_conflict $PID1 || error "getattr is blocked"
1420 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1421 rmdir $DIR2/$tfile-3
1422 check_pdo_conflict $PID1 || error "unlink is blocked"
1423 # all operations above shouldn't wait the first one
1425 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1430 run_test 40b "pdirops: open|create and others =============="
1433 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1435 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1436 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1437 link $DIR1/$tfile $DIR1/$tfile-0 &
1441 touch $DIR2/$tfile-2
1442 check_pdo_conflict $PID1 || error "create is blocked"
1443 mkdir $DIR2/$tfile-3
1444 check_pdo_conflict $PID1 || error "mkdir is blocked"
1445 link $DIR2/$tfile-2 $DIR2/$tfile-4
1446 check_pdo_conflict $PID1 || error "link is blocked"
1447 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1448 check_pdo_conflict $PID1 || error "rename is blocked"
1449 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1450 check_pdo_conflict $PID1 || error "getattr is blocked"
1451 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1452 rmdir $DIR2/$tfile-3
1453 check_pdo_conflict $PID1 || error "unlink is blocked"
1455 # all operations above shouldn't wait the first one
1456 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1461 run_test 40c "pdirops: link and others =============="
1464 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1466 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1467 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1472 touch $DIR2/$tfile-2
1473 check_pdo_conflict $PID1 || error "create is blocked"
1474 mkdir $DIR2/$tfile-3
1475 check_pdo_conflict $PID1 || error "mkdir is blocked"
1476 link $DIR2/$tfile-2 $DIR2/$tfile-4
1477 check_pdo_conflict $PID1 || error "link is blocked"
1478 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1479 check_pdo_conflict $PID1 || error "rename is blocked"
1480 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1481 check_pdo_conflict $PID1 || error "getattr is blocked"
1482 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1483 rmdir $DIR2/$tfile-3
1484 check_pdo_conflict $PID1 || error "unlink is blocked"
1486 # all operations above shouldn't wait the first one
1487 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1491 run_test 40d "pdirops: unlink and others =============="
1494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1496 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1497 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1498 mv $DIR1/$tfile $DIR1/$tfile-0 &
1502 touch $DIR2/$tfile-2
1503 check_pdo_conflict $PID1 || error "create is blocked"
1504 mkdir $DIR2/$tfile-3
1505 check_pdo_conflict $PID1 || error "mkdir is blocked"
1506 link $DIR2/$tfile-2 $DIR2/$tfile-4
1507 check_pdo_conflict $PID1 || error "link is blocked"
1508 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1509 check_pdo_conflict $PID1 || error "getattr is blocked"
1510 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1511 rmdir $DIR2/$tfile-3
1512 check_pdo_conflict $PID1 || error "unlink is blocked"
1514 # all operations above shouldn't wait the first one
1515 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1520 run_test 40e "pdirops: rename and others =============="
1522 # test 41: create blocking operations
1524 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1525 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1526 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1529 mkdir $DIR2/$tfile && error "mkdir must fail"
1530 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1534 run_test 41a "pdirops: create vs mkdir =============="
1537 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1538 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1539 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1542 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1543 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1547 run_test 41b "pdirops: create vs create =============="
1550 touch $DIR1/$tfile-2
1551 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1552 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1553 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1556 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1557 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1561 run_test 41c "pdirops: create vs link =============="
1564 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1565 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1566 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1569 rm $DIR2/$tfile || error "unlink must succeed"
1570 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1574 run_test 41d "pdirops: create vs unlink =============="
1577 touch $DIR1/$tfile-2
1578 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1579 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1580 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1583 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1584 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1588 run_test 41e "pdirops: create and rename (tgt) =============="
1591 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1592 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1593 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1596 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1597 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1601 run_test 41f "pdirops: create and rename (src) =============="
1604 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1605 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1606 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1609 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1610 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1614 run_test 41g "pdirops: create vs getattr =============="
1617 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1618 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1619 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1622 ls -lia $DIR2/ > /dev/null
1623 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1627 run_test 41h "pdirops: create vs readdir =============="
1629 # test 42: unlink and blocking operations
1631 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1632 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1633 mkdir $DIR1/$tfile &
1636 mkdir $DIR2/$tfile && error "mkdir must fail"
1637 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1641 run_test 42a "pdirops: mkdir vs mkdir =============="
1644 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1645 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1646 mkdir $DIR1/$tfile &
1649 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1650 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1654 run_test 42b "pdirops: mkdir vs create =============="
1657 touch $DIR1/$tfile-2
1658 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1659 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1660 mkdir $DIR1/$tfile &
1663 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1664 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1668 run_test 42c "pdirops: mkdir vs link =============="
1671 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1672 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1673 mkdir $DIR1/$tfile &
1676 rmdir $DIR2/$tfile || error "unlink must succeed"
1677 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1681 run_test 42d "pdirops: mkdir vs unlink =============="
1684 touch $DIR1/$tfile-2
1685 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1686 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1687 mkdir $DIR1/$tfile &
1690 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1691 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1695 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1698 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1699 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1700 mkdir $DIR1/$tfile &
1703 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1704 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1708 run_test 42f "pdirops: mkdir and rename (src) =============="
1711 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1712 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1713 mkdir $DIR1/$tfile &
1716 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1717 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1721 run_test 42g "pdirops: mkdir vs getattr =============="
1724 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1725 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1726 mkdir $DIR1/$tfile &
1729 ls -lia $DIR2/ > /dev/null
1730 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1734 run_test 42h "pdirops: mkdir vs readdir =============="
1736 # test 43: unlink and blocking operations
1739 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1740 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1744 mkdir $DIR2/$tfile || error "mkdir must succeed"
1745 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1749 run_test 43a "pdirops: unlink vs mkdir =============="
1753 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1754 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1758 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1763 run_test 43b "pdirops: unlink vs create =============="
1767 touch $DIR1/$tfile-2
1768 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1769 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1773 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1774 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1778 run_test 43c "pdirops: unlink vs link =============="
1782 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1783 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1787 rm $DIR2/$tfile && error "unlink must fail"
1788 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1792 run_test 43d "pdirops: unlink vs unlink =============="
1796 touch $DIR1/$tfile-2
1797 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1798 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1802 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1803 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1807 run_test 43e "pdirops: unlink and rename (tgt) =============="
1811 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1812 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1816 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1817 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1821 run_test 43f "pdirops: unlink and rename (src) =============="
1825 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1826 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1830 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1831 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1835 run_test 43g "pdirops: unlink vs getattr =============="
1839 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1840 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1844 ls -lia $DIR2/ > /dev/null
1845 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1849 run_test 43h "pdirops: unlink vs readdir =============="
1852 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1854 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1855 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1859 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1860 check_pdo_conflict $PID1 &&
1861 { wait $PID1; error "remote mkdir isn't blocked"; }
1865 run_test 43i "pdirops: unlink vs remote mkdir"
1867 # test 44: rename tgt and blocking operations
1869 touch $DIR1/$tfile-2
1870 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1871 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1872 mv $DIR1/$tfile-2 $DIR1/$tfile &
1875 mkdir $DIR2/$tfile && error "mkdir must fail"
1876 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1880 run_test 44a "pdirops: rename tgt vs mkdir =============="
1883 touch $DIR1/$tfile-2
1884 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1885 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1886 mv $DIR1/$tfile-2 $DIR1/$tfile &
1889 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1890 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1894 run_test 44b "pdirops: rename tgt vs create =============="
1897 touch $DIR1/$tfile-2
1898 touch $DIR1/$tfile-3
1899 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1900 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1901 mv $DIR1/$tfile-2 $DIR1/$tfile &
1904 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1905 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1909 run_test 44c "pdirops: rename tgt vs link =============="
1912 touch $DIR1/$tfile-2
1913 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1914 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1915 mv $DIR1/$tfile-2 $DIR1/$tfile &
1918 rm $DIR2/$tfile || error "unlink must succeed"
1919 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1923 run_test 44d "pdirops: rename tgt vs unlink =============="
1927 touch $DIR1/$tfile-2
1928 touch $DIR1/$tfile-3
1929 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1930 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1931 mv $DIR1/$tfile-2 $DIR1/$tfile &
1934 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1935 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1939 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1942 touch $DIR1/$tfile-2
1943 touch $DIR1/$tfile-3
1944 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1945 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1946 mv $DIR1/$tfile-2 $DIR1/$tfile &
1949 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1950 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1954 run_test 44f "pdirops: rename tgt and rename (src) =============="
1957 touch $DIR1/$tfile-2
1958 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1959 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1960 mv $DIR1/$tfile-2 $DIR1/$tfile &
1963 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1964 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1968 run_test 44g "pdirops: rename tgt vs getattr =============="
1971 touch $DIR1/$tfile-2
1972 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1973 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1974 mv $DIR1/$tfile-2 $DIR1/$tfile &
1977 ls -lia $DIR2/ > /dev/null
1978 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1982 run_test 44h "pdirops: rename tgt vs readdir =============="
1984 # test 44: rename tgt and blocking operations
1986 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1987 touch $DIR1/$tfile-2
1988 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1990 mv $DIR1/$tfile-2 $DIR1/$tfile &
1993 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1994 check_pdo_conflict $PID1 && { wait $PID1;
1995 error "remote mkdir isn't blocked"; }
1999 run_test 44i "pdirops: rename tgt vs remote mkdir"
2001 # test 45: rename src and blocking operations
2004 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2005 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2006 mv $DIR1/$tfile $DIR1/$tfile-2 &
2009 mkdir $DIR2/$tfile || error "mkdir must succeed"
2010 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2014 run_test 45a "pdirops: rename src vs mkdir =============="
2018 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2019 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2020 mv $DIR1/$tfile $DIR1/$tfile-2 &
2023 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2024 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2028 run_test 45b "pdirops: rename src vs create =============="
2032 touch $DIR1/$tfile-3
2033 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2034 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2035 mv $DIR1/$tfile $DIR1/$tfile-2 &
2038 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2039 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2043 run_test 45c "pdirops: rename src vs link =============="
2047 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2048 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2049 mv $DIR1/$tfile $DIR1/$tfile-2 &
2052 rm $DIR2/$tfile && error "unlink must fail"
2053 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2057 run_test 45d "pdirops: rename src vs unlink =============="
2061 touch $DIR1/$tfile-3
2062 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2063 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2064 mv $DIR1/$tfile $DIR1/$tfile-2 &
2067 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2068 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2072 run_test 45e "pdirops: rename src and rename (tgt) =============="
2076 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2077 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2078 mv $DIR1/$tfile $DIR1/$tfile-2 &
2081 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2082 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2086 run_test 45f "pdirops: rename src and rename (src) =============="
2090 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2091 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2092 mv $DIR1/$tfile $DIR1/$tfile-2 &
2095 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2096 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2100 run_test 45g "pdirops: rename src vs getattr =============="
2104 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2105 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2106 mv $DIR1/$tfile $DIR1/$tfile-2 &
2109 ls -lia $DIR2/ > /dev/null
2110 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2114 run_test 45h "pdirops: unlink vs readdir =============="
2117 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2119 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2120 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2121 mv $DIR1/$tfile $DIR1/$tfile-2 &
2124 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2125 check_pdo_conflict $PID1 && { wait $PID1;
2126 error "create remote dir isn't blocked"; }
2130 run_test 45i "pdirops: rename src vs remote mkdir"
2132 # test 46: link and blocking operations
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 mkdir $DIR2/$tfile && error "mkdir must fail"
2141 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2145 run_test 46a "pdirops: link vs mkdir =============="
2148 touch $DIR1/$tfile-2
2149 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2150 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2151 link $DIR1/$tfile-2 $DIR1/$tfile &
2154 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2155 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2159 run_test 46b "pdirops: link vs create =============="
2162 touch $DIR1/$tfile-2
2163 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2164 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2165 link $DIR1/$tfile-2 $DIR1/$tfile &
2168 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2169 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2173 run_test 46c "pdirops: link vs link =============="
2176 touch $DIR1/$tfile-2
2177 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2178 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2179 link $DIR1/$tfile-2 $DIR1/$tfile &
2182 rm $DIR2/$tfile || error "unlink must succeed"
2183 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2187 run_test 46d "pdirops: link vs unlink =============="
2190 touch $DIR1/$tfile-2
2191 touch $DIR1/$tfile-3
2192 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2193 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2194 link $DIR1/$tfile-2 $DIR1/$tfile &
2197 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2198 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2202 run_test 46e "pdirops: link and rename (tgt) =============="
2205 touch $DIR1/$tfile-2
2206 touch $DIR1/$tfile-3
2207 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2208 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2209 link $DIR1/$tfile-2 $DIR1/$tfile &
2212 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2213 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2217 run_test 46f "pdirops: link and rename (src) =============="
2220 touch $DIR1/$tfile-2
2221 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2222 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2223 link $DIR1/$tfile-2 $DIR1/$tfile &
2226 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2227 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2231 run_test 46g "pdirops: link vs getattr =============="
2234 touch $DIR1/$tfile-2
2235 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2236 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2237 link $DIR1/$tfile-2 $DIR1/$tfile &
2240 ls -lia $DIR2/ > /dev/null
2241 check_pdo_conflict $PID1 && { wait $PID1;
2242 error "readdir isn't blocked"; }
2246 run_test 46h "pdirops: link vs readdir =============="
2249 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2250 touch $DIR1/$tfile-2
2251 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2252 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2253 link $DIR1/$tfile-2 $DIR1/$tfile &
2256 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2257 check_pdo_conflict $PID1 && { wait $PID1;
2258 error "remote mkdir isn't blocked"; }
2262 run_test 46i "pdirops: link vs remote mkdir"
2264 # test 47: remote mkdir and blocking operations
2266 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2267 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2268 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2269 $LFS mkdir -i 1 $DIR1/$tfile &
2272 mkdir $DIR2/$tfile && error "mkdir must fail"
2273 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2277 run_test 47a "pdirops: remote mkdir vs mkdir"
2280 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2281 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2282 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2283 $LFS mkdir -i 1 $DIR1/$tfile &
2286 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2287 check_pdo_conflict $PID1 && { wait $PID1;
2288 error "create isn't blocked"; }
2292 run_test 47b "pdirops: remote mkdir vs create"
2295 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2296 touch $DIR1/$tfile-2
2297 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2298 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2299 $LFS mkdir -i 1 $DIR1/$tfile &
2302 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2303 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2307 run_test 47c "pdirops: remote mkdir vs link"
2310 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2311 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2312 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2313 $LFS mkdir -i 1 $DIR1/$tfile &
2316 rmdir $DIR2/$tfile || error "unlink must succeed"
2317 check_pdo_conflict $PID1 && { wait $PID1;
2318 error "unlink isn't blocked"; }
2322 run_test 47d "pdirops: remote mkdir vs unlink"
2325 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2326 touch $DIR1/$tfile-2
2327 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2328 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2329 $LFS mkdir -i 1 $DIR1/$tfile &
2332 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2333 check_pdo_conflict $PID1 && { wait $PID1;
2334 error "rename isn't blocked"; }
2338 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2341 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2342 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2343 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2344 $LFS mkdir -i 1 $DIR1/$tfile &
2347 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2348 check_pdo_conflict $PID1 && { wait $PID1;
2349 error "rename isn't blocked"; }
2353 run_test 47f "pdirops: remote mkdir and rename (src)"
2356 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2357 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2358 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2359 $LFS mkdir -i 1 $DIR1/$tfile &
2362 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2363 check_pdo_conflict $PID1 && { wait $PID1;
2364 error "getattr isn't blocked"; }
2368 run_test 47g "pdirops: remote mkdir vs getattr"
2372 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2373 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2374 do_facet client "lctl set_param fail_loc=0x410"
2375 $TRUNCATE $DIR2/$tfile $trunc_size
2376 do_facet client "lctl set_param fail_loc=0x0"
2378 size=`stat -c %s $DIR2/$tfile`
2379 [ $size -eq $trunc_size ] || error "wrong size"
2381 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2385 local origfile=/etc/hosts
2387 filesize=`stat -c %s $origfile`
2389 # create an empty file
2390 $MCREATE $DIR1/$tfile
2391 # cache layout lock on both mount point
2392 stat $DIR1/$tfile > /dev/null
2393 stat $DIR2/$tfile > /dev/null
2395 # open and sleep 2 seconds then read
2396 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2400 # create the layout of testing file
2401 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2403 # MULTIOP proc should be able to read enough bytes and exit
2405 kill -0 $pid && error "multiop is still there"
2406 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2410 run_test 51a "layout lock: refresh layout should work"
2413 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2414 { skip "Need MDS version at least 2.3.59"; return 0; }
2416 local tmpfile=`mktemp`
2418 # create an empty file
2419 $MCREATE $DIR1/$tfile
2421 # delay glimpse so that layout has changed when glimpse finish
2422 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2423 $LCTL set_param fail_loc=0x1404
2424 stat -c %s $DIR2/$tfile |tee $tmpfile &
2428 # create layout of testing file
2429 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2432 local fsize=`cat $tmpfile`
2434 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2436 rm -f $DIR1/$tfile $tmpfile
2438 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2441 [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; }
2443 # set default layout to have 1 stripe
2444 mkdir -p $DIR1/$tdir
2445 $LFS setstripe -c 1 $DIR1/$tdir
2447 # create a file with empty layout
2448 $MCREATE $DIR1/$tdir/$tfile
2450 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2451 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2453 # change the layout of testing file
2454 echo "Setting layout to have $OSTCOUNT stripes ..."
2455 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2459 # write something to the file, it should be blocked on fetching layout
2460 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2461 local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2462 [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT"
2466 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2469 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2470 cancel_lru_locks mdc
2472 # open should grant LAYOUT lock, mmap and read will install pages
2473 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2477 # rss before revoking
2478 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2479 echo "Before revoking layout lock: $br KB mapped"
2481 # delete the file will revoke layout lock
2484 # rss after revoking
2485 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2490 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2492 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2496 echo "==> rename vs getattr vs setxattr should not deadlock"
2497 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2499 do_facet mds $LCTL set_param fail_loc=$1
2501 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2509 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2510 wait $PID1 || error "(3) mv failed"
2511 wait $PID2 || error "(4) stat failed"
2518 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2519 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2521 do_facet mds $LCTL set_param fail_loc=$1
2523 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2531 $MULTIOP $DIR2/d1/d2 Oc &
2535 stat $DIR/d1 || error "(2) stat failed"
2537 wait $PID1 || error "(3) mv failed"
2538 wait $PID2 || error "(4) stat failed"
2539 wait $PID3 && error "(5) multiop failed"
2545 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2546 save_lustre_params client "llite.*.xattr_cache" > $p
2547 lctl set_param llite.*.xattr_cache 1 ||
2548 { skip "xattr cache is not supported"; return 0; }
2550 #define OBD_FAIL_MDS_RENAME 0x153
2551 #define OBD_FAIL_MDS_RENAME2 0x154
2552 test_54_part1 0x80000153 || error 10
2553 test_54_part1 0x80000154 || error 11
2554 test_54_part2 0x80000153 || error 12
2555 test_54_part2 0x80000154 || error 13
2557 restore_lustre_params < $p
2560 run_test 54 "rename locking"
2563 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2565 #define OBD_FAIL_MDS_RENAME4 0x156
2566 do_facet mds $LCTL set_param fail_loc=0x80000156
2568 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2573 wait $PID1 && error "(2) mv succeeded"
2577 run_test 55a "rename vs unlink target dir"
2581 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2583 #define OBD_FAIL_MDS_RENAME4 0x156
2584 do_facet mds $LCTL set_param fail_loc=0x80000156
2586 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2591 wait $PID1 && error "(2) mv succeeded"
2595 run_test 55b "rename vs unlink source dir"
2599 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2601 #define OBD_FAIL_MDS_RENAME4 0x156
2602 do_facet mds $LCTL set_param fail_loc=0x156
2604 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2608 # while rename is sleeping, open and remove d3
2609 $MULTIOP $DIR2/d3 D_c &
2615 # while rename is sleeping 2nd time, close d3
2617 wait $PID2 || error "(3) multiop failed"
2619 wait $PID1 && error "(2) mv succeeded"
2623 run_test 55c "rename vs unlink orphan target dir"
2629 #define OBD_FAIL_MDS_RENAME3 0x155
2630 do_facet mds $LCTL set_param fail_loc=0x155
2631 mv $DIR/f1 $DIR/$tdir &
2635 # while rename is sleeping, create $tdir, but as a directory
2636 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2638 # link in reverse locking order
2639 ln $DIR2/f1 $DIR2/$tdir/
2641 wait $PID1 && error "(2) mv succeeded"
2644 run_test 55d "rename file vs link"
2647 local MDSVER=$(lustre_build_version $SINGLEMDS)
2648 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2649 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2652 test_mkdir -p $DIR1/$tdir
2653 file1=$DIR1/$tdir/file
2654 file2=$DIR2/$tdir/file
2656 echo orig > $file2 || error "Could not create $file2"
2657 version=$($LFS data_version $file1)
2660 echo append >> $file2 || error "Could not append to $file2"
2661 version2=$($LFS data_version $file1)
2662 [ "$version" != "$version2" ] ||
2663 error "append did not change data version: $version"
2666 echo overwrite > $file2 || error "Could not overwrite $file2"
2667 version3=$($LFS data_version $file1)
2668 [ "$version2" != "$version3" ] ||
2669 error "overwrite did not change data version: $version2"
2671 # Truncate before EOF
2672 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2673 version4=$($LFS data_version $file1)
2674 [ "$version3" != "$version4" ] ||
2675 error "truncate did not change data version: $version3"
2677 # Truncate after EOF
2678 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2679 version5=$($LFS data_version $file1)
2680 [ "$version4" != "$version5" ] ||
2681 error "truncate did not change data version: $version4"
2683 # Chmod do not change version
2684 chmod 400 $file2 || error "Could not chmod 400 $file2"
2685 version6=$($LFS data_version $file1)
2686 [ "$version5" == "$version6" ] ||
2687 error "chmod should not change data version: $version5 != $version6"
2689 # Chown do not change version
2690 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2691 version7=$($LFS data_version $file1)
2692 [ "$version5" == "$version7" ] ||
2693 error "chown should not change data version: $version5 != $version7"
2695 run_test 60 "Verify data_version behaviour"
2698 local test_dir=$tdir/test_dir
2700 mkdir -p $DIR1/$tdir
2701 if [ $MDSCOUNT -ge 2 ]; then
2703 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2704 error "Create remote directory failed"
2706 mkdir -p $DIR1/$test_dir
2708 cd $DIR2/$test_dir || error "cd directory failed"
2709 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2711 cd $DIR2/$tdir || error "exit directory"
2713 run_test 70a "cd directory && rm directory"
2715 test_70b() { # LU-2781
2717 mkdir -p $DIR1/$tdir
2719 touch $DIR1/$tdir/file
2720 for ((i = 0; i < 32; i++)); do
2721 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2723 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2725 touch $DIR1/$tdir/file
2726 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2727 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2728 rm -rf $DIR1/$tdir/test_dir ||
2729 error "cannot remove directory after rm_entry"
2730 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2732 run_test 70b "remove files after calling rm_entry"
2735 local server_version=$(lustre_version_code $SINGLEMDS)
2737 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2738 skip "Need MDS version at least 2.1.6" && return
2740 # Patch not applied to 2.2 and 2.3 branches
2741 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2742 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2743 skip "Need MDS version at least 2.4.0" && return
2745 checkfiemap --test ||
2746 { skip "checkfiemap not runnable: $?" && return; }
2747 # write data this way: hole - data - hole - data
2748 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2749 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2751 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2752 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2753 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2755 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2757 checkfiemap $DIR2/$tfile 81920 ||
2758 error "data is not flushed from client"
2759 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2762 # common case of "create file, copy file" on a single node
2763 # should not flush data from ost
2764 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2765 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2767 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2769 checkfiemap $DIR1/$tfile 81920 ||
2771 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2773 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2775 run_test 71 "correct file map just after write operation is finished"
2778 local p="$TMP/sanityN-$TESTNAME.parameters"
2781 save_lustre_params client "llite.*.xattr_cache" > $p
2782 lctl set_param llite.*.xattr_cache 1 ||
2783 { skip "xattr cache is not supported"; return 0; }
2786 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2787 error "setfattr1 failed"
2788 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2789 error "getfattr1 failed"
2790 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2791 error "setfattr2 failed"
2792 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2793 error "getfattr2 failed"
2795 # check that trusted.link is consistent
2796 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2797 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2798 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2799 echo "$tlink1 $tlink2"
2800 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2804 restore_lustre_params < $p
2807 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2810 local p="$TMP/sanityN-$TESTNAME.parameters"
2811 save_lustre_params client "llite.*.xattr_cache" > $p
2812 lctl set_param llite.*.xattr_cache 1 ||
2813 { skip "xattr cache is not supported"; return 0; }
2816 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2817 error "setfattr1 failed"
2818 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2819 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2821 # PR lock should be cached by now on both clients
2822 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2823 # 2 hits for getfattr(0)+getfattr(size)
2824 [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1"
2825 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2826 # 4 hits for more getfattr(0)+getfattr(size)
2827 [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2"
2830 restore_lustre_params < $p
2833 run_test 73 "getxattr should not cause xattr lock cancellation"
2836 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2837 skip "Need MDS version at least 2.4.93" && return
2839 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2840 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2841 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2843 run_test 74 "flock deadlock: different mounts =============="
2847 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2848 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2849 cancel_lru_locks osc
2851 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2854 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2855 $LCTL set_param fail_loc=0x31d
2856 stat -c %s $DIR1/$tfile &
2861 # For bad lock error handler we should ASSERT and got kernel panic here
2863 $LCTL set_param fail_loc=0
2865 run_test 75 "osc: upcall after unuse lock==================="
2868 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2869 skip "Need MDS version at least 2.5.53" && return
2871 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2877 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2883 test_mkdir -p $DIR/$tdir
2885 # drop all open locks and close any cached "open" files on the client
2886 cancel_lru_locks mdc
2888 echo -n "open files "
2890 for ((i = 0; i < $fcount; i++)); do
2891 touch $DIR/$tdir/f_$i
2893 local cmd="exec $fd<$DIR/$tdir/f_$i"
2900 local get_open_fids="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2901 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $get_open_fids))
2903 # Possible errors in openfiles FID list.
2904 # 1. Missing FIDs. Check 1
2905 # 2. Extra FIDs. Check 1
2906 # 3. Duplicated FID. Check 2
2907 # 4. Invalid FIDs. Check 2
2908 # 5. Valid FID, points to some other file. Check 3
2911 [ ${#fid_list[@]} -ne $fcount ] &&
2912 error "${#fid_list[@]} != $fcount open files"
2914 for (( i = 0; i < $fcount; i++ )) ; do
2915 cmd="exec ${fd_list[i]}</dev/null"
2917 filename=$($LFS fid2path $DIR2 ${fid_list[i]})
2920 rm --interactive=no $filename
2922 error "Nonexisting fid ${fid_list[i]} listed."
2926 ls_op=$(ls $DIR2/$tdir | wc -l)
2928 error "Some openfiles are missing in lproc output"
2932 run_test 76 "Verify open file for 2048 files"
2936 local dir=$DIR/$tdir
2939 mkdir $dir || error "mkdir $dir failed"
2940 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
2943 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME"\
2944 bs=1M count=$n > /dev/null 2>&1
2946 for ((i = 0; i < $n; i++)); do
2947 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero\
2948 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1\
2952 do_nodes $CLIENTS sync;
2953 cancel_lru_locks osc
2955 for ((i = 0; i < $n; i++)); do
2956 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME"\
2957 of=/dev/zero bs=1M seek=$i count=1 > /dev/null 2>&1 &
2960 cancel_lru_locks osc
2962 for ((i = 0; i < $n; i++)); do
2966 rm -rf $dir || error "rm -rf $dir failed"
2969 test_77a() { #LU-3266
2970 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_policies="fifo"
2975 run_test 77a "check FIFO NRS policy"
2978 test_77b() { #LU-3266
2979 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_policies="crrn"
2980 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_crrn_quantum=1
2982 echo "policy: crr-n, crrn_quantum 1"
2985 do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_crrn_quantum=64
2987 echo "policy: crr-n, crrn_quantum 64"
2992 run_test 77b "check CRR-N NRS policy"
2997 for i in $(seq 1 $OSTCOUNT)
2999 do_facet ost"$i" lctl set_param \
3000 ost.OSS.ost_io.nrs_policies=$policy
3001 do_facet ost"$i" lctl set_param \
3002 ost.OSS.*.nrs_"$policy"_quantum=1
3003 do_facet ost"$i" lctl set_param \
3004 ost.OSS.*.nrs_"$policy"_offset_type="physical"
3005 do_facet ost"$i" lctl set_param \
3006 ost.OSS.*.nrs_"$policy"_supported="reads"
3009 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type \
3010 physical, ${policy}_supported reads"
3013 for i in $(seq 1 $OSTCOUNT)
3015 do_facet ost"$i" lctl set_param \
3016 ost.OSS.*.nrs_${policy}_supported="writes"
3017 do_facet ost"$i" lctl set_param \
3018 ost.OSS.*.nrs_${policy}_quantum=64
3020 echo "policy: $policy, ${policy}_quantum 64, \
3021 ${policy}_offset_type physical, ${policy}_supported writes"
3024 for i in $(seq 1 $OSTCOUNT)
3026 do_facet ost"$i" lctl set_param \
3027 ost.OSS.*.nrs_${policy}_supported="reads_and_writes"
3028 do_facet ost"$i" lctl set_param \
3029 ost.OSS.*.nrs_${policy}_offset_type="logical"
3031 echo "policy: $policy, ${policy}_quantum 64, \
3032 ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3038 test_77c() { #LU-3266
3042 run_test 77c "check ORR NRS policy"
3044 test_77d() { #LU-3266
3048 run_test 77d "check TRR nrs policy"
3055 do_facet $facet lctl set_param \
3056 ost.OSS.ost_io.nrs_tbf_rule="$*"
3058 error "failed to operate on TBF rules"
3062 for i in $(seq 1 $OSTCOUNT)
3064 do_facet ost"$i" lctl set_param \
3065 ost.OSS.ost_io.nrs_policies="tbf\ nid"
3067 error "failed to set TBF policy"
3072 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3077 # Only operate rules on ost1 since OSTs might run on the same OSS
3079 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3080 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3081 local client_nids=$(nids_list $address "\\")
3082 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3083 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3087 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3088 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3089 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3093 tbf_rule_operate ost1 "stop\ localhost"
3094 tbf_rule_operate ost1 "stop\ clients"
3095 tbf_rule_operate ost1 "stop\ others"
3098 # Cleanup the TBF policy
3099 for i in $(seq 1 $OSTCOUNT)
3101 do_facet ost"$i" lctl set_param \
3102 ost.OSS.ost_io.nrs_policies="fifo"
3104 error "failed to set policy back to fifo"
3109 run_test 77e "check TBF NID nrs policy"
3112 # Configure jobid_var
3113 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3114 if [ $saved_jobid_var != procname_uid ]; then
3115 set_conf_param_and_check client \
3116 "$LCTL get_param -n jobid_var" \
3117 "$FSNAME.sys.jobid_var" procname_uid
3120 for i in $(seq 1 $OSTCOUNT)
3122 do_facet ost"$i" lctl set_param \
3123 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3125 error "failed to set TBF policy"
3130 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3135 # Only operate rules on ost1 since OSTs might run on the same OSS
3137 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3138 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3139 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3140 nrs_write_read "$RUNAS"
3143 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3144 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3145 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3146 nrs_write_read "$RUNAS"
3149 tbf_rule_operate ost1 "stop\ runas"
3150 tbf_rule_operate ost1 "stop\ iozone_runas"
3151 tbf_rule_operate ost1 "stop\ dd_runas"
3152 nrs_write_read "$RUNAS"
3154 # Cleanup the TBF policy
3155 for i in $(seq 1 $OSTCOUNT)
3157 do_facet ost"$i" lctl set_param \
3158 ost.OSS.ost_io.nrs_policies="fifo"
3160 error "failed to set policy back to fifo"
3162 nrs_write_read "$RUNAS"
3164 local current_jobid_var=$($LCTL get_param -n jobid_var)
3165 if [ $saved_jobid_var != $current_jobid_var ]; then
3166 set_conf_param_and_check client \
3167 "$LCTL get_param -n jobid_var" \
3168 "$FSNAME.sys.jobid_var" $saved_jobid_var
3172 run_test 77f "check TBF JobID nrs policy"
3175 for i in $(seq 1 $OSTCOUNT)
3177 do_facet ost"$i" lctl set_param \
3178 ost.OSS.ost_io.nrs_policies="tbf\ nid"
3180 error "failed to set TBF policy"
3183 for i in $(seq 1 $OSTCOUNT)
3185 do_facet ost"$i" lctl set_param \
3186 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3188 error "failed to set TBF policy"
3193 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3198 # Add a rule that only valid for Jobid TBF. If direct change between
3199 # TBF types is not supported, this operation will fail.
3200 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3202 # Cleanup the TBF policy
3203 for i in $(seq 1 $OSTCOUNT)
3205 do_facet ost"$i" lctl set_param \
3206 ost.OSS.ost_io.nrs_policies="fifo"
3208 error "failed to set policy back to fifo"
3212 run_test 77g "Change TBF type directly"
3215 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3216 { skip "Need OST version at least 2.8.55"; return 0; }
3218 local old_policy=$(do_facet ost1 \
3219 lctl get_param ost.OSS.ost_io.nrs_policies)
3222 do_facet ost1 lctl set_param \
3223 ost.OSS.ost_io.nrs_policies="abc"
3224 [ $? -eq 0 ] && error "should return error"
3226 do_facet ost1 lctl set_param \
3227 ost.OSS.ost_io.nrs_policies="tbf\ abc"
3228 [ $? -eq 0 ] && error "should return error"
3230 do_facet ost1 lctl set_param \
3231 ost.OSS.ost_io.nrs_policies="tbf\ reg"
3232 [ $? -eq 0 ] && error "should return error"
3234 do_facet ost1 lctl set_param \
3235 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
3236 [ $? -eq 0 ] && error "should return error"
3238 do_facet ost1 lctl set_param \
3239 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
3240 [ $? -eq 0 ] && error "should return error"
3242 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
3243 [ $? -eq 0 ] || error "shouldn't LBUG"
3245 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
3249 run_test 77h "Wrong policy name should report error, not LBUG"
3251 test_78() { #LU-6673
3254 for i in $(seq 1 $OSTCOUNT)
3256 do_facet ost"$i" lctl set_param \
3257 ost.OSS.ost_io.nrs_policies="orr" &
3258 do_facet ost"$i" lctl set_param \
3259 ost.OSS.*.nrs_orr_quantum=1
3261 # Valid return codes are:
3262 # 0: Tuning succeeded
3263 # ENODEV: Policy is still stopped
3264 # EAGAIN: Policy is being initialized
3265 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3266 error "Expected set_param to return 0|ENODEV|EAGAIN"
3269 # Cleanup the ORR policy
3270 for i in $(seq 1 $OSTCOUNT)
3272 do_facet ost"$i" lctl set_param \
3273 ost.OSS.ost_io.nrs_policies="fifo"
3275 error "failed to set policy back to fifo"
3279 run_test 78 "Enable policy and specify tunings right away"
3282 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3289 mkdir -p $DIR1/$tdir/dir
3290 createmany -o $DIR1/$tdir/dir/f 10 ||
3291 error "create files under remote dir failed $i"
3293 cp /etc/passwd $DIR1/$tdir/$tfile
3295 #migrate open file should fails
3296 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3298 # give multiop a chance to open
3301 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3302 error "migrate open files should failed with open files"
3306 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3307 error "migrate remote dir error"
3309 echo "Finish migration, then checking.."
3310 for file in $(find $DIR1/$tdir); do
3311 mdt_index=$($LFS getstripe -M $file)
3312 [ $mdt_index == $MDTIDX ] ||
3313 error "$file is not on MDT${MDTIDX}"
3316 diff /etc/passwd $DIR1/$tdir/$tfile ||
3317 error "file different after migration"
3319 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3321 run_test 80a "migrate directory when some children is being opened"
3325 kill -9 $migrate_pid
3329 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3330 local migrate_dir1=$DIR1/$tdir/migrate_dir
3331 local migrate_dir2=$DIR2/$tdir/migrate_dir
3332 local migrate_run=$LUSTRE/tests/migrate.sh
3340 trap cleanup_80b EXIT
3341 #prepare migrate directory
3342 mkdir -p $migrate_dir1
3343 for F in {1,2,3,4,5}; do
3344 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3345 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3348 #migrate the directories among MDTs
3351 mdt_idx=$((RANDOM % MDSCOUNT))
3352 $LFS migrate -m $mdt_idx $migrate_dir1 2&>/dev/null ||
3354 [ $rc -ne 0 -o $rc -ne 16 ] || break
3359 echo "start migration thread $migrate_pid"
3360 #Access the files at the same time
3361 start_time=$(date +%s)
3362 echo "accessing the migrating directory for 5 minutes..."
3364 ls $migrate_dir2 > /dev/null || {
3365 echo "read dir fails"
3368 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3369 echo "access file1 fails"
3373 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3374 echo "access file2/3 fails"
3378 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3379 echo "access file4 fails"
3383 stat $migrate_dir2/file5 > /dev/null || {
3384 echo "stat file5 fails"
3388 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3389 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3390 echo "touch file failed with $rc1"
3394 if [ -e $migrate_dir2/source_file ]; then
3395 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3396 2&>/dev/null || rc1=$?
3397 if [ -e $migrate_dir2/link_file ]; then
3398 rm -rf $migrate_dir2/link_file
3401 mrename $migrate_dir2/source_file \
3402 $migrate_dir2/target_file 2&>/dev/null || rc1=$?
3403 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3404 echo "rename failed with $rc1"
3408 if [ -e $migrate_dir2/target_file ]; then
3409 rm -rf $migrate_dir2/target_file 2&>/dev/null ||
3412 rm -rf $migrate_dir2/source_file 2&>/dev/null ||
3415 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3416 echo "unlink failed with $rc1"
3421 end_time=$(date +%s)
3422 duration=$((end_time - start_time))
3423 if [ $((duration % 10)) -eq 0 ]; then
3424 if [ $show_time -eq 1 ]; then
3425 echo "...$duration seconds"
3432 kill -0 $migrate_pid || {
3433 echo "migration stopped 1"
3437 [ $duration -ge 300 ] && break
3440 #check migration are still there
3441 kill -0 $migrate_pid || error "migration stopped 2"
3444 run_test 80b "Accessing directory during migration"
3447 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3451 mkdir -p $DIR1/$tdir
3453 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3454 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3457 touch d0/0 || error "create 0 failed"
3458 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3459 stat d0/0 && error "stat mv filed succeed"
3460 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3461 stat d0/0 || error "stat failed"
3463 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3465 if [ $t -ne 3 ]; then
3466 ls -ai $DIR1/$tdir/d0
3467 error "expect 3 get $t"
3472 run_test 81 "rename and stat under striped directory"
3475 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3476 { skip "Need MDS version at least 2.6.92"; return 0; }
3478 # Client 1 creates a file.
3479 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3481 # Client 2 opens the file.
3482 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3484 # Client 1 makes the file an orphan.
3485 rm $DIR1/$tfile || error "rm"
3486 # Client 2 sets EA "user.multiop".
3488 wait $pid2 || error "multiop 2"
3489 # Client 1 gets EA "user.multiop". This used to fail because the EA
3490 # cache refill would get "trusted.link" from mdd_xattr_list() but
3491 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3494 wait $pid1 || error "multiop 1"
3496 run_test 82 "fsetxattr and fgetxattr on orphan files"
3499 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3506 $LFS mkdir -i1 -c2 $tdir
3511 echo "start pid $pid1 to create/unlink striped directory"
3513 # Access the directory at the same time
3517 stat $tdir > /dev/null 2>&1
3521 echo "start pid $pid2 to stat striped directory"
3529 run_test 83 "access striped directory while it is being created/unlinked"
3532 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3537 [ "$SLOW" = "yes" ] && duration=600
3538 # Open/Create under striped directory
3542 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3543 touch $tdir/f{0..3} > /dev/null 2>&1
3547 echo "start pid $pid1 to open/create under striped directory"
3549 # unlink the striped directory at the same time
3553 rm -rf $tdir > /dev/null 2>&1
3557 echo "start pid $pid2 to unlink striped directory"
3566 run_test 90 "open/create and unlink striped directory"
3569 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3574 [ "$SLOW" = "yes" ] && duration=600
3575 # chmod striped directory
3579 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3580 chmod go+w $tdir > /dev/null 2>&1
3584 echo "start pid $pid1 to chmod striped directory"
3586 # unlink the striped directory at the same time
3590 rm -rf $tdir > /dev/null 2>&1
3594 echo "start pid $pid2 to unlink striped directory"
3603 run_test 91 "chmod and unlink striped directory"
3606 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3609 local cmd="exec $fd<$DIR1/$tdir"
3610 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3613 trap "eval $cmd" EXIT
3614 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3615 rmdir ../$tdir || error "rmdir ../$tdir fails"
3617 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3618 $LCTL set_param fail_loc=0x1408
3619 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3620 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3621 error "create remote dir succeeds"
3622 $LCTL set_param fail_loc=0
3626 run_test 92 "create remote directory under orphan directory"
3628 log "cleanup: ======================================================"
3630 # kill and wait in each test only guarentee script finish, but command in script
3631 # like 'rm' 'chmod' may still be running, wait for all commands to finish
3632 # otherwise umount below will fail
3633 wait_update $HOSTNAME "fuser -m $MOUNT2" "" || true
3635 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
3639 check_and_cleanup_lustre