-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Linux: always check or verify return of igrab() #11704
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
Conversation
Thanks for improving this bit of the code. In general the original undocumented rational for not checking for NULL when using I agree we should really make this all much more clear. A reasonable approach might be to add a |
I honestly can't tell which cases know there's already a ref vs those which don't; should I assume that all the existing code is correct and just VERIFY() that? Should I make the same assumption that igrab() is always being used where there's already a ref, as well as zhold()? |
It's definitely not very clear. But I believe it's the case that we're checking the A good example of a place where we know we must have a reference, and it's not currently checked, would be the |
Is this version more what you had in mind? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, think this is preferable since it makes it clear why it can never be NULL.
I think this is done now. |
Functionally this looks good to me, could you just address the style comments about lines over 80 characters. You can run |
Oh... yes... sorry, forgot about checkstyle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Signed-off-by: Adam Moss <[email protected]>
Hi @behlendorf is this waiting on anything more from me? Thanks. |
@adamdmoss no this one was just blocked on me to circle back to merge it. Although more review is always welcome! I'll go ahead and merge it now. Thanks! |
zhold() wraps igrab() on Linux, and igrab() may fail when the inode is in the process of being deleted. This means zhold() must only be called when a reference exists and therefore it cannot be deleted. This is the case for all existing consumers so add a VERIFY and a comment explaining this requirement. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Adam Moss <[email protected]> Closes openzfs#11704
zhold() wraps igrab() on Linux, and igrab() may fail when the inode is in the process of being deleted. This means zhold() must only be called when a reference exists and therefore it cannot be deleted. This is the case for all existing consumers so add a VERIFY and a comment explaining this requirement. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Adam Moss <[email protected]> Closes openzfs#11704
zhold() wraps igrab() on Linux, and igrab() may fail when the inode is in the process of being deleted. This means zhold() must only be called when a reference exists and therefore it cannot be deleted. This is the case for all existing consumers so add a VERIFY and a comment explaining this requirement. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Adam Moss <[email protected]> Closes openzfs#11704
zhold() wraps igrab() on Linux, and igrab() may fail when the inode is in the process of being deleted. This means zhold() must only be called when a reference exists and therefore it cannot be deleted. This is the case for all existing consumers so add a VERIFY and a comment explaining this requirement. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Adam Moss <[email protected]> Closes openzfs#11704
zhold() wraps igrab() on Linux, and igrab() may fail when the inode is in the process of being deleted. This means zhold() must only be called when a reference exists and therefore it cannot be deleted. This is the case for all existing consumers so add a VERIFY and a comment explaining this requirement. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Adam Moss <[email protected]> Closes #11704
Motivation and Context
zhold()
wraps Linux'sigrab()
;igrab()
andzhold()
are used in several places in ZFS where they are expected to succeed, with an eventual symmetriczrele()
/iput()
. However, if the inode is already in the process of being deleted thenigrab()
can fail and return NULL; in this case a reference is not created on the inode and it a bug to subsequentlyiput()
it (possible premature recycling of the inode memory leading to hard-to-diagnose issues).Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.