randtrimwrite: fix corner case with variable block sizes
authorVincent Fu <vincent.fu@samsung.com>
Mon, 3 Oct 2022 17:42:41 +0000 (10:42 -0700)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 3 Oct 2022 21:36:57 +0000 (17:36 -0400)
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 <vincent.fu@samsung.com>
io_u.c

diff --git a/io_u.c b/io_u.c
index 2c37720f05b6873c6b35c0747b3b67bf80e0099f..91f1a3584da4761b43e066d431b9c16f8bb64f69 100644 (file)
--- 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;