Put the ->real_file_size handling into fio
authorJens Axboe <jens.axboe@oracle.com>
Thu, 12 Apr 2007 11:02:38 +0000 (13:02 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 12 Apr 2007 11:02:38 +0000 (13:02 +0200)
Then we can remove it from the io engines, where the disk-less IO
engines provided a ->setup() hook just to set that.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
engines/cpu.c
engines/net.c
engines/null.c
filesetup.c
init.c

index dd69cedeaff7ee438fb284198dc2b91ad5f2b785..14ad9717aa5fbd024a7e9f286a36fd79542c6365 100644 (file)
@@ -13,21 +13,6 @@ static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u)
        return FIO_Q_COMPLETED;
 }
 
-static int fio_cpuio_setup(struct thread_data fio_unused *td)
-{
-       struct fio_file *f;
-       unsigned int i;
-
-       for_each_file(td, f, i) {
-               if (td->o.size)
-                       f->real_file_size = td->o.size / td->o.nr_files;
-               else
-                       f->real_file_size = -1ULL;
-       }
-
-       return 0;
-}
-
 static int fio_cpuio_init(struct thread_data *td)
 {
        struct thread_options *o = &td->o;
@@ -62,7 +47,6 @@ static struct ioengine_ops ioengine = {
        .version        = FIO_IOOPS_VERSION,
        .queue          = fio_cpuio_queue,
        .init           = fio_cpuio_init,
-       .setup          = fio_cpuio_setup,
        .open_file      = fio_cpuio_open,
        .flags          = FIO_SYNCIO | FIO_DISKLESSIO,
 };
index cc707db972178a5cee9c8815d15ce6f97d963f16..2b48b0abb56c41ab69e1ec50928664e91d478e21 100644 (file)
@@ -269,8 +269,6 @@ static void fio_netio_cleanup(struct thread_data *td)
 static int fio_netio_setup(struct thread_data *td)
 {
        struct netio_data *nd;
-       struct fio_file *f;
-       unsigned int i;
 
        if (!td->io_ops->data) {
                nd = malloc(sizeof(*nd));;
@@ -278,13 +276,6 @@ static int fio_netio_setup(struct thread_data *td)
                memset(nd, 0, sizeof(*nd));
                nd->listenfd = -1;
                td->io_ops->data = nd;
-
-               for_each_file(td, f, i) {
-                       if (td->o.size)
-                               f->real_file_size = td->o.size / td->o.nr_files;
-                       else
-                               f->real_file_size = -1ULL;
-               }
        }
 
        return 0;
index 318952c2c00d492bed40486c05a12d3300a6a075..823d40def272c820a2d635b994483af94a61b014 100644 (file)
@@ -65,21 +65,6 @@ static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
        return FIO_Q_QUEUED;
 }
 
-static int fio_null_setup(struct thread_data *td)
-{
-       struct fio_file *f;
-       unsigned int i;
-
-       for_each_file(td, f, i) {
-               if (td->o.size)
-                       f->real_file_size = td->o.size / td->o.nr_files;
-               else
-                       f->real_file_size = -1ULL;
-       }
-
-       return 0;
-}
-
 static int fio_null_open(struct thread_data fio_unused *td,
                         struct fio_file fio_unused *f)
 {
@@ -117,7 +102,6 @@ static int fio_null_init(struct thread_data *td)
 static struct ioengine_ops ioengine = {
        .name           = "null",
        .version        = FIO_IOOPS_VERSION,
-       .setup          = fio_null_setup,
        .queue          = fio_null_queue,
        .commit         = fio_null_commit,
        .getevents      = fio_null_getevents,
index 62d048ead5065763262e3a02100c6680cbb10f2b..bd975d82470ce4dc7bedb82a5f1cbd151e5574c1 100644 (file)
@@ -288,8 +288,10 @@ static int get_file_sizes(struct thread_data *td)
                                err = 1;
                        }
                        clear_error(td);
-               } else
-                       td->io_ops->close_file(td, f);
+               } else {
+                       if (td->io_ops->close_file)
+                               td->io_ops->close_file(td, f);
+               }
 
                if (f->real_file_size == -1ULL && td->o.size)
                        f->real_file_size = td->o.size / td->o.nr_files;
@@ -499,6 +501,12 @@ void add_file(struct thread_data *td, const char *fname)
        memset(f, 0, sizeof(*f));
        f->fd = -1;
 
+       /*
+        * init function, io engine may not be loaded yet
+        */
+       if (td->io_ops && (td->io_ops->flags & FIO_DISKLESSIO))
+               f->real_file_size = -1ULL;
+
        if (td->o.directory)
                len = sprintf(file_name, "%s/", td->o.directory);
 
diff --git a/init.c b/init.c
index 0151c9bd4b2979626e17c592c76938c9e2b68b35..bc33f4fea34cb7a0dc2d122208c21efdaf654136 100644 (file)
--- a/init.c
+++ b/init.c
@@ -427,6 +427,13 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (fixup_options(td))
                goto err;
 
+       if (td->io_ops->flags & FIO_DISKLESSIO) {
+               struct fio_file *f;
+
+               for_each_file(td, f, i)
+                       f->real_file_size = -1ULL;
+       }
+
        td->mutex = fio_sem_init(0);
 
        td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX;