[PATCH] fio: Add start of 'verify' option
authorJens Axboe <axboe@suse.de>
Thu, 3 Nov 2005 15:08:07 +0000 (16:08 +0100)
committerJens Axboe <axboe@suse.de>
Thu, 3 Nov 2005 15:08:07 +0000 (16:08 +0100)
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
fio.c

index 2b0f56bc8da50b20b7908a9f52c08c37f567e891..b5362806ae37675e57c427d9a41d395c139307fe 100644 (file)
@@ -52,6 +52,7 @@ The <jobs> 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 8c94a540d68a36ae589a1f6586cf4c793a4c5b7d..c99ac0ae3e93db06a98192c4a1bc42a22b41d231 100644 (file)
--- 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);