linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] f2fs: avoid unneeded free nid building
@ 2017-11-30 11:32 Chao Yu
  2017-11-30 11:32 ` [PATCH 2/3] f2fs: refactor __build_free_nids Chao Yu
  2017-11-30 11:32 ` [PATCH 3/3] f2fs: allocate full free nat block in prior Chao Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Chao Yu @ 2017-11-30 11:32 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

This patch adds nm_i::valid_bitmap_count to count current valid free
nid bitmap, with it we can skip running into __build_free_nids more
early.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/f2fs.h |  1 +
 fs/f2fs/node.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f08e0feb38c1..fd9c8d1bffd5 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -730,6 +730,7 @@ struct f2fs_nm_info {
 	unsigned char *nat_block_bitmap;
 	unsigned short *free_nid_count;	/* free nid count of NAT block */
 	unsigned int available_free_nids;	/* available free nid count in bitmaps */
+	unsigned int valid_bitmap_count;	/* valid bitmap count */
 
 	/* for checkpoint */
 	char *nat_bitmap;		/* NAT bitmap pointer */
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index d2c9dcb0cbf8..4c758747980c 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1882,6 +1882,7 @@ static void scan_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
 	nat_blk = page_address(page);
 
 	__set_bit_le(nat_ofs, nm_i->nat_block_bitmap);
+	nm_i->valid_bitmap_count++;
 
 	i = nid % NAT_ENTRY_PER_BLOCK;
 
@@ -1969,6 +1970,16 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool mount)
 
 void build_free_nids(struct f2fs_sb_info *sbi, bool mount)
 {
+	/*
+	 * do not try to load nid bitmap from NAT blocks if all nid
+	 * bitmaps are available now.
+	 */
+	if (NM_I(sbi)->valid_bitmap_count >= NM_I(sbi)->nat_blocks) {
+		if (!mount)
+			cond_resched();
+		return;
+	}
+
 	mutex_lock(&NM_I(sbi)->build_lock);
 	__build_free_nids(sbi, mount);
 	mutex_unlock(&NM_I(sbi)->build_lock);
@@ -2489,6 +2500,7 @@ static inline void load_free_nid_bitmap(struct f2fs_sb_info *sbi)
 			break;
 
 		__set_bit_le(i, nm_i->nat_block_bitmap);
+		nm_i->valid_bitmap_count++;
 
 		nid = i * NAT_ENTRY_PER_BLOCK;
 		last_nid = nid + NAT_ENTRY_PER_BLOCK;
@@ -2505,6 +2517,7 @@ static inline void load_free_nid_bitmap(struct f2fs_sb_info *sbi)
 			break;
 
 		__set_bit_le(i, nm_i->nat_block_bitmap);
+		nm_i->valid_bitmap_count++;
 	}
 
 	scan_curseg_cache(sbi, 0, nm_i->max_nid);
@@ -2529,6 +2542,7 @@ static int init_node_manager(struct f2fs_sb_info *sbi)
 	nm_i->available_nids = nm_i->max_nid - sbi->total_valid_node_count -
 				sbi->nquota_files - F2FS_RESERVED_NODE_NUM;
 	nm_i->available_free_nids = 0;
+	nm_i->valid_bitmap_count = 0;
 	nm_i->nat_cnt = 0;
 	nm_i->ram_thresh = DEF_RAM_THRESHOLD;
 	nm_i->ra_nid_pages = DEF_RA_NID_PAGES;
-- 
2.15.0.55.gc2ece9dc4de6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-30 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-30 11:32 [PATCH 1/3] f2fs: avoid unneeded free nid building Chao Yu
2017-11-30 11:32 ` [PATCH 2/3] f2fs: refactor __build_free_nids Chao Yu
2017-11-30 11:32 ` [PATCH 3/3] f2fs: allocate full free nat block in prior Chao Yu

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).