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 <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index 4cffd76..c98bf0c 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -234,6 +234,9 @@
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 @@
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;