1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
--- Bonnie.c.orig Wed Aug 28 09:23:49 1996
+++ Bonnie.c Tue Aug 27 09:12:19 2002
@@ -49,7 +49,7 @@
#define Seeks (4000)
#define UpdateSeek (10)
#define SeekProcCount (3)
-#define Chunk (16384)
+#define Chunk (8192)
/* labels for the tests, used as an array index */
typedef enum
@@ -179,7 +179,7 @@
if (bufindex == Chunk / IntSize)
bufindex = 0;
buf[bufindex++]++;
- if (lseek(fd, (off_t) -words, 1) == -1)
+ if (lseek(fd, -words, 1) == -1)
io_error("relative lseek(2)");
if (write(fd, (char *) buf, words) == -1)
io_error("re write(2)");
@@ -288,6 +288,7 @@
{ /* child process */
/* set up and wait for the go-ahead */
+ close(0);
close(seek_feedback[0]);
close(seek_control[1]);
newfile(name, &fd, &stream, 0);
@@ -303,7 +304,12 @@
/* loop until we read a 0 ticket back from our parent */
while(seek_tickets[0])
{ /* until Mom says stop */
- doseek((long) (random() % (size / Chunk)), fd,
+ off_t seekto;
+ if (size < ((off_t)1 << 32))
+ seekto = random() % (size / Chunk);
+ else
+ seekto = ((off_t)random() << 32 + random()) % (size / Chunk);
+ doseek(seekto, fd,
((lseek_count++ % UpdateSeek) == 0));
if (read(seek_control[0], seek_tickets, 1) != 1)
io_error("read ticket");
@@ -413,7 +419,7 @@
printf("K/sec %%CPU K/sec %%CPU K/sec %%CPU K/sec %%CPU K/sec ");
printf("%%CPU /sec %%CPU\n");
- printf("%-8.8s %4d ", machine, size / (1024 * 1024));
+ printf("%-8.8s %4qd ", machine, size / (1024 * 1024));
printf("%5d %4.1f %5d %4.1f %5d %4.1f ",
(int) (((double) size) / (delta[(int) Putc][Elapsed] * 1024.0)),
delta[(int) Putc][CPU] / delta[(int) Putc][Elapsed] * 100.0,
@@ -529,7 +535,7 @@
{
char buf[Chunk];
- sprintf(buf, "Bonnie: drastic I/O error (%s)", message);
+ sprintf(buf, "\nBonnie: drastic I/O error (%s)", message);
perror(buf);
exit(1);
}
@@ -568,7 +574,7 @@
/* touch a word */
buf[((int) random() % (size/IntSize - 2)) + 1]--;
- if (lseek(fd, (long) probe, 0) != probe)
+ if (lseek(fd, probe, 0) != probe)
io_error("lseek in doseek update");
if (write(fd, (char *) buf, size) == -1)
io_error("write in doseek");
|