platform: use F_FULLFSYNC on macOS for SyncFile data durability, fixes #9383#9592
Open
mr-raj12 wants to merge 1 commit intoborgbackup:1.4-maintfrom
Open
platform: use F_FULLFSYNC on macOS for SyncFile data durability, fixes #9383#9592mr-raj12 wants to merge 1 commit intoborgbackup:1.4-maintfrom
mr-raj12 wants to merge 1 commit intoborgbackup:1.4-maintfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 1.4-maint #9592 +/- ##
=============================================
+ Coverage 81.92% 81.94% +0.01%
=============================================
Files 38 38
Lines 11306 11307 +1
Branches 1781 1781
=============================================
+ Hits 9263 9265 +2
Misses 1456 1456
+ Partials 587 586 -1 ☔ View full report in Codecov by Sentry. |
…borgbackup#9383 On macOS, os.fsync() only flushes to the drive's write cache, not to persistent storage. True durability requires fcntl(fd, F_FULLFSYNC). Without it a power loss can silently discard data that SyncFile considered safely persisted. Add fdatasync() and sync_dir() to darwin.pyx using F_FULLFSYNC with an os.fsync() fallback for network filesystems that do not support it. Import them in platform/__init__.py so they override the base implementations on macOS. Backport of borgbackup#9385 to 1.4-maint. Signed-off-by: Mrityunjay Raj <[email protected]>
b186f07 to
58e1c0f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #9385 to
1.4-maint.SyncFile.sync()callsplatform.fdatasync(self.fd), which on macOS resolves toos.fsync().fsync()only flushes to the drive's write cache as it does not guarantee data reaches persistent storage. A power loss could silently lose datathat
SyncFilebelieved was safely persisted.The fix was acknowledged with a TODO in
src/borg/platform/base.py:TODO: Use F_FULLSYNC on macOS.This backport implements the platform-specific override suggested in #9383: add
fdatasync()andsync_dir()toplatform/darwin.pyxusingfcntl(fd, F_FULLFSYNC)with anos.fsync()fallback for network filesystems that do not supportF_FULLFSYNC.Changes
src/borg/platform/darwin.pyxfdatasync()usingfcntl F_FULLFSYNCwithos.fsync()fallback; addsync_dir()using the samesrc/borg/platform/__init__.pyfdatasync,sync_dirfrom.darwinin the darwin blocksrc/borg/platform/base.pysrc/borg/testsuite/platform.pydocs/changes.rstChecklist
1.4-maint(maintenance branch as change is only applicable here as master is already fixed via platform: use F_FULLSYNC on macOS for SyncFile data durability, fixes #9383 #9385)