X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=a0a4b80d33483d70c00db8fe56882ce073136286;hp=57928133369cdd520a1b89052cbc9362b773ca78;hb=2be3eec330360e6735fb4e7d70907e11eaa346f8;hpb=1621031e8a7cbb91afad124da405fc4eabda764f diff --git a/filesetup.c b/filesetup.c index 57928133..a0a4b80d 100644 --- a/filesetup.c +++ b/filesetup.c @@ -246,6 +246,7 @@ static int bdev_size(struct thread_data *td, struct fio_file *f) } f->real_file_size = bytes; + td->io_ops->close_file(td, f); return 0; err: td->io_ops->close_file(td, f); @@ -435,7 +436,7 @@ open_again: char buf[FIO_VERROR_SIZE]; int __e = errno; - if (errno == EPERM && (flags & FIO_O_NOATIME)) { + if (__e == EPERM && (flags & FIO_O_NOATIME)) { flags &= ~FIO_O_NOATIME; goto open_again; } @@ -709,8 +710,10 @@ void close_files(struct thread_data *td) struct fio_file *f; unsigned int i; - for_each_file(td, f, i) - td_io_close_file(td, f); + for_each_file(td, f, i) { + if (fio_file_open(f)) + td_io_close_file(td, f); + } } void close_and_free_files(struct thread_data *td) @@ -726,7 +729,9 @@ void close_and_free_files(struct thread_data *td) unlink(f->file_name); } - td_io_close_file(td, f); + if (fio_file_open(f)) + td_io_close_file(td, f); + remove_file_hash(f); sfree(f->file_name); @@ -847,8 +852,10 @@ int put_file(struct thread_data *td, struct fio_file *f) dprint(FD_FILE, "put file %s, ref=%d\n", f->file_name, f->references); - if (!fio_file_open(f)) + if (!fio_file_open(f)) { + assert(f->fd == -1); return 0; + } assert(f->references); if (--f->references) @@ -865,6 +872,7 @@ int put_file(struct thread_data *td, struct fio_file *f) td->nr_open_files--; fio_file_clear_open(f); + assert(f->fd == -1); return ret; } @@ -1004,6 +1012,7 @@ void dup_files(struct thread_data *td, struct thread_data *org) log_err("fio: smalloc OOM\n"); assert(0); } + __f->fd = -1; if (f->file_name) { __f->file_name = smalloc_strdup(f->file_name);