Skip to content

Commit 9395fb0

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to parse temperature correctly in f2fs_get_segment_temp()
In __get_segment_type(), __get_segment_type_6() may return CURSEG_COLD_DATA_PINNED or CURSEG_ALL_DATA_ATGC log type, but following f2fs_get_segment_temp() can only handle persistent log type, fix it. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent f10a890 commit 9395fb0

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

fs/f2fs/f2fs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,
10191019
#define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE)
10201020
#define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE)
10211021

1022-
enum {
1022+
enum log_type {
10231023
CURSEG_HOT_DATA = 0, /* directory entry blocks */
10241024
CURSEG_WARM_DATA, /* data blocks */
10251025
CURSEG_COLD_DATA, /* multimedia or GCed data blocks */
@@ -3758,7 +3758,8 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
37583758
block_t old_addr, block_t new_addr,
37593759
unsigned char version, bool recover_curseg,
37603760
bool recover_newaddr);
3761-
int f2fs_get_segment_temp(int seg_type);
3761+
enum temp_type f2fs_get_segment_temp(struct f2fs_sb_info *sbi,
3762+
enum log_type seg_type);
37623763
int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
37633764
block_t old_blkaddr, block_t *new_blkaddr,
37643765
struct f2fs_summary *sum, int type,

fs/f2fs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4858,8 +4858,8 @@ static void f2fs_dio_write_submit_io(const struct iomap_iter *iter,
48584858
{
48594859
struct inode *inode = iter->inode;
48604860
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
4861-
int seg_type = f2fs_rw_hint_to_seg_type(sbi, inode->i_write_hint);
4862-
enum temp_type temp = f2fs_get_segment_temp(seg_type);
4861+
enum log_type type = f2fs_rw_hint_to_seg_type(sbi, inode->i_write_hint);
4862+
enum temp_type temp = f2fs_get_segment_temp(sbi, type);
48634863

48644864
bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);
48654865
submit_bio(bio);

fs/f2fs/segment.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3583,18 +3583,35 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
35833583
}
35843584
}
35853585

3586-
int f2fs_get_segment_temp(int seg_type)
3586+
enum temp_type f2fs_get_segment_temp(struct f2fs_sb_info *sbi,
3587+
enum log_type type)
35873588
{
3588-
if (IS_HOT(seg_type))
3589-
return HOT;
3590-
else if (IS_WARM(seg_type))
3591-
return WARM;
3592-
return COLD;
3589+
struct curseg_info *curseg = CURSEG_I(sbi, type);
3590+
enum temp_type temp = COLD;
3591+
3592+
switch (curseg->seg_type) {
3593+
case CURSEG_HOT_NODE:
3594+
case CURSEG_HOT_DATA:
3595+
temp = HOT;
3596+
break;
3597+
case CURSEG_WARM_NODE:
3598+
case CURSEG_WARM_DATA:
3599+
temp = WARM;
3600+
break;
3601+
case CURSEG_COLD_NODE:
3602+
case CURSEG_COLD_DATA:
3603+
temp = COLD;
3604+
break;
3605+
default:
3606+
f2fs_bug_on(sbi, 1);
3607+
}
3608+
3609+
return temp;
35933610
}
35943611

35953612
static int __get_segment_type(struct f2fs_io_info *fio)
35963613
{
3597-
int type = 0;
3614+
enum log_type type = CURSEG_HOT_DATA;
35983615

35993616
switch (F2FS_OPTION(fio->sbi).active_logs) {
36003617
case 2:
@@ -3610,7 +3627,7 @@ static int __get_segment_type(struct f2fs_io_info *fio)
36103627
f2fs_bug_on(fio->sbi, true);
36113628
}
36123629

3613-
fio->temp = f2fs_get_segment_temp(type);
3630+
fio->temp = f2fs_get_segment_temp(fio->sbi, type);
36143631

36153632
return type;
36163633
}

fs/f2fs/segment.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,
3434
f2fs_bug_on(sbi, seg_type >= NR_PERSISTENT_LOG);
3535
}
3636

37-
#define IS_HOT(t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)
38-
#define IS_WARM(t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)
39-
#define IS_COLD(t) ((t) == CURSEG_COLD_NODE || (t) == CURSEG_COLD_DATA)
40-
4137
#define IS_CURSEG(sbi, seg) \
4238
(((seg) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno) || \
4339
((seg) == CURSEG_I(sbi, CURSEG_WARM_DATA)->segno) || \

0 commit comments

Comments
 (0)