Skip to contentSkip to conversation

linux fsync behaviour

DISCUSSION yuanh 3 participants 3 messages Jul 24, 2014 – Jul 25, 2014

lore
Share & tools
lore
#1 lore raw
Quoted 5 lines · yuanh

Hi all,

Two file descriptors are pointing the same file. When fsync is called on
one fd, the data written by the other fd will also be flushed? We are using linux XFS.

Yes.

-Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw

Hi,

Quoted 8 lines · Dave Chinner
Quoted 5 lines · yuanh

Hi all,

Two file descriptors are pointing the same file. When fsync is called on
one fd, the data written by the other fd will also be flushed? We are using linux XFS.

Yes.

But beware of the common mistake of using fwrite + fsync which does not actually do what you intend at all and you must instead use fwrite + fflush + fsync... If you are using write(2) then just fsync is obviously fine.

Best regards,

Anton

Signature · 3 lines
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
University of Cambridge Information Services, Roger Needham Building
7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK