summaryrefslogtreecommitdiff
path: root/fs/f2fs/shrinker.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2015-06-20 01:36:07 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2015-08-05 00:09:55 +0300
commit1b38dc8e74a366b92986755c304591e330f3c3e0 (patch)
treeb5e5b2d8c23eaf31b697b7031692d537f18bf5d7 /fs/f2fs/shrinker.c
parent2658e50de61429f57d9496bfe371f232e2d039a1 (diff)
downloadlinux-1b38dc8e74a366b92986755c304591e330f3c3e0.tar.xz
f2fs: shrink nat_cache entries
This patch registers shrinking nat_cache entries. Reviewed-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.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index 16e9b43635c2..c4bd6ee5936c 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -18,6 +18,11 @@ static LIST_HEAD(f2fs_list);
static DEFINE_SPINLOCK(f2fs_list_lock);
static unsigned int shrinker_run_no;
+static unsigned long __count_nat_entries(struct f2fs_sb_info *sbi)
+{
+ return NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
+}
+
unsigned long f2fs_shrink_count(struct shrinker *shrink,
struct shrink_control *sc)
{
@@ -37,7 +42,8 @@ unsigned long f2fs_shrink_count(struct shrinker *shrink,
}
spin_unlock(&f2fs_list_lock);
- /* TODO: count # of objects */
+ /* shrink clean nat cache entries */
+ count += __count_nat_entries(sbi);
spin_lock(&f2fs_list_lock);
p = p->next;
@@ -76,7 +82,8 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
sbi->shrinker_run_no = run_no;
- /* TODO: shrink caches */
+ /* shrink clean nat cache entries */
+ freed += try_to_free_nats(sbi, nr);
spin_lock(&f2fs_list_lock);
p = p->next;