Always make sure buffer sizes are aligned for allocation
authorJens Axboe <jens.axboe@oracle.com>
Tue, 20 Mar 2007 09:33:11 +0000 (10:33 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 20 Mar 2007 09:33:11 +0000 (10:33 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c

diff --git a/fio.c b/fio.c
index a416856..3c01156 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -603,8 +603,8 @@ 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
-               td->orig_buffer_size += page_mask;
+       else if (td->orig_buffer_size & page_mask)
+               td->orig_buffer_size = (td->orig_buffer_size + page_mask) & ~page_mask;
 
        if (allocate_io_mem(td))
                return 1;