From a5fb461fdff86c442daeebbd28e07984be9f3807 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 28 May 2008 10:54:01 +0200 Subject: [PATCH] Fix bug in put_file() and __file_invalidate_cache() - put_file() has bad logic in detecting fsync() error, only set ret to f_ret if f_ret indicates failure. - Check for open file in __file_invalidate_cache() Signed-off-by: Jens Axboe --- filesetup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/filesetup.c b/filesetup.c index 4cffd766..c98bf0c0 100644 --- a/filesetup.c +++ b/filesetup.c @@ -234,6 +234,9 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, int file_invalidate_cache(struct thread_data *td, struct fio_file *f) { + if (!(f->flags & FIO_FILE_OPEN)) + return 0; + return __file_invalidate_cache(td, f, -1, -1); } @@ -762,7 +765,7 @@ int put_file(struct thread_data *td, struct fio_file *f) ret = td->io_ops->close_file(td, f); if (!ret) - ret = !f_ret; + ret = f_ret; td->nr_open_files--; f->flags &= ~FIO_FILE_OPEN; -- 2.25.1