Re: Writing more than 4096 bytes with O_SYNC flag does not persist all previously written data if system crashes

From: Christoph Hellwig

Date: Tue Feb 24 2026 - 09:50:26 EST


A lot of folks have already explained the O_SYNC semantics correctly,
but I have another major question about your test case.

On Wed, Feb 18, 2026 at 04:29:30PM +0300, Vyacheslav Kovalevsky wrote:
> Detailed description
> ====================
>
> Hello, there seems to be an issue with ext4 crash behavior:
>
> 1. Create and sync a new file.
> 2. Open the file and write some data (must be more than 4096 bytes).
> 3. Close the file.
> 4. Open the file with O_SYNC flag and write some data.
>
> After system crash the file will have the wrong size and some previously
> written data will be lost.

The wrong size here seems incorrect. Even if the old data written
through the non-O_SYNC fd wasn't written out I absolutely can't see how
the file would have an incorrect size here. Can you please share your
test case?