1#!/bin/sh 2 3# 4# SPDX-License-Identifier: BSD-2-Clause 5# 6# Copyright (c) 2021 Peter Holm <pho@FreeBSD.org> 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 11# 1. Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# 2. Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in the 15# documentation and/or other materials provided with the distribution. 16# 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27# SUCH DAMAGE. 28# 29 30# Variation of symlink.sh using a larger swap backed FS. 31 32# "panic: refcount 0xfffff8093d7ed268 wraparound" seen in WiP kernel code. 33# https://people.freebsd.org/~pho/stress/log/log0024.txt 34 35[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 36 37. ../default.cfg 38dbt=`sysctl -n vfs.dirtybufthresh` 39[ $dbt -lt 1000 ] && echo "Note: vfs.dirtybufthresh = $dbt" 40 41D=$diskimage 42 43odir=`pwd` 44dir=$mntpoint 45 46cd /tmp 47sed '1,/^EOF/d' < $odir/$0 > symlink.c 48mycc -o symlink -Wall -Wextra symlink.c || exit 1 49rm -f symlink.c 50cd $odir 51 52mount | grep -q "on $mntpoint " && umount $mntpoint 53mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart 54 55mdconfig -a -t swap -s 1g -u $mdstart 56 57tst() { 58 local i j k 59 60 cd $dir 61 df -ik $mntpoint 62 i=`df -ik $mntpoint | tail -1 | awk '{printf "%d\n", ($7 - 500)/2}'` 63 [ $i -gt 20000 ] && i=20000 64 65 for k in `jot 3`; do 66 for j in `jot 2`; do 67 /tmp/symlink $i & 68 done 69 for j in `jot 2`; do 70 wait 71 done 72 done 73 df -ik $mntpoint | tail -1 74 cd $odir 75} 76 77s=0 78for i in "" "-U"; do 79 t1=`date +%s` 80 echo "newfs $i /dev/md$mdstart" 81 newfs $i /dev/md$mdstart > /dev/null 2>&1 82 [ "$i" = "" ] && tunefs -n disable md$mdstart 83 mount /dev/md$mdstart $mntpoint 84 85 tst; s=$? 86 87 umount -f $mntpoint 88 t2=$((`date +%s` - t1)) 89 echo "$t2 seconds elapsed for newfs option \"$i\"" 90 [ $t2 -gt 1000 ] && s=111 91done 92rm -f /tmp/symlink 93mdconfig -d -u $mdstart 94exit $s 95EOF 96#include <sys/param.h> 97#include <sys/mount.h> 98#include <sys/sysctl.h> 99#include <sys/stat.h> 100 101#include <err.h> 102#include <errno.h> 103#include <fcntl.h> 104#include <stdio.h> 105#include <stdlib.h> 106#include <unistd.h> 107 108int 109main(int argc __unused, char **argv) 110{ 111 pid_t pid; 112 int64_t size; 113 int i, j; 114 char file[128]; 115 116 size = atol(argv[1]); 117 118 pid = getpid(); 119 for (j = 0; j < size; j++) { 120 sprintf(file,"p%05d.%05d", pid, j); 121 if (symlink("/mnt/not/there", file) == -1) { 122 if (errno != EINTR) { 123 warn("symlink(%s)", file); 124 printf("break out at %d, errno %d\n", j, errno); 125 break; 126 } 127 } 128 } 129 130 for (i = --j; i >= 0; i--) { 131 sprintf(file,"p%05d.%05d", pid, i); 132 if (unlink(file) == -1) 133 err(3, "unlink(%s)", file); 134 135 } 136 137 return (0); 138} 139