Skip to contentSkip to conversation

f2fs: remove unneed reada during build free nids

PATCH In review Yunlei He 3 participants 4 messages Feb 9, 2018 – Feb 11, 2018 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: remove unneed reada during build free nids

This patch remove unneed reada during build free nids. If few nids left, three will introduce a lot of no hit read io.

---
 fs/f2fs/node.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
fs/f2fs/node.c +6 -8
index 833b46b..ad28965 100644
@@ -2033,10 +2033,6 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 			return;
 	}
 
-	/* readahead nat pages to be scanned */
-	ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES,
-							META_NAT, true);
-
 	down_read(&nm_i->nat_tree_lock);
 
 	while (1) {
@@ -2052,7 +2048,12 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 		if (unlikely(nid >= nm_i->max_nid))
 			nid = 0;
 
-		if (++i >= FREE_NID_PAGES)
+		/* bg build, no more than 8 pages */
+		if ((!sync || mount) && ++i >= FREE_NID_PAGES)
+			break;
+
+		/* fg build, until free nids is not zero */
+		if (sync && !mount && nm_i->nid_cnt[FREE_NID])
 			break;
 	}
 
@@ -2063,9 +2064,6 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 	scan_curseg_cache(sbi);
 
 	up_read(&nm_i->nat_tree_lock);
-
-	ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid),
-					nm_i->ra_nid_pages, META_NAT, false);
 }
 
 void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
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
maintainer
#1 lore raw
Quoted 3 lines · Yunlei He

This patch remove unneed reada during build free nids. If few nids left, three will introduce a lot of no hit read io.

I guess it is due to be lack of commit c1fe3e981440 ("Revert "f2fs:
reuse nids more aggressively""), before that commit, we will update .next_scan_nid randomly instead of updating it ascendingly, then during __build_free_nids we may readahead NAT pages starting from random position.

Could try that commit to check IO again?

Thanks,

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

author
#2 lore raw
Quoted 13 lines

-----Original Message-----
From: Chao Yu [mailto:[email protected]]
Sent: Friday, February 09, 2018 9:37 PM
To: heyunlei; [email protected]; Yuchao (T); [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: remove unneed reada during build free nids

Quoted 3 lines · Yunlei He

This patch remove unneed reada during build free nids. If few nids left, three will introduce a lot of no hit read io.

Quoted 5 lines

I guess it is due to be lack of commit c1fe3e981440 ("Revert "f2fs:
reuse nids more aggressively""), before that commit, we will update .next_scan_nid randomly instead of updating it ascendingly, then during __build_free_nids we may readahead NAT pages starting from random position.

I think commit c1fe3e981440 will reduce fragment of nat area, it will locate all used nids at the left head of nat area, which I think will do benefit to WA ?

e.g, if we have used 10000 nids, which will hold 10000/455 blocks at least. Without this commit, the blocks taken for nids will expansion, may be 10000 blocks in the worst case, at this time, if we update node info, we will produce more nat IOs?

Quoted 4 lines

Could try that commit to check IO again?

Thanks,

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

#3 lore raw
Quoted 19 lines · heyunlei
Quoted 13 lines

-----Original Message-----
From: Chao Yu [mailto:[email protected]]
Sent: Friday, February 09, 2018 9:37 PM
To: heyunlei; [email protected]; Yuchao (T); [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: remove unneed reada during build free nids

Quoted 3 lines · Yunlei He

This patch remove unneed reada during build free nids. If few nids left, three will introduce a lot of no hit read io.

Quoted 5 lines

I guess it is due to be lack of commit c1fe3e981440 ("Revert "f2fs:
reuse nids more aggressively""), before that commit, we will update .next_scan_nid randomly instead of updating it ascendingly, then during __build_free_nids we may readahead NAT pages starting from random position.

Quoted 3 lines

I think commit c1fe3e981440 will reduce fragment of nat area, it will locate all used nids at the left head of nat area, which I think will do benefit to WA ?

Yup, IMO, it can reduce WA. ;)

Also, there is another patch intends to reduce WA by adjusting allocation policy of free nid.

FYI

https://patchwork.kernel.org/patch/10084653/

Quoted 5 lines

e.g, if we have used 10000 nids, which will hold 10000/455 blocks at least. Without this commit, the blocks taken for nids will expansion, may be 10000 blocks in the worst case, at this time, if we update node info, we will produce more nat IOs?

That's right.

Thanks,

Quoted 5 lines
Quoted 5 lines

Could try that commit to check IO again?

Thanks,

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