randtrimwrite: fix offsets for corner case
authorVincent Fu <vincent.fu@samsung.com>
Fri, 30 Sep 2022 23:54:57 +0000 (16:54 -0700)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 3 Oct 2022 21:36:57 +0000 (17:36 -0400)
commit5e0863daaad1826a6b429e961d9ee83edcaf77ba
treebe973127797c1498d793313b409f42991dc3e413
parentc37183f8a161df252b7b05e9be9c4e0665106146
randtrimwrite: fix offsets for corner case

For randtrimwrite, we decide whether to issue a trim or a write based on
whether the end offsets for the most recent trim and write commands
match.  If they don't match that means we just issued a new trim and the
next operation should be a write. If they *do* match that means we just
completed a trim + write pair and the next command should be a trim.

This works fine for sequential workloads but for random workloads it's
possible to complete a trim + write pair and then have the randomly
generated offset for the next trim command match the previous offset. If
that happens we need to alter the offset for the last write operation in
order to ensure that we issue a write operation the next time through.

It feels dirty to change the meaning of last_pos[DDIR_WRITE] in this way
but hopefully the long comment in the code will be sufficient warning.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
io_u.c