Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.2] vdev_disk: ensure trim errors are returned immediately #16081

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

robn
Copy link
Member

@robn robn commented Apr 11, 2024

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 in txg_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:

  • 4.14.336
  • 5.10.214
  • 6.1.83
  • 6.8.2

On 5.10.214, with loopback devices (which have incorrect discard_granularity, see #16068, both zpool trim and autotrim=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

  • 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)
  • 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:

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 in txg_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.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <[email protected]>
(cherry picked from commit ba9f587)
@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Apr 11, 2024
@behlendorf behlendorf merged commit d0d9dcc into openzfs:zfs-2.2.4-staging Apr 11, 2024
22 of 24 checks passed
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.

3 participants