Skip to content

Conversation

tonyhutter
Copy link
Contributor

Motivation and Context

Fixes: #17761

Description

The zvol blk-mq codepaths would erroneously send FLUSH and TRIM commands down the read codepath, rather than write. This fixes the issue, and updates the zvol_misc_fua test to verify that sync writes are actually happening.

How Has This Been Tested?

Updated test case. Ran test case on master and saw it fail to send enough sync writes to the log device with blk-mq. Re-ran with this PR and saw it send the expected number of sync writes to log with blk-mq.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Sep 25, 2025
@tonyhutter
Copy link
Contributor Author

I believe this is ready to go. Reviewers - please take a look when you get a chance.

@amotin
Copy link
Member

amotin commented Sep 26, 2025

Considering io_data_dir() is used in only one place, I'd probably prefer it inlined and be brought in sync with the surrounding code. For example, it explicitly verifies for op_is_discard(), but not for io_is_secure_erase(). Though both are probably covered by op_is_write().

The zvol blk-mq codepaths would erroneously send FLUSH and TRIM
commands down the read codepath, rather than write.  This fixes
the issue, and updates the zvol_misc_fua test to verify that
sync writes are actually happening.

Fixes: openzfs#17761
Signed-off-by: Tony Hutter <[email protected]>
@tonyhutter
Copy link
Contributor Author

@amotin my latest push inlines io_data_dir().

@behlendorf behlendorf merged commit 8d4c3ee into openzfs:master Sep 29, 2025
24 of 25 checks passed
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Sep 29, 2025
@amotin
Copy link
Member

amotin commented Sep 29, 2025

my latest push inlines io_data_dir().

@tonyhutter You sure inlined it, but haven't synchronized with the surrounding code as I asked.

behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Sep 29, 2025
The zvol blk-mq codepaths would erroneously send FLUSH and TRIM
commands down the read codepath, rather than write.  This fixes
the issue, and updates the zvol_misc_fua test to verify that
sync writes are actually happening.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Ameer Hamza <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes openzfs#17761
Closes openzfs#17765
@tonyhutter
Copy link
Contributor Author

@amotin sorry I jumped the gun. I think you've inadvertently raised another issue - I'm not 100% convinced we are advertising that our zvols can do secure erase. I'm not seeing us set max_secure_erase_sectors or set QUEUE_FLAG_SECERASE (depending on kernel version). That's probably a good thing, since secure erase doesn't really make sense in the context of zvols. We should probably disable any io_is_secure_erase() codepaths. I can open a separate issue after I've looked into it more.

@amotin
Copy link
Member

amotin commented Sep 30, 2025

@tonyhutter You might be right about io_is_secure_erase(), but (op_is_sync(rq->cmd_flags) && req_op(rq) != REQ_OP_READ) in its uncertainty makes me shiver also.

@tonyhutter
Copy link
Contributor Author

(op_is_sync(rq->cmd_flags) && req_op(rq) != REQ_OP_READ) in its uncertainty makes me shiver also.

Yea, the kernel macros are somewhat scattershot in what they check for. There's an op_is_write() but not an op_is_read(), for example. This bubbled up as the least bad option for checking sync writes.

@tonyhutter
Copy link
Contributor Author

Here's the follow-up with the secure erase updates: #17803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zvol: blk-mq sync isn't working correctly
4 participants