Commit 2df79573 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jaegeuk Kim
Browse files

f2fs: refactor __allocate_new_segment



Simplify the check whether to allocate a new segment or reuse an open
one.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 6392e9ff
Loading
Loading
Loading
Loading
+5 −9
Original line number Original line Diff line number Diff line
@@ -2913,16 +2913,12 @@ static void __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
	struct curseg_info *curseg = CURSEG_I(sbi, type);
	struct curseg_info *curseg = CURSEG_I(sbi, type);
	unsigned int old_segno;
	unsigned int old_segno;


	if (!curseg->inited)
	if (!force && curseg->inited &&
		goto alloc;
	    !curseg->next_blkoff &&

	    !get_valid_blocks(sbi, curseg->segno, new_sec) &&
	if (force || curseg->next_blkoff ||
	    !get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
		get_valid_blocks(sbi, curseg->segno, new_sec))
		goto alloc;

	if (!get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
		return;
		return;
alloc:

	old_segno = curseg->segno;
	old_segno = curseg->segno;
	new_curseg(sbi, type, true);
	new_curseg(sbi, type, true);
	stat_inc_seg_type(sbi, curseg);
	stat_inc_seg_type(sbi, curseg);