Skip to content

Commit a320b2f

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to avoid allocating WARM_DATA segment for direct IO
If active_log is not 6, we never use WARM_DATA segment, let's avoid allocating WARM_DATA segment for direct IO. Signed-off-by: Yunlei He <[email protected]> Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent ecd69be commit a320b2f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

fs/f2fs/data.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4179,7 +4179,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
41794179
map.m_lblk = bytes_to_blks(inode, offset);
41804180
map.m_len = bytes_to_blks(inode, offset + length - 1) - map.m_lblk + 1;
41814181
map.m_next_pgofs = &next_pgofs;
4182-
map.m_seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint);
4182+
map.m_seg_type = f2fs_rw_hint_to_seg_type(F2FS_I_SB(inode),
4183+
inode->i_write_hint);
41834184
if (flags & IOMAP_WRITE)
41844185
map.m_may_create = true;
41854186

fs/f2fs/f2fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3745,7 +3745,7 @@ int f2fs_build_segment_manager(struct f2fs_sb_info *sbi);
37453745
void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi);
37463746
int __init f2fs_create_segment_manager_caches(void);
37473747
void f2fs_destroy_segment_manager_caches(void);
3748-
int f2fs_rw_hint_to_seg_type(enum rw_hint hint);
3748+
int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint);
37493749
enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,
37503750
enum page_type type, enum temp_type temp);
37513751
unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi,

fs/f2fs/file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4637,7 +4637,8 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
46374637

46384638
map.m_may_create = true;
46394639
if (dio) {
4640-
map.m_seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint);
4640+
map.m_seg_type = f2fs_rw_hint_to_seg_type(sbi,
4641+
inode->i_write_hint);
46414642
flag = F2FS_GET_BLOCK_PRE_DIO;
46424643
} else {
46434644
map.m_seg_type = NO_CHECK_TYPE;
@@ -4690,7 +4691,7 @@ static void f2fs_dio_write_submit_io(const struct iomap_iter *iter,
46904691
{
46914692
struct inode *inode = iter->inode;
46924693
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
4693-
int seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint);
4694+
int seg_type = f2fs_rw_hint_to_seg_type(sbi, inode->i_write_hint);
46944695
enum temp_type temp = f2fs_get_segment_temp(seg_type);
46954696

46964697
bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);

fs/f2fs/segment.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,8 +3351,14 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
33513351
return err;
33523352
}
33533353

3354-
int f2fs_rw_hint_to_seg_type(enum rw_hint hint)
3354+
int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint)
33553355
{
3356+
if (F2FS_OPTION(sbi).active_logs == 2)
3357+
return CURSEG_HOT_DATA;
3358+
else if (F2FS_OPTION(sbi).active_logs == 4)
3359+
return CURSEG_COLD_DATA;
3360+
3361+
/* active_log == 6 */
33563362
switch (hint) {
33573363
case WRITE_LIFE_SHORT:
33583364
return CURSEG_HOT_DATA;
@@ -3492,7 +3498,8 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
34923498
is_inode_flag_set(inode, FI_HOT_DATA) ||
34933499
f2fs_is_cow_file(inode))
34943500
return CURSEG_HOT_DATA;
3495-
return f2fs_rw_hint_to_seg_type(inode->i_write_hint);
3501+
return f2fs_rw_hint_to_seg_type(F2FS_I_SB(inode),
3502+
inode->i_write_hint);
34963503
} else {
34973504
if (IS_DNODE(fio->page))
34983505
return is_cold_node(fio->page) ? CURSEG_WARM_NODE :

0 commit comments

Comments
 (0)