From d87612ac34a3cf1ac94a9ddc0cada672b6541b3c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Jul 2007 15:06:57 +0200 Subject: [PATCH] malloc memory still needs to be aligned, if we are doing direct IO Signed-off-by: Jens Axboe --- fio.c | 2 -- memory.c | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fio.c b/fio.c index 94da6b48..ead118ec 100644 --- a/fio.c +++ b/fio.c @@ -629,8 +629,6 @@ static int init_io_u(struct thread_data *td) if (td->o.mem_type == MEM_SHMHUGE || td->o.mem_type == MEM_MMAPHUGE) td->orig_buffer_size = (td->orig_buffer_size + td->o.hugepage_size - 1) & ~(td->o.hugepage_size - 1); - else if (td->orig_buffer_size & page_mask) - td->orig_buffer_size = (td->orig_buffer_size + page_mask) & ~page_mask; if (td->orig_buffer_size != (size_t) td->orig_buffer_size) { log_err("fio: IO memory too large. Reduce max_bs or iodepth\n"); diff --git a/memory.c b/memory.c index 46eb852a..c147229e 100644 --- a/memory.c +++ b/memory.c @@ -126,7 +126,12 @@ static int alloc_mem_mmap(struct thread_data *td) static int alloc_mem_malloc(struct thread_data *td) { - td->orig_buffer = malloc(td->orig_buffer_size); + unsigned int bsize = td->orig_buffer_size; + + if (td->o.odirect) + bsize += page_mask; + + td->orig_buffer = malloc(bsize); if (td->orig_buffer) return 0; -- 2.25.1