diff options
author | Chao Yu <yuchao0@huawei.com> | 2019-12-27 11:44:56 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-01-18 01:48:42 +0100 |
commit | 3e5e479a39ce9ed60cd63f7565cc1d9da77c2a4e (patch) | |
tree | f858046976316236bc79e49855de71ebd4270272 /fs/udf | |
parent | f2fs: run fsck when getting bad inode during GC (diff) | |
download | linux-3e5e479a39ce9ed60cd63f7565cc1d9da77c2a4e.tar.xz linux-3e5e479a39ce9ed60cd63f7565cc1d9da77c2a4e.zip |
f2fs: fix to add swap extent correctly
As Youling reported in mailing list:
https://www.linuxquestions.org/questions/linux-newbie-8/the-file-system-f2fs-is-broken-4175666043/
https://www.linux.org/threads/the-file-system-f2fs-is-broken.26490/
There is a test case can corrupt f2fs image:
- dd if=/dev/zero of=/swapfile bs=1M count=4096
- chmod 600 /swapfile
- mkswap /swapfile
- swapon --discard /swapfile
The root cause is f2fs_swap_activate() intends to return zero value
to setup_swap_extents() to enable SWP_FS mode (swap file goes through
fs), in this flow, setup_swap_extents() setups swap extent with wrong
block address range, result in discard_swap() erasing incorrect address.
Because f2fs_swap_activate() has pinned swapfile, its data block
address will not change, it's safe to let swap to handle IO through
raw device, so we can get rid of SWAP_FS mode and initial swap extents
inside f2fs_swap_activate(), by this way, later discard_swap() can trim
in right address range.
Fixes: 4969c06a0d83 ("f2fs: support swap file w/ DIO")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/udf')
0 files changed, 0 insertions, 0 deletions