Skip to contentSkip to conversation

f2fs: fix to check compression feature before enabling file compression

PATCH In review Chao Yu 2 participants 3 messages Aug 4, 2022 – Aug 5, 2022 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix to check compression feature before enabling file compression

From: Chao Yu <[email protected]>

This patch disallow to enable file compression in image which doesn't support compression feature.

---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/file.c +2 -0
index 24f5b02c78e7..4a3f4eaa3fc5 100644
@@ -1872,6 +1872,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 			if (!f2fs_disable_compressed_file(inode))
 				return -EINVAL;
 		} else {
+			if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
+				return -EOPNOTSUPP;
 			if (!f2fs_may_compress(inode))
 				return -EINVAL;
 			if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
Signature · 1 line
2.36.1
#1 lore raw
Quoted 16 lines · Chao Yu

From: Chao Yu <[email protected]>

This patch disallow to enable file compression in image which doesn't support compression feature.

---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/file.c +0 -0
index 24f5b02c78e7..4a3f4eaa3fc5 100644

fs/f2fs/file.c static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) · line 1879

Quoted 8 lines
fs/f2fs/file.c +2 -0
@@ -1872,6 +1872,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 			if (!f2fs_disable_compressed_file(inode))
 				return -EINVAL;
 		} else {
+			if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
+				return -EOPNOTSUPP;
 			if (!f2fs_may_compress(inode))
 				return -EINVAL;
 			if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))

How is this different from the same check that occurs earlier in the function?

- Eric

author maintainer
#2 lore raw
Quoted 1 line · Eric Biggers

How is this different from the same check that occurs earlier in the function?

Oops, I missed that one, please ignore this patch.

Thanks,