Add 'fsync_on_close' option
authorJens Axboe <jens.axboe@oracle.com>
Tue, 13 Mar 2007 13:42:15 +0000 (14:42 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 13 Mar 2007 13:42:15 +0000 (14:42 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
HOWTO
filesetup.c
fio.h
init.c

diff --git a/HOWTO b/HOWTO
index 24beeb8adbd5fa1363d7305c279b6c0d288275c8..ec4f3e21170a49a0cbae4a26571739f36c1e0d6a 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -358,6 +358,10 @@ overwrite=bool     If writing to a file, setup the file first and do overwrites.
 
 end_fsync=bool If true, fsync file contents when the job exits.
 
+fsync_on_close=bool    If true, fio will fsync() a dirty file on close.
+               This differs from end_fsync in that it will happen on every
+               file close, not just at the end of the job.
+
 rwmixcycle=int Value in milliseconds describing how often to switch between
                reads and writes for a mixed workload. The default is
                500 msecs.
index 4a5a665ec0dd630fa42563be6752b3f634302d5c..2a7e7cf55e33e31e9bd1e6a23eb260d1ee895c9b 100644 (file)
@@ -465,6 +465,9 @@ void put_file(struct thread_data *td, struct fio_file *f)
        if (--f->references)
                return;
 
+       if (should_fsync(td) && td->fsync_on_close)
+               fsync(f->fd);
+
        if (td->io_ops->close_file)
                td->io_ops->close_file(td, f);
        td->nr_open_files--;
diff --git a/fio.h b/fio.h
index 0fbf6ce8b45d2efa68cf4b892b1af71e6ac00462..7db30909e563a3b51ab683bcd9ce9016e5001485 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -357,6 +357,7 @@ struct thread_data {
        unsigned int write_bw_log;
        unsigned int norandommap;
        unsigned int bs_unaligned;
+       unsigned int fsync_on_close;
 
        unsigned int bs[2];
        unsigned int min_bs[2];
diff --git a/init.c b/init.c
index 1cb384570200d5d575201de47da48b1bc08ef92b..cf66ec0e8ee9875ded959cb616be5c633c4e13fc 100644 (file)
--- a/init.c
+++ b/init.c
@@ -499,6 +499,13 @@ static struct fio_option options[] = {
                .help   = "Include fsync at the end of job",
                .def    = "0",
        },
+       {
+               .name   = "fsync_on_close",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(fsync_on_close),
+               .help   = "fsync files on close",
+               .def    = "0",
+       },
        {
                .name   = "unlink",
                .type   = FIO_OPT_BOOL,