X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=d8135ef08342ce05b0201fdf2fb8e8a8760afc3c;hp=4cd62d68a3fae3bd16cecd857b3e0468abbac3be;hb=9467b77c9ac41f09a93a8a984d21b94c1f7d515e;hpb=e1161c325f7866bae879e686d1c673ca32ab09ae diff --git a/filesetup.c b/filesetup.c index 4cd62d68..d8135ef0 100644 --- a/filesetup.c +++ b/filesetup.c @@ -113,8 +113,7 @@ static int create_files(struct thread_data *td) for_each_file(td, f, i) { int file_there = !file_ok(td, f); - if (file_there && td->ddir == DDIR_WRITE && - !td->overwrite) { + if (file_there && td_write(td) && !td->overwrite) { unlink(f->file_name); file_there = 0; } @@ -240,11 +239,13 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f) */ if (td->io_ops->flags & FIO_MMAPIO) ret = madvise(f->mmap, f->file_size, MADV_DONTNEED); - else if (td->filetype == FIO_TYPE_FILE) - ret = fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_DONTNEED); - else if (td->filetype == FIO_TYPE_BD) - ret = blockdev_invalidate_cache(f->fd); - else if (td->filetype == FIO_TYPE_CHAR) + else if (td->filetype == FIO_TYPE_FILE) { + if (!td->odirect) + ret = fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_DONTNEED); + } else if (td->filetype == FIO_TYPE_BD) { + if (!td->odirect) + ret = blockdev_invalidate_cache(f->fd); + } else if (td->filetype == FIO_TYPE_CHAR) ret = 0; if (ret < 0) { @@ -252,7 +253,7 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f) return 1; } - return 0; + return ret; } static int __setup_file_mmap(struct thread_data *td, struct fio_file *f) @@ -279,7 +280,7 @@ static int __setup_file_mmap(struct thread_data *td, struct fio_file *f) if (td->invalidate_cache && file_invalidate_cache(td, f)) return 1; - if (td->sequential) { + if (!td_random(td)) { if (madvise(f->mmap, f->file_size, MADV_SEQUENTIAL) < 0) { td_verror(td, errno, "madvise"); return 1; @@ -313,7 +314,7 @@ static int __setup_file_plain(struct thread_data *td, struct fio_file *f) if (td->invalidate_cache && file_invalidate_cache(td, f)) return 1; - if (td->sequential) { + if (!td_random(td)) { if (fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_SEQUENTIAL) < 0) { td_verror(td, errno, "fadvise"); return 1; @@ -387,7 +388,7 @@ static int setup_file(struct thread_data *td, struct fio_file *f) td_verror(td, __e, "open"); if (__e == EINVAL && td->odirect) - log_err("fio: destinations does not support O_DIRECT\n"); + log_err("fio: destination does not support O_DIRECT\n"); return 1; }