4 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
6 # Copyright (c) 2021 Peter Holm <pho@FreeBSD.org>
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
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.
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
30 # O_CREAT / unlink() timing test with different FFS options.
32 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
33 [ `uname -m` = "i386" ] && exit 0 # very long runtime
36 [ $# -eq 0 ] && half=1 # SU and SUJ workaround
38 export LANG=en_US.ISO8859-1
43 sed '1,/^EOF/d' < $odir/$0 > perf.c
44 mycc -o perf -Wall -Wextra perf.c || exit 1
48 mount | grep -q "on $mntpoint " && umount $mntpoint
49 mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart
51 mdconfig -a -t swap -s 2g -u $mdstart
58 inodes=`df -ik $mntpoint | tail -1 | \
59 awk '{printf "%d\n", $7}'`
60 # SU and SUJ tests fail with ENOSPC
63 i=$(((inodes - 500) / 2))
65 printf "Using %'\''d inodes out of a total of %'\''d.\n" \
85 for i in "" "-U" "-j"; do
86 newfs $i /dev/md$mdstart > /dev/null 2>&1
87 mount /dev/md$mdstart $mntpoint
91 t2=$((`date +%s` - t1))
94 t2=$((`date +%s` - t1))
96 [ -z "$base" ] && base=$t2
97 pct=$(((t2 - base) * 100 / base))
98 printf '%3d seconds elapsed for newfs option "%2s" (%+4d%%)\n' \
100 [ $pct -gt 10 ] && s=111
101 [ $s -eq 0 -a $r -ne 0 ] && s=$r
104 mdconfig -d -u $mdstart
107 #include <sys/types.h>
108 #include <sys/stat.h>
117 main(int argc __unused, char **argv)
124 size = atol(argv[1]);
128 for (j = 0; j < size; j++) {
129 sprintf(file,"p%05d.%05d", pid, j);
130 if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC,
131 DEFFILEMODE)) == -1) {
133 if (errno != EINTR) {
134 warn("open(%s)", file);
135 printf("break out at %d, errno %d\n", j,
143 for (i = --j; i >= 0; i--) {
144 sprintf(file,"p%05d.%05d", pid, i);
145 if (unlink(file) == -1)
146 err(3, "unlink(%s)", file);