--- Bonnie.c.orig Wed Aug 28 18:23:49 1996 +++ Bonnie.c Sun Jun 11 20:26:29 2006 @@ -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 @@ -146,7 +146,7 @@ /* size is in meg, rounded down to multiple of Chunk */ size *= (1024 * 1024); size = Chunk * (size / Chunk); - fprintf(stderr, "File '%s', size: %ld\n", name, size); + fprintf(stderr, "File '%s', size: %qd\n", name, (int64_t) size); /* Fill up a file, writing it a char at a time with the stdio putc() call */ fprintf(stderr, "Writing with putc()..."); @@ -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 / Chunk < (1 << 25)) + seekto = random() % (size / Chunk); + else + seekto = (((off_t)random() << 31) + 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");