]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
f2fs: compress: don't redirty sparse cluster during {,de}compress
authorYeongjin Gil <youngjin.gil@samsung.com>
Mon, 19 Aug 2024 08:34:30 +0000 (17:34 +0900)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 21 Aug 2024 00:59:00 +0000 (00:59 +0000)
commitf785cec298c95d00058560c0715233294a04b8f3
treeb8a18d517e880596afc79631e97e25b8e9cb255c
parent43aec4d01bd2ce961817a777b3846f8318f398e4
f2fs: compress: don't redirty sparse cluster during {,de}compress

In f2fs_do_write_data_page, when the data block is NULL_ADDR, it skips
writepage considering that it has been already truncated.
This results in an infinite loop as the PAGECACHE_TAG_TOWRITE tag is not
cleared during the writeback process for a compressed file including
NULL_ADDR in compress_mode=user.

This is the reproduction process:

1. dd if=/dev/zero bs=4096 count=1024 seek=1024 of=testfile
2. f2fs_io compress testfile
3. dd if=/dev/zero bs=4096 count=1 conv=notrunc of=testfile
4. f2fs_io decompress testfile

To prevent the problem, let's check whether the cluster is fully
allocated before redirty its pages.

Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com>
Tested-by: Jaewook Kim <jw5454.kim@samsung.com>
Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c
fs/f2fs/f2fs.h
fs/f2fs/file.c