Commit db2c5b9
f2fs: keep atomic write retry from zeroing original data
commit 6d874b6 upstream.
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: 3db1de0 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 20190e4 commit db2c5b9
1 file changed
Lines changed: 11 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3537 | 3537 | | |
3538 | 3538 | | |
3539 | 3539 | | |
| 3540 | + | |
3540 | 3541 | | |
3541 | 3542 | | |
3542 | 3543 | | |
| |||
3546 | 3547 | | |
3547 | 3548 | | |
3548 | 3549 | | |
3549 | | - | |
| 3550 | + | |
3550 | 3551 | | |
3551 | 3552 | | |
| 3553 | + | |
| 3554 | + | |
3552 | 3555 | | |
3553 | 3556 | | |
3554 | 3557 | | |
| |||
3561 | 3564 | | |
3562 | 3565 | | |
3563 | 3566 | | |
3564 | | - | |
3565 | | - | |
3566 | | - | |
3567 | | - | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
3568 | 3574 | | |
3569 | 3575 | | |
3570 | 3576 | | |
| |||
0 commit comments