Skip to content

Commit

Permalink
f2fs: assign the write hint per stream by default
Browse files Browse the repository at this point in the history
This reverts commit 930e260 ("f2fs: remove obsolete whint_mode"), as we
decide to pass write hints to the disk.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Jaegeuk Kim committed Apr 17, 2024
1 parent f4bc2e0 commit 0f894ad
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Documentation/filesystems/f2fs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,35 @@ In order to identify whether the data in the victim segment are valid or not,
F2FS manages a bitmap. Each bit represents the validity of a block, and the
bitmap is composed of a bit stream covering whole blocks in main area.

Write-hint Policy
-----------------

F2FS sets the whint all the time with the below policy.

===================== ======================== ===================
User F2FS Block
===================== ======================== ===================
N/A META WRITE_LIFE_NONE|REQ_META
N/A HOT_NODE WRITE_LIFE_NONE
N/A WARM_NODE WRITE_LIFE_MEDIUM
N/A COLD_NODE WRITE_LIFE_LONG
ioctl(COLD) COLD_DATA WRITE_LIFE_EXTREME
extension list " "

-- buffered io
N/A COLD_DATA WRITE_LIFE_EXTREME
N/A HOT_DATA WRITE_LIFE_SHORT
N/A WARM_DATA WRITE_LIFE_NOT_SET

-- direct io
WRITE_LIFE_EXTREME COLD_DATA WRITE_LIFE_EXTREME
WRITE_LIFE_SHORT HOT_DATA WRITE_LIFE_SHORT
WRITE_LIFE_NOT_SET WARM_DATA WRITE_LIFE_NOT_SET
WRITE_LIFE_NONE " WRITE_LIFE_NONE
WRITE_LIFE_MEDIUM " WRITE_LIFE_MEDIUM
WRITE_LIFE_LONG " WRITE_LIFE_LONG
===================== ======================== ===================

Fallocate(2) Policy
-------------------

Expand Down
2 changes: 2 additions & 0 deletions fs/f2fs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages)
} else {
bio->bi_end_io = f2fs_write_end_io;
bio->bi_private = sbi;
bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi,
fio->type, fio->temp);
}
iostat_alloc_and_bind_ctx(sbi, bio, NULL);

Expand Down
2 changes: 2 additions & 0 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3745,6 +3745,8 @@ void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi);
int __init f2fs_create_segment_manager_caches(void);
void f2fs_destroy_segment_manager_caches(void);
int f2fs_rw_hint_to_seg_type(enum rw_hint hint);
enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,
enum page_type type, enum temp_type temp);
unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi,
unsigned int segno);
unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi,
Expand Down
59 changes: 59 additions & 0 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,65 @@ int f2fs_rw_hint_to_seg_type(enum rw_hint hint)
}
}

/*
* This returns write hints for each segment type. This hints will be
* passed down to block layer as below by default.
*
* User F2FS Block
* ---- ---- -----
* META WRITE_LIFE_NONE|REQ_META
* HOT_NODE WRITE_LIFE_NONE
* WARM_NODE WRITE_LIFE_MEDIUM
* COLD_NODE WRITE_LIFE_LONG
* ioctl(COLD) COLD_DATA WRITE_LIFE_EXTREME
* extension list " "
*
* -- buffered io
* COLD_DATA WRITE_LIFE_EXTREME
* HOT_DATA WRITE_LIFE_SHORT
* WARM_DATA WRITE_LIFE_NOT_SET
*
* -- direct io
* WRITE_LIFE_EXTREME COLD_DATA WRITE_LIFE_EXTREME
* WRITE_LIFE_SHORT HOT_DATA WRITE_LIFE_SHORT
* WRITE_LIFE_NOT_SET WARM_DATA WRITE_LIFE_NOT_SET
* WRITE_LIFE_NONE " WRITE_LIFE_NONE
* WRITE_LIFE_MEDIUM " WRITE_LIFE_MEDIUM
* WRITE_LIFE_LONG " WRITE_LIFE_LONG
*/
enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,
enum page_type type, enum temp_type temp)
{
switch (type) {
case DATA:
switch (temp) {
case WARM:
return WRITE_LIFE_NOT_SET;
case HOT:
return WRITE_LIFE_SHORT;
case COLD:
return WRITE_LIFE_EXTREME;
default:
return WRITE_LIFE_NONE;
}
case NODE:
switch (temp) {
case WARM:
return WRITE_LIFE_MEDIUM;
case HOT:
return WRITE_LIFE_NONE;
case COLD:
return WRITE_LIFE_LONG;
default:
return WRITE_LIFE_NONE;
}
case META:
return WRITE_LIFE_NONE;
default:
return WRITE_LIFE_NONE;
}
}

static int __get_segment_type_2(struct f2fs_io_info *fio)
{
if (fio->type == DATA)
Expand Down

0 comments on commit 0f894ad

Please sign in to comment.