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

Signed-off-by: Yunlei He <heyun...@huawei.com>
---
 fs/f2fs/node.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 833b46b..ad28965 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -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)
-- 
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
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to