From 61ee0f86fc428db9403f0c1123e4c2f125152466 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 11 Feb 2013 11:26:55 +0100 Subject: [PATCH 1/1] Handle end_fsync if a file is closed Should not happen, but better be careful since it could have an impact on data integrity. Additionally, add a log_err() error if we do fail it. Signed-off-by: Jens Axboe --- backend.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/backend.c b/backend.c index 6461fff7..d1fe9641 100644 --- a/backend.c +++ b/backend.c @@ -322,6 +322,21 @@ requeue: return 0; } +static int fio_file_fsync(struct thread_data *td, struct fio_file *f) +{ + int ret; + + if (fio_file_open(f)) + return fio_io_sync(td, f); + + if (td_io_open_file(td, f)) + return 1; + + ret = fio_io_sync(td, f); + td_io_close_file(td, f); + return ret; +} + static inline void __update_tv_cache(struct thread_data *td) { fio_gettime(&td->tv_cache, NULL); @@ -822,9 +837,11 @@ sync_done: td_set_runstate(td, TD_FSYNCING); for_each_file(td, f, i) { - if (!fio_file_open(f)) + if (!fio_file_fsync(td, f)) continue; - fio_io_sync(td, f); + + log_err("fio: end_fsync failed for file %s\n", + f->file_name); } } } else -- 2.25.1