Skip to contentSkip to conversation

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

PATCH Superseded Yunlei He 3 participants 3 messages Nov 17, 2017 – Nov 27, 2017 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 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..104b44c 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 v1 1/1
#1 lore raw
Quoted 22 lines · Yunlei He

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 +0 -3
index fe1fc66..104b44c 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;

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

Quoted 10 lines
fs/f2fs/node.c +5 -1
@@ -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;
+		}

Coding style, we don't need brace for a single line, other party looks good to me:

Thanks,

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

Quoted 9 lines
fs/f2fs/node.c +2 -1
+		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

maintainer
#2 lore raw
Quoted 25 lines · Chao Yu
Quoted 24 lines · Yunlei He

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 +0 -3
index fe1fc66..104b44c 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);
 
Quoted 8 lines

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

Quoted 8 lines
fs/f2fs/node.c +5 -1
 	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;
+		}

I modified this to avoid goto statement like:

		if (!test_bit_le()) {
			/* do something */
		}

Thanks,

Quoted 7 lines

Coding style, we don't need brace for a single line, other party looks good to me:

Thanks,

Quoted 9 lines

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

Quoted 9 lines
fs/f2fs/node.c +2 -1
+		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