hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/f2fs/extent_cache.c
....@@ -41,41 +41,14 @@
4141 }
4242 }
4343
44
-static bool __may_read_extent_tree(struct inode *inode)
45
-{
46
- struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
47
-
48
- if (!test_opt(sbi, READ_EXTENT_CACHE))
49
- return false;
50
- if (is_inode_flag_set(inode, FI_NO_EXTENT))
51
- return false;
52
- if (is_inode_flag_set(inode, FI_COMPRESSED_FILE) &&
53
- !f2fs_sb_has_readonly(sbi))
54
- return false;
55
- return S_ISREG(inode->i_mode);
56
-}
57
-
58
-static bool __may_age_extent_tree(struct inode *inode)
59
-{
60
- struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
61
-
62
- if (!test_opt(sbi, AGE_EXTENT_CACHE))
63
- return false;
64
- /* don't cache block age info for cold file */
65
- if (is_inode_flag_set(inode, FI_COMPRESSED_FILE))
66
- return false;
67
- if (file_is_cold(inode))
68
- return false;
69
-
70
- return S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode);
71
-}
72
-
7344 static bool __init_may_extent_tree(struct inode *inode, enum extent_type type)
7445 {
7546 if (type == EX_READ)
76
- return __may_read_extent_tree(inode);
77
- else if (type == EX_BLOCK_AGE)
78
- return __may_age_extent_tree(inode);
47
+ return test_opt(F2FS_I_SB(inode), READ_EXTENT_CACHE) &&
48
+ S_ISREG(inode->i_mode);
49
+ if (type == EX_BLOCK_AGE)
50
+ return test_opt(F2FS_I_SB(inode), AGE_EXTENT_CACHE) &&
51
+ (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode));
7952 return false;
8053 }
8154
....@@ -88,7 +61,22 @@
8861 if (list_empty(&F2FS_I_SB(inode)->s_list))
8962 return false;
9063
91
- return __init_may_extent_tree(inode, type);
64
+ if (!__init_may_extent_tree(inode, type))
65
+ return false;
66
+
67
+ if (type == EX_READ) {
68
+ if (is_inode_flag_set(inode, FI_NO_EXTENT))
69
+ return false;
70
+ if (is_inode_flag_set(inode, FI_COMPRESSED_FILE) &&
71
+ !f2fs_sb_has_readonly(F2FS_I_SB(inode)))
72
+ return false;
73
+ } else if (type == EX_BLOCK_AGE) {
74
+ if (is_inode_flag_set(inode, FI_COMPRESSED_FILE))
75
+ return false;
76
+ if (file_is_cold(inode))
77
+ return false;
78
+ }
79
+ return true;
9280 }
9381
9482 static void __try_update_largest_extent(struct extent_tree *et,