From c465cd14ca958dfdb87bb1998add722d62ae3691 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 9 May 2016 08:42:40 -0600 Subject: [PATCH] filesetup: ensure that we align file starting offset If --offset=xx is given, and xx isn't a multiple of the block size, then align it if we're doing O_DIRECT IO. Signed-off-by: Jens Axboe --- filesetup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/filesetup.c b/filesetup.c index 3fc14641..9c37ae57 100644 --- a/filesetup.c +++ b/filesetup.c @@ -761,12 +761,16 @@ static unsigned long long get_fs_free_counts(struct thread_data *td) uint64_t get_start_offset(struct thread_data *td, struct fio_file *f) { struct thread_options *o = &td->o; + uint64_t offset; if (o->file_append && f->filetype == FIO_TYPE_FILE) return f->real_file_size; - return td->o.start_offset + - td->subjob_number * td->o.offset_increment; + offset = td->o.start_offset + td->subjob_number * td->o.offset_increment; + if (offset % td_max_bs(td)) + offset -= (offset % td_max_bs(td)); + + return offset; } /* -- 2.25.1