Skip to content

Commit 912f0d6

Browse files
author
Jaegeuk Kim
committed
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. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent dbf8e63 commit 912f0d6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

fs/f2fs/f2fs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4292,8 +4292,9 @@ static inline void f2fs_update_extent_tree_range_compressed(struct inode *inode,
42924292
unsigned int c_len) { }
42934293
#endif
42944294

4295-
static inline void set_compress_context(struct inode *inode)
4295+
static inline int set_compress_context(struct inode *inode)
42964296
{
4297+
#ifdef CONFIG_F2FS_FS_COMPRESSION
42974298
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
42984299

42994300
F2FS_I(inode)->i_compress_algorithm =
@@ -4316,6 +4317,10 @@ static inline void set_compress_context(struct inode *inode)
43164317
stat_inc_compr_inode(inode);
43174318
inc_compr_inode_stat(inode);
43184319
f2fs_mark_inode_dirty_sync(inode, true);
4320+
return 0;
4321+
#else
4322+
return -EOPNOTSUPP;
4323+
#endif
43194324
}
43204325

43214326
static inline bool f2fs_disable_compressed_file(struct inode *inode)

fs/f2fs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,8 +1878,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
18781878
return -EINVAL;
18791879
if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
18801880
return -EINVAL;
1881-
1882-
set_compress_context(inode);
1881+
if (set_compress_context(inode))
1882+
return -EOPNOTSUPP;
18831883
}
18841884
}
18851885

0 commit comments

Comments
 (0)