Skip to content

Conversation

overheadhunter
Copy link
Contributor

@overheadhunter overheadhunter commented Mar 3, 2021

Added new capability flag UnixNativeDispatcher.SUPPORTS_XATTR, which gets set #ifdef _SYS_XATTR_H_.

Note that _SYS_XATTR_H_ is defined in xattr.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

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8262957: (fs) Fail fast in UnixFileStore.isExtendedAttributesEnabled

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 3, 2021

👋 Welcome back overheadhunter! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 3, 2021
@openjdk
Copy link

openjdk bot commented Mar 3, 2021

@overheadhunter The following label will be automatically applied to this pull request:

  • nio

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.

@openjdk openjdk bot added the nio nio-dev@openjdk.org label Mar 3, 2021
@mlbridge
Copy link

mlbridge bot commented Mar 3, 2021

Webrevs

@overheadhunter overheadhunter changed the title JDK-8262957 Fail fast in UnixFileStore.isExtendedAttributesEnabled JDK-8262957 (fs) Fail fast in UnixFileStore.isExtendedAttributesEnabled Mar 3, 2021
@bplb
Copy link
Member

bplb commented Mar 4, 2021

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;
}

Copy link
Contributor

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.

Copy link
Contributor Author

@overheadhunter overheadhunter Mar 4, 2021

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

@overheadhunter overheadhunter Mar 24, 2021

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:

/**
* 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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

@overheadhunter
Copy link
Contributor Author

@bplb @AlanBateman Bump 😉

@openjdk
Copy link

openjdk bot commented Apr 7, 2021

@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:

8262957: (fs) Fail fast in UnixFileStore.isExtendedAttributesEnabled

Reviewed-by: alanb

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 master branch:

  • d3fdd73: 8264173: [s390] Improve Hardware Feature Detection And Reporting
  • 9d65039: 8263984: Invalidate printServices when there are no printers
  • adb860e: 8255800: Raster creation methods need some specification clean up
  • eab8455: 8261137: Optimization of Box nodes in uncommon_trap
  • 92fad1b: 8264680: Use the blessed modifier order in java.desktop
  • 17202c8: 8264748: Do not include arguments.hpp from compilerDefinitions.hpp
  • c3abdc9: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp
  • eb5c097: 8262389: Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present
  • bfb034a: 8264524: jdk/internal/platform/docker/TestDockerMemoryMetrics.java fails due to swapping not working
  • a756d8d: 8264759: x86_32 Minimal VM build failure after JDK-8262355
  • ... and 491 more: https://git.openjdk.java.net/jdk/compare/b397472e4f030e546fd6c565c336dd2fb0a6f60e...master

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 in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 7, 2021
@overheadhunter
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Apr 7, 2021
@openjdk
Copy link

openjdk bot commented Apr 7, 2021

@overheadhunter
Your change (at version 6bd45ec) is now ready to be sponsored by a Committer.

@shipilev
Copy link
Member

Alan, are you good with integrating this?

@AlanBateman
Copy link
Contributor

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).

@AlanBateman
Copy link
Contributor

/sponsor

@openjdk openjdk bot closed this Apr 14, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 14, 2021
@openjdk
Copy link

openjdk bot commented Apr 14, 2021

@AlanBateman @overheadhunter Since your change was applied there have been 592 commits pushed to the master branch:

  • e2106d5: 8265104: CpuLoad and SystemCpuLoad in OperatingSystem MXBean returns -1.0
  • ebbce91: 8264681: Use the blessed modifier order in java.security
  • ea5c55a: 8265103: Remove unnecessary inclusion of oopMap.hpp
  • 26186ec: 8039261: [TEST_BUG]: There is not a minimal security level in Java Preferences and the TestApplet.html is blocked.
  • 283d64f: 8262896: [macos_aarch64] Crash in jni_fast_GetLongField
  • 55d5649: 8263157: [macos]: java.library.path is being set incorrectly
  • e80012e: 8264768: JFR: Allow events to be printed to the log
  • 3b576ed: 8265100: (fs) WindowsFileStore.hashCode() should read cached hash code once
  • 8df8512: 8265125: IGV: cannot edit forms with NetBeans GUI builder
  • 9cd5400: 8265138: Simplify DerUtils::checkAlg
  • ... and 582 more: https://git.openjdk.java.net/jdk/compare/b397472e4f030e546fd6c565c336dd2fb0a6f60e...master

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.

@overheadhunter overheadhunter deleted the JDK-8262957 branch April 14, 2021 12:01
@ajbaldocchi
Copy link

ajbaldocchi commented Sep 30, 2021

Doesn't glibc use _SYS_XATTR_H rather than _SYS_XATTR_H_? Wouldn't it be better to use something like XATTR_CREATE instead of _SYS_XATTR_H_?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated nio nio-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

5 participants