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 test_39d() { # LU-7310
1356 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1358 local mtime1=$(stat -c %Y $DIR2/$tfile)
1359 [ "$mtime1" = $TEST_39_MTIME ] ||
1360 error "mtime: $mtime1, should be $TEST_39_MTIME"
1363 # define OBD_FAIL_OSC_NO_GRANT 0x411
1364 $LCTL set_param fail_loc=0x411
1366 local d1=$(date +%s)
1367 echo hello >> $DIR1/$tfile
1368 local d2=$(date +%s)
1370 $LCTL set_param fail_loc=0
1372 cancel_lru_locks osc
1374 local mtime2=$(stat -c %Y $DIR2/$tfile)
1375 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1376 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1378 run_test 39d "sync write should update mtime"
1380 # check that pid exists hence second operation wasn't blocked by first one
1381 # if it is so then there is no conflict, return 0
1382 # else second operation is conflicting with first one, return 1
1383 check_pdo_conflict() {
1386 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1387 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1397 # test 40: check non-blocking operations
1399 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1400 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1401 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1403 mkdir $DIR1/$tfile &
1406 touch $DIR2/$tfile-2
1407 check_pdo_conflict $PID1 || error "create is blocked"
1408 mkdir $DIR2/$tfile-3
1409 check_pdo_conflict $PID1 || error "mkdir is blocked"
1410 link $DIR2/$tfile-2 $DIR2/$tfile-4
1411 check_pdo_conflict $PID1 || error "link is blocked"
1412 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1413 check_pdo_conflict $PID1 || error "rename is blocked"
1414 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1415 check_pdo_conflict $PID1 || error "getattr is blocked"
1416 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1417 rmdir $DIR2/$tfile-3
1418 check_pdo_conflict $PID1 || error "unlink is blocked"
1420 # all operations above shouldn't wait the first one
1421 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1426 run_test 40a "pdirops: create vs others =============="
1429 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1430 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1431 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1432 touch $DIR1/$tfile &
1436 touch $DIR2/$tfile-2
1437 check_pdo_conflict $PID1 || error "create is blocked"
1438 mkdir $DIR2/$tfile-3
1439 check_pdo_conflict $PID1 || error "mkdir is blocked"
1440 link $DIR2/$tfile-2 $DIR2/$tfile-4
1441 check_pdo_conflict $PID1 || error "link is blocked"
1442 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1443 check_pdo_conflict $PID1 || error "rename is blocked"
1444 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1445 check_pdo_conflict $PID1 || error "getattr is blocked"
1446 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1447 rmdir $DIR2/$tfile-3
1448 check_pdo_conflict $PID1 || error "unlink is blocked"
1449 # all operations above shouldn't wait the first one
1451 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1456 run_test 40b "pdirops: open|create and others =============="
1459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1461 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1462 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1463 link $DIR1/$tfile $DIR1/$tfile-0 &
1467 touch $DIR2/$tfile-2
1468 check_pdo_conflict $PID1 || error "create is blocked"
1469 mkdir $DIR2/$tfile-3
1470 check_pdo_conflict $PID1 || error "mkdir is blocked"
1471 link $DIR2/$tfile-2 $DIR2/$tfile-4
1472 check_pdo_conflict $PID1 || error "link is blocked"
1473 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1474 check_pdo_conflict $PID1 || error "rename is blocked"
1475 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1476 check_pdo_conflict $PID1 || error "getattr is blocked"
1477 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1478 rmdir $DIR2/$tfile-3
1479 check_pdo_conflict $PID1 || error "unlink is blocked"
1481 # all operations above shouldn't wait the first one
1482 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1487 run_test 40c "pdirops: link and others =============="
1490 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1492 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1493 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1498 touch $DIR2/$tfile-2
1499 check_pdo_conflict $PID1 || error "create is blocked"
1500 mkdir $DIR2/$tfile-3
1501 check_pdo_conflict $PID1 || error "mkdir is blocked"
1502 link $DIR2/$tfile-2 $DIR2/$tfile-4
1503 check_pdo_conflict $PID1 || error "link is blocked"
1504 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1505 check_pdo_conflict $PID1 || error "rename is blocked"
1506 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1507 check_pdo_conflict $PID1 || error "getattr is blocked"
1508 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1509 rmdir $DIR2/$tfile-3
1510 check_pdo_conflict $PID1 || error "unlink is blocked"
1512 # all operations above shouldn't wait the first one
1513 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1517 run_test 40d "pdirops: unlink and others =============="
1520 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1522 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1523 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1524 mv $DIR1/$tfile $DIR1/$tfile-0 &
1528 touch $DIR2/$tfile-2
1529 check_pdo_conflict $PID1 || error "create is blocked"
1530 mkdir $DIR2/$tfile-3
1531 check_pdo_conflict $PID1 || error "mkdir is blocked"
1532 link $DIR2/$tfile-2 $DIR2/$tfile-4
1533 check_pdo_conflict $PID1 || error "link is blocked"
1534 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1535 check_pdo_conflict $PID1 || error "getattr is blocked"
1536 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1537 rmdir $DIR2/$tfile-3
1538 check_pdo_conflict $PID1 || error "unlink is blocked"
1540 # all operations above shouldn't wait the first one
1541 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1546 run_test 40e "pdirops: rename and others =============="
1548 # test 41: create blocking operations
1550 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1551 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1552 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1555 mkdir $DIR2/$tfile && error "mkdir must fail"
1556 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1560 run_test 41a "pdirops: create vs mkdir =============="
1563 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1564 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1565 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1568 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1569 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1573 run_test 41b "pdirops: create vs create =============="
1576 touch $DIR1/$tfile-2
1577 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1578 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1579 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1582 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1583 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1587 run_test 41c "pdirops: create vs link =============="
1590 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1591 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1592 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1595 rm $DIR2/$tfile || error "unlink must succeed"
1596 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1600 run_test 41d "pdirops: create vs unlink =============="
1603 touch $DIR1/$tfile-2
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 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1610 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1614 run_test 41e "pdirops: create and rename (tgt) =============="
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 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1623 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1627 run_test 41f "pdirops: create and rename (src) =============="
1630 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1631 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1632 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1635 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1636 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1640 run_test 41g "pdirops: create vs getattr =============="
1643 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1644 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1645 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1648 ls -lia $DIR2/ > /dev/null
1649 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1653 run_test 41h "pdirops: create vs readdir =============="
1655 # test 42: unlink and blocking operations
1657 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1658 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1659 mkdir $DIR1/$tfile &
1662 mkdir $DIR2/$tfile && error "mkdir must fail"
1663 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1667 run_test 42a "pdirops: mkdir vs mkdir =============="
1670 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1671 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1672 mkdir $DIR1/$tfile &
1675 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1676 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1680 run_test 42b "pdirops: mkdir vs create =============="
1683 touch $DIR1/$tfile-2
1684 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1685 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1686 mkdir $DIR1/$tfile &
1689 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1690 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1694 run_test 42c "pdirops: mkdir vs link =============="
1697 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1698 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1699 mkdir $DIR1/$tfile &
1702 rmdir $DIR2/$tfile || error "unlink must succeed"
1703 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1707 run_test 42d "pdirops: mkdir vs unlink =============="
1710 touch $DIR1/$tfile-2
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 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1717 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1721 run_test 42e "pdirops: mkdir and rename (tgt) =============="
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 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1730 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1734 run_test 42f "pdirops: mkdir and rename (src) =============="
1737 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1738 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1739 mkdir $DIR1/$tfile &
1742 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1743 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1747 run_test 42g "pdirops: mkdir vs getattr =============="
1750 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1751 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1752 mkdir $DIR1/$tfile &
1755 ls -lia $DIR2/ > /dev/null
1756 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1760 run_test 42h "pdirops: mkdir vs readdir =============="
1762 # test 43: unlink and blocking operations
1765 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1766 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1770 mkdir $DIR2/$tfile || error "mkdir must succeed"
1771 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1775 run_test 43a "pdirops: unlink vs mkdir =============="
1779 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1780 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1784 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1785 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1789 run_test 43b "pdirops: unlink vs create =============="
1793 touch $DIR1/$tfile-2
1794 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1795 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1799 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1800 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1804 run_test 43c "pdirops: unlink vs link =============="
1808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1809 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1813 rm $DIR2/$tfile && error "unlink must fail"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1818 run_test 43d "pdirops: unlink vs unlink =============="
1822 touch $DIR1/$tfile-2
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1828 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1833 run_test 43e "pdirops: unlink and rename (tgt) =============="
1837 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1838 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1842 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1843 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1847 run_test 43f "pdirops: unlink and rename (src) =============="
1851 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1852 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1856 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1857 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1861 run_test 43g "pdirops: unlink vs getattr =============="
1865 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1866 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1870 ls -lia $DIR2/ > /dev/null
1871 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1875 run_test 43h "pdirops: unlink vs readdir =============="
1878 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1880 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1881 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1885 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1886 check_pdo_conflict $PID1 &&
1887 { wait $PID1; error "remote mkdir isn't blocked"; }
1891 run_test 43i "pdirops: unlink vs remote mkdir"
1893 # test 44: rename tgt and blocking operations
1895 touch $DIR1/$tfile-2
1896 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1897 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1898 mv $DIR1/$tfile-2 $DIR1/$tfile &
1901 mkdir $DIR2/$tfile && error "mkdir must fail"
1902 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1906 run_test 44a "pdirops: rename tgt vs mkdir =============="
1909 touch $DIR1/$tfile-2
1910 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1911 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1912 mv $DIR1/$tfile-2 $DIR1/$tfile &
1915 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1916 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1920 run_test 44b "pdirops: rename tgt vs create =============="
1923 touch $DIR1/$tfile-2
1924 touch $DIR1/$tfile-3
1925 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1926 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1927 mv $DIR1/$tfile-2 $DIR1/$tfile &
1930 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1931 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1935 run_test 44c "pdirops: rename tgt vs link =============="
1938 touch $DIR1/$tfile-2
1939 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1940 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1941 mv $DIR1/$tfile-2 $DIR1/$tfile &
1944 rm $DIR2/$tfile || error "unlink must succeed"
1945 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1949 run_test 44d "pdirops: rename tgt vs unlink =============="
1953 touch $DIR1/$tfile-2
1954 touch $DIR1/$tfile-3
1955 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1956 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1957 mv $DIR1/$tfile-2 $DIR1/$tfile &
1960 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1961 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1965 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1968 touch $DIR1/$tfile-2
1969 touch $DIR1/$tfile-3
1970 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1971 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1972 mv $DIR1/$tfile-2 $DIR1/$tfile &
1975 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1976 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1980 run_test 44f "pdirops: rename tgt and rename (src) =============="
1983 touch $DIR1/$tfile-2
1984 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1985 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1986 mv $DIR1/$tfile-2 $DIR1/$tfile &
1989 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1990 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1994 run_test 44g "pdirops: rename tgt vs getattr =============="
1997 touch $DIR1/$tfile-2
1998 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1999 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2000 mv $DIR1/$tfile-2 $DIR1/$tfile &
2003 ls -lia $DIR2/ > /dev/null
2004 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2008 run_test 44h "pdirops: rename tgt vs readdir =============="
2010 # test 44: rename tgt and blocking operations
2012 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2013 touch $DIR1/$tfile-2
2014 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2015 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
2016 mv $DIR1/$tfile-2 $DIR1/$tfile &
2019 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2020 check_pdo_conflict $PID1 && { wait $PID1;
2021 error "remote mkdir isn't blocked"; }
2025 run_test 44i "pdirops: rename tgt vs remote mkdir"
2027 # test 45: rename src and blocking operations
2030 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2031 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2032 mv $DIR1/$tfile $DIR1/$tfile-2 &
2035 mkdir $DIR2/$tfile || error "mkdir must succeed"
2036 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2040 run_test 45a "pdirops: rename src vs mkdir =============="
2044 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2045 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2046 mv $DIR1/$tfile $DIR1/$tfile-2 &
2049 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
2050 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2054 run_test 45b "pdirops: rename src vs create =============="
2058 touch $DIR1/$tfile-3
2059 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2060 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2061 mv $DIR1/$tfile $DIR1/$tfile-2 &
2064 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
2065 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2069 run_test 45c "pdirops: rename src vs link =============="
2073 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2074 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2075 mv $DIR1/$tfile $DIR1/$tfile-2 &
2078 rm $DIR2/$tfile && error "unlink must fail"
2079 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2083 run_test 45d "pdirops: rename src vs unlink =============="
2087 touch $DIR1/$tfile-3
2088 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2089 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2090 mv $DIR1/$tfile $DIR1/$tfile-2 &
2093 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2094 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2098 run_test 45e "pdirops: rename src and rename (tgt) =============="
2102 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2103 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2104 mv $DIR1/$tfile $DIR1/$tfile-2 &
2107 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
2108 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2112 run_test 45f "pdirops: rename src and rename (src) =============="
2116 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2117 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2118 mv $DIR1/$tfile $DIR1/$tfile-2 &
2121 stat $DIR2/$tfile > /dev/null && error "stat must fail"
2122 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2126 run_test 45g "pdirops: rename src vs getattr =============="
2130 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2131 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2132 mv $DIR1/$tfile $DIR1/$tfile-2 &
2135 ls -lia $DIR2/ > /dev/null
2136 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2140 run_test 45h "pdirops: unlink vs readdir =============="
2143 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2145 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2146 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2147 mv $DIR1/$tfile $DIR1/$tfile-2 &
2150 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2151 check_pdo_conflict $PID1 && { wait $PID1;
2152 error "create remote dir isn't blocked"; }
2156 run_test 45i "pdirops: rename src vs remote mkdir"
2158 # test 46: link and blocking operations
2160 touch $DIR1/$tfile-2
2161 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2162 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2163 link $DIR1/$tfile-2 $DIR1/$tfile &
2166 mkdir $DIR2/$tfile && error "mkdir must fail"
2167 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2171 run_test 46a "pdirops: link vs mkdir =============="
2174 touch $DIR1/$tfile-2
2175 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2176 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2177 link $DIR1/$tfile-2 $DIR1/$tfile &
2180 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2181 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2185 run_test 46b "pdirops: link vs create =============="
2188 touch $DIR1/$tfile-2
2189 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2190 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2191 link $DIR1/$tfile-2 $DIR1/$tfile &
2194 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2195 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2199 run_test 46c "pdirops: link vs link =============="
2202 touch $DIR1/$tfile-2
2203 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2204 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2205 link $DIR1/$tfile-2 $DIR1/$tfile &
2208 rm $DIR2/$tfile || error "unlink must succeed"
2209 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2213 run_test 46d "pdirops: link vs unlink =============="
2216 touch $DIR1/$tfile-2
2217 touch $DIR1/$tfile-3
2218 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2219 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2220 link $DIR1/$tfile-2 $DIR1/$tfile &
2223 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2224 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2228 run_test 46e "pdirops: link and rename (tgt) =============="
2231 touch $DIR1/$tfile-2
2232 touch $DIR1/$tfile-3
2233 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2234 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2235 link $DIR1/$tfile-2 $DIR1/$tfile &
2238 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2239 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2243 run_test 46f "pdirops: link and rename (src) =============="
2246 touch $DIR1/$tfile-2
2247 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2248 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2249 link $DIR1/$tfile-2 $DIR1/$tfile &
2252 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2253 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2257 run_test 46g "pdirops: link vs getattr =============="
2260 touch $DIR1/$tfile-2
2261 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2262 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2263 link $DIR1/$tfile-2 $DIR1/$tfile &
2266 ls -lia $DIR2/ > /dev/null
2267 check_pdo_conflict $PID1 && { wait $PID1;
2268 error "readdir isn't blocked"; }
2272 run_test 46h "pdirops: link vs readdir =============="
2275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2276 touch $DIR1/$tfile-2
2277 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2278 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2279 link $DIR1/$tfile-2 $DIR1/$tfile &
2282 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2283 check_pdo_conflict $PID1 && { wait $PID1;
2284 error "remote mkdir isn't blocked"; }
2288 run_test 46i "pdirops: link vs remote mkdir"
2290 # test 47: remote mkdir and blocking operations
2292 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2293 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2294 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2295 $LFS mkdir -i 1 $DIR1/$tfile &
2298 mkdir $DIR2/$tfile && error "mkdir must fail"
2299 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2303 run_test 47a "pdirops: remote mkdir vs mkdir"
2306 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2307 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2308 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2309 $LFS mkdir -i 1 $DIR1/$tfile &
2312 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2313 check_pdo_conflict $PID1 && { wait $PID1;
2314 error "create isn't blocked"; }
2318 run_test 47b "pdirops: remote mkdir vs create"
2321 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2322 touch $DIR1/$tfile-2
2323 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2324 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2325 $LFS mkdir -i 1 $DIR1/$tfile &
2328 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2329 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2333 run_test 47c "pdirops: remote mkdir vs link"
2336 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2337 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2338 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2339 $LFS mkdir -i 1 $DIR1/$tfile &
2342 rmdir $DIR2/$tfile || error "unlink must succeed"
2343 check_pdo_conflict $PID1 && { wait $PID1;
2344 error "unlink isn't blocked"; }
2348 run_test 47d "pdirops: remote mkdir vs unlink"
2351 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2352 touch $DIR1/$tfile-2
2353 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2354 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2355 $LFS mkdir -i 1 $DIR1/$tfile &
2358 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2359 check_pdo_conflict $PID1 && { wait $PID1;
2360 error "rename isn't blocked"; }
2364 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2367 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2368 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2369 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2370 $LFS mkdir -i 1 $DIR1/$tfile &
2373 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2374 check_pdo_conflict $PID1 && { wait $PID1;
2375 error "rename isn't blocked"; }
2379 run_test 47f "pdirops: remote mkdir and rename (src)"
2382 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2383 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2384 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2385 $LFS mkdir -i 1 $DIR1/$tfile &
2388 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2389 check_pdo_conflict $PID1 && { wait $PID1;
2390 error "getattr isn't blocked"; }
2394 run_test 47g "pdirops: remote mkdir vs getattr"
2398 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2399 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2400 do_facet client "lctl set_param fail_loc=0x410"
2401 $TRUNCATE $DIR2/$tfile $trunc_size
2402 do_facet client "lctl set_param fail_loc=0x0"
2404 size=`stat -c %s $DIR2/$tfile`
2405 [ $size -eq $trunc_size ] || error "wrong size"
2407 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2411 local origfile=/etc/hosts
2413 filesize=`stat -c %s $origfile`
2415 # create an empty file
2416 $MCREATE $DIR1/$tfile
2417 # cache layout lock on both mount point
2418 stat $DIR1/$tfile > /dev/null
2419 stat $DIR2/$tfile > /dev/null
2421 # open and sleep 2 seconds then read
2422 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2426 # create the layout of testing file
2427 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2429 # MULTIOP proc should be able to read enough bytes and exit
2431 kill -0 $pid && error "multiop is still there"
2432 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2436 run_test 51a "layout lock: refresh layout should work"
2439 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2440 { skip "Need MDS version at least 2.3.59"; return 0; }
2442 local tmpfile=`mktemp`
2444 # create an empty file
2445 $MCREATE $DIR1/$tfile
2447 # delay glimpse so that layout has changed when glimpse finish
2448 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2449 $LCTL set_param fail_loc=0x1404
2450 stat -c %s $DIR2/$tfile |tee $tmpfile &
2454 # create layout of testing file
2455 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2458 local fsize=`cat $tmpfile`
2460 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2462 rm -f $DIR1/$tfile $tmpfile
2464 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2467 [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; }
2469 # set default layout to have 1 stripe
2470 mkdir -p $DIR1/$tdir
2471 $LFS setstripe -c 1 $DIR1/$tdir
2473 # create a file with empty layout
2474 $MCREATE $DIR1/$tdir/$tfile
2476 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2477 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2479 # change the layout of testing file
2480 echo "Setting layout to have $OSTCOUNT stripes ..."
2481 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2485 # write something to the file, it should be blocked on fetching layout
2486 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2487 local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2488 [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT"
2492 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2495 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2496 cancel_lru_locks mdc
2498 # open should grant LAYOUT lock, mmap and read will install pages
2499 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2503 # rss before revoking
2504 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2505 echo "Before revoking layout lock: $br KB mapped"
2507 # delete the file will revoke layout lock
2510 # rss after revoking
2511 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2516 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2518 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2522 echo "==> rename vs getattr vs setxattr should not deadlock"
2523 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2525 do_facet mds1 $LCTL set_param fail_loc=$1
2527 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2535 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
2536 wait $PID1 || error "(3) mv failed"
2537 wait $PID2 || error "(4) stat failed"
2544 echo "==> rename vs getattr vs open vs getattr should not deadlock"
2545 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
2547 do_facet mds1 $LCTL set_param fail_loc=$1
2549 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
2557 $MULTIOP $DIR2/d1/d2 Oc &
2561 stat $DIR/d1 || error "(2) stat failed"
2563 wait $PID1 || error "(3) mv failed"
2564 wait $PID2 || error "(4) stat failed"
2565 wait $PID3 && error "(5) multiop failed"
2571 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
2572 save_lustre_params client "llite.*.xattr_cache" > $p
2573 lctl set_param llite.*.xattr_cache 1 ||
2574 { skip "xattr cache is not supported"; return 0; }
2576 #define OBD_FAIL_MDS_RENAME 0x153
2577 #define OBD_FAIL_MDS_RENAME2 0x154
2578 test_54_part1 0x80000153 || error 10
2579 test_54_part1 0x80000154 || error 11
2580 test_54_part2 0x80000153 || error 12
2581 test_54_part2 0x80000154 || error 13
2583 restore_lustre_params < $p
2586 run_test 54 "rename locking"
2589 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2591 #define OBD_FAIL_MDS_RENAME4 0x156
2592 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2594 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2599 wait $PID1 && error "(2) mv succeeded"
2603 run_test 55a "rename vs unlink target dir"
2607 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2609 #define OBD_FAIL_MDS_RENAME4 0x156
2610 do_facet mds1 $LCTL set_param fail_loc=0x80000156
2612 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2617 wait $PID1 && error "(2) mv succeeded"
2621 run_test 55b "rename vs unlink source dir"
2625 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
2627 #define OBD_FAIL_MDS_RENAME4 0x156
2628 do_facet mds1 $LCTL set_param fail_loc=0x156
2630 mv -T $DIR/d1/d2 $DIR/d3/d2 &
2634 # while rename is sleeping, open and remove d3
2635 $MULTIOP $DIR2/d3 D_c &
2641 # while rename is sleeping 2nd time, close d3
2643 wait $PID2 || error "(3) multiop failed"
2645 wait $PID1 && error "(2) mv succeeded"
2649 run_test 55c "rename vs unlink orphan target dir"
2655 #define OBD_FAIL_MDS_RENAME3 0x155
2656 do_facet mds1 $LCTL set_param fail_loc=0x155
2657 mv $DIR/f1 $DIR/$tdir &
2661 # while rename is sleeping, create $tdir, but as a directory
2662 mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
2664 # link in reverse locking order
2665 ln $DIR2/f1 $DIR2/$tdir/
2667 wait $PID1 && error "(2) mv succeeded"
2670 run_test 55d "rename file vs link"
2673 local MDSVER=$(lustre_build_version $SINGLEMDS)
2674 [ $(version_code $MDSVER) -lt $(version_code 2.3.0) ] &&
2675 skip "MDS version $MDSVER must be >= 2.3.0" && return 0
2678 test_mkdir -p $DIR1/$tdir
2679 file1=$DIR1/$tdir/file
2680 file2=$DIR2/$tdir/file
2682 echo orig > $file2 || error "Could not create $file2"
2683 version=$($LFS data_version $file1)
2686 echo append >> $file2 || error "Could not append to $file2"
2687 version2=$($LFS data_version $file1)
2688 [ "$version" != "$version2" ] ||
2689 error "append did not change data version: $version"
2692 echo overwrite > $file2 || error "Could not overwrite $file2"
2693 version3=$($LFS data_version $file1)
2694 [ "$version2" != "$version3" ] ||
2695 error "overwrite did not change data version: $version2"
2697 # Truncate before EOF
2698 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2699 version4=$($LFS data_version $file1)
2700 [ "$version3" != "$version4" ] ||
2701 error "truncate did not change data version: $version3"
2703 # Truncate after EOF
2704 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2705 version5=$($LFS data_version $file1)
2706 [ "$version4" != "$version5" ] ||
2707 error "truncate did not change data version: $version4"
2709 # Chmod do not change version
2710 chmod 400 $file2 || error "Could not chmod 400 $file2"
2711 version6=$($LFS data_version $file1)
2712 [ "$version5" == "$version6" ] ||
2713 error "chmod should not change data version: $version5 != $version6"
2715 # Chown do not change version
2716 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2717 version7=$($LFS data_version $file1)
2718 [ "$version5" == "$version7" ] ||
2719 error "chown should not change data version: $version5 != $version7"
2721 run_test 60 "Verify data_version behaviour"
2724 local test_dir=$tdir/test_dir
2726 mkdir -p $DIR1/$tdir
2727 if [ $MDSCOUNT -ge 2 ]; then
2729 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2730 error "Create remote directory failed"
2732 mkdir -p $DIR1/$test_dir
2734 cd $DIR2/$test_dir || error "cd directory failed"
2735 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2737 cd $DIR2/$tdir || error "exit directory"
2739 run_test 70a "cd directory && rm directory"
2741 test_70b() { # LU-2781
2743 mkdir -p $DIR1/$tdir
2745 touch $DIR1/$tdir/file
2746 for ((i = 0; i < 32; i++)); do
2747 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2749 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2751 touch $DIR1/$tdir/file
2752 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2753 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2754 rm -rf $DIR1/$tdir/test_dir ||
2755 error "cannot remove directory after rm_entry"
2756 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2758 run_test 70b "remove files after calling rm_entry"
2761 local server_version=$(lustre_version_code $SINGLEMDS)
2763 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2764 skip "Need MDS version at least 2.1.6" && return
2766 # Patch not applied to 2.2 and 2.3 branches
2767 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2768 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2769 skip "Need MDS version at least 2.4.0" && return
2771 checkfiemap --test ||
2772 { skip "checkfiemap not runnable: $?" && return; }
2773 # write data this way: hole - data - hole - data
2774 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2775 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2777 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2778 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2779 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2781 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2783 checkfiemap $DIR2/$tfile 81920 ||
2784 error "data is not flushed from client"
2785 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2788 # common case of "create file, copy file" on a single node
2789 # should not flush data from ost
2790 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2791 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2793 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2795 checkfiemap $DIR1/$tfile 81920 ||
2797 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2799 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2801 run_test 71 "correct file map just after write operation is finished"
2804 local p="$TMP/sanityN-$TESTNAME.parameters"
2807 save_lustre_params client "llite.*.xattr_cache" > $p
2808 lctl set_param llite.*.xattr_cache 1 ||
2809 { skip "xattr cache is not supported"; return 0; }
2812 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2813 error "setfattr1 failed"
2814 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2815 error "getfattr1 failed"
2816 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2817 error "setfattr2 failed"
2818 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2819 error "getfattr2 failed"
2821 # check that trusted.link is consistent
2822 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2823 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2824 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2825 echo "$tlink1 $tlink2"
2826 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2830 restore_lustre_params < $p
2833 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2836 local p="$TMP/sanityN-$TESTNAME.parameters"
2837 save_lustre_params client "llite.*.xattr_cache" > $p
2838 lctl set_param llite.*.xattr_cache 1 ||
2839 { skip "xattr cache is not supported"; return 0; }
2842 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2843 error "setfattr1 failed"
2844 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2845 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2847 # PR lock should be cached by now on both clients
2848 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2849 # 2 hits for getfattr(0)+getfattr(size)
2850 [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1"
2851 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2852 # 4 hits for more getfattr(0)+getfattr(size)
2853 [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2"
2856 restore_lustre_params < $p
2859 run_test 73 "getxattr should not cause xattr lock cancellation"
2862 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2863 skip "Need MDS version at least 2.4.93" && return
2865 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2866 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2867 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2869 run_test 74 "flock deadlock: different mounts =============="
2873 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2874 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2875 cancel_lru_locks osc
2877 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2880 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2881 $LCTL set_param fail_loc=0x31d
2882 stat -c %s $DIR1/$tfile &
2887 # For bad lock error handler we should ASSERT and got kernel panic here
2889 $LCTL set_param fail_loc=0
2891 run_test 75 "osc: upcall after unuse lock==================="
2894 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2895 skip "Need MDS version at least 2.5.53" && return
2897 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2903 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2909 test_mkdir -p $DIR/$tdir
2911 # drop all open locks and close any cached "open" files on the client
2912 cancel_lru_locks mdc
2914 echo -n "open files "
2916 for ((i = 0; i < $fcount; i++)); do
2917 touch $DIR/$tdir/f_$i
2919 local cmd="exec $fd<$DIR/$tdir/f_$i"
2926 local get_open_fids="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
2927 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $get_open_fids))
2929 # Possible errors in openfiles FID list.
2930 # 1. Missing FIDs. Check 1
2931 # 2. Extra FIDs. Check 1
2932 # 3. Duplicated FID. Check 2
2933 # 4. Invalid FIDs. Check 2
2934 # 5. Valid FID, points to some other file. Check 3
2937 [ ${#fid_list[@]} -ne $fcount ] &&
2938 error "${#fid_list[@]} != $fcount open files"
2940 for (( i = 0; i < $fcount; i++ )) ; do
2941 cmd="exec ${fd_list[i]}</dev/null"
2943 filename=$($LFS fid2path $DIR2 ${fid_list[i]})
2946 rm --interactive=no $filename
2948 error "Nonexisting fid ${fid_list[i]} listed."
2952 ls_op=$(ls $DIR2/$tdir | wc -l)
2954 error "Some openfiles are missing in lproc output"
2958 run_test 76 "Verify open file for 2048 files"
2962 local dir=$DIR/$tdir
2965 mkdir $dir || error "mkdir $dir failed"
2966 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
2969 do_nodes $CLIENTS $myRUNAS \
2970 dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
2971 error "dd at 0 on client failed (1)"
2973 for ((i = 0; i < $n; i++)); do
2974 do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \
2975 of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 ||
2976 error "dd at ${i}MB on client failed (2)" &
2979 do_nodes $CLIENTS sync;
2980 cancel_lru_locks osc
2982 for ((i = 0; i < $n; i++)); do
2983 do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \
2984 of=/dev/zero bs=1M seek=$i count=1 > /dev/null ||
2985 error "dd at ${i}MB on client failed (3)"
2988 cancel_lru_locks osc
2990 for ((i = 0; i < $n; i++)); do
2994 rm -rf $dir || error "rm -rf $dir failed"
2997 test_77a() { #LU-3266
2998 oss=$(comma_list $(osts_nodes))
2999 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
3004 run_test 77a "check FIFO NRS policy"
3006 test_77b() { #LU-3266
3007 oss=$(comma_list $(osts_nodes))
3009 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3010 ost.OSS.*.nrs_crrn_quantum=1
3012 echo "policy: crr-n, crrn_quantum 1"
3015 do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
3017 echo "policy: crr-n, crrn_quantum 64"
3021 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3024 run_test 77b "check CRR-N NRS policy"
3029 oss=$(comma_list $(osts_nodes))
3031 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3032 ost.OSS.*.nrs_"$policy"_quantum=1 \
3033 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3034 ost.OSS.*.nrs_"$policy"_supported="reads"
3036 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
3039 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
3040 ost.OSS.*.nrs_${policy}_quantum=64
3042 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
3045 do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3046 ost.OSS.*.nrs_${policy}_offset_type="logical"
3047 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
3051 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3055 test_77c() { #LU-3266
3059 run_test 77c "check ORR NRS policy"
3061 test_77d() { #LU-3266
3065 run_test 77d "check TRR nrs policy"
3072 do_facet $facet lctl set_param \
3073 ost.OSS.ost_io.nrs_tbf_rule="$*"
3075 error "failed to run operate '$*' on TBF rules"
3079 local server_version=$(lustre_version_code ost1)
3080 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3081 { skip "Need server version newer than 2.7.57"; return 0; }
3083 oss=$(comma_list $(osts_nodes))
3085 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3086 [ $? -ne 0 ] && error "failed to set TBF policy"
3090 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3095 # Only operate rules on ost1 since OSTs might run on the same OSS
3097 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3098 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3099 local client_nids=$(nids_list $address "\\")
3100 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3101 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3105 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3106 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3107 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3111 tbf_rule_operate ost1 "stop\ localhost"
3112 tbf_rule_operate ost1 "stop\ clients"
3113 tbf_rule_operate ost1 "stop\ others"
3116 # Cleanup the TBF policy
3117 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3118 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3122 run_test 77e "check TBF NID nrs policy"
3125 local server_version=$(lustre_version_code ost1)
3126 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3127 { skip "Need server version newer than 2.7.57"; return 0; }
3129 oss=$(comma_list $(osts_nodes))
3131 # Configure jobid_var
3132 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3133 if [ $saved_jobid_var != procname_uid ]; then
3134 set_conf_param_and_check client \
3135 "$LCTL get_param -n jobid_var" \
3136 "$FSNAME.sys.jobid_var" procname_uid
3139 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3140 [ $? -ne 0 ] && error "failed to set TBF policy"
3144 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3149 # Only operate rules on ost1 since OSTs might run on the same OSS
3151 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3152 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3153 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3154 nrs_write_read "$RUNAS"
3157 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3158 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3159 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3160 nrs_write_read "$RUNAS"
3163 tbf_rule_operate ost1 "stop\ runas"
3164 tbf_rule_operate ost1 "stop\ iozone_runas"
3165 tbf_rule_operate ost1 "stop\ dd_runas"
3166 nrs_write_read "$RUNAS"
3168 # Cleanup the TBF policy
3169 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3170 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3171 nrs_write_read "$RUNAS"
3173 local current_jobid_var=$($LCTL get_param -n jobid_var)
3174 if [ $saved_jobid_var != $current_jobid_var ]; then
3175 set_conf_param_and_check client \
3176 "$LCTL get_param -n jobid_var" \
3177 "$FSNAME.sys.jobid_var" $saved_jobid_var
3181 run_test 77f "check TBF JobID nrs policy"
3184 local server_version=$(lustre_version_code ost1)
3185 [[ $server_version -ge $(version_code 2.7.58) ]] ||
3186 { skip "Need server version newer than 2.7.57"; return 0; }
3188 oss=$(comma_list $(osts_nodes))
3190 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
3191 [ $? -ne 0 ] && error "failed to set TBF policy"
3193 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3194 [ $? -ne 0 ] && error "failed to set TBF policy"
3198 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
3203 # Add a rule that only valid for Jobid TBF. If direct change between
3204 # TBF types is not supported, this operation will fail.
3205 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3207 # Cleanup the TBF policy
3208 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3209 [ $? -ne 0 ] && 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"
3255 local error_message=$3
3257 for rule in $expected; do
3258 rule_number=$((rule_number + 1))
3260 local stop_line=$(($rule_number + 3))
3261 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
3263 local output=$(do_facet $facet lctl get_param \
3264 ost.OSS.ost_io.nrs_tbf_rule |
3268 if [ "$output" != "$expected" ]; then
3269 error "$error_message, expected '$expected', got '$output'"
3274 [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
3275 { skip "Need OST version at least 2.8.55"; return 0; }
3277 for i in $(seq 1 $OSTCOUNT)
3279 do_facet ost"$i" lctl set_param \
3280 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
3282 error "failed to set TBF policy"
3285 tbf_rule_check ost1 "default" "error before inserting any rule"
3287 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
3288 tbf_rule_check ost1 "before default" \
3289 "error when inserting rule 'before'"
3291 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
3292 tbf_rule_check ost1 "before after default" \
3293 "error when inserting rule 'after'"
3295 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
3296 tbf_rule_check ost1 "before target after default" \
3297 "error when inserting rule 'target'"
3299 echo "Move before itself"
3300 tbf_rule_operate ost1 "change\ target\ rank=target"
3301 tbf_rule_check ost1 "before target after default" \
3302 "error when moving before itself"
3304 echo "Move to higher rank"
3305 tbf_rule_operate ost1 "change\ target\ rank=before"
3306 tbf_rule_check ost1 "target before after default" \
3307 "error when moving to higher rank"
3309 echo "Move to lower rank"
3310 tbf_rule_operate ost1 "change\ target\ rank=after"
3311 tbf_rule_check ost1 "before target after default" \
3312 "error when moving to lower rank"
3314 echo "Move before default"
3315 tbf_rule_operate ost1 "change\ target\ rank=default"
3316 tbf_rule_check ost1 "before after target default" \
3317 error "error when moving before default"
3319 # Cleanup the TBF policy
3320 do_nodes $(comma_list $(osts_nodes)) \
3321 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
3324 run_test 77i "Change rank of TBF rule"
3326 test_78() { #LU-6673
3329 oss=$(comma_list $(osts_nodes))
3330 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
3331 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
3333 # Valid return codes are:
3334 # 0: Tuning succeeded
3335 # ENODEV: Policy is still stopped
3336 # EAGAIN: Policy is being initialized
3337 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
3338 error "Expected set_param to return 0|ENODEV|EAGAIN"
3340 # Cleanup the ORR policy
3341 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3342 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3345 run_test 78 "Enable policy and specify tunings right away"
3348 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3349 test_mkdir -p $DIR/$tdir
3351 # Prevent interference from layout intent RPCs due to
3352 # asynchronous writeback. These will be tested in 130c below.
3353 do_nodes ${CLIENTS:-$HOSTNAME} sync
3355 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
3356 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
3358 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
3359 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
3360 local facet=mds$((mdtidx + 1))
3362 set_nodes_failloc $(facet_active_host $facet) 0x80000160
3363 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
3367 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
3368 set_nodes_failloc $(facet_active_host $facet) 0x80000131
3373 run_test 79 "xattr: intent error"
3376 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3383 mkdir -p $DIR1/$tdir/dir
3384 createmany -o $DIR1/$tdir/dir/f 10 ||
3385 error "create files under remote dir failed $i"
3387 cp /etc/passwd $DIR1/$tdir/$tfile
3389 #migrate open file should fails
3390 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
3392 # give multiop a chance to open
3395 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
3396 error "migrate open files should failed with open files"
3400 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
3401 error "migrate remote dir error"
3403 echo "Finish migration, then checking.."
3404 for file in $(find $DIR1/$tdir); do
3405 mdt_index=$($LFS getstripe -M $file)
3406 [ $mdt_index == $MDTIDX ] ||
3407 error "$file is not on MDT${MDTIDX}"
3410 diff /etc/passwd $DIR1/$tdir/$tfile ||
3411 error "file different after migration"
3413 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
3415 run_test 80a "migrate directory when some children is being opened"
3419 kill -9 $migrate_pid
3423 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3424 local migrate_dir1=$DIR1/$tdir/migrate_dir
3425 local migrate_dir2=$DIR2/$tdir/migrate_dir
3426 local migrate_run=$LUSTRE/tests/migrate.sh
3434 trap cleanup_80b EXIT
3435 #prepare migrate directory
3436 mkdir -p $migrate_dir1
3437 for F in {1,2,3,4,5}; do
3438 echo "$F$F$F$F$F" > $migrate_dir1/file$F
3439 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
3442 #migrate the directories among MDTs
3445 mdt_idx=$((RANDOM % MDSCOUNT))
3446 $LFS migrate -m $mdt_idx $migrate_dir1 2&>/dev/null ||
3448 [ $rc -ne 0 -o $rc -ne 16 ] || break
3453 echo "start migration thread $migrate_pid"
3454 #Access the files at the same time
3455 start_time=$(date +%s)
3456 echo "accessing the migrating directory for 5 minutes..."
3458 ls $migrate_dir2 > /dev/null || {
3459 echo "read dir fails"
3462 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
3463 echo "access file1 fails"
3467 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
3468 echo "access file2/3 fails"
3472 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
3473 echo "access file4 fails"
3477 stat $migrate_dir2/file5 > /dev/null || {
3478 echo "stat file5 fails"
3482 touch $migrate_dir2/source_file > /dev/null || rc1=$?
3483 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3484 echo "touch file failed with $rc1"
3488 if [ -e $migrate_dir2/source_file ]; then
3489 ln $migrate_dir2/source_file $migrate_dir2/link_file \
3490 2&>/dev/null || rc1=$?
3491 if [ -e $migrate_dir2/link_file ]; then
3492 rm -rf $migrate_dir2/link_file
3495 mrename $migrate_dir2/source_file \
3496 $migrate_dir2/target_file 2&>/dev/null || rc1=$?
3497 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3498 echo "rename failed with $rc1"
3502 if [ -e $migrate_dir2/target_file ]; then
3503 rm -rf $migrate_dir2/target_file 2&>/dev/null ||
3506 rm -rf $migrate_dir2/source_file 2&>/dev/null ||
3509 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
3510 echo "unlink failed with $rc1"
3515 end_time=$(date +%s)
3516 duration=$((end_time - start_time))
3517 if [ $((duration % 10)) -eq 0 ]; then
3518 if [ $show_time -eq 1 ]; then
3519 echo "...$duration seconds"
3526 kill -0 $migrate_pid || {
3527 echo "migration stopped 1"
3531 [ $duration -ge 300 ] && break
3534 #check migration are still there
3535 kill -0 $migrate_pid || error "migration stopped 2"
3538 run_test 80b "Accessing directory during migration"
3541 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3545 mkdir -p $DIR1/$tdir
3547 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
3548 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
3551 touch d0/0 || error "create 0 failed"
3552 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
3553 stat d0/0 && error "stat mv filed succeed"
3554 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
3555 stat d0/0 || error "stat failed"
3557 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
3559 if [ $t -ne 3 ]; then
3560 ls -ai $DIR1/$tdir/d0
3561 error "expect 3 get $t"
3566 run_test 81 "rename and stat under striped directory"
3569 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] ||
3570 { skip "Need MDS version at least 2.6.92"; return 0; }
3572 # Client 1 creates a file.
3573 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
3575 # Client 2 opens the file.
3576 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
3578 # Client 1 makes the file an orphan.
3579 rm $DIR1/$tfile || error "rm"
3580 # Client 2 sets EA "user.multiop".
3582 wait $pid2 || error "multiop 2"
3583 # Client 1 gets EA "user.multiop". This used to fail because the EA
3584 # cache refill would get "trusted.link" from mdd_xattr_list() but
3585 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
3588 wait $pid1 || error "multiop 1"
3590 run_test 82 "fsetxattr and fgetxattr on orphan files"
3593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3600 $LFS mkdir -i1 -c2 $tdir
3605 echo "start pid $pid1 to create/unlink striped directory"
3607 # Access the directory at the same time
3611 stat $tdir > /dev/null 2>&1
3615 echo "start pid $pid2 to stat striped directory"
3623 run_test 83 "access striped directory while it is being created/unlinked"
3626 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3631 [ "$SLOW" = "yes" ] && duration=600
3632 # Open/Create under striped directory
3636 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3637 touch $tdir/f{0..3} > /dev/null 2>&1
3641 echo "start pid $pid1 to open/create under striped directory"
3643 # unlink the striped directory at the same time
3647 rm -rf $tdir > /dev/null 2>&1
3651 echo "start pid $pid2 to unlink striped directory"
3660 run_test 90 "open/create and unlink striped directory"
3663 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3668 [ "$SLOW" = "yes" ] && duration=600
3669 # chmod striped directory
3673 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
3674 chmod go+w $tdir > /dev/null 2>&1
3678 echo "start pid $pid1 to chmod striped directory"
3680 # unlink the striped directory at the same time
3684 rm -rf $tdir > /dev/null 2>&1
3688 echo "start pid $pid2 to unlink striped directory"
3697 run_test 91 "chmod and unlink striped directory"
3700 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3703 local cmd="exec $fd<$DIR1/$tdir"
3704 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
3707 trap "eval $cmd" EXIT
3708 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
3709 rmdir ../$tdir || error "rmdir ../$tdir fails"
3711 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
3712 $LCTL set_param fail_loc=0x1408
3713 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
3714 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
3715 error "create remote dir succeeds"
3716 $LCTL set_param fail_loc=0
3720 run_test 92 "create remote directory under orphan directory"
3727 mkdir -p $DIR1/$tfile-1/
3728 mkdir -p $DIR2/$tfile-2/
3729 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
3730 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//')
3731 do_facet $SINGLEMDS lctl set_param -n \
3732 'lod.lustre-MDT*/qos_threshold_rr' 100
3733 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
3734 do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
3736 $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
3739 $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
3743 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
3744 do_facet $SINGLEMDS "lctl set_param -n \
3745 'lod.lustre-MDT*/qos_threshold_rr' $old_rr"
3747 $GETSTRIPE $DIR1/$tfile-1/file1
3748 rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 |
3749 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
3750 $GETSTRIPE $DIR2/$tfile-2/file2
3751 rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 |
3752 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
3753 echo "rc1=$rc1 and rc2=$rc2 "
3754 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
3755 error "object allocate on same ost detected"
3757 run_test 93 "alloc_rr should not allocate on same ost"
3759 log "cleanup: ======================================================"
3761 # kill and wait in each test only guarentee script finish, but command in script
3762 # like 'rm' 'chmod' may still be running, wait for all commands to finish
3763 # otherwise umount below will fail
3764 wait_update $HOSTNAME "fuser -m $MOUNT2" "" || true
3766 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
3770 check_and_cleanup_lustre