.. | .. |
---|
18 | 18 | |
---|
19 | 19 | static unsigned long __count_nat_entries(struct f2fs_sb_info *sbi) |
---|
20 | 20 | { |
---|
21 | | - long count = NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt; |
---|
22 | | - |
---|
23 | | - return count > 0 ? count : 0; |
---|
| 21 | + return NM_I(sbi)->nat_cnt[RECLAIMABLE_NAT]; |
---|
24 | 22 | } |
---|
25 | 23 | |
---|
26 | 24 | static unsigned long __count_free_nids(struct f2fs_sb_info *sbi) |
---|
.. | .. |
---|
30 | 28 | return count > 0 ? count : 0; |
---|
31 | 29 | } |
---|
32 | 30 | |
---|
33 | | -static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi) |
---|
| 31 | +static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi, |
---|
| 32 | + enum extent_type type) |
---|
34 | 33 | { |
---|
35 | | - return atomic_read(&sbi->total_zombie_tree) + |
---|
36 | | - atomic_read(&sbi->total_ext_node); |
---|
| 34 | + struct extent_tree_info *eti = &sbi->extent_tree[type]; |
---|
| 35 | + |
---|
| 36 | + return atomic_read(&eti->total_zombie_tree) + |
---|
| 37 | + atomic_read(&eti->total_ext_node); |
---|
37 | 38 | } |
---|
38 | 39 | |
---|
39 | 40 | unsigned long f2fs_shrink_count(struct shrinker *shrink, |
---|
.. | .. |
---|
55 | 56 | } |
---|
56 | 57 | spin_unlock(&f2fs_list_lock); |
---|
57 | 58 | |
---|
58 | | - /* count extent cache entries */ |
---|
59 | | - count += __count_extent_cache(sbi); |
---|
| 59 | + /* count read extent cache entries */ |
---|
| 60 | + count += __count_extent_cache(sbi, EX_READ); |
---|
| 61 | + |
---|
| 62 | + /* count block age extent cache entries */ |
---|
| 63 | + count += __count_extent_cache(sbi, EX_BLOCK_AGE); |
---|
60 | 64 | |
---|
61 | 65 | /* count clean nat cache entries */ |
---|
62 | 66 | count += __count_nat_entries(sbi); |
---|
.. | .. |
---|
102 | 106 | sbi->shrinker_run_no = run_no; |
---|
103 | 107 | |
---|
104 | 108 | /* shrink extent cache entries */ |
---|
105 | | - freed += f2fs_shrink_extent_tree(sbi, nr >> 1); |
---|
| 109 | + freed += f2fs_shrink_age_extent_tree(sbi, nr >> 2); |
---|
| 110 | + |
---|
| 111 | + /* shrink read extent cache entries */ |
---|
| 112 | + freed += f2fs_shrink_read_extent_tree(sbi, nr >> 2); |
---|
106 | 113 | |
---|
107 | 114 | /* shrink clean nat cache entries */ |
---|
108 | 115 | if (freed < nr) |
---|
.. | .. |
---|
132 | 139 | |
---|
133 | 140 | void f2fs_leave_shrinker(struct f2fs_sb_info *sbi) |
---|
134 | 141 | { |
---|
135 | | - f2fs_shrink_extent_tree(sbi, __count_extent_cache(sbi)); |
---|
| 142 | + f2fs_shrink_read_extent_tree(sbi, __count_extent_cache(sbi, EX_READ)); |
---|
| 143 | + f2fs_shrink_age_extent_tree(sbi, |
---|
| 144 | + __count_extent_cache(sbi, EX_BLOCK_AGE)); |
---|
136 | 145 | |
---|
137 | 146 | spin_lock(&f2fs_list_lock); |
---|
138 | 147 | list_del_init(&sbi->s_list); |
---|