summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorHyeong-Jun Kim <hj514.kim@samsung.com>2021-10-27 13:16:00 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-11-25 09:48:31 +0100
commit9c9afedf3ac58aa8a88964068e9ad6ec6cafdb2f (patch)
tree0c63315fa60ff6d6e373daaa7f0e06d859a05b8a /fs/f2fs
parent3d937f901cea25765a3dea5f54c4a04322790f6e (diff)
downloadlinux-stable-9c9afedf3ac58aa8a88964068e9ad6ec6cafdb2f.tar.gz
linux-stable-9c9afedf3ac58aa8a88964068e9ad6ec6cafdb2f.tar.bz2
linux-stable-9c9afedf3ac58aa8a88964068e9ad6ec6cafdb2f.zip
f2fs: compress: disallow disabling compress on non-empty compressed file
[ Upstream commit 02d58cd253d7536c412993573fc6b3b4454960eb ] Compresse file and normal file has differ in i_addr addressing, specifically addrs per inode/block. So, we will face data loss, if we disable the compression flag on non-empty files. Therefore we should disallow not only enabling but disabling the compression flag on non-empty files. Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> Signed-off-by: Hyeong-Jun Kim <hj514.kim@samsung.com> Reviewed-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 'fs/f2fs')
-rw-r--r--fs/f2fs/f2fs.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index b339ae89c1ad..c242274e3479 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -4152,8 +4152,7 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode)
if (!f2fs_compressed_file(inode))
return true;
- if (S_ISREG(inode->i_mode) &&
- (get_dirty_pages(inode) || atomic_read(&fi->i_compr_blocks)))
+ if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
return false;
fi->i_flags &= ~F2FS_COMPR_FL;