filesetup: ensure that we align file starting offset
[fio.git] / filesetup.c
index 3fc14641ed7d34380d5f735006eb129ab0b7faf0..9c37ae57e24af13cc411a8f3f8398e06f5963626 100644 (file)
@@ -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;
 }
 
 /*