Skip to content

Commit 42a80aa

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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: Chao Yu <[email protected]> Reviewed-by: Daeho Jeong <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1081b51 commit 42a80aa

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

fs/f2fs/segment.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,12 +3108,16 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
31083108
struct curseg_info *curseg = CURSEG_I(sbi, type);
31093109
unsigned int old_segno;
31103110

3111+
if (type == CURSEG_COLD_DATA_PINNED && !curseg->inited)
3112+
goto allocate;
3113+
31113114
if (!force && curseg->inited &&
31123115
!curseg->next_blkoff &&
31133116
!get_valid_blocks(sbi, curseg->segno, new_sec) &&
31143117
!get_ckpt_valid_blocks(sbi, curseg->segno, new_sec))
31153118
return 0;
31163119

3120+
allocate:
31173121
old_segno = curseg->segno;
31183122
if (new_curseg(sbi, type, true))
31193123
return -EAGAIN;
@@ -3458,6 +3462,13 @@ static void f2fs_randomize_chunk(struct f2fs_sb_info *sbi,
34583462
get_random_u32_inclusive(1, sbi->max_fragment_hole);
34593463
}
34603464

3465+
static void reset_curseg_fields(struct curseg_info *curseg)
3466+
{
3467+
curseg->inited = false;
3468+
curseg->segno = NULL_SEGNO;
3469+
curseg->next_segno = 0;
3470+
}
3471+
34613472
int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
34623473
block_t old_blkaddr, block_t *new_blkaddr,
34633474
struct f2fs_summary *sum, int type,
@@ -3524,8 +3535,10 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
35243535
*/
35253536
if (segment_full) {
35263537
if (type == CURSEG_COLD_DATA_PINNED &&
3527-
!((curseg->segno + 1) % sbi->segs_per_sec))
3538+
!((curseg->segno + 1) % sbi->segs_per_sec)) {
3539+
reset_curseg_fields(curseg);
35283540
goto skip_new_segment;
3541+
}
35293542

35303543
if (from_gc) {
35313544
get_atssr_segment(sbi, type, se->type,
@@ -4601,9 +4614,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
46014614
array[i].seg_type = CURSEG_COLD_DATA;
46024615
else if (i == CURSEG_ALL_DATA_ATGC)
46034616
array[i].seg_type = CURSEG_COLD_DATA;
4604-
array[i].segno = NULL_SEGNO;
4605-
array[i].next_blkoff = 0;
4606-
array[i].inited = false;
4617+
reset_curseg_fields(&array[i]);
46074618
}
46084619
return restore_curseg_summaries(sbi);
46094620
}

0 commit comments

Comments
 (0)