mbcache.c (b73077eb03f510a84b102fb97640e595a958403c) | mbcache.c (1495f230fa7750479c79e3656286b9183d662077) |
---|---|
1/* 2 * linux/fs/mbcache.c 3 * (C) 2001-2002 Andreas Gruenbacher, <a.gruenbacher@computer.org> 4 */ 5 6/* 7 * Filesystem Meta Information Block Cache (mbcache) 8 * --- 76 unchanged lines hidden (view full) --- 85static LIST_HEAD(mb_cache_list); 86static LIST_HEAD(mb_cache_lru_list); 87static DEFINE_SPINLOCK(mb_cache_spinlock); 88 89/* 90 * What the mbcache registers as to get shrunk dynamically. 91 */ 92 | 1/* 2 * linux/fs/mbcache.c 3 * (C) 2001-2002 Andreas Gruenbacher, <a.gruenbacher@computer.org> 4 */ 5 6/* 7 * Filesystem Meta Information Block Cache (mbcache) 8 * --- 76 unchanged lines hidden (view full) --- 85static LIST_HEAD(mb_cache_list); 86static LIST_HEAD(mb_cache_lru_list); 87static DEFINE_SPINLOCK(mb_cache_spinlock); 88 89/* 90 * What the mbcache registers as to get shrunk dynamically. 91 */ 92 |
93static int mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask); | 93static int mb_cache_shrink_fn(struct shrinker *shrink, 94 struct shrink_control *sc); |
94 95static struct shrinker mb_cache_shrinker = { 96 .shrink = mb_cache_shrink_fn, 97 .seeks = DEFAULT_SEEKS, 98}; 99 100static inline int 101__mb_cache_entry_is_hashed(struct mb_cache_entry *ce) --- 49 unchanged lines hidden (view full) --- 151 152/* 153 * mb_cache_shrink_fn() memory pressure callback 154 * 155 * This function is called by the kernel memory management when memory 156 * gets low. 157 * 158 * @shrink: (ignored) | 95 96static struct shrinker mb_cache_shrinker = { 97 .shrink = mb_cache_shrink_fn, 98 .seeks = DEFAULT_SEEKS, 99}; 100 101static inline int 102__mb_cache_entry_is_hashed(struct mb_cache_entry *ce) --- 49 unchanged lines hidden (view full) --- 152 153/* 154 * mb_cache_shrink_fn() memory pressure callback 155 * 156 * This function is called by the kernel memory management when memory 157 * gets low. 158 * 159 * @shrink: (ignored) |
159 * @nr_to_scan: Number of objects to scan 160 * @gfp_mask: (ignored) | 160 * @sc: shrink_control passed from reclaim |
161 * 162 * Returns the number of objects which are present in the cache. 163 */ 164static int | 161 * 162 * Returns the number of objects which are present in the cache. 163 */ 164static int |
165mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask) | 165mb_cache_shrink_fn(struct shrinker *shrink, struct shrink_control *sc) |
166{ 167 LIST_HEAD(free_list); 168 struct mb_cache *cache; 169 struct mb_cache_entry *entry, *tmp; 170 int count = 0; | 166{ 167 LIST_HEAD(free_list); 168 struct mb_cache *cache; 169 struct mb_cache_entry *entry, *tmp; 170 int count = 0; |
171 int nr_to_scan = sc->nr_to_scan; 172 gfp_t gfp_mask = sc->gfp_mask; |
|
171 172 mb_debug("trying to free %d entries", nr_to_scan); 173 spin_lock(&mb_cache_spinlock); 174 while (nr_to_scan-- && !list_empty(&mb_cache_lru_list)) { 175 struct mb_cache_entry *ce = 176 list_entry(mb_cache_lru_list.next, 177 struct mb_cache_entry, e_lru_list); 178 list_move_tail(&ce->e_lru_list, &free_list); --- 440 unchanged lines hidden --- | 173 174 mb_debug("trying to free %d entries", nr_to_scan); 175 spin_lock(&mb_cache_spinlock); 176 while (nr_to_scan-- && !list_empty(&mb_cache_lru_list)) { 177 struct mb_cache_entry *ce = 178 list_entry(mb_cache_lru_list.next, 179 struct mb_cache_entry, e_lru_list); 180 list_move_tail(&ce->e_lru_list, &free_list); --- 440 unchanged lines hidden --- |