/* * Prune the dcache to remove unused children of the parent dentry. */ void shrink_dcache_parent(struct dentry * parent) { int found; while ((found = select_parent(parent)) != 0) prune_dcache(found); }
/* * This is called from kswapd when we think we need some * more memory, but aren't really sure how much. So we * carefully try to free a _bit_ of our dcache, but not * too much. * * Priority: * 0 - very urgent: shrink everything * ... * 6 - base-level: try to shrink a bit. */ void shrink_dcache_memory(int priority, unsigned int gfp_mask) { if (gfp_mask & __GFP_IO) { int count = 0; if (priority) count = dentry_stat.nr_unused / priority; prune_dcache(count, -1); } }
void shrink_dcache_parent(struct dentry * parent) { int found; while ((found = select_parent(parent)) != 0) { prune_dcache(found); conditional_schedule(); /* Typically sys_rmdir() */ } }
static void shrink_dentry_inodes(int goal) { int found; spin_unlock(&inode_lock); found = select_dcache(goal, 0); if (found < goal) found = goal; prune_dcache(found); spin_lock(&inode_lock); }
/* * Searches the inodes list for freeable inodes, * shrinking the dcache before (and possible after, * if we're low) */ static void try_to_free_inodes(int goal) { /* * First stry to just get rid of unused inodes. * * If we can't reach our goal that way, we'll have * to try to shrink the dcache and sync existing * inodes.. */ free_inodes(); goal -= inodes_stat.nr_free_inodes; if (goal > 0) { spin_unlock(&inode_lock); select_dcache(goal, 0); prune_dcache(goal); spin_lock(&inode_lock); sync_all_inodes(); free_inodes(); } }
/* * This is called from kswapd when we think we need some * more memory, but aren't really sure how much. So we * carefully try to free a _bit_ of our dcache, but not * too much. * * Priority: * 0 - very urgent: shrink everything * ... * 6 - base-level: try to shrink a bit. */ int shrink_dcache_memory(int priority, unsigned int gfp_mask) { int count = 0; /* * Nasty deadlock avoidance. * * ext2_new_block->getblk->GFP->shrink_dcache_memory->prune_dcache-> * prune_one_dentry->dput->dentry_iput->iput->inode->i_sb->s_op-> * put_inode->ext2_discard_prealloc->ext2_free_blocks->lock_super-> * DEADLOCK. * * We should make sure we don't hold the superblock lock over * block allocations, but for now: */ if (!(gfp_mask & __GFP_FS)) return 0; count = dentry_stat.nr_unused / priority; prune_dcache(count); return kmem_cache_shrink(dentry_cache); }
/* * This is called from kswapd when we think we need some * more memory, but aren't really sure how much. So we * carefully try to free a _bit_ of our dcache, but not * too much. * * Priority: * 0 - very urgent: shrink everything * ... * 6 - base-level: try to shrink a bit. */ void shrink_dcache_memory(int priority, unsigned int gfp_mask) { prune_dcache(0); }