From ad21b61d27fd94b4c94a5e26842106d76ea54ba0 Mon Sep 17 00:00:00 2001 From: Horshack Date: Sun, 26 Feb 2023 10:12:05 -0500 Subject: [PATCH] Fix "verify bad_hdr rand_seed" for requeued I/Os On configurations that can cause I/Os to be internally requeued from FIO_Q_BUSY such as '--iodepth_batch_complete_max', and the workload has verify enabled, the subsequent verification of the data fails with a bad verify rand_seed because the pattern for the I/O is generated twice for the same I/O, causing the seed to become out of sync when the verify is later performed. The seed is generate twice because do_io() handles the I/O twice, first when it originates the I/O and again when it later gets the same I/O back from get_io_u() after it's is pulled from the requeue list, which is where the first submission landed due to the workload reaching '--iodepth_batch_complete_max'. The fix is for do_io() to track when it has generated the verify pattern for an I/O via a new io_u flag 'IO_U_F_PATTERN_DONE', avoiding a second call to populate_verify_io_u() when that flag is detected. Link: https://github.com/axboe/fio/issues/1526 Signed-off-by: Adam Horshack (horshack@live.com) --- backend.c | 7 +++++-- io_u.c | 2 +- io_u.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index f494c831..975ef489 100644 --- a/backend.c +++ b/backend.c @@ -1040,8 +1040,11 @@ static void do_io(struct thread_data *td, uint64_t *bytes_done) } if (io_u->ddir == DDIR_WRITE && td->flags & TD_F_DO_VERIFY) { - io_u->numberio = td->io_issues[io_u->ddir]; - populate_verify_io_u(td, io_u); + if (!(io_u->flags & IO_U_F_PATTERN_DONE)) { + io_u_set(td, io_u, IO_U_F_PATTERN_DONE); + io_u->numberio = td->io_issues[io_u->ddir]; + populate_verify_io_u(td, io_u); + } } ddir = io_u->ddir; diff --git a/io_u.c b/io_u.c index eb617e64..0b2754f1 100644 --- a/io_u.c +++ b/io_u.c @@ -2004,7 +2004,7 @@ static void io_completed(struct thread_data *td, struct io_u **io_u_ptr, dprint_io_u(io_u, "complete"); assert(io_u->flags & IO_U_F_FLIGHT); - io_u_clear(td, io_u, IO_U_F_FLIGHT | IO_U_F_BUSY_OK); + io_u_clear(td, io_u, IO_U_F_FLIGHT | IO_U_F_BUSY_OK | IO_U_F_PATTERN_DONE); /* * Mark IO ok to verify diff --git a/io_u.h b/io_u.h index 206e24fe..9b5d697d 100644 --- a/io_u.h +++ b/io_u.h @@ -21,6 +21,7 @@ enum { IO_U_F_TRIMMED = 1 << 5, IO_U_F_BARRIER = 1 << 6, IO_U_F_VER_LIST = 1 << 7, + IO_U_F_PATTERN_DONE = 1 << 8, }; /* -- 2.25.1