Skip to contentSkip to conversation

f2fs: no need to read nat block if nat_block_bitmap is set

PATCH In review Yunlei He 2 participants 2 messages Nov 20, 2017 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH v2 1/1 f2fs: no need to read nat block if nat_block_bitmap is set

No need to read nat block if nat_block_bitmap is set.

---
 fs/f2fs/node.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/f2fs/node.c +7 -5
index fe1fc66..7fd65928 100644
@@ -1949,9 +1949,6 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
 	unsigned int nat_ofs = NAT_BLOCK_OFFSET(start_nid);
 	int i;
 
-	if (test_bit_le(nat_ofs, nm_i->nat_block_bitmap))
-		return;
-
 	__set_bit_le(nat_ofs, nm_i->nat_block_bitmap);
 
 	i = start_nid % NAT_ENTRY_PER_BLOCK;
@@ -2056,11 +2053,16 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 	down_read(&nm_i->nat_tree_lock);
 
 	while (1) {
-		struct page *page = get_current_nat_page(sbi, nid);
+		struct page *page;
 
+		if (test_bit_le(NAT_BLOCK_OFFSET(nid),
+					nm_i->nat_block_bitmap))
+			goto skip;
+
+		page = get_current_nat_page(sbi, nid);
 		scan_nat_page(sbi, page, nid);
 		f2fs_put_page(page, 1);
-
+skip:
 		nid += (NAT_ENTRY_PER_BLOCK - (nid % NAT_ENTRY_PER_BLOCK));
 		if (unlikely(nid >= nm_i->max_nid))
 			nid = 0;
Signature · 6 lines
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Reviewed-by on v2 1/1
#1 lore raw
Quoted 3 lines · Yunlei He

No need to read nat block if nat_block_bitmap is set.

Thanks,

Quoted 28 lines
---
 fs/f2fs/node.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/f2fs/node.c +3 -4
index fe1fc66..7fd65928 100644
@@ -1949,9 +1949,6 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
 	unsigned int nat_ofs = NAT_BLOCK_OFFSET(start_nid);
 	int i;
 
-	if (test_bit_le(nat_ofs, nm_i->nat_block_bitmap))
-		return;
-
 	__set_bit_le(nat_ofs, nm_i->nat_block_bitmap);
 
 	i = start_nid % NAT_ENTRY_PER_BLOCK;
@@ -2056,11 +2053,16 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 	down_read(&nm_i->nat_tree_lock);
 
 	while (1) {
-		struct page *page = get_current_nat_page(sbi, nid);
+		struct page *page;
 
+		if (test_bit_le(NAT_BLOCK_OFFSET(nid),
+					nm_i->nat_block_bitmap))

fs/f2fs/node.c static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount) · line 2068

Quoted 10 lines
fs/f2fs/node.c +4 -1
+			goto skip;
+
+		page = get_current_nat_page(sbi, nid);
 		scan_nat_page(sbi, page, nid);
 		f2fs_put_page(page, 1);
-
+skip:
 		nid += (NAT_ENTRY_PER_BLOCK - (nid % NAT_ENTRY_PER_BLOCK));
 		if (unlikely(nid >= nm_i->max_nid))
 			nid = 0;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot