f2fs: enable extent cache for compression files in read-only
authorDaeho Jeong <daehojeong@google.com>
Tue, 15 Jun 2021 22:39:04 +0000 (15:39 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 28 Jun 2021 15:43:51 +0000 (08:43 -0700)
Let's allow extent cache for RO partition.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h

index d84e78d..16ce1ad 100644 (file)
@@ -3148,25 +3148,6 @@ static inline bool is_dot_dotdot(const u8 *name, size_t len)
        return false;
 }
 
-static inline bool f2fs_may_extent_tree(struct inode *inode)
-{
-       struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
-
-       if (!test_opt(sbi, EXTENT_CACHE) ||
-                       is_inode_flag_set(inode, FI_NO_EXTENT) ||
-                       is_inode_flag_set(inode, FI_COMPRESSED_FILE))
-               return false;
-
-       /*
-        * for recovered files during mount do not create extents
-        * if shrinker is not registered.
-        */
-       if (list_empty(&sbi->s_list))
-               return false;
-
-       return S_ISREG(inode->i_mode);
-}
-
 static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
                                        size_t size, gfp_t flags)
 {
@@ -4201,6 +4182,26 @@ F2FS_FEATURE_FUNCS(casefold, CASEFOLD);
 F2FS_FEATURE_FUNCS(compression, COMPRESSION);
 F2FS_FEATURE_FUNCS(readonly, RO);
 
+static inline bool f2fs_may_extent_tree(struct inode *inode)
+{
+       struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+
+       if (!test_opt(sbi, EXTENT_CACHE) ||
+                       is_inode_flag_set(inode, FI_NO_EXTENT) ||
+                       (is_inode_flag_set(inode, FI_COMPRESSED_FILE) &&
+                        !f2fs_sb_has_readonly(sbi)))
+               return false;
+
+       /*
+        * for recovered files during mount do not create extents
+        * if shrinker is not registered.
+        */
+       if (list_empty(&sbi->s_list))
+               return false;
+
+       return S_ISREG(inode->i_mode);
+}
+
 #ifdef CONFIG_BLK_DEV_ZONED
 static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
                                    block_t blkaddr)