summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/shrinker.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-07-28 18:33:46 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2015-08-20 09:00:06 -0700
commit31696580bf4c042a0f7b06d855e04441488d18b1 (patch)
tree33904342d5332881fc6ffc925dbcb294c8ed87e4 /fs/f2fs/shrinker.c
parent206e61be29624499af46546076e835da93e6bde5 (diff)
downloadlinux-31696580bf4c042a0f7b06d855e04441488d18b1.tar.bz2
f2fs: shrink free_nids entries
This patch introduces __count_free_nids/try_to_free_nids and registers them in slab shrinker for shrinking under memory pressure. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/shrinker.c')
-rw-r--r--fs/f2fs/shrinker.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index 9aa4235cd304..da0d8e0b55a5 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -23,6 +23,13 @@ static unsigned long __count_nat_entries(struct f2fs_sb_info *sbi)
return NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
}
+static unsigned long __count_free_nids(struct f2fs_sb_info *sbi)
+{
+ if (NM_I(sbi)->fcnt > NAT_ENTRY_PER_BLOCK)
+ return NM_I(sbi)->fcnt - NAT_ENTRY_PER_BLOCK;
+ return 0;
+}
+
static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi)
{
return sbi->total_ext_tree + atomic_read(&sbi->total_ext_node);
@@ -53,6 +60,9 @@ unsigned long f2fs_shrink_count(struct shrinker *shrink,
/* shrink clean nat cache entries */
count += __count_nat_entries(sbi);
+ /* count free nids cache entries */
+ count += __count_free_nids(sbi);
+
spin_lock(&f2fs_list_lock);
p = p->next;
mutex_unlock(&sbi->umount_mutex);
@@ -97,6 +107,10 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
if (freed < nr)
freed += try_to_free_nats(sbi, nr - freed);
+ /* shrink free nids cache entries */
+ if (freed < nr)
+ freed += try_to_free_nids(sbi, nr - freed);
+
spin_lock(&f2fs_list_lock);
p = p->next;
list_move_tail(&sbi->s_list, &f2fs_list);