4 # Copyright (c) 2016 EMC Corp.
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 # Temp file test scenario.
30 # "temp: unlink(file.034434.48): Permission denied" seen.
33 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
39 sed '1,/^EOF/d' < $odir/$0 > $dir/temp.c
40 mycc -o temp -Wall -Wextra -O0 -g temp.c || exit 1
44 [ -z "$nfs_export" ] && exit 0
45 ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 ||
48 mount | grep "on $mntpoint " | grep -q nfs && umount $mntpoint
49 mount -t nfs -o tcp -o retrycnt=3 -o soft -o rw $nfs_export $mntpoint
50 mp2=$mntpoint/temp.`jot -rc 8 a z | tr -d '\n'`/temp.dir
56 /tmp/temp $mp2 2> $log
58 #[ $s -eq 0 ] && ministat -C 3 -A < $log
61 while mount | grep "on $mntpoint " | grep -q nfs; do
62 umount $mntpoint || sleep 1
68 #include <sys/param.h>
73 #include <machine/atomic.h>
83 volatile u_int *share;
89 #define RUNTIME (10 * 60)
98 atomic_add_int(&share[SYNC], 1);
99 while (share[SYNC] != PARALLEL)
103 for (i = 0; i < FILES; i++) {
104 snprintf(path, sizeof(path), "%s/file.%06d.%d", dir, pid, i);
105 if ((fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1)
106 err(1, "open(%s)", path);
107 if (write(fd, path, sizeof(path)) != sizeof(path))
110 if (unlink(path) == -1)
111 err(1, "unlink(%s)", path);
117 main(int argc, char *argv[])
120 struct timeval start, stop, diff;
124 int e, i, loop, pids[PARALLEL], status;
129 fprintf(stderr, "Usage: %s <path>\n", argv[0]);
133 if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE,
134 MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
140 while ((time(NULL) - now) < RUNTIME && e == 0) {
142 gettimeofday(&start, NULL);
143 for (i = 0; i < PARALLEL; i++) {
144 if ((pids[i] = fork()) == 0)
147 for (i = 0; i < PARALLEL; i++) {
148 waitpid(pids[i], &status, 0);
149 e += status == 0 ? 0 : 1;
151 gettimeofday(&stop, NULL);
152 timersub(&stop, &start, &diff);
153 usec = ((uint64_t)1000000 *
154 diff.tv_sec + diff.tv_usec);
156 tp = localtime(&then);
157 strftime(buf, sizeof(buf), "%H:%M:%S", tp);
158 if (loop != 0) /* Skip warmup */
159 fprintf(stderr, "%s %6d %.3f\n",
161 (double)usec / 1000000);