-
Notifications
You must be signed in to change notification settings - Fork 6.3k
JDK-8262957 (fs) Fail fast in UnixFileStore.isExtendedAttributesEnabled #2816
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
…ispatcher doesn't support xattr
👋 Welcome back overheadhunter! A progress list of the required criteria for merging this PR into |
@overheadhunter The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
I think this look all right. I'll withhold approving until @AlanBateman has commented. |
// avoid I/O if native code doesn't support xattr | ||
return false; | ||
} | ||
|
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.
Add SUPPORTS_XATTR is a good idea.
Style-wise, it might be a bit neater to use if (UnixNativeDispatcher.xattrSupported()) { ...} so there will only one "return false" code path.
Looking at this code now make me wonder about the close(fd) for the case that the open fails. It should be checking if fd or there should be a nested try-finally so that close is only invoked when the open succeeds.
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.
Style-wise, it might be a bit neater to use if (UnixNativeDispatcher.xattrSupported()) { ...} so there will only one "return false" code path.
I prefer to avoid nested blocks for improved readability, but thats mostly a matter of taste. If you like, I can reverse the "if".
Looking at this code now make me wonder about the close(fd) for the case that the open fails. It should be checking if fd or there should be a nested try-finally so that close is only invoked when the open succeeds.
True. But I guess that would be off-topic in this PR?
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.
It's somewhat subjective. What you have is fine, I just would have done is differently to avoid too many return paths.
I think we should clean up the close(-1) case while we are in the area, separate PR of course.
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.
All right, will you create another bug report for the close(-1)
issue?
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.
I just wanted to create another issue, but then I noticed that close(-1)
is allowed as per contract:
jdk/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java
Lines 90 to 97 in 45e1bab
/** | |
* close(int filedes). If fd is -1 this is a no-op. | |
*/ | |
static void close(int fd) { | |
if (fd != -1) { | |
close0(fd); | |
} | |
} |
We can still change this, of course, but I wouldn't consider this a necessary change for this PR and would therefore suggest to deal with this another time.
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.
Okay, I had forgotten that that UnixNativeDispatcher.close(-1) is a no-op.
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.
I guess we're good to merge, then?
@bplb @AlanBateman Bump 😉 |
@overheadhunter This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 501 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@AlanBateman) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@overheadhunter |
Alan, are you good with integrating this? |
Yes, one I get time to do more testing (the optimisation is for AIX only and I want to double check that we don't have side effects on the main stream platforms). |
/sponsor |
@AlanBateman @overheadhunter Since your change was applied there have been 592 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 27dd88b. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Doesn't glibc use |
Added new capability flag
UnixNativeDispatcher.SUPPORTS_XATTR
, which gets set#ifdef _SYS_XATTR_H_
.Note that
_SYS_XATTR_H_
is defined inxattr.h
in both macOS/Darwin, Linux and GNU-based BSD systems using glibc. It might not be defined for other operating systems that still support xattr. So if OpenJDK eventually adds support for further platforms, this might need to be adjusted as well.If xattr capabilities are missing,
UnixFileStore.isExtendedAttributesEnabled
will return false immediately, avoiding any I/O.As a side effect of this change, I redefined some other (private) capabilities. Strictly speaking, this change is not required but keeps the code consistent, as previously discussed in the mailing list.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/2816/head:pull/2816
$ git checkout pull/2816
Update a local copy of the PR:
$ git checkout pull/2816
$ git pull https://git.openjdk.java.net/jdk pull/2816/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2816
View PR using the GUI difftool:
$ git pr show -t 2816
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/2816.diff