linux/fs/f2fs
Chao Yu 3e5e479a39 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: 4969c06a0d ("f2fs: support swap file w/ DIO")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-01-17 16:48:42 -08:00
..
acl.c f2fs: Replace spaces with tab 2019-05-08 21:23:11 -07:00
acl.h f2fs: add SPDX license identifiers 2018-09-12 13:07:10 -07:00
checkpoint.c f2fs: don't keep META_MAPPING pages used for moving verity file blocks 2020-01-15 13:43:48 -08:00
compress.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
data.c f2fs: fix to add swap extent correctly 2020-01-17 16:48:42 -08:00
debug.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
dir.c f2fs: show f2fs instance in printk_ratelimited 2019-11-19 14:41:21 -08:00
extent_cache.c f2fs: introduce f2fs_<level> macros to wrap f2fs_printk() 2019-07-02 15:40:40 -07:00
f2fs.h f2fs: support data compression 2020-01-17 16:48:07 -08:00
file.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
gc.c f2fs: run fsck when getting bad inode during GC 2020-01-17 16:48:42 -08:00
gc.h f2fs: add SPDX license identifiers 2018-09-12 13:07:10 -07:00
hash.c f2fs: Support case-insensitive file name lookups 2019-08-23 07:57:13 -07:00
inline.c f2fs: set GFP_NOFS when moving inline dentries 2019-12-12 13:24:34 -08:00
inode.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
Kconfig f2fs: support data compression 2020-01-17 16:48:07 -08:00
Makefile f2fs: support data compression 2020-01-17 16:48:07 -08:00
namei.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
node.c f2fs: show f2fs instance in printk_ratelimited 2019-11-19 14:41:21 -08:00
node.h f2fs: check PageWriteback flag for ordered case 2018-12-26 15:16:56 -08:00
recovery.c f2fs: Check write pointer consistency of open zones 2020-01-15 13:42:14 -08:00
segment.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
segment.h f2fs: support data compression 2020-01-17 16:48:07 -08:00
shrinker.c f2fs: fix sbi->extent_list corruption issue 2018-12-26 15:16:54 -08:00
super.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
sysfs.c f2fs: support data compression 2020-01-17 16:48:07 -08:00
trace.c f2fs: do not use mutex lock in atomic context 2019-03-05 19:58:06 -08:00
trace.h f2fs: add SPDX license identifiers 2018-09-12 13:07:10 -07:00
verity.c f2fs: add fs-verity support 2019-08-12 19:33:51 -07:00
xattr.c f2fs: fix to avoid memory leakage in f2fs_listxattr 2019-10-22 10:32:42 -07:00
xattr.h f2fs: add fs-verity support 2019-08-12 19:33:51 -07:00