6 # bug number for skipped test: 3192 LU-1205 15528/3811 16929 9977 15528/11549 18080
7 ALWAYS_EXCEPT=" 14b 18c 19 22 28 29 35 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 # bug number for skipped test: 12652 12652
11 grep -q 'Enterprise Server 10' /etc/SuSE-release 2> /dev/null &&
12 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 14" || true
14 # It will be ported soon.
18 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
21 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
22 MCREATE=${MCREATE:-mcreate}
23 OPENFILE=${OPENFILE:-openfile}
24 OPENUNLINK=${OPENUNLINK:-openunlink}
25 export MULTIOP=${MULTIOP:-multiop}
26 export TMP=${TMP:-/tmp}
27 MOUNT_2=${MOUNT_2:-"yes"}
28 CHECK_GRANT=${CHECK_GRANT:-"yes"}
29 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
33 export NAME=${NAME:-local}
35 LUSTRE=${LUSTRE:-`dirname $0`/..}
36 . $LUSTRE/tests/test-framework.sh
40 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
43 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
44 # bug number for skipped test: LU-2840 LU-2189 LU-2776
45 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 21 36 51a"
46 # LU-2829 / LU-2887 - make allowances for ZFS slowness
47 TEST33_NFILES=${TEST33_NFILES:-1000}
50 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
57 check_and_setup_lustre
59 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
60 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
63 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
65 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
66 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
68 # $RUNAS_ID may get set incorrectly somewhere else
69 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
71 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
80 [ -f $DIR2/f1 ] || error
82 run_test 1a "check create on 2 mtpt's =========================="
86 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
89 run_test 1b "check attribute updates on 2 mtpt's ==============="
92 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
94 run_test 1c "check after remount attribute updates on 2 mtpt's ="
98 $CHECKSTAT -a $DIR1/f1 || error
100 run_test 1d "unlink on one mountpoint removes file on other ===="
106 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
108 run_test 2a "check cached attribute updates on 2 mtpt's ========"
114 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
116 run_test 2b "check cached attribute updates on 2 mtpt's ========"
118 # NEED TO SAVE ROOT DIR MODE
121 $CHECKSTAT -t dir -p 0777 $DIR2 || error
123 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
127 $CHECKSTAT -t dir -p 0755 $DIR2 || error
129 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
136 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
138 run_test 2e "check chmod on root is propagated to others"
141 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
143 local remote_dir=$tdir/remote_dir
146 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
147 error "Create remote directory failed"
149 touch $DIR1/$remote_dir/$tfile ||
150 error "Create file under remote directory failed"
151 chmod 777 $DIR1/$remote_dir/$tfile ||
152 error "Chmod file under remote directory failed"
154 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
155 error "Check attr of file under remote directory failed"
157 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
158 error "Chown file under remote directory failed"
160 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
161 error "Check owner of file under remote directory failed"
163 cd $DIR2/$remote_dir || error "enter remote dir"
164 rm -rf $DIR1/$remote_dir/$tfile ||
165 error "Unlink remote directory failed"
167 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
168 error "unlink file still exists!"
170 cd $DIR2/$tdir || error "exit remote dir"
171 rm -rf $DIR1/$tdir || error "unlink directory failed"
173 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
176 local target="this/is/good"
177 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
178 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
179 error "link $DIR2/$tfile not as expected"
181 run_test 3 "symlink on one mtpt, readlink on another ==========="
184 multifstat $DIR1/f4 $DIR2/f4
186 run_test 4 "fstat validation on multiple mount points =========="
190 $TRUNCATE $DIR2/f5 100
191 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
194 run_test 5 "create a file on one mount, truncate it on the other"
197 openunlink $DIR1/$tfile $DIR2/$tfile || \
198 error "openunlink $DIR1/$tfile $DIR2/$tfile"
200 run_test 6 "remove of open file on other node =================="
204 opendirunlink $DIR1/$dir $DIR2/$dir || \
205 error "opendirunlink $DIR1/$dir $DIR2/$dir"
207 run_test 7 "remove of open directory on other node ============="
210 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
211 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
213 run_test 8 "remove of open special file on other node =========="
219 for C in a b c d e f g h i j k l; do
220 dir=`eval echo \\$DIR$MTPT`
221 echo -n $C >> $dir/f9
222 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
224 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
225 error "`od -a $DIR1/f9` != abcdefghijkl"
227 run_test 9 "append of file with sub-page size on multiple mounts"
234 for C in a b c d e f g h i j k l; do
235 dir=`eval echo \\$DIR$MTPT`
236 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
237 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
238 OFFSET=`expr $OFFSET + 1`
240 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
241 error "`od -a $DIR1/f10` != abcdefghijkl"
243 run_test 10a "write of file with sub-page size on multiple mounts "
247 yes "R" | head -c 4000 >$TMP/f10b-seed
248 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
250 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
252 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
254 # create a test file locally to compare
255 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
256 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
257 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
258 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
260 run_test 10b "write of file with sub-page size on multiple mounts "
264 multiop_bg_pause $DIR1/d11/f O_c || return 1
266 cp -p /bin/ls $DIR1/d11/f
270 wait $MULTIPID || error
271 [ $RC -eq 0 ] && error || true
273 run_test 11 "execution of file opened for write should return error ===="
276 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
278 run_test 12 "test lock ordering (link, stat, unlink) ==========="
280 test_13() { # bug 2451 - directory coherency
281 test_mkdir $DIR1/d13 || error
282 cd $DIR1/d13 || error
284 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
286 rm -f $DIR2/d13/f13 || error
287 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
288 # need to run it twice
289 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
291 rm -f $DIR2/d13/f13 || error
292 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
294 run_test 13 "test directory page revocation ===================="
297 test_mkdir -p $DIR1/$tdir
298 cp -p /bin/ls $DIR1/$tdir/$tfile
299 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
302 $DIR2/$tdir/$tfile && error || true
304 wait $MULTIPID || return 2
306 run_test 14 "execution of file open for write returns -ETXTBSY ="
309 test_mkdir -p $DIR1/d14
310 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
311 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
313 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
314 kill -USR1 $MULTIOP_PID || return 2
315 wait $MULTIOP_PID || return 3
316 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
318 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
320 test_14b() { # bug 3192, 7040
321 test_mkdir -p $DIR1/d14
322 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
323 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
325 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
326 error "expected truncate error, got success"
327 kill -USR1 $MULTIOP_PID || return 2
328 wait $MULTIOP_PID || return 3
329 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
330 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
332 run_test 14b "truncate of executing file returns -ETXTBSY ======"
334 test_14c() { # bug 3430, 7040
335 test_mkdir -p $DIR1/d14
336 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
337 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
339 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
340 kill -USR1 $MULTIOP_PID || return 2
341 wait $MULTIOP_PID || return 3
342 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
343 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
345 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
347 test_14d() { # bug 10921
348 test_mkdir -p $DIR1/d14
349 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
350 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
353 chmod 600 $DIR1/d14/multiop || error "chmod failed"
354 kill -USR1 $MULTIOP_PID || return 2
355 wait $MULTIOP_PID || return 3
356 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
357 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
359 run_test 14d "chmod of executing file is still possible ========"
361 test_14e() { # LU-4398
362 test_mkdir -p $DIR1/$tdir
363 rm -f $DIR1/$tdir/echo
364 cp /bin/echo $DIR1/$tdir/echo
367 echo Bye > $DIR2/$tdir/echo
369 run_test 14e "conflicting locks are flushed on open"
371 test_15() { # bug 974 - ENOSPC
373 sh oos2.sh $MOUNT1 $MOUNT2
374 wait_delete_completed
375 grant_error=`dmesg | grep "> available"`
376 [ -z "$grant_error" ] || error "$grant_error"
378 run_test 15 "test out-of-space with multiple writers ==========="
381 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
382 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
383 # pass a 2500 operation dual-mount run within the time limit.
384 if [ "$(facet_fstype ost1)" = "zfs" ]; then
385 FSXNUM=$((COUNT / 5))
387 elif [ "$SLOW" = "yes" ]; then
388 FSXNUM=$((COUNT * 5))
396 local file1=$DIR1/$tfile
397 local file2=$DIR2/$tfile
399 # to allocate grant because it may run out due to test_15.
400 lfs setstripe -c -1 $file1
401 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
402 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
405 lfs setstripe -c -1 $file1 # b=10919
406 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
408 run_test 16 "$FSXNUM iterations of dual-mount fsx"
410 test_17() { # bug 3513, 3667
411 remote_ost_nodsh && skip "remote OST with nodsh" && return
413 lfs setstripe $DIR1/$tfile -i 0 -c 1
414 cp $SAMPLE_FILE $DIR1/$tfile
415 cancel_lru_locks osc > /dev/null
416 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
417 do_facet ost1 lctl set_param fail_loc=0x8000030a
418 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
419 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
421 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
423 run_test 17 "resource creation/LVB creation race ==============="
426 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
429 for idx in {a..z}; do
430 local ptr=EXCEPT_ALWAYS_18$idx
431 [ x${!ptr} = xtrue ] || continue
433 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
436 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
439 run_test 18 "mmap sanity check ================================="
441 test_19() { # bug3811
442 local node=$(facet_active_host ost1)
444 # check whether obdfilter is cache capable at all
445 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
446 echo "not cache-capable obdfilter"
450 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
452 set_osd_param $node '' readcache_max_filesize 4096
453 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
454 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
455 cp $TMP/$tfile $DIR1/$tfile
456 for i in `seq 1 20`; do
457 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
458 cancel_lru_locks osc > /dev/null
459 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
460 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
462 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
463 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
464 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
465 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
467 set_osd_param $node '' readcache_max_filesize $MAX
470 run_test 19 "test concurrent uncached read races ==============="
475 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
476 $MULTIOP $DIR1/f20 Ow8190c
477 $MULTIOP $DIR2/f20 Oz8194w8190c
478 $MULTIOP $DIR1/f20 Oz0r8190c
480 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
482 error $CNTD" page left in cache after lock cancel" || true
484 run_test 20 "test extra readahead page left in cache ===="
491 test_21() { # Bug 5907
492 test_mkdir $DIR1/$tdir
493 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
495 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
496 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
497 test -d $DIR1/$tdir || error "Mounted directory disappeared"
499 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
502 run_test 21 " Try to remove mountpoint on another dir ===="
504 test_23() { # Bug 5972
505 local at_diff=$(do_facet $SINGLEMDS \
506 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
507 echo "atime should be updated while another read" > $DIR1/$tfile
509 # clear the lock(mode: LCK_PW) gotten from creating operation
513 sleep $((at_diff + 1))
515 echo "starting reads"
516 multiop_bg_pause $DIR1/$tfile or20_c || return 1
517 # with SOM and opencache enabled, we need to close a file and cancel
518 # open lock to get atime propogated to MDS
519 kill -USR1 $! || return 2
522 time2=$(stat -c "%X" $DIR/$tfile)
523 echo "new atime is $time2"
525 [ $time2 -gt $time1 ] || error "atime was not updated"
526 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
529 run_test 23 " others should see updated atime while another read===="
533 lfs df || error "lfs df failed"
534 lfs df -ih || error "lfs df -ih failed"
535 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
536 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
537 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
538 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
540 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
541 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
542 lctl --device %$OSC deactivate
543 lfs df -i || error "lfs df -i with deactivated OSC failed"
544 lctl --device %$OSC activate
545 lfs df || error "lfs df with reactivated OSC failed"
547 run_test 24a "lfs df [-ih] [path] test ========================="
551 fsnum=$(lfs_df | grep -c "summary")
552 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
554 run_test 24b "lfs df should show both filesystems ==============="
557 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
559 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
562 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
563 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
565 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
566 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
567 error "setfacl $DIR2/$tdir #1"
568 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
569 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
570 error "setfacl $DIR2/$tdir #2"
571 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
572 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
573 error "setfacl $DIR2/$tdir #3"
574 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
575 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
576 error "setfacl $DIR2/$tdir #4"
577 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
581 run_test 25a "change ACL on one mountpoint be seen on another ==="
584 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
586 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
588 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
591 $LFS mkdir -i 1 $DIR1/$tdir
592 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
593 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
595 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
596 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
597 error "setfacl $DIR2/$tdir #1"
598 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
599 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
600 error "setfacl $DIR2/$tdir #2"
601 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
602 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
603 error "setfacl $DIR2/$tdir #3"
604 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
605 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
606 error "setfacl $DIR2/$tdir #4"
607 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
611 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
614 utime $DIR1/f26a -s $DIR2/f26a || error
616 run_test 26a "allow mtime to get older"
621 echo "aaa" >> $DIR1/$tfile
623 chmod a+x $DIR2/$tfile
624 mt1=`stat -c %Y $DIR1/$tfile`
625 mt2=`stat -c %Y $DIR2/$tfile`
627 if [ x"$mt1" != x"$mt2" ]; then
628 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
631 run_test 26b "sync mtime between ost and mds"
636 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
641 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
646 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
648 lctl set_param -n ldlm.dump_namespaces ""
649 wait $DD1_PID $DD2_PID
650 [ $? -ne 0 ] && lctl dk $TMP/debug || true
652 run_test 27 "align non-overlapping extent locks from request ==="
654 test_28() { # bug 9977
655 ECHO_UUID="ECHO_osc1_UUID"
656 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
658 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
659 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
660 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
664 attach echo_client ECHO_osc1 $ECHO_UUID
668 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
669 $LCTL --device $tECHOID destroy "${tOBJID}:0"
677 # reading of 1st stripe should pass
678 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
679 # reading of 2nd stripe should fail (this stripe was destroyed)
680 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
682 # now, recreating test file
683 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
684 # reading of 1st stripe should pass
685 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
686 # reading of 2nd stripe should pass
687 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
689 run_test 28 "read/write/truncate file with lost stripes"
691 test_29() { # bug 10999
693 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
694 lctl set_param fail_loc=0x8000030f
697 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
700 #bug 11549 - permanently turn test off in b1_5
701 run_test 29 "lock put race between glimpse and enqueue ========="
703 test_30() { #bug #11110, LU-2523
704 test_mkdir -p $DIR1/$tdir
705 cp -f /bin/bash $DIR1/$tdir/bash
706 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
707 cp /bin/bash $DIR2/$tdir' &
708 $DIR1/$tdir/bash -c 'sleep 2;
709 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
714 run_test 30 "recreate file race"
717 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
718 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
719 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
720 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
721 lctl set_param fail_loc=0x314
722 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
723 awk 'BEGIN { FS="+" } /in/ {print $1}')
724 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
726 run_test 31a "voluntary cancel / blocking ast race=============="
729 remote_ost || { skip "local OST" && return 0; }
730 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
732 # make sure there is no local locks due to destroy
733 wait_mds_ost_sync || error "wait_mds_ost_sync()"
734 wait_delete_completed || error "wait_delete_completed()"
736 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
737 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
738 cp /etc/hosts $DIR/$tdir/$tfile
739 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
740 lctl set_param fail_loc=0x314
741 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
742 do_facet ost1 lctl set_param fail_loc=0x316
744 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
745 lctl set_param fail_loc=0
746 do_facet ost1 lctl set_param fail_loc=0
747 # cleanup: reconnect the client back
750 run_test 31b "voluntary OST cancel / blocking ast race=============="
752 # enable/disable lockless truncate feature, depending on the arg 0/1
753 enable_lockless_truncate() {
754 lctl set_param -n osc.*.lockless_truncate $1
757 test_32a() { # bug 11270
758 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
759 save_lustre_params client "osc.*.lockless_truncate" > $p
761 enable_lockless_truncate 1
763 lfs setstripe -c -1 $DIR1/$tfile
764 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
768 log "checking cached lockless truncate"
769 $TRUNCATE $DIR1/$tfile 8000000
770 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
771 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
772 error "lockless truncate doesn't use cached locks"
774 log "checking not cached lockless truncate"
775 $TRUNCATE $DIR2/$tfile 5000000
776 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
777 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
778 error "not cached trancate isn't lockless"
780 log "disabled lockless truncate"
781 enable_lockless_truncate 0
783 $TRUNCATE $DIR2/$tfile 3000000
784 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
785 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
786 error "lockless truncate disabling failed"
788 # restore lockless_truncate default values
789 restore_lustre_params < $p
792 run_test 32a "lockless truncate"
794 test_32b() { # bug 11270
795 remote_ost_nodsh && skip "remote OST with nodsh" && return
798 local facets=$(get_facets OST)
799 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
801 save_lustre_params client "osc.*.contention_seconds" > $p
802 save_lustre_params $facets \
803 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
804 save_lustre_params $facets \
805 "ldlm.namespaces.filter-*.contended_locks" >> $p
806 save_lustre_params $facets \
807 "ldlm.namespaces.filter-*.contention_seconds" >> $p
810 # agressive lockless i/o settings
811 for node in $(osts_nodes); do
812 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'
814 lctl set_param -n osc.*.contention_seconds 60
815 for i in $(seq 5); do
816 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
817 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
819 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
820 # disable lockless i/o (it is disabled by default)
821 for node in $(osts_nodes); do
822 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'
824 # set contention_seconds to 0 at client too, otherwise Lustre still
825 # remembers lock contention
826 lctl set_param -n osc.*.contention_seconds 0
828 for i in $(seq 1); do
829 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
830 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
832 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
833 error "lockless i/o works when disabled"
835 restore_lustre_params <$p
838 run_test 32b "lockless i/o"
842 local mdts=$(get_facets MDS)
847 for mds in ${mdts//,/ }; do
849 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
850 xargs readlink -f" ))
851 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
854 stat=$(( stat + val))
859 # commit on sharing tests
861 remote_mds_nodsh && skip "remote MDS with nodsh" && return
863 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
864 [ $CLIENTCOUNT -lt 2 ] &&
865 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
867 local nfiles=${TEST33_NFILES:-10000}
868 local param_file=$TMP/$tfile-params
869 local fstype=$(facet_fstype $SINGLEMDS)
871 save_lustre_params $(get_facets MDS) \
872 "mdt.*.commit_on_sharing" > $param_file
880 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
884 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
886 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
887 echo "=== START createmany old: $jbdold transaction"
888 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")
889 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
890 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
891 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
892 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
893 avgtime=$(( avgtime + elapsed ))
895 eval cos${COS}_jbd=$((avgjbd / 3))
896 eval cos${COS}_time=$((avgtime / 3))
899 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
900 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
901 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
902 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
904 restore_lustre_params < $param_file
908 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
910 # commit on sharing tests
912 remote_mds_nodsh && skip "remote MDS with nodsh" && return
914 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
915 [ $CLIENTCOUNT -ge 2 ] ||
916 { skip "Need two or more clients, have $CLIENTCOUNT" &&
918 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
920 local nfiles=${TEST33_NFILES:-10000}
921 local param_file=$TMP/$tfile-params
923 save_lustre_params $(get_facets MDS) \
924 "mdt.*.commit_on_sharing" > $param_file
933 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
937 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \
938 $DIR1/$tdir-\\\$(hostname)-$i"
940 jbdold=$(print_jbd_stat)
941 echo "=== START createmany old: $jbdold transaction"
942 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
943 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
944 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
946 jbdnew=$(print_jbd_stat)
947 jbd=$(( jbdnew - jbdold ))
948 echo "=== END createmany new: $jbdnew transaction : \
949 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
950 avgjbd=$(( avgjbd + jbd ))
951 avgtime=$(( avgtime + elapsed ))
953 eval cos${COS}_jbd=$((avgjbd / 3))
954 eval cos${COS}_time=$((avgtime / 3))
957 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
958 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
959 [ "$cos0_jbd" != 0 ] &&
960 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
961 [ "$cos0_time" != 0 ] &&
962 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
964 restore_lustre_params < $param_file
968 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
970 # End commit on sharing tests
972 get_ost_lock_timeouts() {
973 local nodes=${1:-$(comma_list $(osts_nodes))}
975 local locks=$(do_nodes $nodes \
976 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
984 do_nodes $(comma_list $(osts_nodes)) \
985 "lctl set_param -n fail_loc=0 2>/dev/null || true"
986 for i in $(seq $OSTCOUNT); do
987 wait_osc_import_state client ost$i FULL
995 trap cleanup_34 EXIT RETURN
996 for OPER in notimeout timeout ; do
997 rm $DIR1/$tfile 2>/dev/null
998 lock_in=$(get_ost_lock_timeouts)
999 if [ $OPER == "timeout" ] ; then
1000 for j in `seq $OSTCOUNT`; do
1001 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1002 do_facet ost$j lctl set_param fail_loc=0x511
1004 echo lock should expire
1006 for j in `seq $OSTCOUNT`; do
1007 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1008 do_facet ost$j lctl set_param fail_loc=0x512
1010 echo lock should not expire
1012 echo writing on client1
1013 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1015 echo reading on client2
1016 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1017 # wait for a lock timeout
1019 lock_out=$(get_ost_lock_timeouts)
1020 if [ $OPER == "timeout" ] ; then
1021 if [ $lock_in == $lock_out ]; then
1022 error "no lock timeout happened"
1027 if [ $lock_in != $lock_out ]; then
1028 error "lock timeout happened"
1036 run_test 34 "no lock timeout under IO"
1038 test_35() { # bug 17645
1041 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1042 g=$(awk '/generation/{print $2}' $imp/import)
1043 generation[count]=$g
1047 test_mkdir -p $MOUNT1/$tfile
1048 cancel_lru_locks mdc
1050 # Let's initiate -EINTR situation by setting fail_loc and take
1051 # write lock on same file from same client. This will not cause
1052 # bl_ast yet as lock is already in local cache.
1053 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1054 do_facet client "lctl set_param fail_loc=0x80000317"
1055 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1056 let timeout=timeout*3
1058 while test $nr -lt 10; do
1059 log "Race attempt $nr"
1060 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1061 test "x$blk1" = "x" && blk1=0
1062 createmany -o $MOUNT2/$tfile/a 4000 &
1066 # Let's make conflict and bl_ast
1067 ls -la $MOUNT1/$tfile > /dev/null &
1070 log "Wait for $pid1 $pid2 for $timeout sec..."
1072 kill -9 $pid1 $pid2 > /dev/null 2>&1
1074 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1075 test "x$blk2" = "x" && blk2=0
1076 test $blk2 -gt $blk1 && break
1077 rm -fr $MOUNT1/$tfile/*
1078 cancel_lru_locks mdc
1081 do_facet client "lctl set_param fail_loc=0x0"
1082 df -h $MOUNT1 $MOUNT2
1084 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1085 g=$(awk '/generation/{print $2}' $imp/import)
1086 if ! test "$g" -eq "${generation[count]}"; then
1087 error "Eviction happened on import $(basename $imp)"
1092 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1094 test_36() { #bug 16417
1099 test_mkdir -p $DIR1/$tdir
1100 $LFS setstripe -c -1 $DIR1/$tdir
1103 let SIZE_B=SIZE*1024*1024
1104 sync; sleep 5; sync # wait for delete thread
1106 while [ $i -le 10 ]; do
1107 lctl mark "start test"
1108 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1109 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1110 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1111 sync # sync data from client cache
1112 sync_all_data # sync data from server cache (delayed allocation)
1114 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1115 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1117 rm -f $DIR1/$tdir/$tfile
1118 kill -USR1 $read_pid
1120 wait_delete_completed
1121 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1122 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1124 # this free space! not used
1125 (( $after_dd <= $after)) ||
1126 error "space leaked after_dd:$after_dd > after:$after"
1130 run_test 36 "handle ESTALE/open-unlink correctly"
1132 test_37() { # bug 18695
1133 test_mkdir -p $DIR1/$tdir
1134 multiop_bg_pause $DIR1/$tdir D_c || return 1
1136 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1137 createmany -m $DIR2/$tdir/f 10000
1138 # set mtime/atime backward
1139 touch -t 198001010000 $DIR2/$tdir
1140 kill -USR1 $MULTIPID
1141 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1142 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1145 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1147 # this should be set to past
1148 TEST_39_MTIME=`date -d "1 year ago" +%s`
1152 local client1=${CLIENT1:-`hostname`}
1153 local client2=${CLIENT2:-`hostname`}
1155 do_node $client1 "touch $DIR1/$tfile"
1157 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1158 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1159 [ "$mtime1" = $TEST_39_MTIME ] || \
1160 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1162 local d1=`do_node $client1 date +%s`
1163 do_node $client1 'echo hello >> '$DIR1/$tfile
1164 local d2=`do_node $client1 date +%s`
1166 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1167 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1168 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1170 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1172 for (( i=0; i < 2; i++ )) ; do
1173 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1174 [ "$mtime2" = "$mtime3" ] || \
1175 error "mtime ($mtime2) changed (to $mtime3) on rename"
1177 cancel_lru_locks osc
1178 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1181 run_test 39a "test from 11063 =================================="
1184 local client1=${CLIENT1:-`hostname`}
1185 local client2=${CLIENT2:-`hostname`}
1189 local mtime1=`stat -c %Y $DIR1/$tfile`
1190 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1193 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1195 for (( i=0; i < 2; i++ )) ; do
1196 local mtime3=`stat -c %Y $DIR1/$tfile`
1197 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1199 [ "$mtime3" = "$mtime4" ] || \
1200 error "different mtime on clients: $mtime3, $mtime4"
1201 [ "$mtime3" = $TEST_39_MTIME ] || \
1202 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1204 cancel_lru_locks osc
1205 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1208 run_test 39b "11063 problem 1 =================================="
1211 local client1=${CLIENT1:-`hostname`}
1212 local client2=${CLIENT2:-`hostname`}
1214 echo hello > $DIR1/$tfile
1216 local mtime1=`stat -c %Y $DIR1/$tfile`
1217 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1218 [ "$mtime1" = "$mtime2" ] || \
1219 error "create: different mtime on clients: $mtime1, $mtime2"
1222 $TRUNCATE $DIR1/$tfile 1
1224 for (( i=0; i < 2; i++ )) ; do
1225 local mtime3=`stat -c %Y $DIR1/$tfile`
1226 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1228 [ "$mtime3" = "$mtime4" ] || \
1229 error "different mtime on clients: $mtime3, $mtime4"
1230 [ "$mtime3" -gt $mtime2 ] || \
1231 error "truncate did not update mtime: $mtime2, $mtime3"
1233 cancel_lru_locks osc
1234 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1237 run_test 39c "check truncate mtime update ======================"
1239 # check that pid exists hence second operation wasn't blocked by first one
1240 # if it is so then there is no conflict, return 0
1241 # else second operation is conflicting with first one, return 1
1242 check_pdo_conflict() {
1245 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1246 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1256 # test 40: check non-blocking operations
1258 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1259 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1260 mkdir $DIR1/$tfile &
1263 touch $DIR2/$tfile-2
1264 check_pdo_conflict $PID1 || error "create is blocked"
1265 mkdir $DIR2/$tfile-3
1266 check_pdo_conflict $PID1 || error "mkdir is blocked"
1267 link $DIR2/$tfile-2 $DIR2/$tfile-4
1268 check_pdo_conflict $PID1 || error "link is blocked"
1269 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1270 check_pdo_conflict $PID1 || error "rename is blocked"
1271 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1272 check_pdo_conflict $PID1 || error "getattr is blocked"
1273 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1274 rmdir $DIR2/$tfile-3
1275 check_pdo_conflict $PID1 || error "unlink is blocked"
1277 # all operations above shouldn't wait the first one
1278 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1283 run_test 40a "pdirops: create vs others =============="
1286 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1287 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1288 touch $DIR1/$tfile &
1292 touch $DIR2/$tfile-2
1293 check_pdo_conflict $PID1 || error "create is blocked"
1294 mkdir $DIR2/$tfile-3
1295 check_pdo_conflict $PID1 || error "mkdir is blocked"
1296 link $DIR2/$tfile-2 $DIR2/$tfile-4
1297 check_pdo_conflict $PID1 || error "link is blocked"
1298 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1299 check_pdo_conflict $PID1 || error "rename is blocked"
1300 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1301 check_pdo_conflict $PID1 || error "getattr is blocked"
1302 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1303 rmdir $DIR2/$tfile-3
1304 check_pdo_conflict $PID1 || error "unlink is blocked"
1305 # all operations above shouldn't wait the first one
1307 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1312 run_test 40b "pdirops: open|create and others =============="
1316 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1317 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1318 link $DIR1/$tfile $DIR1/$tfile-0 &
1322 touch $DIR2/$tfile-2
1323 check_pdo_conflict $PID1 || error "create is blocked"
1324 mkdir $DIR2/$tfile-3
1325 check_pdo_conflict $PID1 || error "mkdir is blocked"
1326 link $DIR2/$tfile-2 $DIR2/$tfile-4
1327 check_pdo_conflict $PID1 || error "link is blocked"
1328 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1329 check_pdo_conflict $PID1 || error "rename is blocked"
1330 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1331 check_pdo_conflict $PID1 || error "getattr is blocked"
1332 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1333 rmdir $DIR2/$tfile-3
1334 check_pdo_conflict $PID1 || error "unlink is blocked"
1336 # all operations above shouldn't wait the first one
1337 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1342 run_test 40c "pdirops: link and others =============="
1346 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1347 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1352 touch $DIR2/$tfile-2
1353 check_pdo_conflict $PID1 || error "create is blocked"
1354 mkdir $DIR2/$tfile-3
1355 check_pdo_conflict $PID1 || error "mkdir is blocked"
1356 link $DIR2/$tfile-2 $DIR2/$tfile-4
1357 check_pdo_conflict $PID1 || error "link is blocked"
1358 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1359 check_pdo_conflict $PID1 || error "rename is blocked"
1360 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1361 check_pdo_conflict $PID1 || error "getattr is blocked"
1362 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1363 rmdir $DIR2/$tfile-3
1364 check_pdo_conflict $PID1 || error "unlink is blocked"
1366 # all operations above shouldn't wait the first one
1367 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1371 run_test 40d "pdirops: unlink and others =============="
1375 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1376 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1377 mv $DIR1/$tfile $DIR1/$tfile-0 &
1381 touch $DIR2/$tfile-2
1382 check_pdo_conflict $PID1 || error "create is blocked"
1383 mkdir $DIR2/$tfile-3
1384 check_pdo_conflict $PID1 || error "mkdir is blocked"
1385 link $DIR2/$tfile-2 $DIR2/$tfile-4
1386 check_pdo_conflict $PID1 || error "link is blocked"
1387 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1388 check_pdo_conflict $PID1 || error "getattr is blocked"
1389 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1390 rmdir $DIR2/$tfile-3
1391 check_pdo_conflict $PID1 || error "unlink is blocked"
1393 # all operations above shouldn't wait the first one
1394 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1399 run_test 40e "pdirops: rename and others =============="
1401 # test 41: create blocking operations
1403 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1404 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1405 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1408 mkdir $DIR2/$tfile && error "mkdir must fail"
1409 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1413 run_test 41a "pdirops: create vs mkdir =============="
1416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1417 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1418 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1421 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1422 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1426 run_test 41b "pdirops: create vs create =============="
1429 touch $DIR1/$tfile-2
1430 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1431 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1432 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1435 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1436 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1440 run_test 41c "pdirops: create vs link =============="
1443 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1444 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1445 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1448 rm $DIR2/$tfile || error "unlink must succeed"
1449 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1453 run_test 41d "pdirops: create vs unlink =============="
1456 touch $DIR1/$tfile-2
1457 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1458 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1459 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1462 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1463 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1467 run_test 41e "pdirops: create and rename (tgt) =============="
1470 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1471 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1472 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1475 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1476 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1480 run_test 41f "pdirops: create and rename (src) =============="
1483 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1484 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1485 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1488 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1489 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1493 run_test 41g "pdirops: create vs getattr =============="
1496 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1497 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1498 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1501 ls -lia $DIR2/ > /dev/null
1502 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1506 run_test 41h "pdirops: create vs readdir =============="
1508 # test 42: unlink and blocking operations
1510 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1511 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1512 mkdir $DIR1/$tfile &
1515 mkdir $DIR2/$tfile && error "mkdir must fail"
1516 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1520 run_test 42a "pdirops: mkdir vs mkdir =============="
1523 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1524 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1525 mkdir $DIR1/$tfile &
1528 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1529 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1533 run_test 42b "pdirops: mkdir vs create =============="
1536 touch $DIR1/$tfile-2
1537 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1538 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1539 mkdir $DIR1/$tfile &
1542 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1543 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1547 run_test 42c "pdirops: mkdir vs link =============="
1550 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1551 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1552 mkdir $DIR1/$tfile &
1555 rmdir $DIR2/$tfile || error "unlink must succeed"
1556 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1560 run_test 42d "pdirops: mkdir vs unlink =============="
1563 touch $DIR1/$tfile-2
1564 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1565 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1566 mkdir $DIR1/$tfile &
1569 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1570 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1574 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1577 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1578 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1579 mkdir $DIR1/$tfile &
1582 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1583 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1587 run_test 42f "pdirops: mkdir and rename (src) =============="
1590 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1591 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1592 mkdir $DIR1/$tfile &
1595 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1596 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1600 run_test 42g "pdirops: mkdir vs getattr =============="
1603 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1604 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1605 mkdir $DIR1/$tfile &
1608 ls -lia $DIR2/ > /dev/null
1609 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1613 run_test 42h "pdirops: mkdir vs readdir =============="
1615 # test 43: unlink and blocking operations
1618 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1619 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1623 mkdir $DIR2/$tfile || error "mkdir must succeed"
1624 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1628 run_test 43a "pdirops: unlink vs mkdir =============="
1632 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1633 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1637 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1638 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1642 run_test 43b "pdirops: unlink vs create =============="
1646 touch $DIR1/$tfile-2
1647 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1648 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1652 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1653 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1657 run_test 43c "pdirops: unlink vs link =============="
1661 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1662 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1666 rm $DIR2/$tfile && error "unlink must fail"
1667 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1671 run_test 43d "pdirops: unlink vs unlink =============="
1675 touch $DIR1/$tfile-2
1676 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1677 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1681 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1682 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1686 run_test 43e "pdirops: unlink and rename (tgt) =============="
1690 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1691 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1695 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1696 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1700 run_test 43f "pdirops: unlink and rename (src) =============="
1704 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1705 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1709 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1710 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1714 run_test 43g "pdirops: unlink vs getattr =============="
1718 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1719 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1723 ls -lia $DIR2/ > /dev/null
1724 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1728 run_test 43h "pdirops: unlink vs readdir =============="
1731 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1733 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1734 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1738 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1739 check_pdo_conflict $PID1 &&
1740 { wait $PID1; error "remote mkdir isn't blocked"; }
1744 run_test 43i "pdirops: unlink vs remote mkdir"
1746 # test 44: rename tgt and blocking operations
1748 touch $DIR1/$tfile-2
1749 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1750 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1751 mv $DIR1/$tfile-2 $DIR1/$tfile &
1754 mkdir $DIR2/$tfile && error "mkdir must fail"
1755 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1759 run_test 44a "pdirops: rename tgt vs mkdir =============="
1762 touch $DIR1/$tfile-2
1763 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1764 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1765 mv $DIR1/$tfile-2 $DIR1/$tfile &
1768 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1769 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1773 run_test 44b "pdirops: rename tgt vs create =============="
1776 touch $DIR1/$tfile-2
1777 touch $DIR1/$tfile-3
1778 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1779 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1780 mv $DIR1/$tfile-2 $DIR1/$tfile &
1783 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1784 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1788 run_test 44c "pdirops: rename tgt vs link =============="
1791 touch $DIR1/$tfile-2
1792 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1793 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1794 mv $DIR1/$tfile-2 $DIR1/$tfile &
1797 rm $DIR2/$tfile || error "unlink must succeed"
1798 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1802 run_test 44d "pdirops: rename tgt vs unlink =============="
1806 touch $DIR1/$tfile-2
1807 touch $DIR1/$tfile-3
1808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1809 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1810 mv $DIR1/$tfile-2 $DIR1/$tfile &
1813 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1818 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1821 touch $DIR1/$tfile-2
1822 touch $DIR1/$tfile-3
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1825 mv $DIR1/$tfile-2 $DIR1/$tfile &
1828 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1833 run_test 44f "pdirops: rename tgt and rename (src) =============="
1836 touch $DIR1/$tfile-2
1837 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1838 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1839 mv $DIR1/$tfile-2 $DIR1/$tfile &
1842 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1843 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1847 run_test 44g "pdirops: rename tgt vs getattr =============="
1850 touch $DIR1/$tfile-2
1851 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1852 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1853 mv $DIR1/$tfile-2 $DIR1/$tfile &
1856 ls -lia $DIR2/ > /dev/null
1857 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1861 run_test 44h "pdirops: rename tgt vs readdir =============="
1863 # test 44: rename tgt and blocking operations
1865 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1866 touch $DIR1/$tfile-2
1867 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1868 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1869 mv $DIR1/$tfile-2 $DIR1/$tfile &
1872 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1873 check_pdo_conflict $PID1 && { wait $PID1;
1874 error "remote mkdir isn't blocked"; }
1878 run_test 44i "pdirops: rename tgt vs remote mkdir"
1880 # test 45: rename src and blocking operations
1883 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1884 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1885 mv $DIR1/$tfile $DIR1/$tfile-2 &
1888 mkdir $DIR2/$tfile || error "mkdir must succeed"
1889 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1893 run_test 45a "pdirops: rename src vs mkdir =============="
1897 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1898 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1899 mv $DIR1/$tfile $DIR1/$tfile-2 &
1902 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1903 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1907 run_test 45b "pdirops: rename src vs create =============="
1911 touch $DIR1/$tfile-3
1912 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1913 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1914 mv $DIR1/$tfile $DIR1/$tfile-2 &
1917 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1918 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1922 run_test 45c "pdirops: rename src vs link =============="
1926 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1927 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1928 mv $DIR1/$tfile $DIR1/$tfile-2 &
1931 rm $DIR2/$tfile && error "unlink must fail"
1932 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1936 run_test 45d "pdirops: rename src vs unlink =============="
1940 touch $DIR1/$tfile-3
1941 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1942 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1943 mv $DIR1/$tfile $DIR1/$tfile-2 &
1946 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1947 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1951 run_test 45e "pdirops: rename src and rename (tgt) =============="
1955 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1956 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1957 mv $DIR1/$tfile $DIR1/$tfile-2 &
1960 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1961 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1965 run_test 45f "pdirops: rename src and rename (src) =============="
1969 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1970 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1971 mv $DIR1/$tfile $DIR1/$tfile-2 &
1974 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1975 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1979 run_test 45g "pdirops: rename src vs getattr =============="
1983 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1984 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1985 mv $DIR1/$tfile $DIR1/$tfile-2 &
1988 ls -lia $DIR2/ > /dev/null
1989 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1993 run_test 45h "pdirops: unlink vs readdir =============="
1996 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1998 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1999 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2000 mv $DIR1/$tfile $DIR1/$tfile-2 &
2003 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2004 check_pdo_conflict $PID1 && { wait $PID1;
2005 error "create remote dir isn't blocked"; }
2009 run_test 45i "pdirops: rename src vs remote mkdir"
2011 # test 46: link and blocking operations
2013 touch $DIR1/$tfile-2
2014 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2015 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2016 link $DIR1/$tfile-2 $DIR1/$tfile &
2019 mkdir $DIR2/$tfile && error "mkdir must fail"
2020 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2024 run_test 46a "pdirops: link vs mkdir =============="
2027 touch $DIR1/$tfile-2
2028 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2029 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2030 link $DIR1/$tfile-2 $DIR1/$tfile &
2033 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2034 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2038 run_test 46b "pdirops: link vs create =============="
2041 touch $DIR1/$tfile-2
2042 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2043 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2044 link $DIR1/$tfile-2 $DIR1/$tfile &
2047 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2048 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2052 run_test 46c "pdirops: link vs link =============="
2055 touch $DIR1/$tfile-2
2056 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2057 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2058 link $DIR1/$tfile-2 $DIR1/$tfile &
2061 rm $DIR2/$tfile || error "unlink must succeed"
2062 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2066 run_test 46d "pdirops: link vs unlink =============="
2069 touch $DIR1/$tfile-2
2070 touch $DIR1/$tfile-3
2071 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2072 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2073 link $DIR1/$tfile-2 $DIR1/$tfile &
2076 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2077 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2081 run_test 46e "pdirops: link and rename (tgt) =============="
2084 touch $DIR1/$tfile-2
2085 touch $DIR1/$tfile-3
2086 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2087 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2088 link $DIR1/$tfile-2 $DIR1/$tfile &
2091 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2092 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2096 run_test 46f "pdirops: link and rename (src) =============="
2099 touch $DIR1/$tfile-2
2100 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2101 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2102 link $DIR1/$tfile-2 $DIR1/$tfile &
2105 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2106 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2110 run_test 46g "pdirops: link vs getattr =============="
2113 touch $DIR1/$tfile-2
2114 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2115 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2116 link $DIR1/$tfile-2 $DIR1/$tfile &
2119 ls -lia $DIR2/ > /dev/null
2120 check_pdo_conflict $PID1 && { wait $PID1;
2121 error "readdir isn't blocked"; }
2125 run_test 46h "pdirops: link vs readdir =============="
2128 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2129 touch $DIR1/$tfile-2
2130 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2131 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2132 link $DIR1/$tfile-2 $DIR1/$tfile &
2135 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2136 check_pdo_conflict $PID1 && { wait $PID1;
2137 error "remote mkdir isn't blocked"; }
2141 run_test 46i "pdirops: link vs remote mkdir"
2143 # test 47: remote mkdir and blocking operations
2145 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2146 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2147 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2148 $LFS mkdir -i 1 $DIR1/$tfile &
2151 mkdir $DIR2/$tfile && error "mkdir must fail"
2152 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2156 run_test 47a "pdirops: remote mkdir vs mkdir"
2159 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2161 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2162 $LFS mkdir -i 1 $DIR1/$tfile &
2165 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2166 check_pdo_conflict $PID1 && { wait $PID1;
2167 error "create isn't blocked"; }
2171 run_test 47b "pdirops: remote mkdir vs create"
2174 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2175 touch $DIR1/$tfile-2
2176 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2177 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2178 $LFS mkdir -i 1 $DIR1/$tfile &
2181 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2182 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2186 run_test 47c "pdirops: remote mkdir vs link"
2189 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2190 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2191 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2192 $LFS mkdir -i 1 $DIR1/$tfile &
2195 rmdir $DIR2/$tfile || error "unlink must succeed"
2196 check_pdo_conflict $PID1 && { wait $PID1;
2197 error "unlink isn't blocked"; }
2201 run_test 47d "pdirops: remote mkdir vs unlink"
2204 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2205 touch $DIR1/$tfile-2
2206 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2207 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2208 $LFS mkdir -i 1 $DIR1/$tfile &
2211 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2212 check_pdo_conflict $PID1 && { wait $PID1;
2213 error "rename isn't blocked"; }
2217 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2220 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2221 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2222 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2223 $LFS mkdir -i 1 $DIR1/$tfile &
2226 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2227 check_pdo_conflict $PID1 && { wait $PID1;
2228 error "rename isn't blocked"; }
2232 run_test 47f "pdirops: remote mkdir and rename (src)"
2235 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2236 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2237 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2238 $LFS mkdir -i 1 $DIR1/$tfile &
2241 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2242 check_pdo_conflict $PID1 && { wait $PID1;
2243 error "getattr isn't blocked"; }
2247 run_test 47g "pdirops: remote mkdir vs getattr"
2251 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2252 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2253 do_facet client "lctl set_param fail_loc=0x410"
2254 $TRUNCATE $DIR2/$tfile $trunc_size
2255 do_facet client "lctl set_param fail_loc=0x0"
2257 size=`stat -c %s $DIR2/$tfile`
2258 [ $size -eq $trunc_size ] || error "wrong size"
2260 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2264 local origfile=/etc/hosts
2266 filesize=`stat -c %s $origfile`
2268 # create an empty file
2269 $MCREATE $DIR1/$tfile
2270 # cache layout lock on both mount point
2271 stat $DIR1/$tfile > /dev/null
2272 stat $DIR2/$tfile > /dev/null
2274 # open and sleep 2 seconds then read
2275 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2279 # create the layout of testing file
2280 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2282 # MULTIOP proc should be able to read enough bytes and exit
2284 kill -0 $pid && error "multiop is still there"
2285 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2289 run_test 51a "layout lock: refresh layout should work"
2292 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2293 { skip "Need MDS version at least 2.3.59"; return 0; }
2295 local tmpfile=`mktemp`
2297 # create an empty file
2298 $MCREATE $DIR1/$tfile
2300 # delay glimpse so that layout has changed when glimpse finish
2301 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2302 $LCTL set_param fail_loc=0x1404
2303 stat -c %s $DIR2/$tfile |tee $tmpfile &
2307 # create layout of testing file
2308 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2311 local fsize=`cat $tmpfile`
2313 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2315 rm -f $DIR1/$tfile $tmpfile
2317 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2320 [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; }
2322 # set default layout to have 1 stripe
2323 mkdir -p $DIR1/$tdir
2324 $LFS setstripe -c 1 $DIR1/$tdir
2326 # create a file with empty layout
2327 $MCREATE $DIR1/$tdir/$tfile
2329 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2330 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
2332 # change the layout of testing file
2333 echo "Setting layout to have $OSTCOUNT stripes ..."
2334 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
2338 # write something to the file, it should be blocked on fetching layout
2339 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
2340 local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
2341 [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT"
2345 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2348 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
2349 cancel_lru_locks mdc
2351 # open should grant LAYOUT lock, mmap and read will install pages
2352 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
2356 # rss before revoking
2357 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2358 echo "Before revoking layout lock: $br KB mapped"
2360 # delete the file will revoke layout lock
2363 # rss after revoking
2364 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
2369 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
2371 run_test 51d "layout lock: losing layout lock should clean up memory map region"
2374 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
2375 { skip "Need MDS version at least 2.3.0"; return; }
2377 test_mkdir -p $DIR1/$tdir
2378 file1=$DIR1/$tdir/file
2379 file2=$DIR2/$tdir/file
2381 echo orig > $file2 || error "Could not create $file2"
2382 version=$($LFS data_version $file1)
2385 echo append >> $file2 || error "Could not append to $file2"
2386 version2=$($LFS data_version $file1)
2387 [ "$version" != "$version2" ] ||
2388 error "append did not change data version: $version"
2391 echo overwrite > $file2 || error "Could not overwrite $file2"
2392 version3=$($LFS data_version $file1)
2393 [ "$version2" != "$version3" ] ||
2394 error "overwrite did not change data version: $version2"
2396 # Truncate before EOF
2397 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2398 version4=$($LFS data_version $file1)
2399 [ "$version3" != "$version4" ] ||
2400 error "truncate did not change data version: $version3"
2402 # Truncate after EOF
2403 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2404 version5=$($LFS data_version $file1)
2405 [ "$version4" != "$version5" ] ||
2406 error "truncate did not change data version: $version4"
2408 # Chmod do not change version
2409 chmod 400 $file2 || error "Could not chmod 400 $file2"
2410 version6=$($LFS data_version $file1)
2411 [ "$version5" == "$version6" ] ||
2412 error "chmod should not change data version: $version5 != $version6"
2414 # Chown do not change version
2415 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2416 version7=$($LFS data_version $file1)
2417 [ "$version5" == "$version7" ] ||
2418 error "chown should not change data version: $version5 != $version7"
2420 run_test 60 "Verify data_version behaviour"
2423 local test_dir=$tdir/test_dir
2425 mkdir -p $DIR1/$tdir
2426 if [ $MDSCOUNT -ge 2 ]; then
2428 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2429 error "Create remote directory failed"
2431 mkdir -p $DIR1/$test_dir
2433 cd $DIR2/$test_dir || error "cd directory failed"
2434 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2436 cd $DIR2/$tdir || error "exit directory"
2438 run_test 70a "cd directory && rm directory"
2440 test_70b() { # LU-2781
2442 mkdir -p $DIR1/$tdir
2444 touch $DIR1/$tdir/file
2445 for ((i = 0; i < 32; i++)); do
2446 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2448 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2450 touch $DIR1/$tdir/file
2451 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2452 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2453 rm -rf $DIR1/$tdir/test_dir ||
2454 error "cannot remove directory after rm_entry"
2455 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2457 run_test 70b "remove files after calling rm_entry"
2460 local server_version=$(lustre_version_code $SINGLEMDS)
2462 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2463 skip "Need MDS version at least 2.1.6" && return
2465 # Patch not applied to 2.2 and 2.3 branches
2466 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2467 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2468 skip "Need MDS version at least 2.4.0" && return
2470 checkfiemap --test ||
2471 { skip "checkfiemap not runnable: $?" && return; }
2472 # write data this way: hole - data - hole - data
2473 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2474 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2476 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2477 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2478 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2480 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2482 checkfiemap $DIR2/$tfile 81920 ||
2483 error "data is not flushed from client"
2484 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2487 # common case of "create file, copy file" on a single node
2488 # should not flush data from ost
2489 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2490 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2492 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2494 checkfiemap $DIR1/$tfile 81920 ||
2496 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2498 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2500 run_test 71 "correct file map just after write operation is finished"
2503 local p="$TMP/sanityN-$TESTNAME.parameters"
2506 save_lustre_params client "llite.*.xattr_cache" > $p
2507 lctl set_param llite.*.xattr_cache 1 ||
2508 { skip "xattr cache is not supported"; return 0; }
2511 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2512 error "setfattr1 failed"
2513 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2514 error "getfattr1 failed"
2515 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2516 error "setfattr2 failed"
2517 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2518 error "getfattr2 failed"
2520 # check that trusted.link is consistent
2521 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2522 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2523 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2524 echo "$tlink1 $tlink2"
2525 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2529 restore_lustre_params < $p
2532 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2535 local p="$TMP/sanityN-$TESTNAME.parameters"
2536 save_lustre_params client "llite.*.xattr_cache" > $p
2537 lctl set_param llite.*.xattr_cache 1 ||
2538 { skip "xattr cache is not supported"; return 0; }
2541 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2542 error "setfattr1 failed"
2543 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2544 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2546 # PR lock should be cached by now on both clients
2547 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2548 # 2 hits for getfattr(0)+getfattr(size)
2549 [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1"
2550 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2551 # 4 hits for more getfattr(0)+getfattr(size)
2552 [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2"
2555 restore_lustre_params < $p
2558 run_test 73 "getxattr should not cause xattr lock cancellation"
2561 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2562 skip "Need MDS version at least 2.4.93" && return
2564 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2565 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2566 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2568 run_test 74 "flock deadlock: different mounts =============="
2572 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2573 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2574 cancel_lru_locks osc
2576 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2579 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2580 $LCTL set_param fail_loc=0x31d
2581 stat -c %s $DIR1/$tfile &
2586 # For bad lock error handler we should ASSERT and got kernel panic here
2588 $LCTL set_param fail_loc=0
2590 run_test 75 "osc: upcall after unuse lock==================="
2593 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2594 skip "Need MDS version at least 2.5.53" && return
2595 [ $MDSCOUNT -ge 2 ] && skip "skip now for LU-4573" && return #LU-4573
2597 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2607 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2613 test_mkdir -p $DIR/$tdir
2614 if [ $MDSCOUNT -gt 1 ]; then
2615 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
2619 mds_idx=$((mdt_idx + 1))
2620 proc_ofile="mdt.*$mdt_idx.exports.'$nid'.open_files"
2622 cancel_lru_locks mdc
2624 echo -n "open files "
2626 for (( i = 0; i < $fcount; i++ )) ; do
2627 touch $DIR/$tdir/f_$i
2629 cmd="exec $fd<$DIR/$tdir/f_$i"
2636 fid_list=($(do_facet mds$mds_idx $LCTL get_param -n $proc_ofile))
2638 # Possible errors in openfiles FID list.
2639 # 1. Missing FIDs. Check 1
2640 # 2. Extra FIDs. Check 1
2641 # 3. Duplicated FID. Check 2
2642 # 4. Invalid FIDs. Check 2
2643 # 5. Valid FID, points to some other file. Check 3
2646 [ ${#fid_list[@]} -ne $fcount ] &&
2647 error "${#fid_list[@]} != $fcount open files"
2649 for (( i = 0; i < $fcount; i++ )) ; do
2650 cmd="exec ${fd_list[i]}</dev/null"
2652 filename=$($LFS fid2path $DIR2 ${fid_list[i]})
2655 rm --interactive=no $filename
2657 error "Nonexisting fid ${fid_list[i]} listed."
2661 ls_op=$(ls $DIR2/$tdir | wc -l)
2663 error "Some openfiles are missing in lproc output"
2667 run_test 76 "Verify open file for 2048 files"
2670 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2677 mkdir -p $DIR1/$tdir/dir
2678 createmany -o $DIR1/$tdir/dir/f 10 ||
2679 error "create files under remote dir failed $i"
2681 cp /etc/passwd $DIR1/$tdir/$tfile
2683 #migrate open file should fails
2684 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
2686 # give multiop a chance to open
2689 $LFS mv -M $MDTIDX $DIR1/$tdir &&
2690 error "migrate open files should failed with open files"
2694 $LFS mv -M $MDTIDX $DIR1/$tdir ||
2695 error "migrate remote dir error"
2697 echo "Finish migration, then checking.."
2698 for file in $(find $DIR1/$tdir); do
2699 mdt_index=$($LFS getstripe -M $file)
2700 [ $mdt_index == $MDTIDX ] ||
2701 error "$file is not on MDT${MDTIDX}"
2704 diff /etc/passwd $DIR1/$tdir/$tfile ||
2705 error "file different after migration"
2707 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
2709 run_test 80 "migrate directory when some children is being opened"
2711 log "cleanup: ======================================================"
2713 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
2717 check_and_cleanup_lustre