f2fs: fix to enable readahead last NAT block
Subsystems (2)
PATCH 1/1 f2fs: fix to enable readahead last NAT block
We skip reading last one of NAT blocks when readahead them since max value of valid block is calculated incorrectly. We should fix this problem to avoid it.
--- fs/f2fs/checkpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/checkpoint.c +1 -1
@@ -77,7 +77,7 @@ inline int get_max_meta_blks(struct f2fs_sb_info *sbi, int type) {switch (type) {case META_NAT : -return NM_I (sbi)->max_nid /NAT_ENTRY_PER_BLOCK ; +return (NM_I (sbi)->max_nid +3 ) /NAT_ENTRY_PER_BLOCK ;case META_SIT :return SIT_BLK_CNT (sbi);case META_SSA :
Signature · 10 lines
1.7.9.5 ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech
Hi Chao,
How about this?
--- fs/f2fs/f2fs.h | 1 + fs/f2fs/node.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/f2fs/f2fs.h +0 -0
@@ -244,6 +244,7 @@ static inline void set_raw_extent(struct extent_info
*ext,
struct f2fs_nm_info {
block_t nat_blkaddr; /* base disk address of NAT */
nid_t max_nid; /* maximum possible node ids */
+ nid_t available_nids; /* maximum available node ids */
nid_t next_scan_nid; /* the next nid to be scanned */
unsigned int ram_thresh; /* control the memory footprint */
fs/f2fs/node.c +0 -0
@@ -1447,7 +1447,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t
*nid)
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct free_nid *i = NULL;
retry:
- if (unlikely(sbi->total_valid_node_count + 1 >= nm_i->max_nid))
+ if (unlikely(sbi->total_valid_node_count + 1 >= nm_i->available_nids))
return false;
spin_lock(&nm_i->free_nid_list_lock);
@@ -1859,8 +1859,10 @@ static int init_node_manager(struct f2fs_sb_info *sbi)
nat_segs = le32_to_cpu(sb_raw->segment_count_nat) >> 1; nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg);
+ nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks;
+
/* not used nids: 0, node, meta, (and root counted as valid node) */
- nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks - 3;
+ nm_i->available_nids = nm_i->max_nid - 3;
nm_i->fcnt = 0;
nm_i->nat_cnt = 0;
nm_i->ram_thresh = DEF_RAM_THRESHOLD;
Signature · 6 lines
1.8.4.474.g128a96c -- Jaegeuk Kim Samsung
Chao Yu
Reviewed-byHi,
Quoted 11 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, April 18, 2014 10:16 AM
To: Chao Yu
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to enable readahead last NAT blockHi Chao,
How about this?
This modification can really fix the previously deadloop problem without bringing more problem. I'd like use your patch.
Thanks.
One comment as following.
Quoted 24 lines
--- fs/f2fs/f2fs.h | 1 + fs/f2fs/node.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)fs/f2fs/f2fs.h +1
-0@@ -244,6 +244,7 @@ static inline void set_raw_extent(struct extent_info *ext,struct f2fs_nm_info {block_t nat_blkaddr;/* base disk address of NAT */ nid_t max_nid;/* maximum possible node ids */ +nid_t available_nids;/* maximum available node ids */ nid_t next_scan_nid;/* the next nid to be scanned */ unsigned int ram_thresh;/* control the memory footprint */ fs/f2fs/node.c +0
-0
fs/f2fs/node.c bool alloc_nid(struct f2fs_sb_info *sbi, nid_t · line 1451
Quoted 6 lines
fs/f2fs/node.c +1
-1@@ -1447,7 +1447,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)struct f2fs_nm_info *nm_i =NM_I (sbi);struct free_nid *i =NULL ; retry: -if (unlikely (sbi->total_valid_node_count +1 >= nm_i->max_nid)) +if (unlikely (sbi->total_valid_node_count +1 >= nm_i->available_nids))
Could we use the last valid nid and modify like this?
if (unlikely(sbi->total_valid_node_count + 1 > nm_i->available_nids))
Quoted 23 lines
fs/f2fs/node.c +0
-0return false;fs/f2fs/node.c +3
-1spin_lock (&nm_i->free_nid_list_lock);@@ -1859,8 +1859,10 @@ static int init_node_manager(struct f2fs_sb_info *sbi) nat_segs =le32_to_cpu (sb_raw->segment_count_nat) >>1 ; nat_blocks = nat_segs <<le32_to_cpu (sb_raw->log_blocks_per_seg); + nm_i->max_nid =NAT_ENTRY_PER_BLOCK * nat_blocks; +/* not used nids: 0, node, meta, (and root counted as valid node) */ - nm_i->max_nid =NAT_ENTRY_PER_BLOCK * nat_blocks -3 ; + nm_i->available_nids = nm_i->max_nid -3 ; nm_i->fcnt =0 ; nm_i->nat_cnt =0 ;
nm_i->ram_thresh=DEF_RAM_THRESHOLD;
--
1.8.4.474.g128a96c--
Jaegeuk Kim
Samsung
Jaegeuk Kim
Reviewed-by Chao YuGot it.
The patch is like this.
Thanks,
Quoted 1 line
From
5f7a3bcf0df10bbb47a6e4409cc92ba8e6090674Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
Date: Fri, 18 Apr 2014 11:14:37 +0900
Subject: [PATCH] f2fs: add available_nids to fix handling max_nid correctly
This patch introduces available_nids for alloc_nids() and fixes max_nid forbuild_free_nids() and scan_nat_pages().
--- fs/f2fs/f2fs.h | 1 + fs/f2fs/node.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/f2fs/f2fs.h +0 -0
@@ -244,6 +244,7 @@ static inline void set_raw_extent(struct extent_info
*ext,
struct f2fs_nm_info {
block_t nat_blkaddr; /* base disk address of NAT */
nid_t max_nid; /* maximum possible node ids */
+ nid_t available_nids; /* maximum available node ids */
nid_t next_scan_nid; /* the next nid to be scanned */
unsigned int ram_thresh; /* control the memory footprint */
fs/f2fs/node.c +0 -0
@@ -1447,7 +1447,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t
*nid)
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct free_nid *i = NULL;
retry:
- if (unlikely(sbi->total_valid_node_count + 1 >= nm_i->max_nid))
+ if (unlikely(sbi->total_valid_node_count + 1 > nm_i->available_nids))
return false;
spin_lock(&nm_i->free_nid_list_lock);
@@ -1859,8 +1859,10 @@ static int init_node_manager(struct f2fs_sb_info *sbi)
nat_segs = le32_to_cpu(sb_raw->segment_count_nat) >> 1; nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg);
+ nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks;
+
/* not used nids: 0, node, meta, (and root counted as valid node) */
- nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks - 3;
+ nm_i->available_nids = nm_i->max_nid - 3;
nm_i->fcnt = 0;
nm_i->nat_cnt = 0;
nm_i->ram_thresh = DEF_RAM_THRESHOLD;
Signature · 16 lines
1.8.4.474.g128a96c -- Jaegeuk Kim Samsung ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech