From: Jens Axboe Date: Wed, 28 May 2008 08:54:01 +0000 (+0200) Subject: Fix bug in put_file() and __file_invalidate_cache() X-Git-Tag: fio-1.21-rc3~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=a5fb461fdff86c442daeebbd28e07984be9f3807 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 --- 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;