]> git.baikalelectronics.ru Git - kernel.git/commitdiff
f2fs: do not set compression bit if kernel doesn't support
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 4 Aug 2022 03:33:54 +0000 (20:33 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 5 Aug 2022 11:18:08 +0000 (04:18 -0700)
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 <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/file.c

index 4dc7da8347ceab4ab41111f7461e0e177ff6eeba..d187bdc39b793a309bf1faf2f2c8270640cb86d2 100644 (file)
@@ -4292,8 +4292,9 @@ static inline void f2fs_update_extent_tree_range_compressed(struct inode *inode,
                                unsigned int c_len) { }
 #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 =
@@ -4316,6 +4317,10 @@ static inline void set_compress_context(struct inode *inode)
        stat_inc_compr_inode(inode);
        inc_compr_inode_stat(inode);
        f2fs_mark_inode_dirty_sync(inode, true);
+       return 0;
+#else
+       return -EOPNOTSUPP;
+#endif
 }
 
 static inline bool f2fs_disable_compressed_file(struct inode *inode)
index d2159d6880d65d49c5a7b5dd5f070d52de865908..67e5a6cd25e8c4bffd1e629b86b6df9e0a5a88d2 100644 (file)
@@ -1878,8 +1878,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
                                return -EINVAL;
                        if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
                                return -EINVAL;
-
-                       set_compress_context(inode);
+                       if (set_compress_context(inode))
+                               return -EOPNOTSUPP;
                }
        }