Skip to content

Commit 51d3d95

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to convert log type to segment data type correctly
This patch introduces a new helper log_type_to_seg_type() to convert log type to segment data type, and uses it to clean up opened codes in build_curseg(), and also it fixes to convert log type before use in do_write_page(). Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1df2bc3 commit 51d3d95

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

fs/f2fs/segment.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,10 +3812,35 @@ void f2fs_update_device_state(struct f2fs_sb_info *sbi, nid_t ino,
38123812
}
38133813
}
38143814

3815+
static int log_type_to_seg_type(enum log_type type)
3816+
{
3817+
int seg_type = CURSEG_COLD_DATA;
3818+
3819+
switch (type) {
3820+
case CURSEG_HOT_DATA:
3821+
case CURSEG_WARM_DATA:
3822+
case CURSEG_COLD_DATA:
3823+
case CURSEG_HOT_NODE:
3824+
case CURSEG_WARM_NODE:
3825+
case CURSEG_COLD_NODE:
3826+
seg_type = (int)type;
3827+
break;
3828+
case CURSEG_COLD_DATA_PINNED:
3829+
case CURSEG_ALL_DATA_ATGC:
3830+
seg_type = CURSEG_COLD_DATA;
3831+
break;
3832+
default:
3833+
break;
3834+
}
3835+
return seg_type;
3836+
}
3837+
38153838
static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
38163839
{
3817-
int type = __get_segment_type(fio);
3818-
bool keep_order = (f2fs_lfs_mode(fio->sbi) && type == CURSEG_COLD_DATA);
3840+
enum log_type type = __get_segment_type(fio);
3841+
int seg_type = log_type_to_seg_type(type);
3842+
bool keep_order = (f2fs_lfs_mode(fio->sbi) &&
3843+
seg_type == CURSEG_COLD_DATA);
38193844

38203845
if (keep_order)
38213846
f2fs_down_read(&fio->sbi->io_order_lock);
@@ -4797,12 +4822,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
47974822
sizeof(struct f2fs_journal), GFP_KERNEL);
47984823
if (!array[i].journal)
47994824
return -ENOMEM;
4800-
if (i < NR_PERSISTENT_LOG)
4801-
array[i].seg_type = CURSEG_HOT_DATA + i;
4802-
else if (i == CURSEG_COLD_DATA_PINNED)
4803-
array[i].seg_type = CURSEG_COLD_DATA;
4804-
else if (i == CURSEG_ALL_DATA_ATGC)
4805-
array[i].seg_type = CURSEG_COLD_DATA;
4825+
array[i].seg_type = log_type_to_seg_type(i);
48064826
reset_curseg_fields(&array[i]);
48074827
}
48084828
return restore_curseg_summaries(sbi);

0 commit comments

Comments
 (0)