static int root_warn;
+static inline void clear_error(struct thread_data *td)
+{
+ td->error = 0;
+ td->verror[0] = '\0';
+}
+
/*
* Leaves f->fd open on success, caller must close
*/
goto err;
}
}
- if (td->o.fill_device) {
+ if (td->o.fill_device && !td_write(td)) {
fio_file_clear_size_known(f);
if (td_io_get_file_size(td, f))
goto err;
}
f->real_file_size = bytes;
+ td->io_ops->close_file(td, f);
return 0;
err:
td->io_ops->close_file(td, f);
if (off == -1ULL)
off = f->file_offset;
+ if (len == -1ULL || off == -1ULL)
+ return 0;
+
dprint(FD_IO, "invalidate cache %s: %llu/%llu\n", f->file_name, off,
len);
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;
}
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);
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)
td->nr_open_files--;
fio_file_clear_open(f);
+ assert(f->fd == -1);
return ret;
}
log_err("fio: smalloc OOM\n");
assert(0);
}
+ __f->fd = -1;
if (f->file_name) {
__f->file_name = smalloc_strdup(f->file_name);