From 81eb8d6e2869b119d4a7b8c02091c3779733a3ac Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 24 Oct 2013 13:31:34 +0900 Subject: f2fs: reclaim prefree segments periodically Previously, f2fs postpones reclaiming prefree segments into free segments as much as possible. However, if user writes and deletes a bunch of data without any sync or fsync calls, some flash storages can suffer from garbage collections. So, this patch adds the reclaiming codes to f2fs_write_node_pages and background GC thread. If there are a lot of prefree segments, let's do checkpoint so that f2fs submits discard commands for the prefree regions to the flash storage. Signed-off-by: Changman Lee Signed-off-by: Jaegeuk Kim --- fs/f2fs/node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs/f2fs/node.c') diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index cc119b65a0d3..89dd8a5a3ca3 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1206,7 +1206,8 @@ static int f2fs_write_node_pages(struct address_space *mapping, long nr_to_write = wbc->nr_to_write; /* First check balancing cached NAT entries */ - if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK)) { + if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || + excess_prefree_segs(sbi)) { f2fs_sync_fs(sbi->sb, true); return 0; } -- cgit v1.2.3