summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/node.c
diff options
context:
space:
mode:
authorChao Yu2015-07-28 12:33:46 +0200
committerJaegeuk Kim2015-08-20 18:00:06 +0200
commit31696580bf4c042a0f7b06d855e04441488d18b1 (patch)
tree33904342d5332881fc6ffc925dbcb294c8ed87e4 /fs/f2fs/node.c
parentf2fs: avoid clear valid page (diff)
downloadkernel-qcow2-linux-31696580bf4c042a0f7b06d855e04441488d18b1.tar.gz
kernel-qcow2-linux-31696580bf4c042a0f7b06d855e04441488d18b1.tar.xz
kernel-qcow2-linux-31696580bf4c042a0f7b06d855e04441488d18b1.zip
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/node.c')
-rw-r--r--fs/f2fs/node.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index ac9110788b17..6e10c2a08ec6 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1635,6 +1635,34 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
kmem_cache_free(free_nid_slab, i);
}
+int try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
+{
+ struct f2fs_nm_info *nm_i = NM_I(sbi);
+ struct free_nid *i, *next;
+ int nr = nr_shrink;
+
+ if (!mutex_trylock(&nm_i->build_lock))
+ return 0;
+
+ spin_lock(&nm_i->free_nid_list_lock);
+ list_for_each_entry_safe(i, next, &nm_i->free_nid_list, list) {
+ if (nr_shrink <= 0 || nm_i->fcnt <= NAT_ENTRY_PER_BLOCK)
+ break;
+ if (i->state == NID_ALLOC)
+ continue;
+ __del_from_free_nid_list(nm_i, i);
+ nm_i->fcnt--;
+ spin_unlock(&nm_i->free_nid_list_lock);
+ kmem_cache_free(free_nid_slab, i);
+ nr_shrink--;
+ spin_lock(&nm_i->free_nid_list_lock);
+ }
+ spin_unlock(&nm_i->free_nid_list_lock);
+ mutex_unlock(&nm_i->build_lock);
+
+ return nr - nr_shrink;
+}
+
void recover_inline_xattr(struct inode *inode, struct page *page)
{
void *src_addr, *dst_addr;