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

Fix wrong assertion in libzfs diff error handling #8743

Merged
merged 1 commit into from May 20, 2019
Merged

Fix wrong assertion in libzfs diff error handling #8743

merged 1 commit into from May 20, 2019

Conversation

ghost
Copy link

@ghost ghost commented May 14, 2019

Motivation and Context

During testing of the ZoL port to FreeBSD, this mishandled error case was discovered. It should be fixed for correctness.

Description

In differ(), all error cases set the error code to EPIPE, so when an error is set, the correct assertion to make is that the error is EPIPE, not EINVAL.

How Has This Been Tested?

I have run ZTS against this change.

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)
  • Documentation (a change to man pages or other documentation)

Checklist:

In compare(), all error cases set the error code to EPIPE, so when an
error is set, the correct assertion to make is that the error is EPIPE,
not EINVAL.

Signed-off-by: Ryan Moeller <[email protected]>
@ahrens ahrens added the Status: Code Review Needed Ready for review and testing label May 14, 2019
@codecov
Copy link

codecov bot commented May 15, 2019

Codecov Report

Merging #8743 into master will decrease coverage by 0.23%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8743      +/-   ##
==========================================
- Coverage   78.97%   78.74%   -0.24%     
==========================================
  Files         381      381              
  Lines      117797   117797              
==========================================
- Hits        93034    92760     -274     
- Misses      24763    25037     +274
Flag Coverage Δ
#kernel 79.24% <ø> (-0.19%) ⬇️
#user 67.47% <0%> (-0.28%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f378f42...33359a9. Read the comment docs.

@@ -478,7 +478,7 @@ differ(void *arg)
if (err)
return ((void *)-1);
if (di->zerr) {
ASSERT(di->zerr == EINVAL);
ASSERT(di->zerr == EPIPE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, the updated code looks right and I'm OK with it as is. But I wonder if it wouldn't be better to instead remove the ASSERT and update the error message to log the di->err. This way it's still useful even in non-debug builds.

Copy link
Author

@ghost ghost May 15, 2019

Choose a reason for hiding this comment

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

I prefer the ASSERT since it informs the reader that any other value here would be a programming error, not a conceivable run-time error. The value of di->zerr will only ever be EPIPE in this context, and the assertion serves to document that fact. The purpose of this special case is to give a more relevant internal error message in the context of differ(). Any other possible non-zero value of di->zerr should result in err being set as well, and is therefore covered by the preceding if (err) return -1;.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels May 15, 2019
@behlendorf behlendorf merged commit 9dc41a7 into openzfs:master May 20, 2019
allanjude pushed a commit to allanjude/zfs that referenced this pull request Jun 7, 2019
In compare(), all error cases set the error code to EPIPE, so when an
error is set, the correct assertion to make is that the error is EPIPE,
not EINVAL.

Reviewed-by: Richard Elling <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#8743
allanjude pushed a commit to allanjude/zfs that referenced this pull request Jun 15, 2019
In compare(), all error cases set the error code to EPIPE, so when an
error is set, the correct assertion to make is that the error is EPIPE,
not EINVAL.

Reviewed-by: Richard Elling <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#8743
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