From ebb1415f729c123b8a13bcbd667bf4b4cc95b4d4 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 13 Mar 2007 14:42:15 +0100 Subject: [PATCH] Add 'fsync_on_close' option Signed-off-by: Jens Axboe --- HOWTO | 4 ++++ filesetup.c | 3 +++ fio.h | 1 + init.c | 7 +++++++ 4 files changed, 15 insertions(+) diff --git a/HOWTO b/HOWTO index 24beeb8a..ec4f3e21 100644 --- 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. diff --git a/filesetup.c b/filesetup.c index 4a5a665e..2a7e7cf5 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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 0fbf6ce8..7db30909 100644 --- 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 1cb38457..cf66ec0e 100644 --- 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, -- 2.25.1