io_u: fix offset calculation in randtrimwrite
authorJungwon Lee <jjung1.lee@samsung.com>
Thu, 26 Jun 2025 05:10:25 +0000 (14:10 +0900)
committerMinwoo Im <minwoo.im@samsung.com>
Sun, 29 Jun 2025 23:19:37 +0000 (08:19 +0900)
commit544be3b143564a13a29b5bd36f681c823aa32054
tree14a475a0a1e993f08cd5e90edf29d58cb3ad2794
parent7037b833e175aae32900b73bf597aad08c1d8472
io_u: fix offset calculation in randtrimwrite

For randtrimwrite, we should issue trim + write pair and those offsets
should be same.

This works good for cases without `offset=` option, but not for cases
with `offset=` option.  In cases with `offset=` option, it's necessary
to subtract `file_offset`, which is value of `offset=` option, when
calculationg offset of write.

This is a bit confusing because `last_start` is an actual offset that
has already been issued through trim.  However, `last_start` is the
value to which `file_offset` is added.  Since we add back `file_offset`
later on after calling `get_next_block` in `get_next_offset`,
`last_start` should be adjusted.

Signed-off-by: Jungwon Lee <jjung1.lee@samsung.com>
Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
[+ updated commit title]
io_u.c