]> Cypherpunks repositories - gostls13.git/commit
internal/poll: use F_FULLFSYNC fcntl for FD.Fsync on OS X
authorEmmanuel T Odeke <emmanuel@orijtech.com>
Wed, 22 Aug 2018 05:58:08 +0000 (22:58 -0700)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Wed, 22 Aug 2018 22:26:40 +0000 (22:26 +0000)
commitbe10ad762289943638efb279fc7e04c73b8d7cee
tree2a7b6b65511ea4c647d06a166944c96303f1efce
parentccb70bd19c44b90ef4030c6399c884f82a12bc68
internal/poll: use F_FULLFSYNC fcntl for FD.Fsync on OS X

As reported in #26650 and also cautioned on the man page
for fsync on OS X, fsync doesn't properly flush content
to permanent storage, and might cause corruption of data if
the OS crashes or if the drive loses power. Thus it is recommended
to use the F_FULLFSYNC fcntl, which flushes all buffered data to
permanent storage and is important for applications such as
databases that require a strict ordering of writes.

Also added a note in syscall_darwin.go that syscall.Fsync is
not invoked for os.File.Sync.

Fixes #26650.

Change-Id: Idecd9adbbdd640b9c5b02e73b60ed254c98b48b6
Reviewed-on: https://go-review.googlesource.com/130676
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/internal/poll/fd_fsync_darwin.go [new file with mode: 0644]
src/internal/poll/fd_fsync_posix.go [new file with mode: 0644]
src/internal/poll/fd_posix.go
src/syscall/syscall_darwin.go