mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
f2fs: open code allocate_segment_by_default
[ Upstream commit 8442d94b8a ]
allocate_segment_by_default has just two callers, which use very
different code pathes inside it based on the force paramter. Just
open code the logic in the two callers using a new helper to decided
if a new segment should be allocated.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Stable-dep-of: 43563069e1c1 ("f2fs: check curseg->inited before write_sum_page in change_curseg")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7d9b8b6ca9
commit
f3ba45c176
@@ -2859,31 +2859,20 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static bool need_new_seg(struct f2fs_sb_info *sbi, int type)
|
||||||
* flush out current segment and replace it with new segment
|
|
||||||
* This function should be returned with success, otherwise BUG
|
|
||||||
*/
|
|
||||||
static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
|
|
||||||
int type, bool force)
|
|
||||||
{
|
{
|
||||||
struct curseg_info *curseg = CURSEG_I(sbi, type);
|
struct curseg_info *curseg = CURSEG_I(sbi, type);
|
||||||
|
|
||||||
if (force)
|
if (!is_set_ckpt_flags(sbi, CP_CRC_RECOVERY_FLAG) &&
|
||||||
new_curseg(sbi, type, true);
|
curseg->seg_type == CURSEG_WARM_NODE)
|
||||||
else if (!is_set_ckpt_flags(sbi, CP_CRC_RECOVERY_FLAG) &&
|
return true;
|
||||||
curseg->seg_type == CURSEG_WARM_NODE)
|
if (curseg->alloc_type == LFS &&
|
||||||
new_curseg(sbi, type, false);
|
is_next_segment_free(sbi, curseg, type) &&
|
||||||
else if (curseg->alloc_type == LFS &&
|
likely(!is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
|
||||||
is_next_segment_free(sbi, curseg, type) &&
|
return true;
|
||||||
likely(!is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
|
if (!f2fs_need_SSR(sbi) || !get_ssr_segment(sbi, type, SSR, 0))
|
||||||
new_curseg(sbi, type, false);
|
return true;
|
||||||
else if (f2fs_need_SSR(sbi) &&
|
return false;
|
||||||
get_ssr_segment(sbi, type, SSR, 0))
|
|
||||||
change_curseg(sbi, type, true);
|
|
||||||
else
|
|
||||||
new_curseg(sbi, type, false);
|
|
||||||
|
|
||||||
stat_inc_seg_type(sbi, curseg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type,
|
void f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type,
|
||||||
@@ -2936,7 +2925,8 @@ static void __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
|
|||||||
return;
|
return;
|
||||||
alloc:
|
alloc:
|
||||||
old_segno = curseg->segno;
|
old_segno = curseg->segno;
|
||||||
allocate_segment_by_default(sbi, type, true);
|
new_curseg(sbi, type, true);
|
||||||
|
stat_inc_seg_type(sbi, curseg);
|
||||||
locate_dirty_segment(sbi, old_segno);
|
locate_dirty_segment(sbi, old_segno);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3287,11 +3277,19 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
|
|||||||
update_sit_entry(sbi, old_blkaddr, -1);
|
update_sit_entry(sbi, old_blkaddr, -1);
|
||||||
|
|
||||||
if (!__has_curseg_space(sbi, curseg)) {
|
if (!__has_curseg_space(sbi, curseg)) {
|
||||||
if (from_gc)
|
/*
|
||||||
|
* Flush out current segment and replace it with new segment.
|
||||||
|
*/
|
||||||
|
if (from_gc) {
|
||||||
get_atssr_segment(sbi, type, se->type,
|
get_atssr_segment(sbi, type, se->type,
|
||||||
AT_SSR, se->mtime);
|
AT_SSR, se->mtime);
|
||||||
else
|
} else {
|
||||||
allocate_segment_by_default(sbi, type, false);
|
if (need_new_seg(sbi, type))
|
||||||
|
new_curseg(sbi, type, false);
|
||||||
|
else
|
||||||
|
change_curseg(sbi, type, true);
|
||||||
|
stat_inc_seg_type(sbi, curseg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* segment dirty status should be updated after segment allocation,
|
* segment dirty status should be updated after segment allocation,
|
||||||
|
|||||||
Reference in New Issue
Block a user