shrinker.c (e7547daccd6a37522f0af74ec4b5a3036f3dd328) | shrinker.c (71644dff481180ba024ac4f5cb1f068756357adf) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * f2fs shrinker support 4 * the basic infra was copied from fs/ubifs/shrinker.c 5 * 6 * Copyright (c) 2015 Motorola Mobility 7 * Copyright (c) 2015 Jaegeuk Kim <jaegeuk@kernel.org> 8 */ --- 45 unchanged lines hidden (view full) --- 54 p = p->next; 55 continue; 56 } 57 spin_unlock(&f2fs_list_lock); 58 59 /* count read extent cache entries */ 60 count += __count_extent_cache(sbi, EX_READ); 61 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * f2fs shrinker support 4 * the basic infra was copied from fs/ubifs/shrinker.c 5 * 6 * Copyright (c) 2015 Motorola Mobility 7 * Copyright (c) 2015 Jaegeuk Kim <jaegeuk@kernel.org> 8 */ --- 45 unchanged lines hidden (view full) --- 54 p = p->next; 55 continue; 56 } 57 spin_unlock(&f2fs_list_lock); 58 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); 64 |
|
62 /* count clean nat cache entries */ 63 count += __count_nat_entries(sbi); 64 65 /* count free nids cache entries */ 66 count += __count_free_nids(sbi); 67 68 spin_lock(&f2fs_list_lock); 69 p = p->next; --- 27 unchanged lines hidden (view full) --- 97 if (!mutex_trylock(&sbi->umount_mutex)) { 98 p = p->next; 99 continue; 100 } 101 spin_unlock(&f2fs_list_lock); 102 103 sbi->shrinker_run_no = run_no; 104 | 65 /* count clean nat cache entries */ 66 count += __count_nat_entries(sbi); 67 68 /* count free nids cache entries */ 69 count += __count_free_nids(sbi); 70 71 spin_lock(&f2fs_list_lock); 72 p = p->next; --- 27 unchanged lines hidden (view full) --- 100 if (!mutex_trylock(&sbi->umount_mutex)) { 101 p = p->next; 102 continue; 103 } 104 spin_unlock(&f2fs_list_lock); 105 106 sbi->shrinker_run_no = run_no; 107 |
108 /* shrink extent cache entries */ 109 freed += f2fs_shrink_age_extent_tree(sbi, nr >> 2); 110 |
|
105 /* shrink read extent cache entries */ | 111 /* shrink read extent cache entries */ |
106 freed += f2fs_shrink_read_extent_tree(sbi, nr >> 1); | 112 freed += f2fs_shrink_read_extent_tree(sbi, nr >> 2); |
107 108 /* shrink clean nat cache entries */ 109 if (freed < nr) 110 freed += f2fs_try_to_free_nats(sbi, nr - freed); 111 112 /* shrink free nids cache entries */ 113 if (freed < nr) 114 freed += f2fs_try_to_free_nids(sbi, nr - freed); --- 14 unchanged lines hidden (view full) --- 129 spin_lock(&f2fs_list_lock); 130 list_add_tail(&sbi->s_list, &f2fs_list); 131 spin_unlock(&f2fs_list_lock); 132} 133 134void f2fs_leave_shrinker(struct f2fs_sb_info *sbi) 135{ 136 f2fs_shrink_read_extent_tree(sbi, __count_extent_cache(sbi, EX_READ)); | 113 114 /* shrink clean nat cache entries */ 115 if (freed < nr) 116 freed += f2fs_try_to_free_nats(sbi, nr - freed); 117 118 /* shrink free nids cache entries */ 119 if (freed < nr) 120 freed += f2fs_try_to_free_nids(sbi, nr - freed); --- 14 unchanged lines hidden (view full) --- 135 spin_lock(&f2fs_list_lock); 136 list_add_tail(&sbi->s_list, &f2fs_list); 137 spin_unlock(&f2fs_list_lock); 138} 139 140void f2fs_leave_shrinker(struct f2fs_sb_info *sbi) 141{ 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)); |
|
137 138 spin_lock(&f2fs_list_lock); 139 list_del_init(&sbi->s_list); 140 spin_unlock(&f2fs_list_lock); 141} | 145 146 spin_lock(&f2fs_list_lock); 147 list_del_init(&sbi->s_list); 148 spin_unlock(&f2fs_list_lock); 149} |