Commit a320b2f0 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

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: default avatarYunlei He <heyunlei@oppo.com>
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent ecd69be7
...@@ -4179,7 +4179,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, ...@@ -4179,7 +4179,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
map.m_lblk = bytes_to_blks(inode, offset); map.m_lblk = bytes_to_blks(inode, offset);
map.m_len = bytes_to_blks(inode, offset + length - 1) - map.m_lblk + 1; map.m_len = bytes_to_blks(inode, offset + length - 1) - map.m_lblk + 1;
map.m_next_pgofs = &next_pgofs; map.m_next_pgofs = &next_pgofs;
map.m_seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint); map.m_seg_type = f2fs_rw_hint_to_seg_type(F2FS_I_SB(inode),
inode->i_write_hint);
if (flags & IOMAP_WRITE) if (flags & IOMAP_WRITE)
map.m_may_create = true; map.m_may_create = true;
......
...@@ -3745,7 +3745,7 @@ int f2fs_build_segment_manager(struct f2fs_sb_info *sbi); ...@@ -3745,7 +3745,7 @@ int f2fs_build_segment_manager(struct f2fs_sb_info *sbi);
void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi); void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi);
int __init f2fs_create_segment_manager_caches(void); int __init f2fs_create_segment_manager_caches(void);
void f2fs_destroy_segment_manager_caches(void); void f2fs_destroy_segment_manager_caches(void);
int f2fs_rw_hint_to_seg_type(enum rw_hint hint); int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint);
enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi, enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,
enum page_type type, enum temp_type temp); enum page_type type, enum temp_type temp);
unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi, unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi,
......
...@@ -4637,7 +4637,8 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter, ...@@ -4637,7 +4637,8 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
map.m_may_create = true; map.m_may_create = true;
if (dio) { if (dio) {
map.m_seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint); map.m_seg_type = f2fs_rw_hint_to_seg_type(sbi,
inode->i_write_hint);
flag = F2FS_GET_BLOCK_PRE_DIO; flag = F2FS_GET_BLOCK_PRE_DIO;
} else { } else {
map.m_seg_type = NO_CHECK_TYPE; map.m_seg_type = NO_CHECK_TYPE;
...@@ -4690,7 +4691,7 @@ static void f2fs_dio_write_submit_io(const struct iomap_iter *iter, ...@@ -4690,7 +4691,7 @@ static void f2fs_dio_write_submit_io(const struct iomap_iter *iter,
{ {
struct inode *inode = iter->inode; struct inode *inode = iter->inode;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
int seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint); int seg_type = f2fs_rw_hint_to_seg_type(sbi, inode->i_write_hint);
enum temp_type temp = f2fs_get_segment_temp(seg_type); enum temp_type temp = f2fs_get_segment_temp(seg_type);
bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp); bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);
......
...@@ -3351,8 +3351,14 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) ...@@ -3351,8 +3351,14 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
return err; return err;
} }
int f2fs_rw_hint_to_seg_type(enum rw_hint hint) int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint)
{ {
if (F2FS_OPTION(sbi).active_logs == 2)
return CURSEG_HOT_DATA;
else if (F2FS_OPTION(sbi).active_logs == 4)
return CURSEG_COLD_DATA;
/* active_log == 6 */
switch (hint) { switch (hint) {
case WRITE_LIFE_SHORT: case WRITE_LIFE_SHORT:
return CURSEG_HOT_DATA; return CURSEG_HOT_DATA;
...@@ -3492,7 +3498,8 @@ static int __get_segment_type_6(struct f2fs_io_info *fio) ...@@ -3492,7 +3498,8 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
is_inode_flag_set(inode, FI_HOT_DATA) || is_inode_flag_set(inode, FI_HOT_DATA) ||
f2fs_is_cow_file(inode)) f2fs_is_cow_file(inode))
return CURSEG_HOT_DATA; return CURSEG_HOT_DATA;
return f2fs_rw_hint_to_seg_type(inode->i_write_hint); return f2fs_rw_hint_to_seg_type(F2FS_I_SB(inode),
inode->i_write_hint);
} else { } else {
if (IS_DNODE(fio->page)) if (IS_DNODE(fio->page))
return is_cold_node(fio->page) ? CURSEG_WARM_NODE : return is_cold_node(fio->page) ? CURSEG_WARM_NODE :
......
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