diff options
author | pjd <pjd@FreeBSD.org> | 2004-11-06 17:10:24 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2004-11-06 17:10:24 +0000 |
commit | 97a0c2205ede93c5171edfa24e871edb2af88770 (patch) | |
tree | d5da3999924d01ecd3f3f5b1d968ead0795ccb79 /tools | |
parent | 0141ffb284c5b8e035c62bfeb600019e3370dd9c (diff) | |
download | FreeBSD-src-97a0c2205ede93c5171edfa24e871edb2af88770.zip FreeBSD-src-97a0c2205ede93c5171edfa24e871edb2af88770.tar.gz |
Allow to write random data while testing RAID device, so we can also
test data integrity.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/raidtest/raidtest.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tools/tools/raidtest/raidtest.c b/tools/tools/raidtest/raidtest.c index f5eb962..407ccca 100644 --- a/tools/tools/raidtest/raidtest.c +++ b/tools/tools/raidtest/raidtest.c @@ -66,7 +66,7 @@ usage(void) { fprintf(stderr, "usage: %s genfile [-frw] <-s mediasize> [-S sectorsize] <-n nrequests> [file]\n", getprogname()); - fprintf(stderr, " %s test [-rw] <-d device> [-n processes] [file]\n", getprogname()); + fprintf(stderr, " %s test [-Rrw] <-d device> [-n processes] [file]\n", getprogname()); exit(EXIT_FAILURE); } @@ -211,7 +211,18 @@ raidtest_genfile(int argc, char *argv[]) } static void -test_start(int fd, struct ioreq *iorqs, uintmax_t nreqs) +rand_fill(unsigned char *data, unsigned length) +{ + u_int32_t *datap = (u_int32_t *)data; + unsigned i; + + length /= sizeof(u_int32_t); + for (i = 0; i < length; i++) + datap[i] = arc4random(); +} + +static void +test_start(int fd, struct ioreq *iorqs, uintmax_t nreqs, int randdata) { unsigned char data[MAX_IO_LENGTH]; struct ioreq *iorq; @@ -230,6 +241,8 @@ test_start(int fd, struct ioreq *iorqs, uintmax_t nreqs) } break; case IO_TYPE_WRITE: + if (randdata) + rand_fill(data, iorq->iorq_length); if (pwrite(fd, data, iorq->iorq_length, iorq->iorq_offset) != (ssize_t)iorq->iorq_length) { fprintf(stderr, @@ -264,12 +277,12 @@ raidtest_test(int argc, char *argv[]) unsigned nprocs; struct stat sb; pid_t *procs; - int ch, fdd, fdf, j, rdonly, wronly; + int ch, fdd, fdf, j, randdata, rdonly, wronly; dev = NULL; nprocs = 1; - rdonly = wronly = 0; - while ((ch = getopt(argc, argv, "d:n:rvw")) != -1) { + randdata = rdonly = wronly = 0; + while ((ch = getopt(argc, argv, "d:n:Rrvw")) != -1) { switch (ch) { case 'd': dev = optarg; @@ -282,6 +295,9 @@ raidtest_test(int argc, char *argv[]) "Invalid value for '%c' argument.", ch); } break; + case 'R': + randdata = 1; + break; case 'r': rdonly = 1; break; @@ -373,7 +389,8 @@ raidtest_test(int argc, char *argv[]) switch (procs[i]) { case 0: free(procs); - test_start(fdd, &iorqs[nstart], reqs_per_proc); + test_start(fdd, &iorqs[nstart], reqs_per_proc, + randdata); free(iorqs); close(fdd); exit(EXIT_SUCCESS); |