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

flush: don't report flush error when disabling flush support #16855

Closed
wants to merge 2 commits into from

Conversation

robn
Copy link
Member

@robn robn commented Dec 11, 2024

[Sponsors: Klara, Inc., Wasabi Technology, Inc.]

Motivation and Context

The first time a device returns ENOTSUP in repsonse to a flush request, we set vdev_nowritecache so we don't issue flushes in the future and instead just pretend the succeeded. However, we still return an error for the initial flush, even though we just decided such errors are meaningless!

Description

So, when setting vdev_nowritecache in response to a flush error, also reset the error code to assume success.

Along the way, it seems there's no good reason for vdev_disk & vdev_geom to explicitly detect no support for flush and set vdev_nowritecache; just letting the error through to zio_vdev_io_assess() will cause it all to fall out nicely. So remove those checks.

This patch was suggested by @amotin in #16314. I'm unlikely to continue with that PR in that form, but this patch is still good and will be wanted when we do stat paying attention to flush errors. No reason not to include it now and get it off my plate!

How Has This Been Tested?

Direct testing against various unpublished flush error-response prototypes. Hard to test in OpenZFS proper, since nothing responds to flush errors.

Successful ZTS run against Linux 6.1.

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:

@robn robn requested a review from amotin December 11, 2024 20:55
Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for remembering it. I am OK about this, but I am not completely certain that unifying this in OS-independent code is the right direction. Different OS and vdev types might have different ways of reporting it. I worry that mapping of Linux EOPNOTSUPP into ENOTSUP is too much of a special case. Or we expect other cases to translate whatever they have into ENOTSUP? If so, then why do we also check for ENOTTY?

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Dec 12, 2024
robn added 2 commits December 13, 2024 22:22
The first time a device returns ENOTSUP in repsonse to a flush request,
we set vdev_nowritecache so we don't issue flushes in the future and
instead just pretend the succeeded. However, we still return an error
for the initial flush, even though we just decided such errors are
meaningless!

So, when setting vdev_nowritecache in response to a flush error, also
reset the error code to assume success.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
It seems there's no good reason for vdev_disk & vdev_geom to explicitly
detect no support for flush and set vdev_nowritecache.  Instead, just
signal it by setting the error to ENOTSUP, and let zio_vdev_io_assess()
take care of it in one place.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
@robn robn force-pushed the zio-flush-no-error branch from 21016c3 to 96adb7e Compare December 13, 2024 11:27
@robn
Copy link
Member Author

robn commented Dec 13, 2024

Yeah, this is a reasonable point.

I've split this PR into two commits. The actual change as described is in the first commit, and could stand alone.

The second changes things to make ENOTSUP the only way to signal that flush is not supported. For Linux, we then explicitly check for EOPNOTSUPP and ENOTTY, and convert. I could drop ENOTTY, as it seems to go back to ancient Linux where it was implemented with an ioctl-like interface to the block device, but I haven't done the study to really confirm that. As for EOPNOTSUPP, it's kind of redundant, but you are right that they aren't necessarily the same, and although we mix them throughout the code, we can easily just say that this a first tiny step towards cleaning them all up.

Or I can just drop the commit :)

Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but once we go that way, would be nice to also patch zfs_file_deallocate() on both FreeBSD and Linux to use ENOTSUP instead of EOPNOTSUP (I honestly don't know which of them is better, so would be fine either way), plus on FreeBSD we need to map ENODEV into ENOTSUP there too.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Dec 13, 2024
behlendorf pushed a commit that referenced this pull request Dec 13, 2024
It seems there's no good reason for vdev_disk & vdev_geom to explicitly
detect no support for flush and set vdev_nowritecache.  Instead, just
signal it by setting the error to ENOTSUP, and let zio_vdev_io_assess()
take care of it in one place.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16855
@robn
Copy link
Member Author

robn commented Dec 14, 2024

@amotin agreed.

FWIW, POSIX describes ENOTSUP and EOPNOTSUPP as:

[ENOTSUP]
Not supported (may be the same value as [EOPNOTSUPP]).

[EOPNOTSUPP]
Operation not supported on socket (may be the same value as [ENOTSUP]).

So I prefer ENOTSUP as the more general option. Nothing will care in practice, but consistency is good.

behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Dec 16, 2024
The first time a device returns ENOTSUP in repsonse to a flush request,
we set vdev_nowritecache so we don't issue flushes in the future and
instead just pretend the succeeded. However, we still return an error
for the initial flush, even though we just decided such errors are
meaningless!

So, when setting vdev_nowritecache in response to a flush error, also
reset the error code to assume success.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16855
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Dec 16, 2024
It seems there's no good reason for vdev_disk & vdev_geom to explicitly
detect no support for flush and set vdev_nowritecache.  Instead, just
signal it by setting the error to ENOTSUP, and let zio_vdev_io_assess()
take care of it in one place.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16855
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Jan 26, 2025
The first time a device returns ENOTSUP in repsonse to a flush request,
we set vdev_nowritecache so we don't issue flushes in the future and
instead just pretend the succeeded. However, we still return an error
for the initial flush, even though we just decided such errors are
meaningless!

So, when setting vdev_nowritecache in response to a flush error, also
reset the error code to assume success.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16855
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Jan 26, 2025
It seems there's no good reason for vdev_disk & vdev_geom to explicitly
detect no support for flush and set vdev_nowritecache.  Instead, just
signal it by setting the error to ENOTSUP, and let zio_vdev_io_assess()
take care of it in one place.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16855
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