diff mbox series

[f2fs-dev,5/8] f2fs: refactor __allocate_new_segment

Message ID 20230119063625.466485-6-hch@lst.de (mailing list archive)
State Accepted
Commit 53577f7c5b8bbb39eec4c1c1514beba856381ecb
Headers show
Series [f2fs-dev,1/8] f2fs: remove __add_sum_entry | expand

Commit Message

Christoph Hellwig Jan. 19, 2023, 6:36 a.m. UTC
Simplify the check whether to allocate a new segment or reuse an open
one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/f2fs/segment.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Chao Yu Jan. 29, 2023, 10:39 a.m. UTC | #1
On 2023/1/19 14:36, Christoph Hellwig wrote:
> Simplify the check whether to allocate a new segment or reuse an open
> one.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
diff mbox series

Patch

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index ad323b6e8609cd..b25ee37d0375e2 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2897,16 +2897,12 @@  static void __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
 	struct curseg_info *curseg = CURSEG_I(sbi, type);
 	unsigned int old_segno;
 
-	if (!curseg->inited)
-		goto alloc;
-
-	if (force || curseg->next_blkoff ||
-		get_valid_blocks(sbi, curseg->segno, new_sec))
-		goto alloc;
-
-	if (!get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
+	if (!force && curseg->inited &&
+	    !curseg->next_blkoff &&
+	    !get_valid_blocks(sbi, curseg->segno, new_sec) &&
+	    !get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
 		return;
-alloc:
+
 	old_segno = curseg->segno;
 	new_curseg(sbi, type, true);
 	stat_inc_seg_type(sbi, curseg);