The error path doesn't close already opened files. Also set
O_SYNC regardless of file type.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
if (td->odirect)
flags |= OS_O_DIRECT;
if (td->odirect)
flags |= OS_O_DIRECT;
+ if (td->sync_io)
+ flags |= O_SYNC;
if (td_write(td) || td_rw(td)) {
if (td_write(td) || td_rw(td)) {
if (td->filetype == FIO_TYPE_FILE) {
if (!td->overwrite)
flags |= O_TRUNC;
flags |= O_CREAT;
}
if (td->filetype == FIO_TYPE_FILE) {
if (!td->overwrite)
flags |= O_TRUNC;
flags |= O_CREAT;
}
- if (td->sync_io)
- flags |= O_SYNC;
-
- flags |= O_RDWR;
f->fd = open(f->file_name, flags, 0600);
} else {
f->fd = open(f->file_name, flags, 0600);
} else {
+ if (!err)
+ return 0;
+
+ for_each_file(td, f, i) {
+ if (f->fd != -1) {
+ close(f->fd);
+ f->fd = -1;
+ }
+ }
+