| .. | .. |
|---|
| 41 | 41 | } |
|---|
| 42 | 42 | } |
|---|
| 43 | 43 | |
|---|
| 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 | | - |
|---|
| 73 | 44 | static bool __init_may_extent_tree(struct inode *inode, enum extent_type type) |
|---|
| 74 | 45 | { |
|---|
| 75 | 46 | 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)); |
|---|
| 79 | 52 | return false; |
|---|
| 80 | 53 | } |
|---|
| 81 | 54 | |
|---|
| .. | .. |
|---|
| 88 | 61 | if (list_empty(&F2FS_I_SB(inode)->s_list)) |
|---|
| 89 | 62 | return false; |
|---|
| 90 | 63 | |
|---|
| 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; |
|---|
| 92 | 80 | } |
|---|
| 93 | 81 | |
|---|
| 94 | 82 | static void __try_update_largest_extent(struct extent_tree *et, |
|---|