linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Yunlei He <heyunlei@huawei.com>
To: jaegeuk@kernel.org, yuchao0@huawei.com,
	linux-f2fs-devel@lists.sourceforge.net
Cc: zhangdianfang@huawei.com
Subject: [PATCH v3] f2fs: build free nid bitmap during flush nat entries
Date: Thu, 26 Apr 2018 14:06:56 +0800	[thread overview]
Message-ID: <1524722816-2218-1-git-send-email-heyunlei@huawei.com> (raw)

This patch introduce free nid bitmap build during flush
nat entries in order to reduce synchronous read in the
process of build free nids.

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

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index f202398..cc825a4 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1947,7 +1947,7 @@ static void remove_free_nid(struct f2fs_sb_info *sbi, nid_t nid)
 }
 
 static void scan_nat_page(struct f2fs_sb_info *sbi,
-			struct page *nat_page, nid_t start_nid)
+		struct page *nat_page, nid_t start_nid, bool in_build)
 {
 	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct f2fs_nat_block *nat_blk = page_address(nat_page);
@@ -1955,6 +1955,9 @@ 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;
@@ -1966,7 +1969,14 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
 		blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);
 		f2fs_bug_on(sbi, blk_addr == NEW_ADDR);
 		if (blk_addr == NULL_ADDR) {
-			add_free_nid(sbi, start_nid, true, true);
+			if (in_build) {
+				add_free_nid(sbi, start_nid, true, true);
+			} else {
+				spin_lock(&NM_I(sbi)->nid_list_lock);
+				update_free_nid_bitmap(sbi,
+						start_nid, true, true);
+				spin_unlock(&NM_I(sbi)->nid_list_lock);
+			}
 		} else {
 			spin_lock(&NM_I(sbi)->nid_list_lock);
 			update_free_nid_bitmap(sbi, start_nid, false, true);
@@ -2063,7 +2073,7 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 						nm_i->nat_block_bitmap)) {
 			struct page *page = get_current_nat_page(sbi, nid);
 
-			scan_nat_page(sbi, page, nid);
+			scan_nat_page(sbi, page, nid, true);
 			f2fs_put_page(page, 1);
 		}
 
@@ -2534,6 +2544,7 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
 	if (to_journal) {
 		up_write(&curseg->journal_rwsem);
 	} else {
+		scan_nat_page(sbi, page, start_nid, false);
 		__update_nat_bits(sbi, start_nid, page);
 		f2fs_put_page(page, 1);
 	}
-- 
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

             reply	other threads:[~2018-04-26  6:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26  6:06 Yunlei He [this message]
2018-05-04  8:28 ` [PATCH v3] f2fs: build free nid bitmap during flush nat entries heyunlei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524722816-2218-1-git-send-email-heyunlei@huawei.com \
    --to=heyunlei@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=yuchao0@huawei.com \
    --cc=zhangdianfang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).