return 1;
}
+#ifdef FIO_HAVE_FALLOCATE
+ if (td->o.fallocate && !td->o.fill_device) {
+ dprint(FD_FILE, "fallocate file %s size %llu\n", f->file_name,
+ f->real_file_size);
+
+ r = posix_fallocate(f->fd, 0, f->real_file_size);
+ if (r < 0) {
+ log_err("fio: posix_fallocate fails: %s\n",
+ strerror(-r));
+ }
+ }
+#endif
+
if (!new_layout)
goto done;
td_verror(td, errno, "ftruncate");
goto err;
}
-
-#ifdef FIO_HAVE_FALLOCATE
- dprint(FD_FILE, "fallocate file %s, size %llu\n", f->file_name,
- f->real_file_size);
- r = posix_fallocate(f->fd, 0, f->real_file_size);
- if (r < 0) {
- log_err("fio: posix_fallocate fails: %s\n",
- strerror(-r));
- }
-#endif
}
b = malloc(td->o.max_bs[DDIR_WRITE]);
unsigned int bs;
char *b;
+ if (td->io_ops->flags & FIO_PIPEIO)
+ return 0;
+
if (!fio_file_open(f)) {
if (td->io_ops->open_file(td, f)) {
log_err("fio: cannot pre-read, failed to open file\n");
/*
* FIXME: add blockdev flushing too
*/
- if (f->mmap_ptr)
+ if (f->mmap_ptr) {
ret = madvise(f->mmap_ptr, f->mmap_sz, MADV_DONTNEED);
- else if (f->filetype == FIO_TYPE_FILE) {
+#ifdef FIO_MADV_FREE
+ (void) madvise(f->mmap_ptr, f->mmap_sz, FIO_MADV_FREE);
+#endif
+ } else if (f->filetype == FIO_TYPE_FILE) {
ret = fadvise(f->fd, off, len, POSIX_FADV_DONTNEED);
} else if (f->filetype == FIO_TYPE_BD) {
ret = blockdev_invalidate_cache(f->fd);
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;
}
temp_stall_ts = 1;
if (!terse_output)
log_info("%s: Laying out IO file(s) (%u file(s) /"
- " %LuMiB)\n", td->o.name, need_extend,
+ " %LuMB)\n", td->o.name, need_extend,
extend_size >> 20);
for_each_file(td, f, i) {
fio_file_clear_extend(f);
if (!td->o.fill_device) {
old_len = f->real_file_size;
- extend_len = f->io_size + f->file_offset - old_len;
+ extend_len = f->io_size + f->file_offset -
+ old_len;
}
f->real_file_size = (f->io_size + f->file_offset);
err = extend_file(td, f);
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)
else
f->filetype = FIO_TYPE_FILE;
- if (!lstat(f->file_name, &sb)) {
+ if (!stat(f->file_name, &sb)) {
if (S_ISBLK(sb.st_mode))
f->filetype = FIO_TYPE_BD;
else if (S_ISCHR(sb.st_mode))
log_err("fio: smalloc OOM\n");
assert(0);
}
-
+
f->fd = -1;
if (td->files_size <= td->files_index) {
log_err("fio: smalloc OOM\n");
assert(0);
}
-
+
get_file_type(f);
switch (td->o.file_lock_mode) {
assert(0);
}
__f->fd = -1;
-
+
if (f->file_name) {
__f->file_name = smalloc_strdup(f->file_name);
if (!__f->file_name) {
log_err("fio: smalloc OOM\n");
assert(0);
}
-
+
__f->filetype = f->filetype;
}