Commit 074b5ea2 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: adjust zone capacity when considering valid block count

This patch fixes counting unusable blocks set by zone capacity when
checking the valid block count in a section.
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b771aadc
...@@ -39,7 +39,7 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi) ...@@ -39,7 +39,7 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi)
bimodal = 0; bimodal = 0;
total_vblocks = 0; total_vblocks = 0;
blks_per_sec = BLKS_PER_SEC(sbi); blks_per_sec = CAP_BLKS_PER_SEC(sbi);
hblks_per_sec = blks_per_sec / 2; hblks_per_sec = blks_per_sec / 2;
for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) { for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) {
vblocks = get_valid_blocks(sbi, segno, true); vblocks = get_valid_blocks(sbi, segno, true);
......
...@@ -1681,7 +1681,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset, ...@@ -1681,7 +1681,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
return 0; return 0;
if (f2fs_is_pinned_file(inode)) { if (f2fs_is_pinned_file(inode)) {
block_t sec_blks = BLKS_PER_SEC(sbi); block_t sec_blks = CAP_BLKS_PER_SEC(sbi);
block_t sec_len = roundup(map.m_len, sec_blks); block_t sec_len = roundup(map.m_len, sec_blks);
map.m_len = sec_blks; map.m_len = sec_blks;
...@@ -2432,7 +2432,7 @@ static int __f2fs_ioc_gc_range(struct file *filp, struct f2fs_gc_range *range) ...@@ -2432,7 +2432,7 @@ static int __f2fs_ioc_gc_range(struct file *filp, struct f2fs_gc_range *range)
ret = -EAGAIN; ret = -EAGAIN;
goto out; goto out;
} }
range->start += BLKS_PER_SEC(sbi); range->start += CAP_BLKS_PER_SEC(sbi);
if (range->start <= end) if (range->start <= end)
goto do_more; goto do_more;
out: out:
...@@ -2557,7 +2557,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, ...@@ -2557,7 +2557,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
goto out; goto out;
} }
sec_num = DIV_ROUND_UP(total, BLKS_PER_SEC(sbi)); sec_num = DIV_ROUND_UP(total, CAP_BLKS_PER_SEC(sbi));
/* /*
* make sure there are enough free section for LFS allocation, this can * make sure there are enough free section for LFS allocation, this can
......
...@@ -487,7 +487,7 @@ static void atgc_lookup_victim(struct f2fs_sb_info *sbi, ...@@ -487,7 +487,7 @@ static void atgc_lookup_victim(struct f2fs_sb_info *sbi,
unsigned long long age, u, accu; unsigned long long age, u, accu;
unsigned long long max_mtime = sit_i->dirty_max_mtime; unsigned long long max_mtime = sit_i->dirty_max_mtime;
unsigned long long min_mtime = sit_i->dirty_min_mtime; unsigned long long min_mtime = sit_i->dirty_min_mtime;
unsigned int sec_blocks = BLKS_PER_SEC(sbi); unsigned int sec_blocks = CAP_BLKS_PER_SEC(sbi);
unsigned int vblocks; unsigned int vblocks;
unsigned int dirty_threshold = max(am->max_candidate_count, unsigned int dirty_threshold = max(am->max_candidate_count,
am->candidate_ratio * am->candidate_ratio *
...@@ -1487,7 +1487,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, ...@@ -1487,7 +1487,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
*/ */
if ((gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) || if ((gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) ||
(!force_migrate && get_valid_blocks(sbi, segno, true) == (!force_migrate && get_valid_blocks(sbi, segno, true) ==
BLKS_PER_SEC(sbi))) CAP_BLKS_PER_SEC(sbi)))
return submitted; return submitted;
if (check_valid_map(sbi, segno, off) == 0) if (check_valid_map(sbi, segno, off) == 0)
......
...@@ -728,7 +728,7 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, ...@@ -728,7 +728,7 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
get_valid_blocks(sbi, segno, true); get_valid_blocks(sbi, segno, true);
f2fs_bug_on(sbi, unlikely(!valid_blocks || f2fs_bug_on(sbi, unlikely(!valid_blocks ||
valid_blocks == BLKS_PER_SEC(sbi))); valid_blocks == CAP_BLKS_PER_SEC(sbi)));
if (!IS_CURSEC(sbi, secno)) if (!IS_CURSEC(sbi, secno))
set_bit(secno, dirty_i->dirty_secmap); set_bit(secno, dirty_i->dirty_secmap);
...@@ -764,7 +764,7 @@ static void __remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, ...@@ -764,7 +764,7 @@ static void __remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
unsigned int secno = GET_SEC_FROM_SEG(sbi, segno); unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
if (!valid_blocks || if (!valid_blocks ||
valid_blocks == BLKS_PER_SEC(sbi)) { valid_blocks == CAP_BLKS_PER_SEC(sbi)) {
clear_bit(secno, dirty_i->dirty_secmap); clear_bit(secno, dirty_i->dirty_secmap);
return; return;
} }
...@@ -4483,7 +4483,6 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi) ...@@ -4483,7 +4483,6 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi)
struct free_segmap_info *free_i = FREE_I(sbi); struct free_segmap_info *free_i = FREE_I(sbi);
unsigned int segno = 0, offset = 0, secno; unsigned int segno = 0, offset = 0, secno;
block_t valid_blocks, usable_blks_in_seg; block_t valid_blocks, usable_blks_in_seg;
block_t blks_per_sec = BLKS_PER_SEC(sbi);
while (1) { while (1) {
/* find dirty segment based on free segmap */ /* find dirty segment based on free segmap */
...@@ -4512,7 +4511,7 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi) ...@@ -4512,7 +4511,7 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi)
valid_blocks = get_valid_blocks(sbi, segno, true); valid_blocks = get_valid_blocks(sbi, segno, true);
secno = GET_SEC_FROM_SEG(sbi, segno); secno = GET_SEC_FROM_SEG(sbi, segno);
if (!valid_blocks || valid_blocks == blks_per_sec) if (!valid_blocks || valid_blocks == CAP_BLKS_PER_SEC(sbi))
continue; continue;
if (IS_CURSEC(sbi, secno)) if (IS_CURSEC(sbi, secno))
continue; continue;
......
...@@ -612,10 +612,10 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, ...@@ -612,10 +612,10 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi,
get_pages(sbi, F2FS_DIRTY_DENTS) + get_pages(sbi, F2FS_DIRTY_DENTS) +
get_pages(sbi, F2FS_DIRTY_IMETA); get_pages(sbi, F2FS_DIRTY_IMETA);
unsigned int total_dent_blocks = get_pages(sbi, F2FS_DIRTY_DENTS); unsigned int total_dent_blocks = get_pages(sbi, F2FS_DIRTY_DENTS);
unsigned int node_secs = total_node_blocks / BLKS_PER_SEC(sbi); unsigned int node_secs = total_node_blocks / CAP_BLKS_PER_SEC(sbi);
unsigned int dent_secs = total_dent_blocks / BLKS_PER_SEC(sbi); unsigned int dent_secs = total_dent_blocks / CAP_BLKS_PER_SEC(sbi);
unsigned int node_blocks = total_node_blocks % BLKS_PER_SEC(sbi); unsigned int node_blocks = total_node_blocks % CAP_BLKS_PER_SEC(sbi);
unsigned int dent_blocks = total_dent_blocks % BLKS_PER_SEC(sbi); unsigned int dent_blocks = total_dent_blocks % CAP_BLKS_PER_SEC(sbi);
unsigned int free, need_lower, need_upper; unsigned int free, need_lower, need_upper;
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment