Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

linux fsync behaviour

15 views
Skip to first unread message

yuanh

unread,
Jul 24, 2014, 6:50:01 PM7/24/14
to
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.

Thanks,

-Yuan



--
View this message in context: http://linux-kernel.2935.n7.nabble.com/linux-fsync-behaviour-tp911707.html
Sent from the Linux Kernel mailing list archive at Nabble.com.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Dave Chinner

unread,
Jul 24, 2014, 9:20:01 PM7/24/14
to
On Thu, Jul 24, 2014 at 03:41:31PM -0700, yuanh wrote:
> 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.
--
Dave Chinner
da...@fromorbit.com

Anton Altaparmakov

unread,
Jul 25, 2014, 3:40:02 AM7/25/14
to
Hi,

On 25 Jul 2014, at 02:17, Dave Chinner <da...@fromorbit.com> wrote:
> On Thu, Jul 24, 2014 at 03:41:31PM -0700, yuanh wrote:
>> 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
--
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
0 new messages