[2.2] vdev_disk: ensure trim errors are returned immediately #16081
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Backporting #16070 for 2.2.
Description
After 08fd5cc, the discard issuing code was organised such that if requesting an async discard or secure erase failed before the IO was issued (that is, calling
__blkdev_issue_discard()
returned an error), the failed zio would never be executed, resulting intxg_sync
hanging forever waiting for IO to finish.This commit fixes that by immediately executing a failed zio on error. To handle the successful synchronous op case, we fake an async op by, when not using an asynchronous submission method, queuing the successful result zio as part of the discard handler.
Since it was hard to understand the differences between discard and secure erase, and sync and async, across different kernel versions, I've commented and reorganised the code a bit to try and make everything more contained and linear.
How Has This Been Tested?
Compiled and successfully passed
zpool_trim
test suites on kernels:On 5.10.214, with loopback devices (which have incorrect
discard_granularity
, see #16068, bothzpool trim
andautotrim=on
woud hang. With this in place, they appear to succeed, and the failures are recorded in/proc/spl/kstat/zfs/xxx/iostats
. This is returning to the previous behaviour.See also testing on #16070, which should all hold here.
Types of changes
Checklist:
Signed-off-by
.