Add create_on_open option
authorJens Axboe <jens.axboe@oracle.com>
Wed, 4 Mar 2009 11:53:13 +0000 (12:53 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 4 Mar 2009 11:53:13 +0000 (12:53 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
 Please enter the commit message for your changes. Lines starting

HOWTO
filesetup.c
fio.h
options.c

diff --git a/HOWTO b/HOWTO
index b8a7dd74bae68d207466c6a672da818f5238215a..2cfe36954bbf1defe8bdf5868828685e0e0027b5 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -693,6 +693,9 @@ create_serialize=bool       If true, serialize the file creating for the jobs.
 create_fsync=bool      fsync the data file after creation. This is the
                        default.
 
+create_on_open=bool    Don't pre-setup the files for IO, just create open()
+                       when it's time to do IO to that file.
+
 unlink=bool    Unlink the job files when done. Not the default, as repeated
                runs of that job would then waste time recreating the file
                set again and again.
index cfcfa9ae5e5f02398e25cbf49e14a9f033135686..088b77c3f566df9e7490000747de71e310c6ddfd 100644 (file)
@@ -314,6 +314,8 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
                flags |= O_SYNC;
        if (f->filetype != FIO_TYPE_FILE)
                flags |= FIO_O_NOATIME;
+       if (td->o.create_on_open)
+               flags |= O_CREAT;
 
 open_again:
        if (td_write(td)) {
@@ -534,8 +536,11 @@ int setup_files(struct thread_data *td)
                if (f->filetype == FIO_TYPE_FILE &&
                    (f->io_size + f->file_offset) > f->real_file_size &&
                    !(td->io_ops->flags & FIO_DISKLESSIO)) {
-                       need_extend++;
-                       extend_size += (f->io_size + f->file_offset);
+                       if (!td->o.create_on_open) {
+                               need_extend++;
+                               extend_size += (f->io_size + f->file_offset);
+                       } else
+                               f->real_file_size = f->io_size + f->file_offset;
                        f->flags |= FIO_FILE_EXTEND;
                }
        }
diff --git a/fio.h b/fio.h
index 11338eb7496e64d3207eb240dd3182b154b241ad..dd09ceec3a4bcf9570dc308c2d521cf42f2a9431 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -443,6 +443,7 @@ struct thread_options {
        unsigned int invalidate_cache;
        unsigned int create_serialize;
        unsigned int create_fsync;
+       unsigned int create_on_open;
        unsigned int end_fsync;
        unsigned int sync_io;
        unsigned int verify;
index cec7bb79d2422b19f79df258b784c0ab033fbc4b..73815bb0d1d4a6d74d9984b54b98b37ec3b55921 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1289,6 +1289,13 @@ static struct fio_option options[] = {
                .help   = "Fsync file after creation",
                .def    = "1",
        },
+       {
+               .name   = "create_on_open",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(create_on_open),
+               .help   = "Create files when they are opened for IO",
+               .def    = "0",
+       },
        {
                .name   = "cpuload",
                .type   = FIO_OPT_INT,