Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26eb6894 authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

BACKPORT: f2fs: do not set compression bit if kernel doesn't support



If kernel doesn't have CONFIG_F2FS_FS_COMPRESSION, a file having FS_COMPR_FL via
ioctl(FS_IOC_SETFLAGS) is unaccessible due to f2fs_is_compress_backend_ready().
Let's avoid it.

Bug: 240921972
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit d5a44717f6e0f0943808671e36b1909619707016)
Change-Id: Ieb0f8945175ea5ccb0060690e882f054360fb8f0
parent 17bdd623
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -3932,8 +3932,9 @@ static inline int f2fs_init_compress_mempool(void) { return 0; }
static inline void f2fs_destroy_compress_mempool(void) { }
#endif

static inline void set_compress_context(struct inode *inode)
static inline int set_compress_context(struct inode *inode)
{
#ifdef CONFIG_F2FS_FS_COMPRESSION
	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);

	F2FS_I(inode)->i_compress_algorithm =
@@ -3946,6 +3947,10 @@ static inline void set_compress_context(struct inode *inode)
	set_inode_flag(inode, FI_COMPRESSED_FILE);
	stat_inc_compr_inode(inode);
	f2fs_mark_inode_dirty_sync(inode, true);
	return 0;
#else
	return -EOPNOTSUPP;
#endif
}

static inline u32 f2fs_disable_compressed_file(struct inode *inode)
+2 −2
Original line number Diff line number Diff line
@@ -1847,8 +1847,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
		if (iflags & F2FS_COMPR_FL) {
			if (!f2fs_may_compress(inode))
				return -EINVAL;

			set_compress_context(inode);
			if (set_compress_context(inode))
				return -EOPNOTSUPP;
		}
	}
	if ((iflags ^ masked_flags) & F2FS_NOCOMP_FL) {