Commit 42a80aac authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: fix to reset fields for unloaded curseg

In f2fs_allocate_data_block(), before skip allocating new segment
for DATA_PINNED log header, it needs to tag log header as unloaded
one to avoid skipping logic in locate_dirty_segment() and
__f2fs_save_inmem_curseg().
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Reviewed-by: default avatarDaeho Jeong <daehojeong@google.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 1081b512
...@@ -3108,12 +3108,16 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type, ...@@ -3108,12 +3108,16 @@ static int __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 (type == CURSEG_COLD_DATA_PINNED && !curseg->inited)
goto allocate;
if (!force && curseg->inited && if (!force && curseg->inited &&
!curseg->next_blkoff && !curseg->next_blkoff &&
!get_valid_blocks(sbi, curseg->segno, new_sec) && !get_valid_blocks(sbi, curseg->segno, new_sec) &&
!get_ckpt_valid_blocks(sbi, curseg->segno, new_sec)) !get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
return 0; return 0;
allocate:
old_segno = curseg->segno; old_segno = curseg->segno;
if (new_curseg(sbi, type, true)) if (new_curseg(sbi, type, true))
return -EAGAIN; return -EAGAIN;
...@@ -3458,6 +3462,13 @@ static void f2fs_randomize_chunk(struct f2fs_sb_info *sbi, ...@@ -3458,6 +3462,13 @@ static void f2fs_randomize_chunk(struct f2fs_sb_info *sbi,
get_random_u32_inclusive(1, sbi->max_fragment_hole); get_random_u32_inclusive(1, sbi->max_fragment_hole);
} }
static void reset_curseg_fields(struct curseg_info *curseg)
{
curseg->inited = false;
curseg->segno = NULL_SEGNO;
curseg->next_segno = 0;
}
int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
block_t old_blkaddr, block_t *new_blkaddr, block_t old_blkaddr, block_t *new_blkaddr,
struct f2fs_summary *sum, int type, struct f2fs_summary *sum, int type,
...@@ -3524,8 +3535,10 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, ...@@ -3524,8 +3535,10 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
*/ */
if (segment_full) { if (segment_full) {
if (type == CURSEG_COLD_DATA_PINNED && if (type == CURSEG_COLD_DATA_PINNED &&
!((curseg->segno + 1) % sbi->segs_per_sec)) !((curseg->segno + 1) % sbi->segs_per_sec)) {
reset_curseg_fields(curseg);
goto skip_new_segment; goto skip_new_segment;
}
if (from_gc) { if (from_gc) {
get_atssr_segment(sbi, type, se->type, get_atssr_segment(sbi, type, se->type,
...@@ -4601,9 +4614,7 @@ static int build_curseg(struct f2fs_sb_info *sbi) ...@@ -4601,9 +4614,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
array[i].seg_type = CURSEG_COLD_DATA; array[i].seg_type = CURSEG_COLD_DATA;
else if (i == CURSEG_ALL_DATA_ATGC) else if (i == CURSEG_ALL_DATA_ATGC)
array[i].seg_type = CURSEG_COLD_DATA; array[i].seg_type = CURSEG_COLD_DATA;
array[i].segno = NULL_SEGNO; reset_curseg_fields(&array[i]);
array[i].next_blkoff = 0;
array[i].inited = false;
} }
return restore_curseg_summaries(sbi); return restore_curseg_summaries(sbi);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment