-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[native] Skip F_FULLFSYNC on macOS for network file systems #130779
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
Changes from all commits
e67968c
d633e5a
cc4b633
c914251
b4094fc
011f209
f16793c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -41,9 +41,35 @@ public sealed partial class SafeFileHandle : SafeHandleZeroOrMinusOneIsInvalid | |||||
| private NullableBool _canSeek /* = NullableBool.Undefined */; | ||||||
| private NullableBool _supportsRandomAccess /* = NullableBool.Undefined */; | ||||||
| private NullableBool _isAsync /* = NullableBool.Undefined */; | ||||||
| // Lazily initialized on Apple platforms (macOS, iOS, tvOS, Mac Catalyst). | ||||||
| // True = use F_FULLFSYNC. | ||||||
| // False = skip F_FULLFSYNC because the probe indicates the file system should avoid it | ||||||
| // (e.g., NFS/SMB/CIFS/SMB2, or when the probe fails). | ||||||
| // Stays Undefined until first queried; UseFullFSync treats Undefined as True. | ||||||
| // See https://github.com/dotnet/runtime/issues/124722. | ||||||
| private NullableBool _useFullFsync /* = NullableBool.Undefined */; | ||||||
| private bool _deleteOnClose; | ||||||
| private bool _isLocked; | ||||||
|
|
||||||
| // Returns true when F_FULLFSYNC should be attempted. Returns false when | ||||||
| // FileSystemSupportsLocking(LOCK_SH, accessWrite: true) reports the file system as unsupported | ||||||
| // for this probe, which includes known network file systems and probe failures. | ||||||
| // The value is only used on Apple platforms; native code ignores it on other platforms. | ||||||
| // Lazily computed and cached on first access to avoid a syscall for callers that never flush to disk. | ||||||
| internal bool UseFullFSync | ||||||
| { | ||||||
| get | ||||||
| { | ||||||
| NullableBool useFullFsync = _useFullFsync; | ||||||
| if (useFullFsync == NullableBool.Undefined && !IsClosed && OperatingSystem.IsApplePlatform()) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SystemNative_FSync uses
Suggested change
|
||||||
| { | ||||||
| _useFullFsync = useFullFsync = Interop.Sys.FileSystemSupportsLocking(this, Interop.Sys.LockOperations.LOCK_SH, accessWrite: true) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR reuses SystemNative_FileSystemSupportsLocking as a proxy for "is this a network FS," but that function's contract is about locking and its result depends on lockOperation/accessWrite, so it can't simply be renamed to IsNetworkFileSystem. Consider extracting the shared network-FS detection (the FileSystemNameSupportsLocking nfs/cifs/smb/smb2 check) into a dedicated helper. |
||||||
| ? NullableBool.True : NullableBool.False; | ||||||
| } | ||||||
| return useFullFsync != NullableBool.False; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| public SafeFileHandle() : this(ownsHandle: true) | ||||||
| { | ||||||
| } | ||||||
|
|
@@ -461,6 +487,7 @@ private bool Init(string path, FileMode mode, FileAccess access, FileShare share | |||||
| return false; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Enable DeleteOnClose when we've successfully locked the file. | ||||||
| // On Windows, the locking happens atomically as part of opening the file. | ||||||
| _deleteOnClose = (options & FileOptions.DeleteOnClose) != 0; | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.