Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1207936

[PATCH 2/2] f2fs: avoid garbage collecting already moved node blocks

From Jaegeuk Kim <jaegeuk@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 2/2] f2fs: avoid garbage collecting already moved node blocks
Date 2015-08-15 01:20 +0200
Message-ID <pXwqt-89L-9@gated-at.bofh.it> (permalink)
References <pXwgN-7Yv-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If node blocks were already moved, we don't need to move them again.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/gc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 81de28d8..0a5d573 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -396,14 +396,18 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
 {
 	bool initial = true;
 	struct f2fs_summary *entry;
+	block_t start_addr;
 	int off;
 
+	start_addr = START_BLOCK(sbi, segno);
+
 next_step:
 	entry = sum;
 
 	for (off = 0; off < sbi->blocks_per_seg; off++, entry++) {
 		nid_t nid = le32_to_cpu(entry->nid);
 		struct page *node_page;
+		struct node_info ni;
 
 		/* stop BG_GC if there is not enough free sections. */
 		if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0))
@@ -426,6 +430,12 @@ next_step:
 			continue;
 		}
 
+		get_node_info(sbi, nid, &ni);
+		if (ni.blk_addr != start_addr + off) {
+			f2fs_put_page(node_page, 1);
+			continue;
+		}
+
 		/* set page dirty and write it */
 		if (gc_type == FG_GC) {
 			f2fs_wait_on_page_writeback(node_page, NODE);
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] f2fs: handle failed bio allocation Jaegeuk Kim <jaegeuk@kernel.org> - 2015-08-15 01:10 +0200
  [PATCH 2/2] f2fs: avoid garbage collecting already moved node blocks Jaegeuk Kim <jaegeuk@kernel.org> - 2015-08-15 01:20 +0200

csiph-web