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 24beeb8..ec4f3e2 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 4a5a665..2a7e7cf 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 0fbf6ce..7db3090 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 1cb3845..cf66ec0 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,