[PATCH] fio: various updates
authorJens Axboe <axboe@suse.de>
Tue, 6 Dec 2005 13:49:42 +0000 (14:49 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 6 Dec 2005 13:49:42 +0000 (14:49 +0100)
examples/1mbs_clients
examples/aio-read
examples/tiobench-example
fio-ini.c
fio-io.c
fio.c
fio.h

index 69137a5b6fef69cb268eeaf46d5a8a12550e3e82..aa90d5c5c59e0d9adc937a3e329c6c561d83383c 100644 (file)
 ; Keep adding 1024kb/s reading clients at 4 seconds
 
 [/tmp/file1]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=0
 
 [/tmp/file2]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=4
 
 [/tmp/file3]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=8
 
 [/tmp/file4]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=12
 
 [/tmp/file5]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=16
 
 [/tmp/file6]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=20
 
 [/tmp/file7]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=24
 
 [/tmp/file8]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=28
 
 [/tmp/file9]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=32
 
 [/tmp/file10]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=36
 
 [/tmp/file11]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=40
 
 [/tmp/file12]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=44
 
 [/tmp/file13]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=48
 
 [/tmp/file14]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=52
 
 [/tmp/file15]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=56
 
 [/tmp/file16]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=60
 
 [/tmp/file17]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=64
 
 [/tmp/file18]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=68
 
 [/tmp/file19]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=72
 
 [/tmp/file20]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=76
 
 [/tmp/file21]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=80
 
 [/tmp/file22]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=84
 
 [/tmp/file23]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=88
 
 [/tmp/file24]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=92
 
 [/tmp/file25]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=96
 
 [/tmp/file26]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=100
 
 [/tmp/file27]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=104
 
 [/tmp/file28]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=108
 
 [/tmp/file29]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=112
 
 [/tmp/file30]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=116
 
 [/tmp/file31]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=120
 
 [/tmp/file32]
-rw=0
+rw=read
 rate=1250
 ratemin=1024
 startdelay=124
index 30cf5f288142ccc8a5341c28634be09cf9524e42..832e006058219618df990071bfdb9d769fc7ef87 100644 (file)
@@ -1,18 +1,17 @@
 ; Read 4 files with aio at different depths
 [global]
-aio
-random
-rw=0
+ioengine=libaio
+rw=randread
 bs=128k
 
 [/data1/file1]
-aio_depth=4
+iodepth=4
 
 [/data1/file2]
-aio_depth=32
+iodepth=32
 
 [/data1/file3]
-aio_depth=8
+iodepth=8
 
 [/data1/file4]
-aio_depth=16
+iodepth=16
index aeffba2c36aaf4e0b563233c725883807d4079fb..5a4493e76c3de868ad8e863b6f9a841b0341803c 100644 (file)
@@ -9,20 +9,16 @@ timeout=60
 numjobs=4      ; 4 simultaneous threads for each job
 
 [f1]
-sequential
-rw=1
+rw=write
 
 [f2]
 stonewall
-random
-rw=1
+rw=randwrite
 
 [f3]
 stonewall
-sequential
-rw=0
+rw=read
 
 [f4]
 stonewall
-random
-rw=0
+rw=randread
index 88f3b59a10bcd96dab52445e0abcaafe39cc90a9..c9940036a3c507d66f9042c61c17acb3bad317f7 100644 (file)
--- a/fio-ini.c
+++ b/fio-ini.c
@@ -17,6 +17,7 @@
 #define DEF_RATE_CYCLE (1000)
 #define DEF_ODIRECT    (1)
 #define DEF_IO_ENGINE  (FIO_SYNCIO)
+#define DEF_IO_ENGINE_NAME     "sync"
 #define DEF_SEQUENTIAL (1)
 #define DEF_RAND_REPEAT        (1)
 #define DEF_OVERWRITE  (1)
@@ -130,7 +131,7 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent)
        td->rate = parent->rate;
        td->ratemin = parent->ratemin;
        td->ratecycle = parent->ratecycle;
-       td->aio_depth = parent->aio_depth;
+       td->iodepth = parent->iodepth;
        td->sync_io = parent->sync_io;
        td->mem_type = parent->mem_type;
        td->bw_avg_time = parent->bw_avg_time;
@@ -142,6 +143,7 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent)
        td->numjobs = parent->numjobs;
        td->use_thread = parent->use_thread;
        memcpy(&td->cpumask, &parent->cpumask, sizeof(td->cpumask));
