f2fs: add available_nids to fix handling max_nid correctly
This patch introduces available_nids for alloc_nids() and fixes max_nid for build_free_nids() and scan_nat_pages(). Signed-off-by: Chao Yu <chao2.yu@samsung.com> Reviewed-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
b49ad51e6d
commit
7ee0eeabcd
@ -244,6 +244,7 @@ static inline void set_raw_extent(struct extent_info *ext,
|
|||||||
struct f2fs_nm_info {
|
struct f2fs_nm_info {
|
||||||
block_t nat_blkaddr; /* base disk address of NAT */
|
block_t nat_blkaddr; /* base disk address of NAT */
|
||||||
nid_t max_nid; /* maximum possible node ids */
|
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 */
|
nid_t next_scan_nid; /* the next nid to be scanned */
|
||||||
unsigned int ram_thresh; /* control the memory footprint */
|
unsigned int ram_thresh; /* control the memory footprint */
|
||||||
|
|
||||||
|
@ -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 f2fs_nm_info *nm_i = NM_I(sbi);
|
||||||
struct free_nid *i = NULL;
|
struct free_nid *i = NULL;
|
||||||
retry:
|
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;
|
return false;
|
||||||
|
|
||||||
spin_lock(&nm_i->free_nid_list_lock);
|
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_segs = le32_to_cpu(sb_raw->segment_count_nat) >> 1;
|
||||||
nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg);
|
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) */
|
/* 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->fcnt = 0;
|
||||||
nm_i->nat_cnt = 0;
|
nm_i->nat_cnt = 0;
|
||||||
nm_i->ram_thresh = DEF_RAM_THRESHOLD;
|
nm_i->ram_thresh = DEF_RAM_THRESHOLD;
|
||||||
|
Loading…
Reference in New Issue
Block a user