From 793b868671d14f9a3e4fa76ac129545987084a8d Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Mon, 3 Oct 2022 10:42:41 -0700 Subject: [PATCH] randtrimwrite: fix corner case with variable block sizes When we have variable block sizes it's possible to finish a trim + write pair and then have the next (smaller length) trim operation have a different start offset but the same end offset as the previous pair of trim and write operations. This would fool fio into believing that it had already completed a trim + write pair when it actually completed only the trim. Resolve this problem by comparing start offsets instead of end offsets. Signed-off-by: Vincent Fu --- io_u.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io_u.c b/io_u.c index 2c37720f..91f1a358 100644 --- a/io_u.c +++ b/io_u.c @@ -529,7 +529,7 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u, */ if (td_randtrimwrite(td) && ddir == DDIR_TRIM && f->last_start[DDIR_TRIM] == io_u->offset) - f->last_pos[DDIR_WRITE]--; + f->last_start[DDIR_WRITE]--; io_u->verify_offset = io_u->offset; return 0; @@ -798,7 +798,7 @@ static void set_rw_ddir(struct thread_data *td, struct io_u *io_u) if (td_trimwrite(td)) { struct fio_file *f = io_u->file; - if (f->last_pos[DDIR_WRITE] == f->last_pos[DDIR_TRIM]) + if (f->last_start[DDIR_WRITE] == f->last_start[DDIR_TRIM]) ddir = DDIR_TRIM; else ddir = DDIR_WRITE; -- 2.25.1