diff options
author | Chao Yu <chao@kernel.org> | 2024-02-26 04:32:07 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2024-03-04 20:51:53 +0300 |
commit | 1081b5121b27ed4824d90cbcdb1c662c503ffd09 (patch) | |
tree | b96f7d5a2f177fd6f255aefb42ae6282119889b5 | |
parent | f1e7646a8cd446c2003c5f98a89880eb987dec72 (diff) | |
download | linux-1081b5121b27ed4824d90cbcdb1c662c503ffd09.tar.xz |
f2fs: clean up new_curseg()
Move f2fs_valid_pinned_area() check logic from new_curseg() to
get_new_segment(), it can avoid calling __set_free() if it fails
to find free segment in conventional zone for pinned file.
Signed-off-by: Chao Yu <chao@kernel.org>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/segment.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 8014ea9f7a55..c88897db1e44 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2722,12 +2722,19 @@ find_other_zone: got_it: /* set it as dirty segment in free segmap */ f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); + + /* no free section in conventional zone */ + if (new_sec && pinning && + !f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) { + ret = -EAGAIN; + goto out_unlock; + } __set_inuse(sbi, segno); *newseg = segno; out_unlock: spin_unlock(&free_i->segmap_lock); - if (ret) { + if (ret == -ENOSPC) { f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT); f2fs_bug_on(sbi, 1); } @@ -2803,19 +2810,17 @@ static int new_curseg(struct f2fs_sb_info *sbi, int type, bool new_sec) struct curseg_info *curseg = CURSEG_I(sbi, type); unsigned int segno = curseg->segno; bool pinning = type == CURSEG_COLD_DATA_PINNED; + int ret; if (curseg->inited) write_sum_page(sbi, curseg->sum_blk, GET_SUM_BLOCK(sbi, segno)); segno = __get_next_segno(sbi, type); - if (get_new_segment(sbi, &segno, new_sec, pinning)) { - curseg->segno = NULL_SEGNO; - return -ENOSPC; - } - if (new_sec && pinning && - !f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) { - __set_free(sbi, segno); - return -EAGAIN; + ret = get_new_segment(sbi, &segno, new_sec, pinning); + if (ret) { + if (ret == -ENOSPC) + curseg->segno = NULL_SEGNO; + return ret; } curseg->next_segno = segno; |