4 # Copyright (c) 2009 Peter Holm <pho@FreeBSD.org>
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 # Test scenario with a 20G files on two UFS2 FSs with 64k/64k
32 # Test program will hang (deadlock) in "nbufkv"
34 # Test scenario by John-Mark Gurney <jmg at funkthat dot com>
36 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
43 sed '1,/^EOF/d' < $odir/$0 > nbufkv.c
44 cc -o nbufkv -Wall nbufkv.c
52 [ -d mp1 ] || mkdir mp1
53 [ -d mp2 ] || mkdir mp2
57 mount | grep -q /dev/md${u2}$part && umount -f /dev/md${u2}$part
58 mount | grep -q /dev/md${u1}$part && umount -f /dev/md${u1}$part
59 mdconfig -l | grep -q md${u2} && mdconfig -d -u $u2
60 mdconfig -l | grep -q md${u1} && mdconfig -d -u $u1
62 mdconfig -a -t vnode -f $d1 -u $u1
63 bsdlabel -w md$u1 auto
64 newfs -b 65536 -f 65536 -O2 md${u1}${part} > /dev/null
66 mdconfig -a -t vnode -f $d2 -u $u2
67 bsdlabel -w md$u2 auto
68 newfs -b 65536 -f 65536 -O2 md${u2}${part} > /dev/null
70 mount /dev/md${u1}$part mp1
71 mount /dev/md${u2}$part mp2
73 /tmp/nbufkv `pwd`/mp1 &
74 /tmp/nbufkv `pwd`/mp2 &
77 umount /dev/md${u2}$part
78 umount /dev/md${u1}$part
80 mount | grep -q /dev/md${u2}$part && umount -f /dev/md${u2}$part
81 mount | grep -q /dev/md${u1}$part && umount -f /dev/md${u1}$part
86 rm -rf mp1 mp2 $d1 $d2 /tmp/nbufkv
89 #include <sys/types.h>
95 #include <sys/param.h>
98 work(int fd, size_t n)
102 for (i = 0; i < 128 * 1024; i++) {
104 if (lseek(fd, n , SEEK_SET) == -1)
106 if (write(fd, "1", 1) != 1)
113 main(int argc, char **argv)
121 len = len * 1024 * 1024 * 1024;
123 sprintf(path, "%s/nbufkv.%06d", argv[1], getpid());
124 if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0640)) == -1)
126 if (ftruncate(fd, len) == -1)
132 if (unlink(path) == -1)
133 err(1, "unlink(%s)", path);