+       strcpy(td->io_engine_name, parent->io_engine_name);
 
        return td;
 }
@@ -198,8 +200,8 @@ static int add_job(struct thread_data *td, const char *jobname, int prioclass,
        run_str[td->thread_number - 1] = 'P';
 
        if ((td->io_engine & FIO_SYNCIO) == 0) {
-               if (!td->aio_depth)
-                       td->aio_depth = 1;
+               if (!td->iodepth)
+                       td->iodepth = 1;
        }
 
        if (td->min_bs == -1U)
@@ -222,7 +224,7 @@ static int add_job(struct thread_data *td, const char *jobname, int prioclass,
        if (write_bw_log)
                setup_log(&td->bw_log);
 
-       printf("Client%d (g=%d): rw=%d, prio=%d/%d, seq=%d, odir=%d, bs=%d-%d, rate=%d, ioengine=%d, aio_depth=%d\n", td->thread_number, td->groupid, td->ddir, prioclass, prio, td->sequential, td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine, td->aio_depth);
+       printf("Client%d (g=%d): rw=%d, prio=%d/%d, seq=%d, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->thread_number, td->groupid, td->ddir, prioclass, prio, td->sequential, td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine_name, td->iodepth);
 
        /*
         * recurse add identical jobs, clear numjobs and stonewall options
@@ -528,15 +530,19 @@ static int str_mem_cb(struct thread_data *td, char *mem)
 static int str_ioengine_cb(struct thread_data *td, char *str)
 {
        if (!strncmp(str, "linuxaio", 8) || !strncmp(str, "aio", 3)) {
+               strcpy(td->io_engine_name, "libaio");
                td->io_engine = FIO_LIBAIO;
                return 0;
        } else if (!strncmp(str, "posixaio", 8)) {
+               strcpy(td->io_engine_name, "posixaio");
                td->io_engine = FIO_POSIXAIO;
                return 0;
        } else if (!strncmp(str, "sync", 4)) {
+               strcpy(td->io_engine_name, "sync");
                td->io_engine = FIO_SYNCIO;
                return 0;
        } else if (!strncmp(str, "mmap", 4)) {
+               strcpy(td->io_engine_name, "mmap");
                td->io_engine = FIO_MMAPIO;
                return 0;
        }
@@ -650,7 +656,7 @@ int parse_jobs_ini(char *file)
                                fgetpos(f, &off);
                                continue;
                        }
-                       if (!check_int(p, "iodepth", &td->aio_depth)) {
+                       if (!check_int(p, "iodepth", &td->iodepth)) {
                                fgetpos(f, &off);
                                continue;
                        }
@@ -782,6 +788,7 @@ static int fill_def_thread(void)
        def_thread.min_bs = -1;
        def_thread.max_bs = -1;
        def_thread.io_engine = DEF_IO_ENGINE;
+       strcpy(def_thread.io_engine_name, DEF_IO_ENGINE_NAME);
        def_thread.odirect = DEF_ODIRECT;
        def_thread.ratecycle = DEF_RATE_CYCLE;
        def_thread.sequential = DEF_SEQUENTIAL;
index 4e8a880329718fcbd43c6a24f646180c2d9187ac..92a03b0c34f812f03e1a3e8bcf2240180ac47560 100644 (file)
--- a/fio-io.c
+++ b/fio-io.c
@@ -33,7 +33,7 @@ static int fio_libaio_io_prep(struct thread_data *td, struct io_u *io_u,
 
 static struct io_u *fio_libaio_event(struct thread_data *td, int event)
 {
-       struct libaio_data *ld = td->aio_data;
+       struct libaio_data *ld = td->io_data;
 
        return ev_to_iou(ld->aio_events + event);
 }
@@ -41,7 +41,7 @@ static struct io_u *fio_libaio_event(struct thread_data *td, int event)
 static int fio_libaio_getevents(struct thread_data *td, int min, int max,
                                struct timespec *t)
 {
-       struct libaio_data *ld = td->aio_data;
+       struct libaio_data *ld = td->io_data;
 
        int r;
 
@@ -56,7 +56,7 @@ static int fio_libaio_getevents(struct thread_data *td, int min, int max,
 
 static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
 {
-       struct libaio_data *ld = td->aio_data;
+       struct libaio_data *ld = td->io_data;
        struct iocb *iocb = &io_u->iocb;
        int ret;
 
@@ -78,14 +78,14 @@ static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
 
 static int fio_libaio_cancel(struct thread_data *td, struct io_u *io_u)
 {
-       struct libaio_data *ld = td->aio_data;
+       struct libaio_data *ld = td->io_data;
 
        return io_cancel(ld->aio_ctx, &io_u->iocb, ld->aio_events);
 }
 
 static void fio_libaio_cleanup(struct thread_data *td)
 {
-       struct libaio_data *ld = td->aio_data;
+       struct libaio_data *ld = td->io_data;
 
        if (ld) {
                io_destroy(ld->aio_ctx);
@@ -93,7 +93,7 @@ static void fio_libaio_cleanup(struct thread_data *td)
                        free(ld->aio_events);
 
                free(ld);
-               td->aio_data = NULL;
+               td->io_data = NULL;
        }
 }
 
@@ -102,7 +102,7 @@ int fio_libaio_init(struct thread_data *td)
        struct libaio_data *ld = malloc(sizeof(*ld));
 
        memset(ld, 0, sizeof(*ld));
-       if (io_queue_init(td->aio_depth, &ld->aio_ctx)) {
+       if (io_queue_init(td->iodepth, &ld->aio_ctx)) {
                td_verror(td, errno);
                return 1;
        }
@@ -115,8 +115,8 @@ int fio_libaio_init(struct thread_data *td)
        td->io_cleanup = fio_libaio_cleanup;
        td->io_sync = fio_io_sync;
 
-       ld->aio_events = malloc(td->aio_depth * sizeof(struct io_event));
-       td->aio_data = ld;
+       ld->aio_events = malloc(td->iodepth * sizeof(struct io_event));
+       td->io_data = ld;
        return 0;
 }
 
@@ -162,7 +162,7 @@ static int fio_posixaio_prep(struct thread_data *td, struct io_u *io_u,
 static int fio_posixaio_getevents(struct thread_data *td, int min, int max,
                                  struct timespec *t)
 {
-       struct posixaio_data *pd = td->aio_data;
+       struct posixaio_data *pd = td->io_data;
        struct list_head *entry;
        int r;
 
@@ -196,7 +196,7 @@ restart:
 
 static struct io_u *fio_posixaio_event(struct thread_data *td, int event)
 {
-       struct posixaio_data *pd = td->aio_data;
+       struct posixaio_data *pd = td->io_data;
 
        return pd->aio_events[event];
 }
@@ -219,12 +219,12 @@ static int fio_posixaio_queue(struct thread_data *td, struct io_u *io_u)
 
 static void fio_posixaio_cleanup(struct thread_data *td)
 {
-       struct posixaio_data *pd = td->aio_data;
+       struct posixaio_data *pd = td->io_data;
 
        if (pd) {
                free(pd->aio_events);
                free(pd);
-               td->aio_data = NULL;
+               td->io_data = NULL;
        }
 }
 
@@ -232,7 +232,7 @@ int fio_posixaio_init(struct thread_data *td)
 {
        struct posixaio_data *pd = malloc(sizeof(*pd));
 
-       pd->aio_events = malloc(td->aio_depth * sizeof(struct io_u *));
+       pd->aio_events = malloc(td->iodepth * sizeof(struct io_u *));
 
        td->io_prep = fio_posixaio_prep;
        td->io_queue = fio_posixaio_queue;
@@ -242,7 +242,7 @@ int fio_posixaio_init(struct thread_data *td)
        td->io_cleanup = fio_posixaio_cleanup;
        td->io_sync = fio_io_sync;
 
-       td->aio_data = pd;
+       td->io_data = pd;
        return 0;
 }
 
@@ -270,7 +270,7 @@ static int fio_syncio_getevents(struct thread_data *td, int min, int max,
 
 static struct io_u *fio_syncio_event(struct thread_data *td, int event)
 {
-       struct syncio_data *sd = td->aio_data;
+       struct syncio_data *sd = td->io_data;
 
        return sd->last_io_u;
 }
@@ -290,7 +290,7 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u,
 
 static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
 {
-       struct syncio_data *sd = td->aio_data;
+       struct syncio_data *sd = td->io_data;
        int ret;
 
        if (io_u->ddir == DDIR_READ)
@@ -307,8 +307,10 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
 
 static void fio_syncio_cleanup(struct thread_data *td)
 {
-       free(td->aio_data);
-       td->aio_data = NULL;
+       if (td->io_data) {
+               free(td->io_data);
+               td->io_data = NULL;
+       }
 }
 
 int fio_syncio_init(struct thread_data *td)
@@ -324,14 +326,14 @@ int fio_syncio_init(struct thread_data *td)
        td->io_sync = fio_io_sync;
 
        sd->last_io_u = NULL;
-       td->aio_data = sd;
+       td->io_data = sd;
        return 0;
 }
 
 static int fio_mmapio_queue(struct thread_data *td, struct io_u *io_u)
 {
        unsigned long long real_off = io_u->offset - td->file_offset;
-       struct syncio_data *sd = td->aio_data;
+       struct syncio_data *sd = td->io_data;
 
        if (io_u->ddir == DDIR_READ)
                memcpy(io_u->buf, td->mmap + real_off, io_u->buflen);
@@ -368,6 +370,6 @@ int fio_mmapio_init(struct thread_data *td)
        td->io_sync = fio_mmapio_sync;
 
        sd->last_io_u = NULL;
-       td->aio_data = sd;
+       td->io_data = sd;
        return 0;
 }
diff --git a/fio.c b/fio.c
index 9e5c60f1b867ba0ea4fa77ccd8e5951f1f3d554c..7032e8d85eca9849cf14c5cad7f132c218d8557b 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -459,11 +459,18 @@ static int verify_io_u_crc32(struct verify_header *hdr, struct io_u *io_u)
 {
        unsigned char *p = (unsigned char *) io_u->buf;
        unsigned long c;
+       int ret;
 
        p += sizeof(*hdr);
        c = crc32(p, hdr->len - sizeof(*hdr));
+       ret = c != hdr->crc32;
 
-       return c != hdr->crc32;
+       if (ret) {
+               fprintf(stderr, "crc32: verify failed at %llu/%u\n", io_u->offset, io_u->buflen);
+               fprintf(stderr, "crc32: wanted %lx, got %lx\n", hdr->crc32, c);
+       }
+
+       return ret;
 }
 
 static int verify_io_u_md5(struct verify_header *hdr, struct io_u *io_u)
@@ -478,6 +485,7 @@ static int verify_io_u_md5(struct verify_header *hdr, struct io_u *io_u)
 
        ret = memcmp(hdr->md5_digest, md5_ctx.hash, sizeof(md5_ctx.hash));
        if (ret) {
+               fprintf(stderr, "md5: verify failed at %llu/%u\n", io_u->offset, io_u->buflen);
                hexdump(hdr->md5_digest, sizeof(hdr->md5_digest));
                hexdump(md5_ctx.hash, sizeof(md5_ctx.hash));
        }
@@ -896,7 +904,7 @@ static void do_io(struct thread_data *td)
 
                gettimeofday(&io_u->issue_time, NULL);
                add_slat_sample(td, mtime_since(&io_u->start_time, &io_u->issue_time));
-               if (td->cur_depth < td->aio_depth) {
+               if (td->cur_depth < td->iodepth) {
                        timeout = &ts;
                        min_evts = 0;
                } else {
@@ -1004,7 +1012,7 @@ static int init_io_u(struct thread_data *td)
        if (td->io_engine & FIO_SYNCIO)
                max_units = 1;
        else
-               max_units = td->aio_depth;
+               max_units = td->iodepth;
 
        td->orig_buffer_size = td->max_bs * max_units + MASK;
 
diff --git a/fio.h b/fio.h
index 442052021f4e72393ce8131028e1fe488c030456..b71c301c751c9c04b51f1604967ae319d27df5c0 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -133,6 +133,7 @@ struct thread_data {
        unsigned int stonewall;
        unsigned int numjobs;
        unsigned int use_thread;
+       unsigned int iodepth;
        os_cpu_mask_t cpumask;
 
        struct drand48_data bsrange_state;
@@ -142,7 +143,8 @@ struct thread_data {
 
        unsigned long long cur_off;
 
-       void *aio_data;
+       void *io_data;
+       char io_engine_name[16];
        int (*io_prep)(struct thread_data *, struct io_u *, int);
        int (*io_queue)(struct thread_data *, struct io_u *);
        int (*io_getevents)(struct thread_data *, int, int, struct timespec *);
@@ -150,7 +152,6 @@ struct thread_data {
        int (*io_cancel)(struct thread_data *, struct io_u *);
        void (*io_cleanup)(struct thread_data *);
        int (*io_sync)(struct thread_data *);
-       unsigned int aio_depth;
 
        unsigned int cur_depth;
        struct list_head io_u_freelist;