From cfc702bde3700d7a35ffc232537ee4bd49664ed2 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 3 Nov 2005 16:08:07 +0100 Subject: [PATCH] [PATCH] fio: Add start of 'verify' option The plan is to have written files stuffed with random data and meta data to be able to verify the written data after the job completes. --- README.fio | 1 + fio.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.fio b/README.fio index 2b0f56b..b536280 100644 --- a/README.fio +++ b/README.fio @@ -52,6 +52,7 @@ The format is as follows: create_serialize=x If 'x', serialize file creation. create_fsync=x If 'x', run fsync() after file creation. loops=x Run the job 'x' number of times. + verify=x If 'x' and writing, verify data written. Examples using a job file diff --git a/fio.c b/fio.c index 8c94a54..c99ac0a 100644 --- a/fio.c +++ b/fio.c @@ -131,6 +131,7 @@ enum { #define DEF_CREATE_SER (1) #define DEF_CREATE_FSYNC (1) #define DEF_LOOPS (1) +#define DEF_VERIFY (0) #define ALIGN(buf) (char *) (((unsigned long) (buf) + MASK) & ~(MASK)) @@ -239,6 +240,7 @@ struct thread_data { unsigned long long file_offset; unsigned int sync_io; unsigned int mem_type; + unsigned int verify; cpu_set_t cpumask; struct drand48_data bsrange_state; @@ -554,6 +556,14 @@ static inline int runtime_exceeded(struct thread_data *td, struct timeval *t) return 0; } +/* + * fill body of io_u->buf with random data and add a header with the + * (eg) sha1sum of that data. + */ +static void populate_io_u(struct io_u *io_u) +{ +} + static void put_io_u(struct thread_data *td, struct io_u *io_u) { list_del(&io_u->list); @@ -582,6 +592,9 @@ static struct io_u *get_io_u(struct thread_data *td) io_u->offset = off; io_u->buflen = len; + if (!td_read(td) && td->verify) + populate_io_u(io_u); + if (td->use_aio) { if (td_read(td)) io_prep_pread(&io_u->iocb, td->fd, io_u->buf, io_u->buflen, io_u->offset); @@ -594,6 +607,11 @@ static struct io_u *get_io_u(struct thread_data *td) return io_u; } +static int do_sync_verify(struct thread_data *td) +{ + return 0; +} + static void do_sync_io(struct thread_data *td) { unsigned long msec, usec; @@ -748,6 +766,11 @@ static void cleanup_pending_aio(struct thread_data *td) } } +static int do_async_verify(struct thread_data *td) +{ + return 0; +} + static void do_async_io(struct thread_data *td) { struct timeval s, e; @@ -1136,10 +1159,21 @@ static void *thread_main(int shm_id, int offset, char *argv[]) memcpy(&td->stat_sample_time, &td->start, sizeof(td->start)); while (td->loops--) { - if (!td->use_aio) + if (!td->use_aio) { do_sync_io(td); - else + + if (td->verify) { + if (do_sync_verify(td)) + break; + } + } else { do_async_io(td); + + if (td->verify) { + if (do_async_verify(td)) + break; + } + } } td->runtime = mtime_since_now(&td->start); @@ -1283,6 +1317,7 @@ static struct thread_data *get_new_job(int global) td->create_serialize = def_thread.create_serialize; td->create_fsync = def_thread.create_fsync; td->loops = def_thread.loops; + td->verify = def_thread.verify; memcpy(&td->cpumask, &def_thread.cpumask, sizeof(td->cpumask)); return td; @@ -1931,6 +1966,7 @@ int main(int argc, char *argv[]) def_thread.create_serialize = DEF_CREATE_SER; def_thread.create_fsync = DEF_CREATE_FSYNC; def_thread.loops = DEF_LOOPS; + def_thread.verify = DEF_VERIFY; i = parse_options(argc, argv); -- 2.25.1