4 # Copyright (c) 2011 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
29 # Scenario from kern/159971
30 # bstg0003.c by Kirk Russell <kirk ba23 org>
32 # panic: ino 0xc84c9b00(0x3C8209) 65554, 32780 != 65570
33 # https://people.freebsd.org/~pho/stress/log/suj23.txt
35 # panic: first_unlinked_inodedep: prev != next. inodedep = 0xcadf9e00
36 # https://people.freebsd.org/~pho/stress/log/jeff091.txt
38 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
44 sed '1,/^EOF/d' < $here/$0 > suj23.c
45 mycc -o suj23 -Wall -Wextra -O2 suj23.c
48 mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint
49 [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
51 mdconfig -a -t swap -s 1g -u $mdstart
52 bsdlabel -w md$mdstart auto
53 newfs -j md${mdstart}$part > /dev/null
54 mount /dev/md${mdstart}$part $mntpoint
57 su $testuser -c '/tmp/suj23'
59 while mount | grep -q "on $mntpoint "; do
60 umount $mntpoint || sleep 1
62 mdconfig -d -u $mdstart
67 * Copyright 2011 Kirk J. Russell
69 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
70 * use this file except in compliance with the License. You may obtain a copy
71 * of the License at http://www.apache.org/licenses/LICENSE-2.0
73 * Unless required by applicable law or agreed to in writing, software
74 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
75 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
76 * License for the specific language governing permissions and limitations
95 static char *bstg_pathstore[] = {
102 "/mnt/111/ffffff.fff.f",
103 "/mnt/111/gggggggggggg",
106 "/mnt/111/jjjj.jj.jjjjjjjj",
107 "/mnt/111/kkkk.kkkkkkkk",
115 "/mnt/222/ffffff.fff.f",
116 "/mnt/222/gggggggggggg",
119 "/mnt/222/jjjj.jj.jjjjjjjj",
120 "/mnt/222/kkkk.kkkkkkkk",
128 "/mnt/333/ffffff.fff.f",
129 "/mnt/333/gggggggggggg",
132 "/mnt/333/jjjj.jj.jjjjjjjj",
133 "/mnt/333/kkkk.kkkkkkkk",
141 "/mnt/444/ffffff.fff.f",
142 "/mnt/444/gggggggggggg",
145 "/mnt/444/jjjj.jj.jjjjjjjj",
146 "/mnt/444/kkkk.kkkkkkkk",
154 "/mnt/555/ffffff.fff.f",
155 "/mnt/555/gggggggggggg",
158 "/mnt/555/jjjj.jj.jjjjjjjj",
159 "/mnt/555/kkkk.kkkkkkkk",
167 "/mnt/666/ffffff.fff.f",
168 "/mnt/666/gggggggggggg",
171 "/mnt/666/jjjj.jj.jjjjjjjj",
172 "/mnt/666/kkkk.kkkkkkkk",
180 "/mnt/777/ffffff.fff.f",
181 "/mnt/777/gggggggggggg",
184 "/mnt/777/jjjj.jj.jjjjjjjj",
185 "/mnt/777/kkkk.kkkkkkkk",
193 "/mnt/888/ffffff.fff.f",
194 "/mnt/888/gggggggggggg",
197 "/mnt/888/jjjj.jj.jjjjjjjj",
198 "/mnt/888/kkkk.kkkkkkkk",
206 "/mnt/999/ffffff.fff.f",
207 "/mnt/999/gggggggggggg",
210 "/mnt/999/jjjj.jj.jjjjjjjj",
211 "/mnt/999/kkkk.kkkkkkkk",
219 "/mnt/aaa/ffffff.fff.f",
220 "/mnt/aaa/gggggggggggg",
223 "/mnt/aaa/jjjj.jj.jjjjjjjj",
224 "/mnt/aaa/kkkk.kkkkkkkk",
232 "/mnt/bbb/ffffff.fff.f",
233 "/mnt/bbb/gggggggggggg",
236 "/mnt/bbb/jjjj.jj.jjjjjjjj",
237 "/mnt/bbb/kkkk.kkkkkkkk",
245 "/mnt/ccc/ffffff.fff.f",
246 "/mnt/ccc/gggggggggggg",
249 "/mnt/ccc/jjjj.jj.jjjjjjjj",
250 "/mnt/ccc/kkkk.kkkkkkkk",
258 "/mnt/ddd/ffffff.fff.f",
259 "/mnt/ddd/gggggggggggg",
262 "/mnt/ddd/jjjj.jj.jjjjjjjj",
263 "/mnt/ddd/kkkk.kkkkkkkk",
271 "/mnt/eee/ffffff.fff.f",
272 "/mnt/eee/gggggggggggg",
275 "/mnt/eee/jjjj.jj.jjjjjjjj",
276 "/mnt/eee/kkkk.kkkkkkkk",
284 "/mnt/fff/ffffff.fff.f",
285 "/mnt/fff/gggggggggggg",
288 "/mnt/fff/jjjj.jj.jjjjjjjj",
289 "/mnt/fff/kkkk.kkkkkkkk",
296 return bstg_pathstore[rand() %
297 ((sizeof(bstg_pathstore) / sizeof(bstg_pathstore[0])))];
303 pid_t sleepchild, gcorechild;
304 extern char **environ;
306 /* create a child for the gcore target */
307 if ((sleepchild = fork()) == 0) {
310 } else if (sleepchild > 0) {
311 char *token[] = {NULL, NULL, NULL, NULL, NULL};
315 /* use the first process as the target */
316 snprintf(buf, sizeof(buf), "%d", sleepchild);
319 token[2] = bstg_pathstore_get();
321 assert(token[4] == NULL);
323 if ((gcorechild = fork()) > 0) {
324 waitpid(gcorechild, &status, 0);
325 } else if (gcorechild == 0) {
326 execve("/usr/bin/gcore", token, environ);
329 kill(sleepchild, SIGKILL);
330 waitpid(sleepchild, &status, 0);
337 struct iovec data[] = {
345 /* keep existing file open during life of this process */
346 fd = open(bstg_pathstore_get(), O_RDWR | O_NONBLOCK | O_NOCTTY);
348 data[1].iov_base = bstg_pathstore_get();
349 data[1].iov_len = strlen((char *)data[1].iov_base);
351 pwritev(fd, data, 3, 0);
357 unlink(bstg_pathstore_get());
363 link(bstg_pathstore_get(), bstg_pathstore_get());
370 static char *bstg_dirs[] = {
371 "/mnt/111", "/mnt/222", "/mnt/333", "/mnt/444",
372 "/mnt/555", "/mnt/666", "/mnt/777", "/mnt/888",
373 "/mnt/999", "/mnt/aaa", "/mnt/bbb", "/mnt/ccc",
374 "/mnt/ddd", "/mnt/eee", "/mnt/fff", NULL
377 for (pdir = bstg_dirs; *pdir; pdir++) {
378 if (mkdir(*pdir, 0777) == -1)
379 err(1, "mkdir(%s)", *pdir);
395 void (*funcs[]) () = {
414 /* we only can domkdir() once at startup */
417 /* create 128 children that loop forever running 4 operations */
419 for (x = 0; x < 128; x++) {
421 /* give child a new seed for the pathname selection */
425 for (i = 0; i < 1000; i++) {
426 /* each child will start looping at different
428 (*funcs[x++ % 16]) ();
429 if (time(NULL) - start > RUNTIME)
432 /* we never expect this code to run */
437 /* block forever for all our children */
438 while (wait(&status) > 0);