Re: [PATCH] f2fs: keep atomic write retry from zeroing original data

From: Chao Yu

Date: Thu Jun 11 2026 - 04:13:42 EST


On 5/27/26 20:06, Wenjie Qi wrote:
> A partial atomic write reserves a block in the COW inode before reading the
> original data page for the untouched bytes in that page.
>
> If that read fails, write_begin returns an error but leaves the COW inode
> entry as NEW_ADDR. A retry of the same partial write then finds the COW
> entry, treats it as existing COW data, and f2fs_write_begin() zeroes the
> whole folio because blkaddr is NEW_ADDR.
>
> If the retry is committed, the bytes outside the retried write range are
> committed as zeroes instead of preserving the original file contents.
>
> Only use the COW inode as the read source when it already has a real data
> block. If the COW entry is still NEW_ADDR, treat it as a reservation to
> reuse: keep reading the old data from the original inode and avoid
> reserving or accounting the same atomic block again.
>

Cc: stable@xxxxxxxxxx

> Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
> Signed-off-by: Wenjie Qi <qiwenjie@xxxxxxxxxx>

Reviewed-by: Chao Yu <chao@xxxxxxxxxx>

Thanks,