Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51694d8e authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Jaegeuk Kim
Browse files

f2fs: introduce sysfs/data_io_flag to attach REQ_META/FUA



This patch introduces a way to attach REQ_META/FUA explicitly
to all the data writes given temperature.

-> attach REQ_FUA to Hot Data writes

-> attach REQ_FUA to Hot|Warm Data writes

-> attach REQ_FUA to Hot|Warm|Cold Data writes

-> attach REQ_FUA to Hot|Warm|Cold Data writes as well as
          REQ_META to Hot Data writes

Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 3434bce2
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -323,3 +323,12 @@ What: /sys/fs/f2fs/<disk>/mounted_time_sec
Date:		February 2020
Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
Description:	Show the mounted time in secs of this partition.

What:		/sys/fs/f2fs/<disk>/data_io_flag
Date:		April 2020
Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
Description:	Give a way to attach REQ_META|FUA to data writes
		given temperature-based bits. Now the bits indicate:
		*      REQ_META     |      REQ_FUA      |
		*    5 |    4 |   3 |    2 |    1 |   0 |
		* Cold | Warm | Hot | Cold | Warm | Hot |
+23 −0
Original line number Diff line number Diff line
@@ -513,6 +513,28 @@ void f2fs_submit_bio(struct f2fs_sb_info *sbi,
	__submit_bio(sbi, bio, type);
}

static void __attach_data_io_flag(struct f2fs_io_info *fio)
{
	struct f2fs_sb_info *sbi = fio->sbi;
	unsigned int temp_mask = (1 << NR_TEMP_TYPE) - 1;
	unsigned int fua_flag = sbi->data_io_flag & temp_mask;
	unsigned int meta_flag = (sbi->data_io_flag >> NR_TEMP_TYPE) &
								temp_mask;
	/*
	 * data io flag bits per temp:
	 *      REQ_META     |      REQ_FUA      |
	 *    5 |    4 |   3 |    2 |    1 |   0 |
	 * Cold | Warm | Hot | Cold | Warm | Hot |
	 */
	if (fio->type != DATA)
		return;

	if ((1 << fio->temp) & meta_flag)
		fio->op_flags |= REQ_META;
	if ((1 << fio->temp) & fua_flag)
		fio->op_flags |= REQ_FUA;
}

static void __submit_merged_bio(struct f2fs_bio_info *io)
{
	struct f2fs_io_info *fio = &io->fio;
@@ -520,6 +542,7 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
	if (!io->bio)
		return;

	__attach_data_io_flag(fio);
	bio_set_op_attrs(io->bio, fio->op, fio->op_flags);

	if (is_read_io(fio->op))
+3 −0
Original line number Diff line number Diff line
@@ -1506,6 +1506,9 @@ struct f2fs_sb_info {
	unsigned long long write_iostat[NR_IO_TYPE];
	bool iostat_enable;

	/* to attach REQ_META|REQ_FUA flags */
	unsigned int data_io_flag;

	/* For sysfs suppport */
	struct kobject s_kobj;
	struct completion s_kobj_unregister;
+2 −1
Original line number Diff line number Diff line
@@ -372,7 +372,6 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
		return count;
	}


	if (!strcmp(a->attr.name, "iostat_enable")) {
		sbi->iostat_enable = !!t;
		if (!sbi->iostat_enable)
@@ -543,6 +542,7 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_super_block, extension_list, extension_list);
F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate);
F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
#endif
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
F2FS_GENERAL_RO_ATTR(dirty_segments);
F2FS_GENERAL_RO_ATTR(free_segments);
F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
@@ -622,6 +622,7 @@ static struct attribute *f2fs_attrs[] = {
	ATTR_LIST(inject_rate),
	ATTR_LIST(inject_type),
#endif
	ATTR_LIST(data_io_flag),
	ATTR_LIST(dirty_segments),
	ATTR_LIST(free_segments),
	ATTR_LIST(unusable),