From: Jens Axboe Date: Mon, 9 May 2016 14:42:40 +0000 (-0600) Subject: filesetup: ensure that we align file starting offset X-Git-Tag: fio-2.10~36 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=c465cd14ca958dfdb87bb1998add722d62ae3691 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 --- 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; } /*