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

BRT EOPNOTSUPP more speaking return value #15097

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

oromenahar
Copy link
Contributor

return EOPNOTSUPP if the storage pool don't support block cloning.

Motivation and Context

To improve readability and let other programs know what the real error is.

Description

Just changed the return value, if the storage pool don't support BRT.

How Has This Been Tested?

Tested if it still compiles on rocky linux 9.
Tests and docs maybe missing, will check this later.

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:

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

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

This is more accurate, and it looks to me like the latest coreutils will handle EOPNOTSUPP correctly when it bubbles all the way up. That said, the copy_file_range() man page doesn't mention EOPNOTSUPP as a possible errno so I'd rather not change this until we really understand the consequences. At a minimum I see this change breaks the error handling here for FreeBSD which is a problem.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jul 25, 2023
return EOPNOTSUPP if the storage pool don't support block cloning.

Signed-off-by: Kay Pedersen <mail@mkwg.de>
@oromenahar oromenahar force-pushed the fix/brt_return_value branch from 2fdca62 to facf8da Compare July 25, 2023 22:14
@oromenahar
Copy link
Contributor Author

oromenahar commented Jul 25, 2023

@behlendorf yes I saw that, I was a little fast when writing this PR. I will go and check more about this, when changing the return values. I saw one or two more checks, where we should change the return values to a more speaking value. So this should be put on hold for now until I checked everything.

First, this explicit return value wouldn't bubble up, in the BSD code this check happens before zfs_clone_range is ever called. In the Linux part is it the same. This codes would be good for other tools which wanna use zfs_clone_range in the future, for example zfs send/recv with --clone.

EDIT: Also wanna check this here again: EXDEV BSD Maybe it could miss some errors and just do a generic copy, which shouldn't be done on specific errors.
Rebased it to the Linux reflink merge.

@oromenahar oromenahar marked this pull request as draft July 25, 2023 22:20
@robn
Copy link
Member

robn commented Jul 25, 2023

I'm softly ok with this as I think its the right return for zfs_clone_range (as the internal API). The FreeBSD change looks right.

Regarding copy_file_range: zfs_clone_range returning EXDEV is a signal that the caller has asked for something reasonable, but it can't be serviced by a clone, and should always then fall back to a content copy. For Linux we're actually some distance away from the copy_file_range system call; pre 5.3, the kernel will sort out the return code, and after that we do the fallback ourselves. Your FreeBSD change does the same thing. EXDEV mostly isn't a valid return for copy_file_range directly.

Reading code to check all this has caused me to notice a possible bug on Linux 4.15-5.2. It looks like only -ENOTSUPP will trigger the fallback, not -EXDEV, so I think it has to be converted there too. That's not for this PR though, just something I saw on the way. I'll work up a test on some ancient VM later today and send a separate PR if necessary.

Copy link
Contributor

@behlendorf behlendorf 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 the quick revision with the FreeBSD fix. I think we're okay with integrating this now after you've wrapped up any additional testing.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jul 26, 2023
@oromenahar
Copy link
Contributor Author

oromenahar commented Jul 27, 2023

So checked the code, there are still a lot of EXDEV return codes, but they are more or less okay. EXDEV is more used as an generic error in zfs_clone_range and less than a specific error. Sometimes it can cause confusion if some of the EXDEV errors ever reach the userspace. That's not really a big deal, some people say error is error but to keep this in mind is a good idea. Maybe I have time later to think about the return values. I already thought about which could be changed to other values and marked them on my local copy.

EDIT: Also wanna check this here again: EXDEV BSD Maybe it could miss some errors and just do a generic copy, which shouldn't be done on specific errors.

this is fine as well. On all if this cases we can fallback to a genric old style copy on BSD and than the return value would never be EXDEV.

I'm finished my tests and we can merge this into master if you like.

@oromenahar oromenahar marked this pull request as ready for review July 27, 2023 17:55
@behlendorf
Copy link
Contributor

@oromenahar thanks, I'll go ahead and merge this.

@behlendorf behlendorf merged commit 5bdfff5 into openzfs:master Jul 27, 2023
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Jul 27, 2023
Return the more descriptive EOPNOTSUPP instead of EXDEV when the
storage pool doesn't support block cloning.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Kay Pedersen <mail@mkwg.de>
Closes openzfs#15097
@behlendorf behlendorf mentioned this pull request Jul 27, 2023
7 tasks
@oromenahar oromenahar deleted the fix/brt_return_value branch July 27, 2023 20:15
behlendorf pushed a commit that referenced this pull request Jul 27, 2023
Return the more descriptive EOPNOTSUPP instead of EXDEV when the
storage pool doesn't support block cloning.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Kay Pedersen <mail@mkwg.de>
Closes #15097
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Dec 12, 2023
Return the more descriptive EOPNOTSUPP instead of EXDEV when the
storage pool doesn't support block cloning.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Kay Pedersen <mail@mkwg.de>
Closes openzfs#15097
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