diff options
author | Christoph Hellwig <hch@lst.de> | 2023-01-19 07:36:22 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2023-02-02 22:37:16 +0100 |
commit | 2df79573ef0215431dc4be6b0d4b084204a0820a (patch) | |
tree | 347fe2e819e12bc500fb1437da46abcaa5df8e9f /fs/f2fs/segment.c | |
parent | f2fs: add a f2fs_curseg_valid_blocks helper (diff) | |
download | linux-2df79573ef0215431dc4be6b0d4b084204a0820a.tar.xz linux-2df79573ef0215431dc4be6b0d4b084204a0820a.zip |
f2fs: refactor __allocate_new_segment
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>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to '')
-rw-r--r-- | fs/f2fs/segment.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 50af5fcb88e9..3712752d395a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2913,16 +2913,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); |