X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=a6a94ee16f64f34467563dcccdef6a640a75792d;hp=3b2ebd9c1ec70a3b3361bf15dabe7d56b19c979c;hb=6c3169f9cbe179a89bbbaa9de26e54711d027e99;hpb=e1933299ed9f1525e010e0489f0185c063d6d129 diff --git a/filesetup.c b/filesetup.c index 3b2ebd9c..a6a94ee1 100644 --- a/filesetup.c +++ b/filesetup.c @@ -15,6 +15,7 @@ #include "os/os.h" #include "hash.h" #include "lib/axmap.h" +#include "lib/memalign.h" #ifdef CONFIG_LINUX_FALLOCATE #include @@ -67,7 +68,7 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f) switch (td->o.fallocate_mode) { case FIO_FALLOCATE_NATIVE: r = native_fallocate(td, f); - if (r != 0) + if (r != 0 && errno != ENOSYS) log_err("fio: native_fallocate call failed: %s\n", strerror(errno)); break; @@ -100,7 +101,6 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f) log_err("fio: unknown fallocate mode: %d\n", td->o.fallocate_mode); assert(0); } - } /* @@ -147,6 +147,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f) flags |= O_CREAT; if (new_layout) flags |= O_TRUNC; + if (td->o.odirect) + flags |= OS_O_DIRECT; #ifdef WIN32 flags |= _O_BINARY; @@ -160,8 +162,14 @@ static int extend_file(struct thread_data *td, struct fio_file *f) if (err == ENOENT && !td->o.allow_create) log_err("fio: file creation disallowed by " "allow_file_create=0\n"); - else + else { + if (err == EINVAL && (flags & OS_O_DIRECT)) + log_err("fio: looks like your filesystem " + "does not support " + "direct=1/buffered=0\n"); + td_verror(td, err, "open"); + } return 1; } @@ -193,9 +201,9 @@ static int extend_file(struct thread_data *td, struct fio_file *f) if (bs > left) bs = left; - b = malloc(bs); + b = fio_memalign(page_size, bs); if (!b) { - td_verror(td, errno, "malloc"); + td_verror(td, errno, "fio_memalign"); goto err; } @@ -248,14 +256,14 @@ static int extend_file(struct thread_data *td, struct fio_file *f) f->io_size = f->real_file_size; } - free(b); + fio_memfree(b, bs); done: return 0; err: close(f->fd); f->fd = -1; if (b) - free(b); + fio_memfree(b, bs); return 1; }