X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fmmap.c;h=d4299143ecccb02cc17c43147a09b8e873dea086;hp=d32fe969832009d871cb9956b0950ef6413d2a29;hb=e1161c325f7866bae879e686d1c673ca32ab09ae;hpb=36167d82e5f49dee91c6d2cd426068edee90e36f diff --git a/engines/mmap.c b/engines/mmap.c index d32fe969..d4299143 100644 --- a/engines/mmap.c +++ b/engines/mmap.c @@ -37,15 +37,38 @@ static int fio_mmapio_queue(struct thread_data *td, struct io_u *io_u) } if (io_u->error) - td_verror(td, io_u->error); + td_verror(td, io_u->error, "sync"); return FIO_Q_COMPLETED; } +static int fio_mmapio_init(struct thread_data *td) +{ + struct fio_file *f; + int i; + + if (td->ddir == DDIR_READ && !td_rw(td)) + return 0; + + /* + * We need to truncate the files to the right size, if + * we are writing to it. + */ + for_each_file(td, f, i) { + if (ftruncate(f->fd, f->file_size) < 0) { + td_verror(td, errno, "ftruncate"); + return 1; + } + } + + return 0; +} + static struct ioengine_ops ioengine = { .name = "mmap", .version = FIO_IOOPS_VERSION, .queue = fio_mmapio_queue, + .init = fio_mmapio_init, .flags = FIO_SYNCIO | FIO_MMAPIO, };