4 # Copyright (c) 2010 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 # Scenario that causes "panic: brelse: free buffer onto another queue???"
32 # Idea for scenario by kib@. Fixed in r203818
34 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
40 sed '1,/^EOF/d' < $here/$0 > fragments.c
42 cc -o fragments -Wall -Wextra -O2 -g fragments.c
46 mount | grep "$mntpoint" | grep -q md$mdstart && umount -f ${mntpoint}
47 mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
49 mdconfig -a -t swap -s 1g -u $mdstart
50 bsdlabel -w md$mdstart auto
51 newfs -U -m 0 md${mdstart}${part} > /dev/null 2>&1
52 mount /dev/md${mdstart}${part} /mnt
56 su ${testuser} -c "/tmp/fragments"
60 mount | grep "$mntpoint" | grep -q md$mdstart && umount -f ${mntpoint}
61 mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
72 #include <sys/mount.h>
73 #include <sys/param.h>
94 for (i = 0; i < LOOPS; i++) {
95 sprintf(file,"t%05d", i);
101 start = arc4random() % n;
102 for (i = 0; i < LOOPS; i++) {
103 j = (start + i) % LOOPS;
104 sprintf(file,"t%05d", j);
105 if (stat(file, &sb) != 0)
108 if (sb.st_size == 0) {
112 if (truncate(file, 0) == 0) {
121 for (i = 0; i < 10; i++) {
122 if (statfs(".", &sbuf) < 0)
123 err(1, "statfs(%s)", ".");
125 if (sbuf.f_bfree > 8)
129 for (i = 0; i < LOOPS; i++) {
130 j = (start + i) % LOOPS;
131 sprintf(file,"t%05d", j);
132 if (unlink(file) == 0) {
146 sprintf(file,"d%d/f%05d.%05d", i/1000, pid, i);
148 if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
150 warn("open(%s)", file);
155 if (write(fd, buf, len) != len) {
170 sprintf(file,"d%d/b%05d.%05d", i/1000, pid, i);
172 if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
174 warn("open(%s)", file);
179 if (write(fd, buf, len) != len) {
192 for (i = 0; i < 300; i++) {
193 sprintf(file,"d%d", i);
194 if (mkdir(file, 0700) == -1)
195 warn("mkdir(%s)", file);
201 for (i = 0;i < 8; i++) {
202 sprintf(file,"d%d/b%05d.%05d", i/1000, pid, i);
206 for (i = 0;i < 1; i++) {
207 sprintf(file,"d%d/f%05d.%05d", i/1000, pid, i);
220 for (i = 0; i < LOOPS; i++) {
221 sprintf(file,"t%05d", i);
223 if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
226 // n = arc4random() % (12 + 1);
228 len = (arc4random() % (16 * 1024) + 1) + n * 16;
230 if (write(fd, buf, len) == len)
252 if ((buf = malloc(12 * 16 * 1024)) == NULL)
256 for (j = 0; j < 50; j++) {
257 for (i = 0; i < PARALLEL; i++) {
261 for (i = 0; i < PARALLEL; i++)