]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
f2fs: keep atomic write retry from zeroing original data
authorWenjie Qi <qwjhust@gmail.com>
Wed, 27 May 2026 12:06:28 +0000 (20:06 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 22 Jun 2026 19:52:36 +0000 (19:52 +0000)
commit6d874b65aadce56ac78f76129dbcfc2599b638f8
tree356a9f88e8cd854702d0fd91e91962e237393e96
parent846c499a65816d13f1186e3090e825e8bb8bcb8b
f2fs: keep atomic write retry from zeroing original data

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@kernel.org
Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c