diff options
| author | Chao Yu <chao@kernel.org> | 2024-03-08 09:08:34 +0800 |
|---|---|---|
| committer | Sasha Levin <sashal@kernel.org> | 2024-03-26 18:20:03 -0400 |
| commit | c92f2927df860a60ba815d3ee610a944b92a8694 (patch) | |
| tree | 239dd272f343ed00b73a81647e9e3eb6a6bae2fb /include | |
| parent | cfd217f6464dad7308e34b319d20dbbe37151f3f (diff) | |
| download | linux-c92f2927df860a60ba815d3ee610a944b92a8694.tar.gz linux-c92f2927df860a60ba815d3ee610a944b92a8694.tar.bz2 linux-c92f2927df860a60ba815d3ee610a944b92a8694.zip | |
f2fs: fix to truncate meta inode pages forcely
[ Upstream commit 9f0c4a46be1fe9b97dbe66d49204c1371e3ece65 ]
Below race case can cause data corruption:
Thread A GC thread
- gc_data_segment
- ra_data_block
- locked meta_inode page
- f2fs_inplace_write_data
- invalidate_mapping_pages
: fail to invalidate meta_inode page
due to lock failure or dirty|writeback
status
- f2fs_submit_page_bio
: write last dirty data to old blkaddr
- move_data_block
- load old data from meta_inode page
- f2fs_submit_page_write
: write old data to new blkaddr
Because invalidate_mapping_pages() will skip invalidating page which
has unclear status including locked, dirty, writeback and so on, so
we need to use truncate_inode_pages_range() instead of
invalidate_mapping_pages() to make sure meta_inode page will be dropped.
Fixes: 6aa58d8ad20a ("f2fs: readahead encrypted block during GC")
Fixes: e3b49ea36802 ("f2fs: invalidate META_MAPPING before IPU/DIO write")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/f2fs_fs.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h index cf1adceb0269..5aa00bcd42fe 100644 --- a/include/linux/f2fs_fs.h +++ b/include/linux/f2fs_fs.h @@ -27,6 +27,7 @@ #define F2FS_BYTES_TO_BLK(bytes) ((bytes) >> F2FS_BLKSIZE_BITS) #define F2FS_BLK_TO_BYTES(blk) ((blk) << F2FS_BLKSIZE_BITS) +#define F2FS_BLK_END_BYTES(blk) (F2FS_BLK_TO_BYTES(blk + 1) - 1) /* 0, 1(node nid), 2(meta nid) are reserved node id */ #define F2FS_RESERVED_NODE_NUM 3 |
