Make sure io_u->buflen is aligned to the verify_interval
authorJosef Bacik <jbacik@fusionio.com>
Tue, 9 Jul 2013 00:32:50 +0000 (20:32 -0400)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Jul 2013 00:45:18 +0000 (18:45 -0600)
If you specify verify and bs_unaligned you can make fio blow up in interesting
ways.  This is because the verify code assumes that the buflens will be bs
aligned and therefore aligned to the verify_interval.  However this isn't the
case for bs_unaligned.  So to fix this make sure we are always aligned to
verify_interval.  This keeps us from reading off the end of our io buf, or worse
writing past the end of it and makes this fio job pass properly instead of
blowing up.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_u.c

diff --git a/io_u.c b/io_u.c
index 11672cf3c7ab6cd2fd29ce591a0586ac86a0fc09..865c58260d976b916cc2d526a84609c968ca5132 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -459,6 +459,10 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u)
                        }
                }
 
                        }
                }
 
+               if (td->o.do_verify && td->o.verify != VERIFY_NONE)
+                       buflen = (buflen + td->o.verify_interval - 1) &
+                               ~(td->o.verify_interval - 1);
+
                if (!td->o.bs_unaligned && is_power_of_2(minbs))
                        buflen = (buflen + minbs - 1) & ~(minbs - 1);
 
                if (!td->o.bs_unaligned && is_power_of_2(minbs))
                        buflen = (buflen + minbs - 1) & ~(minbs - 1);