Skip to content

backend.c: fix async ioengine prep/queue direction mismatch in experimental_verify - #2007

Merged
axboe merged 1 commit into
axboe:masterfrom
yehormalikov:fix-experimental-verify-iocb-issue
Oct 31, 2025
Merged

axboe merged 1 commit into
axboe:masterfrom
yehormalikov:fix-experimental-verify-iocb-issue

Conversation

@yehormalikov

@yehormalikov yehormalikov commented Oct 29, 2025 •

Copy link
Copy Markdown
Contributor

When using --experimental_verify=1 with async ioengines like libaio, there was a critical mismatch between the I/O direction set during prep and the direction used when queuing operations.

The issue occurred because get_io_u() calls td_io_prep() which configures ioengine structures (like iocb) for WRITE operations, but then io_u->ddir is changed from WRITE to READ for verification after prep completes. This left the iocb configured for writes while fio's accounting expected reads, causing incorrect I/O statistics and potential data integrity issues.

Fix by calling td_io_prep() again after changing the data direction in both TRIM and WRITE cases, ensuring async ioengines re-sync their internal structures with the final I/O direction.

Fixes #1955

@vincentkfu

Copy link
Copy Markdown
Collaborator

To the commit message please add

Fixes: https://github.com/axboe/fio/issues/1955

@vincentkfu

Copy link
Copy Markdown
Collaborator

Quickly scanning through the prep hooks for all of the built-in ioengines suggests that repeated calls to prep do no harm and indeed will resolve the issue in question.

The only problem I found is with the libhdfs ioengine which selects file open flags based on data direction. This pattern already may break experimental_verify, so this patch does no harm.

@yehormalikov
yehormalikov force-pushed the fix-experimental-verify-iocb-issue branch from 7a387f8 to d50f967 Compare October 30, 2025 15:16
@sitsofe

sitsofe commented Oct 30, 2025

Copy link
Copy Markdown
Collaborator

This looks like a far more elegant solution than the one I was suggesting. The logs will be a little confusing because you'll see multiple preps of the same I/O but it keeps all the extra checks and work out of the main I/O path which is a win. My only note is: @yehormalikov that it looks like your committer address and author address are different - is this intentional?

…mental verify

When using --experimental_verify=1 with async ioengines like libaio,
there was a critical mismatch between the I/O direction set during
prep and the direction used when queuing operations.

The issue occurred because get_io_u() calls td_io_prep() which
configures ioengine structures (like iocb) for WRITE operations,
but then io_u->ddir is changed from WRITE to READ for verification
after prep completes. This left the iocb configured for writes while
fio's accounting expected reads, causing incorrect I/O statistics
and potential data integrity issues.

Fix by calling td_io_prep() again after changing the data direction
in both TRIM and WRITE cases, ensuring async ioengines re-sync their
internal structures with the final I/O direction.

Fixes: axboe#1955

Signed-off-by: Yehor Malikov <Yehor.Malikov@solidigmtechnology.com>
@yehormalikov
yehormalikov force-pushed the fix-experimental-verify-iocb-issue branch from d50f967 to 1492830 Compare October 30, 2025 21:23
@yehormalikov

Copy link
Copy Markdown
Contributor Author

This looks like a far more elegant solution than the one I was suggesting. The logs will be a little confusing because you'll see multiple preps of the same I/O but it keeps all the extra checks and work out of the main I/O path which is a win. My only note is: @yehormalikov that it looks like your committer address and author address are different - is this intentional?

Thank you for attention. Have already changed committer address

@axboe
axboe merged commit 71d47f4 into axboe:master Oct 31, 2025
@yehormalikov
yehormalikov deleted the fix-experimental-verify-iocb-issue branch November 3, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using libaio/io_uring engine and executing experimental_verify FIO generates writes instead of reads

4 participants

⌂ 换网址