aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2014-04-17 22:14:37 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-05-06 21:21:55 -0400
commit7ee0eeabcdbb1610d7bc75d1132a43e0c7f7ef28 (patch)
tree94e793d60e76c16361c9e1a0bfaa8dc188d17803
parentb49ad51e6d4fa665a0ab587798d36bebfdfa54a9 (diff)
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>
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/node.c6
2 files changed, 5 insertions, 2 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 55152de1118c..556d06b67e6a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -244,6 +244,7 @@ static inline void set_raw_extent(struct extent_info *ext,
244struct f2fs_nm_info { 244struct f2fs_nm_info {
245 block_t nat_blkaddr; /* base disk address of NAT */ 245 block_t nat_blkaddr; /* base disk address of NAT */
246 nid_t max_nid; /* maximum possible node ids */ 246 nid_t max_nid; /* maximum possible node ids */
247 nid_t available_nids; /* maximum available node ids */
247 nid_t next_scan_nid; /* the next nid to be scanned */ 248 nid_t next_scan_nid; /* the next nid to be scanned */
248 unsigned int ram_thresh; /* control the memory footprint */ 249 unsigned int ram_thresh; /* control the memory footprint */
249 250
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 837f5fdabd19..6ebdba151f12 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1447,7 +1447,7 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
1447 struct f2fs_nm_info *nm_i = NM_I(sbi); 1447 struct f2fs_nm_info *nm_i = NM_I(sbi);
1448 struct free_nid *i = NULL; 1448 struct free_nid *i = NULL;
1449retry: 1449retry:
1450 if (unlikely(sbi->total_valid_node_count + 1 >= nm_i->max_nid)) 1450 if (unlikely(sbi->total_valid_node_count + 1 > nm_i->available_nids))
1451 return false; 1451 return false;
1452 1452
1453 spin_lock(&nm_i->free_nid_list_lock); 1453 spin_lock(&nm_i->free_nid_list_lock);
@@ -1859,8 +1859,10 @@ static int init_node_manager(struct f2fs_sb_info *sbi)
1859 nat_segs = le32_to_cpu(sb_raw->segment_count_nat) >> 1; 1859 nat_segs = le32_to_cpu(sb_raw->segment_count_nat) >> 1;
1860 nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg); 1860 nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg);
1861 1861
1862 nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks;
1863
1862 /* not used nids: 0, node, meta, (and root counted as valid node) */ 1864 /* not used nids: 0, node, meta, (and root counted as valid node) */
1863 nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks - 3; 1865 nm_i->available_nids = nm_i->max_nid - 3;
1864 nm_i->fcnt = 0; 1866 nm_i->fcnt = 0;
1865 nm_i->nat_cnt = 0; 1867 nm_i->nat_cnt = 0;
1866 nm_i->ram_thresh = DEF_RAM_THRESHOLD; 1868 nm_i->ram_thresh = DEF_RAM_THRESHOLD;