* Re: [f2fs-dev] [PATCH] f2fs:Add write priority option based on zone UFS
2024-07-02 6:29 [f2fs-dev] [PATCH] f2fs:Add write priority option based on zone UFS Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-04 8:46 ` Chao Yu
2024-07-05 9:46 ` [f2fs-dev] [PATCH v2] " Liao Yuanhong via Linux-f2fs-devel
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Chao Yu @ 2024-07-04 8:46 UTC (permalink / raw)
To: Liao Yuanhong, Jaegeuk Kim; +Cc: linux-kernel, bo.wu, linux-f2fs-devel
On 2024/7/2 14:29, Liao Yuanhong wrote:
> Currently, we are using a mix of traditional UFS and zone UFS to support
> some functionalities that cannot be achieved on zone UFS alone. However,
> there are some issues with this approach. There exists a significant
> performance difference between traditional UFS and zone UFS. Under normal
> usage, we prioritize writes to zone UFS. However, in critical conditions
> (such as when the entire UFS is almost full), we cannot determine whether
> data will be written to traditional UFS or zone UFS. This can lead to
> significant performance fluctuations, which is not conducive to
> development and testing. To address this, we have added an option
> zlu_io_enable under sys with the following three modes:
> 1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
> 2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
> 3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
> traditional UFS.
Use blkzone_alloc_policy instead of zlu_io_enable? Not sure.
Should update manual of f2fs sysfs entry.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
> ---
> fs/f2fs/f2fs.h | 5 +++++
> fs/f2fs/segment.c | 23 ++++++++++++++++++++++-
> fs/f2fs/sysfs.c | 13 +++++++++++++
> 3 files changed, 40 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index f7ee6c5e371e..7ba782bd15b2 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1781,6 +1781,11 @@ struct f2fs_sb_info {
> u64 committed_atomic_block;
> u64 revoked_atomic_block;
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> + /* For adjust the priority writing position of data in zone UFS */
> + unsigned int zlu_io_enable; /* data write mode */
> +#endif
#ifdef CONFIG_BLK_DEV_ZONED
unsigned int blocks_per_blkz; /* F2FS blocks per zone */
unsigned int max_open_zones; /* max open zone resources of the zoned device */
/* For adjust the priority writing position of data in zone UFS */
unsigned int zlu_io_enable; /* data write mode */
#endif
> +
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> struct kmem_cache *page_array_slab; /* page array entry */
> unsigned int page_array_slab_size; /* default page array slab size */
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 4db1add43e36..327457c28700 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2686,17 +2686,38 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
> goto got_it;
> }
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> /*
> * If we format f2fs on zoned storage, let's try to get pinned sections
> * from beginning of the storage, which should be a conventional one.
> */
> if (f2fs_sb_has_blkzoned(sbi)) {
> - segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> + if (sbi->zlu_io_enable == 2) /* Prioritize writing to traditional UFS */
Please use a macro instead of magic number.
> + segno = 0;
> + else
> + segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> hint = GET_SEC_FROM_SEG(sbi, segno);
> }
> +#endif
>
> find_other_zone:
> secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> +
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
> + if (sbi->zlu_io_enable == 1) { /* Write only to zone UFS */
Ditto.
And we'd better initialize it w/ default policy in somewhere.
> + hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
> + secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> + } else
> + secno = find_first_zero_bit(free_i->free_secmap,
> + MAIN_SECS(sbi));
> + if (secno >= MAIN_SECS(sbi)) {
> + ret = -ENOSPC;
> + goto out_unlock;
> + }
> + }
> +#endif
> +
> if (secno >= MAIN_SECS(sbi)) {
> secno = find_first_zero_bit(free_i->free_secmap,
> MAIN_SECS(sbi));
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index fee7ee45ceaa..bc9e5e8bb749 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -627,6 +627,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
> }
> #endif
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (!strcmp(a->attr.name, "zlu_io_enable")) {
Should check validation of new value?
> + sbi->zlu_io_enable = t;
> + return count;
> + }
> +#endif
> +
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> if (!strcmp(a->attr.name, "compr_written_block") ||
> !strcmp(a->attr.name, "compr_saved_block")) {
> @@ -1006,6 +1013,9 @@ F2FS_SBI_GENERAL_RW_ATTR(dir_level);
> F2FS_SBI_GENERAL_RW_ATTR(iostat_enable);
> F2FS_SBI_GENERAL_RW_ATTR(iostat_period_ms);
> #endif
> +#ifdef CONFIG_BLK_DEV_ZONED
> +F2FS_SBI_GENERAL_RW_ATTR(zlu_io_enable);
#ifdef CONFIG_BLK_DEV_ZONED
F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
F2FS_SBI_GENERAL_RW_ATTR(zlu_io_enable);
#endif
Thanks,
> +#endif
> F2FS_SBI_GENERAL_RW_ATTR(readdir_ra);
> F2FS_SBI_GENERAL_RW_ATTR(max_io_bytes);
> F2FS_SBI_GENERAL_RW_ATTR(data_io_flag);
> @@ -1153,6 +1163,9 @@ static struct attribute *f2fs_attrs[] = {
> #ifdef CONFIG_F2FS_IOSTAT
> ATTR_LIST(iostat_enable),
> ATTR_LIST(iostat_period_ms),
> +#endif
> +#ifdef CONFIG_BLK_DEV_ZONED
> + ATTR_LIST(zlu_io_enable),
> #endif
> ATTR_LIST(readdir_ra),
> ATTR_LIST(max_io_bytes),
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 11+ messages in thread* [f2fs-dev] [PATCH v2] f2fs:Add write priority option based on zone UFS
2024-07-02 6:29 [f2fs-dev] [PATCH] f2fs:Add write priority option based on zone UFS Liao Yuanhong via Linux-f2fs-devel
2024-07-04 8:46 ` Chao Yu
@ 2024-07-05 9:46 ` Liao Yuanhong via Linux-f2fs-devel
2024-07-08 4:00 ` Chao Yu
2024-07-09 2:16 ` [f2fs-dev] [PATCH v3] " Liao Yuanhong via Linux-f2fs-devel
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Liao Yuanhong via Linux-f2fs-devel @ 2024-07-05 9:46 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu; +Cc: Liao Yuanhong, linux-kernel, bo.wu, linux-f2fs-devel
Currently, we are using a mix of traditional UFS and zone UFS to support
some functionalities that cannot be achieved on zone UFS alone. However,
there are some issues with this approach. There exists a significant
performance difference between traditional UFS and zone UFS. Under normal
usage, we prioritize writes to zone UFS. However, in critical conditions
(such as when the entire UFS is almost full), we cannot determine whether
data will be written to traditional UFS or zone UFS. This can lead to
significant performance fluctuations, which is not conducive to
development and testing. To address this, we have added an option
zlu_io_enable under sys with the following three modes:
1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
traditional UFS.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
v2:
-Change name to blkzone_alloc_policy,
-Update manual of f2fs sysfs entry,
-Use macro instead of magic number,
-Initialize it w/ default policy in f2fs_scan_devices,
-Add validation check,
-Merged the ifdef PROFIG-BLK-DEV_ZONED area.
---
Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++
fs/f2fs/f2fs.h | 6 ++++++
fs/f2fs/segment.c | 25 ++++++++++++++++++++++++-
fs/f2fs/super.c | 1 +
fs/f2fs/sysfs.c | 11 +++++++++++
5 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index cad6c3dc1f9c..3500920ab7ce 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -763,3 +763,17 @@ Date: November 2023
Contact: "Chao Yu" <chao@kernel.org>
Description: It controls to enable/disable IO aware feature for background discard.
By default, the value is 1 which indicates IO aware is on.
+
+What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
+Date: July 2024
+Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
+Description: The zone UFS we are currently using consists of two parts:
+ conventional zones and sequential zones. It can be used to control which part
+ to prioritize for writes, with a default value of 0.
+
+ ======================== =========================================
+ value description
+ blkzone_alloc_policy = 0 Prioritize writing to sequential zones
+ blkzone_alloc_policy = 1 Only allow writing to sequential zones
+ blkzone_alloc_policy = 2 Prioritize writing to conventional zones
+ ======================== =========================================
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f7ee6c5e371e..29b0e8897e81 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -134,6 +134,10 @@ typedef u32 nid_t;
#define COMPRESS_EXT_NUM 16
+#define PRIOR_SEQUENTIAL 0
+#define ONLY_SEQUENTIAL 1
+#define PRIOR_CONVENTIONAL 2
+
/*
* An implementation of an rwsem that is explicitly unfair to readers. This
* prevents priority inversion when a low-priority reader acquires the read lock
@@ -1555,6 +1559,8 @@ struct f2fs_sb_info {
#ifdef CONFIG_BLK_DEV_ZONED
unsigned int blocks_per_blkz; /* F2FS blocks per zone */
unsigned int max_open_zones; /* max open zone resources of the zoned device */
+ /* For adjust the priority writing position of data in zone UFS */
+ unsigned int blkzone_alloc_policy; /* data write mode */
#endif
/* for node-related operations */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4db1add43e36..7b8dc255836b 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2686,17 +2686,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
goto got_it;
}
+#ifdef CONFIG_BLK_DEV_ZONED
/*
* If we format f2fs on zoned storage, let's try to get pinned sections
* from beginning of the storage, which should be a conventional one.
*/
if (f2fs_sb_has_blkzoned(sbi)) {
- segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
+ /* Prioritize writing to conventional zones */
+ if (sbi->blkzone_alloc_policy == PRIOR_CONVENTIONAL)
+ segno = 0;
+ else
+ segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
hint = GET_SEC_FROM_SEG(sbi, segno);
}
+#endif
find_other_zone:
secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
+ /* Write only to sequential zones */
+ if (sbi->blkzone_alloc_policy == ONLY_SEQUENTIAL) {
+ hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
+ secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+ } else
+ secno = find_first_zero_bit(free_i->free_secmap,
+ MAIN_SECS(sbi));
+ if (secno >= MAIN_SECS(sbi)) {
+ ret = -ENOSPC;
+ goto out_unlock;
+ }
+ }
+#endif
+
if (secno >= MAIN_SECS(sbi)) {
secno = find_first_zero_bit(free_i->free_secmap,
MAIN_SECS(sbi));
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 4a1bc8f40f9a..d5b0b7b141ce 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4229,6 +4229,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
sbi->aligned_blksize = true;
#ifdef CONFIG_BLK_DEV_ZONED
sbi->max_open_zones = UINT_MAX;
+ sbi->blkzone_alloc_policy = PRIOR_SEQUENTIAL;
#endif
for (i = 0; i < max_devices; i++) {
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index fee7ee45ceaa..359a12f84060 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
}
#endif
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
+ if (t < PRIOR_SEQUENTIAL || t > PRIOR_CONVENTIONAL)
+ return -EINVAL;
+ sbi->blkzone_alloc_policy = t;
+ return count;
+ }
+#endif
+
#ifdef CONFIG_F2FS_FS_COMPRESSION
if (!strcmp(a->attr.name, "compr_written_block") ||
!strcmp(a->attr.name, "compr_saved_block")) {
@@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);
F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
#ifdef CONFIG_BLK_DEV_ZONED
F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
+F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
#endif
/* STAT_INFO ATTR */
@@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {
#endif
#ifdef CONFIG_BLK_DEV_ZONED
ATTR_LIST(unusable_blocks_per_sec),
+ ATTR_LIST(blkzone_alloc_policy),
#endif
#ifdef CONFIG_F2FS_FS_COMPRESSION
ATTR_LIST(compr_written_block),
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [f2fs-dev] [PATCH v2] f2fs:Add write priority option based on zone UFS
2024-07-05 9:46 ` [f2fs-dev] [PATCH v2] " Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-08 4:00 ` Chao Yu
0 siblings, 0 replies; 11+ messages in thread
From: Chao Yu @ 2024-07-08 4:00 UTC (permalink / raw)
To: Liao Yuanhong, Jaegeuk Kim; +Cc: linux-kernel, bo.wu, linux-f2fs-devel
On 2024/7/5 17:46, Liao Yuanhong wrote:
> Currently, we are using a mix of traditional UFS and zone UFS to support
> some functionalities that cannot be achieved on zone UFS alone. However,
> there are some issues with this approach. There exists a significant
> performance difference between traditional UFS and zone UFS. Under normal
> usage, we prioritize writes to zone UFS. However, in critical conditions
> (such as when the entire UFS is almost full), we cannot determine whether
> data will be written to traditional UFS or zone UFS. This can lead to
> significant performance fluctuations, which is not conducive to
> development and testing. To address this, we have added an option
> zlu_io_enable under sys with the following three modes:
> 1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
> 2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
> 3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
> traditional UFS.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
> ---
> v2:
> -Change name to blkzone_alloc_policy,
> -Update manual of f2fs sysfs entry,
> -Use macro instead of magic number,
> -Initialize it w/ default policy in f2fs_scan_devices,
> -Add validation check,
> -Merged the ifdef PROFIG-BLK-DEV_ZONED area.
> ---
> Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++
> fs/f2fs/f2fs.h | 6 ++++++
> fs/f2fs/segment.c | 25 ++++++++++++++++++++++++-
> fs/f2fs/super.c | 1 +
> fs/f2fs/sysfs.c | 11 +++++++++++
> 5 files changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index cad6c3dc1f9c..3500920ab7ce 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -763,3 +763,17 @@ Date: November 2023
> Contact: "Chao Yu" <chao@kernel.org>
> Description: It controls to enable/disable IO aware feature for background discard.
> By default, the value is 1 which indicates IO aware is on.
> +
> +What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
> +Date: July 2024
> +Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
> +Description: The zone UFS we are currently using consists of two parts:
> + conventional zones and sequential zones. It can be used to control which part
> + to prioritize for writes, with a default value of 0.
> +
> + ======================== =========================================
> + value description
> + blkzone_alloc_policy = 0 Prioritize writing to sequential zones
> + blkzone_alloc_policy = 1 Only allow writing to sequential zones
> + blkzone_alloc_policy = 2 Prioritize writing to conventional zones
> + ======================== =========================================
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index f7ee6c5e371e..29b0e8897e81 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -134,6 +134,10 @@ typedef u32 nid_t;
>
> #define COMPRESS_EXT_NUM 16
>
> +#define PRIOR_SEQUENTIAL 0
> +#define ONLY_SEQUENTIAL 1
> +#define PRIOR_CONVENTIONAL 2
enum blkzone_allocation_policy {
BLKZONE_ALLOC_PRIOR_SEQ; /* Prioritize writing to sequential zones */
BLKZONE_ALLOC_ONLY_SEQ; /* Only allow writing to sequential zones */
BLKZONE_ALLOC_PRIOR_CONV; /* Prioritize writing to conventional zones */
};
> +
> /*
> * An implementation of an rwsem that is explicitly unfair to readers. This
> * prevents priority inversion when a low-priority reader acquires the read lock
> @@ -1555,6 +1559,8 @@ struct f2fs_sb_info {
> #ifdef CONFIG_BLK_DEV_ZONED
> unsigned int blocks_per_blkz; /* F2FS blocks per zone */
> unsigned int max_open_zones; /* max open zone resources of the zoned device */
> + /* For adjust the priority writing position of data in zone UFS */
> + unsigned int blkzone_alloc_policy; /* data write mode */
/* data write mode */
Is this comment redundant? If not, how about merging it to above
comment?
> #endif
>
> /* for node-related operations */
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 4db1add43e36..7b8dc255836b 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2686,17 +2686,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
> goto got_it;
> }
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> /*
> * If we format f2fs on zoned storage, let's try to get pinned sections
> * from beginning of the storage, which should be a conventional one.
> */
> if (f2fs_sb_has_blkzoned(sbi)) {
> - segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> + /* Prioritize writing to conventional zones */
> + if (sbi->blkzone_alloc_policy == PRIOR_CONVENTIONAL)
> + segno = 0;
> + else
> + segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
if (sbi->blkzone_alloc_policy == PRIOR_CONVENTIONAL || pinning)
segno = 0;
else
segno = max(first_zoned_segno(sbi), *newseg);
> hint = GET_SEC_FROM_SEG(sbi, segno);
> }
> +#endif
>
> find_other_zone:
> secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> +
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
> + /* Write only to sequential zones */
> + if (sbi->blkzone_alloc_policy == ONLY_SEQUENTIAL) {
> + hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
> + secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> + } else
> + secno = find_first_zero_bit(free_i->free_secmap,
> + MAIN_SECS(sbi));
> + if (secno >= MAIN_SECS(sbi)) {
> + ret = -ENOSPC;
> + goto out_unlock;
> + }
> + }
> +#endif
> +
> if (secno >= MAIN_SECS(sbi)) {
> secno = find_first_zero_bit(free_i->free_secmap,
> MAIN_SECS(sbi));
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 4a1bc8f40f9a..d5b0b7b141ce 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -4229,6 +4229,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
> sbi->aligned_blksize = true;
> #ifdef CONFIG_BLK_DEV_ZONED
> sbi->max_open_zones = UINT_MAX;
> + sbi->blkzone_alloc_policy = PRIOR_SEQUENTIAL;
> #endif
>
> for (i = 0; i < max_devices; i++) {
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index fee7ee45ceaa..359a12f84060 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
> }
> #endif
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
> + if (t < PRIOR_SEQUENTIAL || t > PRIOR_CONVENTIONAL)
> + return -EINVAL;
> + sbi->blkzone_alloc_policy = t;
> + return count;
> + }
> +#endif
> +
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> if (!strcmp(a->attr.name, "compr_written_block") ||
> !strcmp(a->attr.name, "compr_saved_block")) {
> @@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);
> F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
> #ifdef CONFIG_BLK_DEV_ZONED
> F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
> +F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
> #endif
>
> /* STAT_INFO ATTR */
> @@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {
> #endif
> #ifdef CONFIG_BLK_DEV_ZONED
> ATTR_LIST(unusable_blocks_per_sec),
> + ATTR_LIST(blkzone_alloc_policy),
> #endif
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> ATTR_LIST(compr_written_block),
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [f2fs-dev] [PATCH v3] f2fs:Add write priority option based on zone UFS
2024-07-02 6:29 [f2fs-dev] [PATCH] f2fs:Add write priority option based on zone UFS Liao Yuanhong via Linux-f2fs-devel
2024-07-04 8:46 ` Chao Yu
2024-07-05 9:46 ` [f2fs-dev] [PATCH v2] " Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-09 2:16 ` Liao Yuanhong via Linux-f2fs-devel
2024-07-09 9:44 ` Chao Yu
2024-07-10 3:06 ` [f2fs-dev] [PATCH v4] " Liao Yuanhong via Linux-f2fs-devel
2024-07-15 12:34 ` [f2fs-dev] [PATCH v5] " Liao Yuanhong via Linux-f2fs-devel
4 siblings, 1 reply; 11+ messages in thread
From: Liao Yuanhong via Linux-f2fs-devel @ 2024-07-09 2:16 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu; +Cc: Liao Yuanhong, linux-kernel, bo.wu, linux-f2fs-devel
Currently, we are using a mix of traditional UFS and zone UFS to support
some functionalities that cannot be achieved on zone UFS alone. However,
there are some issues with this approach. There exists a significant
performance difference between traditional UFS and zone UFS. Under normal
usage, we prioritize writes to zone UFS. However, in critical conditions
(such as when the entire UFS is almost full), we cannot determine whether
data will be written to traditional UFS or zone UFS. This can lead to
significant performance fluctuations, which is not conducive to
development and testing. To address this, we have added an option
zlu_io_enable under sys with the following three modes:
1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
traditional UFS.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
v3:
-Delete excess comments,
-Use enum instead of define,
-Modify some judgment criteria to make them more reasonable.
---
v2:
-Change name to blkzone_alloc_policy,
-Update manual of f2fs sysfs entry,
-Use macro instead of magic number,
-Initialize it w/ default policy in f2fs_scan_devices,
-Add validation check,
-Merged the ifdef PROFIG-BLK-DEV_ZONED area.
---
Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++
fs/f2fs/f2fs.h | 8 ++++++++
fs/f2fs/segment.c | 25 ++++++++++++++++++++++++-
fs/f2fs/super.c | 1 +
fs/f2fs/sysfs.c | 11 +++++++++++
5 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index cad6c3dc1f9c..3500920ab7ce 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -763,3 +763,17 @@ Date: November 2023
Contact: "Chao Yu" <chao@kernel.org>
Description: It controls to enable/disable IO aware feature for background discard.
By default, the value is 1 which indicates IO aware is on.
+
+What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
+Date: July 2024
+Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
+Description: The zone UFS we are currently using consists of two parts:
+ conventional zones and sequential zones. It can be used to control which part
+ to prioritize for writes, with a default value of 0.
+
+ ======================== =========================================
+ value description
+ blkzone_alloc_policy = 0 Prioritize writing to sequential zones
+ blkzone_alloc_policy = 1 Only allow writing to sequential zones
+ blkzone_alloc_policy = 2 Prioritize writing to conventional zones
+ ======================== =========================================
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f7ee6c5e371e..adefd19810ff 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -134,6 +134,12 @@ typedef u32 nid_t;
#define COMPRESS_EXT_NUM 16
+enum blkzone_allocation_policy {
+ BLKZONE_ALLOC_PRIOR_SEQ; /* Prioritize writing to sequential zones */
+ BLKZONE_ALLOC_ONLY_SEQ; /* Only allow writing to sequential zones */
+ BLKZONE_ALLOC_PRIOR_CONV; /* Prioritize writing to conventional zones */
+};
+
/*
* An implementation of an rwsem that is explicitly unfair to readers. This
* prevents priority inversion when a low-priority reader acquires the read lock
@@ -1555,6 +1561,8 @@ struct f2fs_sb_info {
#ifdef CONFIG_BLK_DEV_ZONED
unsigned int blocks_per_blkz; /* F2FS blocks per zone */
unsigned int max_open_zones; /* max open zone resources of the zoned device */
+ /* For adjust the priority writing position of data in zone UFS */
+ unsigned int blkzone_alloc_policy;
#endif
/* for node-related operations */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4db1add43e36..b38b92e08c6c 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2686,17 +2686,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
goto got_it;
}
+#ifdef CONFIG_BLK_DEV_ZONED
/*
* If we format f2fs on zoned storage, let's try to get pinned sections
* from beginning of the storage, which should be a conventional one.
*/
if (f2fs_sb_has_blkzoned(sbi)) {
- segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
+ /* Prioritize writing to conventional zones */
+ if (sbi->blkzone_alloc_policy == PRIOR_CONVENTIONAL || pinning)
+ segno = 0;
+ else
+ segno = max(first_zoned_segno(sbi), *newseg);
hint = GET_SEC_FROM_SEG(sbi, segno);
}
+#endif
find_other_zone:
secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
+ /* Write only to sequential zones */
+ if (sbi->blkzone_alloc_policy == ONLY_SEQUENTIAL) {
+ hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
+ secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+ } else
+ secno = find_first_zero_bit(free_i->free_secmap,
+ MAIN_SECS(sbi));
+ if (secno >= MAIN_SECS(sbi)) {
+ ret = -ENOSPC;
+ goto out_unlock;
+ }
+ }
+#endif
+
if (secno >= MAIN_SECS(sbi)) {
secno = find_first_zero_bit(free_i->free_secmap,
MAIN_SECS(sbi));
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 4a1bc8f40f9a..d5b0b7b141ce 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4229,6 +4229,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
sbi->aligned_blksize = true;
#ifdef CONFIG_BLK_DEV_ZONED
sbi->max_open_zones = UINT_MAX;
+ sbi->blkzone_alloc_policy = PRIOR_SEQUENTIAL;
#endif
for (i = 0; i < max_devices; i++) {
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index fee7ee45ceaa..359a12f84060 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
}
#endif
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
+ if (t < PRIOR_SEQUENTIAL || t > PRIOR_CONVENTIONAL)
+ return -EINVAL;
+ sbi->blkzone_alloc_policy = t;
+ return count;
+ }
+#endif
+
#ifdef CONFIG_F2FS_FS_COMPRESSION
if (!strcmp(a->attr.name, "compr_written_block") ||
!strcmp(a->attr.name, "compr_saved_block")) {
@@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);
F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
#ifdef CONFIG_BLK_DEV_ZONED
F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
+F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
#endif
/* STAT_INFO ATTR */
@@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {
#endif
#ifdef CONFIG_BLK_DEV_ZONED
ATTR_LIST(unusable_blocks_per_sec),
+ ATTR_LIST(blkzone_alloc_policy),
#endif
#ifdef CONFIG_F2FS_FS_COMPRESSION
ATTR_LIST(compr_written_block),
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [f2fs-dev] [PATCH v3] f2fs:Add write priority option based on zone UFS
2024-07-09 2:16 ` [f2fs-dev] [PATCH v3] " Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-09 9:44 ` Chao Yu
0 siblings, 0 replies; 11+ messages in thread
From: Chao Yu @ 2024-07-09 9:44 UTC (permalink / raw)
To: Liao Yuanhong, Jaegeuk Kim; +Cc: linux-kernel, bo.wu, linux-f2fs-devel
On 2024/7/9 10:16, Liao Yuanhong wrote:
> Currently, we are using a mix of traditional UFS and zone UFS to support
> some functionalities that cannot be achieved on zone UFS alone. However,
> there are some issues with this approach. There exists a significant
> performance difference between traditional UFS and zone UFS. Under normal
> usage, we prioritize writes to zone UFS. However, in critical conditions
> (such as when the entire UFS is almost full), we cannot determine whether
> data will be written to traditional UFS or zone UFS. This can lead to
> significant performance fluctuations, which is not conducive to
> development and testing. To address this, we have added an option
> zlu_io_enable under sys with the following three modes:
> 1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
> 2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
> 3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
> traditional UFS.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
> ---
> v3:
> -Delete excess comments,
> -Use enum instead of define,
> -Modify some judgment criteria to make them more reasonable.
> ---
> v2:
> -Change name to blkzone_alloc_policy,
> -Update manual of f2fs sysfs entry,
> -Use macro instead of magic number,
> -Initialize it w/ default policy in f2fs_scan_devices,
> -Add validation check,
> -Merged the ifdef PROFIG-BLK-DEV_ZONED area.
> ---
> Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++
> fs/f2fs/f2fs.h | 8 ++++++++
> fs/f2fs/segment.c | 25 ++++++++++++++++++++++++-
> fs/f2fs/super.c | 1 +
> fs/f2fs/sysfs.c | 11 +++++++++++
> 5 files changed, 58 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index cad6c3dc1f9c..3500920ab7ce 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -763,3 +763,17 @@ Date: November 2023
> Contact: "Chao Yu" <chao@kernel.org>
> Description: It controls to enable/disable IO aware feature for background discard.
> By default, the value is 1 which indicates IO aware is on.
> +
> +What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
> +Date: July 2024
> +Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
> +Description: The zone UFS we are currently using consists of two parts:
> + conventional zones and sequential zones. It can be used to control which part
> + to prioritize for writes, with a default value of 0.
> +
> + ======================== =========================================
> + value description
> + blkzone_alloc_policy = 0 Prioritize writing to sequential zones
> + blkzone_alloc_policy = 1 Only allow writing to sequential zones
> + blkzone_alloc_policy = 2 Prioritize writing to conventional zones
> + ======================== =========================================
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index f7ee6c5e371e..adefd19810ff 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -134,6 +134,12 @@ typedef u32 nid_t;
>
> #define COMPRESS_EXT_NUM 16
>
> +enum blkzone_allocation_policy {
> + BLKZONE_ALLOC_PRIOR_SEQ; /* Prioritize writing to sequential zones */
> + BLKZONE_ALLOC_ONLY_SEQ; /* Only allow writing to sequential zones */
> + BLKZONE_ALLOC_PRIOR_CONV; /* Prioritize writing to conventional zones */
> +};
> +
> /*
> * An implementation of an rwsem that is explicitly unfair to readers. This
> * prevents priority inversion when a low-priority reader acquires the read lock
> @@ -1555,6 +1561,8 @@ struct f2fs_sb_info {
> #ifdef CONFIG_BLK_DEV_ZONED
> unsigned int blocks_per_blkz; /* F2FS blocks per zone */
> unsigned int max_open_zones; /* max open zone resources of the zoned device */
> + /* For adjust the priority writing position of data in zone UFS */
> + unsigned int blkzone_alloc_policy;
> #endif
>
> /* for node-related operations */
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 4db1add43e36..b38b92e08c6c 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2686,17 +2686,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
> goto got_it;
> }
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> /*
> * If we format f2fs on zoned storage, let's try to get pinned sections
> * from beginning of the storage, which should be a conventional one.
> */
> if (f2fs_sb_has_blkzoned(sbi)) {
> - segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> + /* Prioritize writing to conventional zones */
> + if (sbi->blkzone_alloc_policy == PRIOR_CONVENTIONAL || pinning)
should adjust new enum definition?
> + segno = 0;
> + else
> + segno = max(first_zoned_segno(sbi), *newseg);
> hint = GET_SEC_FROM_SEG(sbi, segno);
> }
> +#endif
>
> find_other_zone:
> secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> +
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
> + /* Write only to sequential zones */
> + if (sbi->blkzone_alloc_policy == ONLY_SEQUENTIAL) {
ditto
> + hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
> + secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> + } else
> + secno = find_first_zero_bit(free_i->free_secmap,
> + MAIN_SECS(sbi));
> + if (secno >= MAIN_SECS(sbi)) {
> + ret = -ENOSPC;
> + goto out_unlock;
> + }
> + }
> +#endif
> +
> if (secno >= MAIN_SECS(sbi)) {
> secno = find_first_zero_bit(free_i->free_secmap,
> MAIN_SECS(sbi));
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 4a1bc8f40f9a..d5b0b7b141ce 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -4229,6 +4229,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
> sbi->aligned_blksize = true;
> #ifdef CONFIG_BLK_DEV_ZONED
> sbi->max_open_zones = UINT_MAX;
> + sbi->blkzone_alloc_policy = PRIOR_SEQUENTIAL;
ditto
> #endif
>
> for (i = 0; i < max_devices; i++) {
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index fee7ee45ceaa..359a12f84060 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
> }
> #endif
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
> + if (t < PRIOR_SEQUENTIAL || t > PRIOR_CONVENTIONAL)
ditto
> + return -EINVAL;
> + sbi->blkzone_alloc_policy = t;
> + return count;
> + }
> +#endif
> +
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> if (!strcmp(a->attr.name, "compr_written_block") ||
> !strcmp(a->attr.name, "compr_saved_block")) {
> @@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);
> F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
> #ifdef CONFIG_BLK_DEV_ZONED
> F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
> +F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
> #endif
>
> /* STAT_INFO ATTR */
> @@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {
> #endif
> #ifdef CONFIG_BLK_DEV_ZONED
> ATTR_LIST(unusable_blocks_per_sec),
> + ATTR_LIST(blkzone_alloc_policy),
> #endif
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> ATTR_LIST(compr_written_block),
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [f2fs-dev] [PATCH v4] f2fs:Add write priority option based on zone UFS
2024-07-02 6:29 [f2fs-dev] [PATCH] f2fs:Add write priority option based on zone UFS Liao Yuanhong via Linux-f2fs-devel
` (2 preceding siblings ...)
2024-07-09 2:16 ` [f2fs-dev] [PATCH v3] " Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-10 3:06 ` Liao Yuanhong via Linux-f2fs-devel
2024-07-12 7:39 ` Chao Yu
2024-07-15 12:34 ` [f2fs-dev] [PATCH v5] " Liao Yuanhong via Linux-f2fs-devel
4 siblings, 1 reply; 11+ messages in thread
From: Liao Yuanhong via Linux-f2fs-devel @ 2024-07-10 3:06 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu; +Cc: Liao Yuanhong, linux-kernel, bo.wu, linux-f2fs-devel
Currently, we are using a mix of traditional UFS and zone UFS to support
some functionalities that cannot be achieved on zone UFS alone. However,
there are some issues with this approach. There exists a significant
performance difference between traditional UFS and zone UFS. Under normal
usage, we prioritize writes to zone UFS. However, in critical conditions
(such as when the entire UFS is almost full), we cannot determine whether
data will be written to traditional UFS or zone UFS. This can lead to
significant performance fluctuations, which is not conducive to
development and testing. To address this, we have added an option
zlu_io_enable under sys with the following three modes:
1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
traditional UFS.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
v4:
-Change some constant's name.
---
v3:
-Delete excess comments,
-Use enum instead of define,
-Modify some judgment criteria to make them more reasonable.
---
v2:
-Change name to blkzone_alloc_policy,
-Update manual of f2fs sysfs entry,
-Use macro instead of magic number,
-Initialize it w/ default policy in f2fs_scan_devices,
-Add validation check,
-Merged the ifdef PROFIG-BLK-DEV_ZONED area.
---
Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++
fs/f2fs/f2fs.h | 8 ++++++++
fs/f2fs/segment.c | 25 ++++++++++++++++++++++++-
fs/f2fs/super.c | 1 +
fs/f2fs/sysfs.c | 11 +++++++++++
5 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index cad6c3dc1f9c..3500920ab7ce 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -763,3 +763,17 @@ Date: November 2023
Contact: "Chao Yu" <chao@kernel.org>
Description: It controls to enable/disable IO aware feature for background discard.
By default, the value is 1 which indicates IO aware is on.
+
+What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
+Date: July 2024
+Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
+Description: The zone UFS we are currently using consists of two parts:
+ conventional zones and sequential zones. It can be used to control which part
+ to prioritize for writes, with a default value of 0.
+
+ ======================== =========================================
+ value description
+ blkzone_alloc_policy = 0 Prioritize writing to sequential zones
+ blkzone_alloc_policy = 1 Only allow writing to sequential zones
+ blkzone_alloc_policy = 2 Prioritize writing to conventional zones
+ ======================== =========================================
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f7ee6c5e371e..adefd19810ff 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -134,6 +134,12 @@ typedef u32 nid_t;
#define COMPRESS_EXT_NUM 16
+enum blkzone_allocation_policy {
+ BLKZONE_ALLOC_PRIOR_SEQ; /* Prioritize writing to sequential zones */
+ BLKZONE_ALLOC_ONLY_SEQ; /* Only allow writing to sequential zones */
+ BLKZONE_ALLOC_PRIOR_CONV; /* Prioritize writing to conventional zones */
+};
+
/*
* An implementation of an rwsem that is explicitly unfair to readers. This
* prevents priority inversion when a low-priority reader acquires the read lock
@@ -1555,6 +1561,8 @@ struct f2fs_sb_info {
#ifdef CONFIG_BLK_DEV_ZONED
unsigned int blocks_per_blkz; /* F2FS blocks per zone */
unsigned int max_open_zones; /* max open zone resources of the zoned device */
+ /* For adjust the priority writing position of data in zone UFS */
+ unsigned int blkzone_alloc_policy;
#endif
/* for node-related operations */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4db1add43e36..026b61602113 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2686,17 +2686,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
goto got_it;
}
+#ifdef CONFIG_BLK_DEV_ZONED
/*
* If we format f2fs on zoned storage, let's try to get pinned sections
* from beginning of the storage, which should be a conventional one.
*/
if (f2fs_sb_has_blkzoned(sbi)) {
- segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
+ /* Prioritize writing to conventional zones */
+ if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_PRIOR_CONV || pinning)
+ segno = 0;
+ else
+ segno = max(first_zoned_segno(sbi), *newseg);
hint = GET_SEC_FROM_SEG(sbi, segno);
}
+#endif
find_other_zone:
secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
+ /* Write only to sequential zones */
+ if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_ONLY_SEQ) {
+ hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
+ secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+ } else
+ secno = find_first_zero_bit(free_i->free_secmap,
+ MAIN_SECS(sbi));
+ if (secno >= MAIN_SECS(sbi)) {
+ ret = -ENOSPC;
+ goto out_unlock;
+ }
+ }
+#endif
+
if (secno >= MAIN_SECS(sbi)) {
secno = find_first_zero_bit(free_i->free_secmap,
MAIN_SECS(sbi));
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 4a1bc8f40f9a..95ae6de77939 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4229,6 +4229,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
sbi->aligned_blksize = true;
#ifdef CONFIG_BLK_DEV_ZONED
sbi->max_open_zones = UINT_MAX;
+ sbi->blkzone_alloc_policy = BLKZONE_ALLOC_PRIOR_SEQ;
#endif
for (i = 0; i < max_devices; i++) {
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index fee7ee45ceaa..63ff2d1647eb 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
}
#endif
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
+ if (t < BLKZONE_ALLOC_PRIOR_SEQ || t > BLKZONE_ALLOC_PRIOR_CONV)
+ return -EINVAL;
+ sbi->blkzone_alloc_policy = t;
+ return count;
+ }
+#endif
+
#ifdef CONFIG_F2FS_FS_COMPRESSION
if (!strcmp(a->attr.name, "compr_written_block") ||
!strcmp(a->attr.name, "compr_saved_block")) {
@@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);
F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
#ifdef CONFIG_BLK_DEV_ZONED
F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
+F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
#endif
/* STAT_INFO ATTR */
@@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {
#endif
#ifdef CONFIG_BLK_DEV_ZONED
ATTR_LIST(unusable_blocks_per_sec),
+ ATTR_LIST(blkzone_alloc_policy),
#endif
#ifdef CONFIG_F2FS_FS_COMPRESSION
ATTR_LIST(compr_written_block),
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [f2fs-dev] [PATCH v4] f2fs:Add write priority option based on zone UFS
2024-07-10 3:06 ` [f2fs-dev] [PATCH v4] " Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-12 7:39 ` Chao Yu
0 siblings, 0 replies; 11+ messages in thread
From: Chao Yu @ 2024-07-12 7:39 UTC (permalink / raw)
To: Liao Yuanhong, Jaegeuk Kim; +Cc: linux-kernel, bo.wu, linux-f2fs-devel
On 2024/7/10 11:06, Liao Yuanhong wrote:
> Currently, we are using a mix of traditional UFS and zone UFS to support
> some functionalities that cannot be achieved on zone UFS alone. However,
> there are some issues with this approach. There exists a significant
> performance difference between traditional UFS and zone UFS. Under normal
> usage, we prioritize writes to zone UFS. However, in critical conditions
> (such as when the entire UFS is almost full), we cannot determine whether
> data will be written to traditional UFS or zone UFS. This can lead to
> significant performance fluctuations, which is not conducive to
> development and testing. To address this, we have added an option
> zlu_io_enable under sys with the following three modes:
> 1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
> 2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
> 3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
> traditional UFS.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
> ---
> v4:
> -Change some constant's name.
> ---
> v3:
> -Delete excess comments,
> -Use enum instead of define,
> -Modify some judgment criteria to make them more reasonable.
> ---
> v2:
> -Change name to blkzone_alloc_policy,
> -Update manual of f2fs sysfs entry,
> -Use macro instead of magic number,
> -Initialize it w/ default policy in f2fs_scan_devices,
> -Add validation check,
> -Merged the ifdef PROFIG-BLK-DEV_ZONED area.
> ---
> Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++
> fs/f2fs/f2fs.h | 8 ++++++++
> fs/f2fs/segment.c | 25 ++++++++++++++++++++++++-
> fs/f2fs/super.c | 1 +
> fs/f2fs/sysfs.c | 11 +++++++++++
> 5 files changed, 58 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index cad6c3dc1f9c..3500920ab7ce 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -763,3 +763,17 @@ Date: November 2023
> Contact: "Chao Yu" <chao@kernel.org>
> Description: It controls to enable/disable IO aware feature for background discard.
> By default, the value is 1 which indicates IO aware is on.
> +
> +What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
> +Date: July 2024
> +Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
> +Description: The zone UFS we are currently using consists of two parts:
> + conventional zones and sequential zones. It can be used to control which part
> + to prioritize for writes, with a default value of 0.
> +
> + ======================== =========================================
> + value description
> + blkzone_alloc_policy = 0 Prioritize writing to sequential zones
> + blkzone_alloc_policy = 1 Only allow writing to sequential zones
> + blkzone_alloc_policy = 2 Prioritize writing to conventional zones
> + ======================== =========================================
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index f7ee6c5e371e..adefd19810ff 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -134,6 +134,12 @@ typedef u32 nid_t;
>
> #define COMPRESS_EXT_NUM 16
>
> +enum blkzone_allocation_policy {
> + BLKZONE_ALLOC_PRIOR_SEQ; /* Prioritize writing to sequential zones */
> + BLKZONE_ALLOC_ONLY_SEQ; /* Only allow writing to sequential zones */
> + BLKZONE_ALLOC_PRIOR_CONV; /* Prioritize writing to conventional zones */
BLKZONE_ALLOC_PRIOR_SEQ, /* Prioritize writing to sequential zones */
BLKZONE_ALLOC_ONLY_SEQ, /* Only allow writing to sequential zones */
BLKZONE_ALLOC_PRIOR_CONV /* Prioritize writing to conventional zones */
> +};
> +
> /*
> * An implementation of an rwsem that is explicitly unfair to readers. This
> * prevents priority inversion when a low-priority reader acquires the read lock
> @@ -1555,6 +1561,8 @@ struct f2fs_sb_info {
> #ifdef CONFIG_BLK_DEV_ZONED
> unsigned int blocks_per_blkz; /* F2FS blocks per zone */
> unsigned int max_open_zones; /* max open zone resources of the zoned device */
> + /* For adjust the priority writing position of data in zone UFS */
> + unsigned int blkzone_alloc_policy;
> #endif
>
> /* for node-related operations */
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 4db1add43e36..026b61602113 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2686,17 +2686,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
> goto got_it;
> }
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> /*
> * If we format f2fs on zoned storage, let's try to get pinned sections
> * from beginning of the storage, which should be a conventional one.
> */
> if (f2fs_sb_has_blkzoned(sbi)) {
> - segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> + /* Prioritize writing to conventional zones */
> + if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_PRIOR_CONV || pinning)
> + segno = 0;
> + else
> + segno = max(first_zoned_segno(sbi), *newseg);
> hint = GET_SEC_FROM_SEG(sbi, segno);
> }
> +#endif
>
> find_other_zone:
> secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> +
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
> + /* Write only to sequential zones */
> + if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_ONLY_SEQ) {
> + hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
> + secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> + } else
> + secno = find_first_zero_bit(free_i->free_secmap,
> + MAIN_SECS(sbi));
> + if (secno >= MAIN_SECS(sbi)) {
> + ret = -ENOSPC;
> + goto out_unlock;
> + }
> + }
> +#endif
> +
> if (secno >= MAIN_SECS(sbi)) {
> secno = find_first_zero_bit(free_i->free_secmap,
> MAIN_SECS(sbi));
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 4a1bc8f40f9a..95ae6de77939 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -4229,6 +4229,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
> sbi->aligned_blksize = true;
> #ifdef CONFIG_BLK_DEV_ZONED
> sbi->max_open_zones = UINT_MAX;
> + sbi->blkzone_alloc_policy = BLKZONE_ALLOC_PRIOR_SEQ;
> #endif
>
> for (i = 0; i < max_devices; i++) {
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index fee7ee45ceaa..63ff2d1647eb 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
> }
> #endif
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> + if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
> + if (t < BLKZONE_ALLOC_PRIOR_SEQ || t > BLKZONE_ALLOC_PRIOR_CONV)
> + return -EINVAL;
> + sbi->blkzone_alloc_policy = t;
> + return count;
> + }
> +#endif
> +
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> if (!strcmp(a->attr.name, "compr_written_block") ||
> !strcmp(a->attr.name, "compr_saved_block")) {
> @@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);
> F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
> #ifdef CONFIG_BLK_DEV_ZONED
> F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
> +F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
> #endif
>
> /* STAT_INFO ATTR */
> @@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {
> #endif
> #ifdef CONFIG_BLK_DEV_ZONED
> ATTR_LIST(unusable_blocks_per_sec),
> + ATTR_LIST(blkzone_alloc_policy),
> #endif
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> ATTR_LIST(compr_written_block),
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [f2fs-dev] [PATCH v5] f2fs:Add write priority option based on zone UFS
2024-07-02 6:29 [f2fs-dev] [PATCH] f2fs:Add write priority option based on zone UFS Liao Yuanhong via Linux-f2fs-devel
` (3 preceding siblings ...)
2024-07-10 3:06 ` [f2fs-dev] [PATCH v4] " Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-15 12:34 ` Liao Yuanhong via Linux-f2fs-devel
2024-07-22 1:31 ` Chao Yu
2024-08-05 23:30 ` patchwork-bot+f2fs
4 siblings, 2 replies; 11+ messages in thread
From: Liao Yuanhong via Linux-f2fs-devel @ 2024-07-15 12:34 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu; +Cc: Liao Yuanhong, linux-kernel, bo.wu, linux-f2fs-devel
Currently, we are using a mix of traditional UFS and zone UFS to support
some functionalities that cannot be achieved on zone UFS alone. However,
there are some issues with this approach. There exists a significant
performance difference between traditional UFS and zone UFS. Under normal
usage, we prioritize writes to zone UFS. However, in critical conditions
(such as when the entire UFS is almost full), we cannot determine whether
data will be written to traditional UFS or zone UFS. This can lead to
significant performance fluctuations, which is not conducive to
development and testing. To address this, we have added an option
zlu_io_enable under sys with the following three modes:
1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
traditional UFS.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
v5:
-Change enum delimiter.
---
v4:
-Change some constant's name.
---
v3:
-Delete excess comments,
-Use enum instead of define,
-Modify some judgment criteria to make them more reasonable.
---
v2:
-Change name to blkzone_alloc_policy,
-Update manual of f2fs sysfs entry,
-Use macro instead of magic number,
-Initialize it w/ default policy in f2fs_scan_devices,
-Add validation check,
-Merged the ifdef PROFIG-BLK-DEV_ZONED area.
---
Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++
fs/f2fs/f2fs.h | 8 ++++++++
fs/f2fs/segment.c | 25 ++++++++++++++++++++++++-
fs/f2fs/super.c | 1 +
fs/f2fs/sysfs.c | 11 +++++++++++
5 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index cad6c3dc1f9c..3500920ab7ce 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -763,3 +763,17 @@ Date: November 2023
Contact: "Chao Yu" <chao@kernel.org>
Description: It controls to enable/disable IO aware feature for background discard.
By default, the value is 1 which indicates IO aware is on.
+
+What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
+Date: July 2024
+Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
+Description: The zone UFS we are currently using consists of two parts:
+ conventional zones and sequential zones. It can be used to control which part
+ to prioritize for writes, with a default value of 0.
+
+ ======================== =========================================
+ value description
+ blkzone_alloc_policy = 0 Prioritize writing to sequential zones
+ blkzone_alloc_policy = 1 Only allow writing to sequential zones
+ blkzone_alloc_policy = 2 Prioritize writing to conventional zones
+ ======================== =========================================
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f7ee6c5e371e..adefd19810ff 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -134,6 +134,12 @@ typedef u32 nid_t;
#define COMPRESS_EXT_NUM 16
+enum blkzone_allocation_policy {
+ BLKZONE_ALLOC_PRIOR_SEQ, /* Prioritize writing to sequential zones */
+ BLKZONE_ALLOC_ONLY_SEQ, /* Only allow writing to sequential zones */
+ BLKZONE_ALLOC_PRIOR_CONV, /* Prioritize writing to conventional zones */
+};
+
/*
* An implementation of an rwsem that is explicitly unfair to readers. This
* prevents priority inversion when a low-priority reader acquires the read lock
@@ -1555,6 +1561,8 @@ struct f2fs_sb_info {
#ifdef CONFIG_BLK_DEV_ZONED
unsigned int blocks_per_blkz; /* F2FS blocks per zone */
unsigned int max_open_zones; /* max open zone resources of the zoned device */
+ /* For adjust the priority writing position of data in zone UFS */
+ unsigned int blkzone_alloc_policy;
#endif
/* for node-related operations */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4db1add43e36..026b61602113 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2686,17 +2686,40 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
goto got_it;
}
+#ifdef CONFIG_BLK_DEV_ZONED
/*
* If we format f2fs on zoned storage, let's try to get pinned sections
* from beginning of the storage, which should be a conventional one.
*/
if (f2fs_sb_has_blkzoned(sbi)) {
- segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
+ /* Prioritize writing to conventional zones */
+ if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_PRIOR_CONV || pinning)
+ segno = 0;
+ else
+ segno = max(first_zoned_segno(sbi), *newseg);
hint = GET_SEC_FROM_SEG(sbi, segno);
}
+#endif
find_other_zone:
secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
+ /* Write only to sequential zones */
+ if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_ONLY_SEQ) {
+ hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
+ secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+ } else
+ secno = find_first_zero_bit(free_i->free_secmap,
+ MAIN_SECS(sbi));
+ if (secno >= MAIN_SECS(sbi)) {
+ ret = -ENOSPC;
+ goto out_unlock;
+ }
+ }
+#endif
+
if (secno >= MAIN_SECS(sbi)) {
secno = find_first_zero_bit(free_i->free_secmap,
MAIN_SECS(sbi));
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 4a1bc8f40f9a..95ae6de77939 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4229,6 +4229,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
sbi->aligned_blksize = true;
#ifdef CONFIG_BLK_DEV_ZONED
sbi->max_open_zones = UINT_MAX;
+ sbi->blkzone_alloc_policy = BLKZONE_ALLOC_PRIOR_SEQ;
#endif
for (i = 0; i < max_devices; i++) {
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index fee7ee45ceaa..63ff2d1647eb 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -627,6 +627,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
}
#endif
+#ifdef CONFIG_BLK_DEV_ZONED
+ if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
+ if (t < BLKZONE_ALLOC_PRIOR_SEQ || t > BLKZONE_ALLOC_PRIOR_CONV)
+ return -EINVAL;
+ sbi->blkzone_alloc_policy = t;
+ return count;
+ }
+#endif
+
#ifdef CONFIG_F2FS_FS_COMPRESSION
if (!strcmp(a->attr.name, "compr_written_block") ||
!strcmp(a->attr.name, "compr_saved_block")) {
@@ -1033,6 +1042,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold);
F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
#ifdef CONFIG_BLK_DEV_ZONED
F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
+F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
#endif
/* STAT_INFO ATTR */
@@ -1187,6 +1197,7 @@ static struct attribute *f2fs_attrs[] = {
#endif
#ifdef CONFIG_BLK_DEV_ZONED
ATTR_LIST(unusable_blocks_per_sec),
+ ATTR_LIST(blkzone_alloc_policy),
#endif
#ifdef CONFIG_F2FS_FS_COMPRESSION
ATTR_LIST(compr_written_block),
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [f2fs-dev] [PATCH v5] f2fs:Add write priority option based on zone UFS
2024-07-15 12:34 ` [f2fs-dev] [PATCH v5] " Liao Yuanhong via Linux-f2fs-devel
@ 2024-07-22 1:31 ` Chao Yu
2024-08-05 23:30 ` patchwork-bot+f2fs
1 sibling, 0 replies; 11+ messages in thread
From: Chao Yu @ 2024-07-22 1:31 UTC (permalink / raw)
To: Liao Yuanhong, Jaegeuk Kim; +Cc: linux-kernel, bo.wu, linux-f2fs-devel
On 2024/7/15 20:34, Liao Yuanhong wrote:
> Currently, we are using a mix of traditional UFS and zone UFS to support
> some functionalities that cannot be achieved on zone UFS alone. However,
> there are some issues with this approach. There exists a significant
> performance difference between traditional UFS and zone UFS. Under normal
> usage, we prioritize writes to zone UFS. However, in critical conditions
> (such as when the entire UFS is almost full), we cannot determine whether
> data will be written to traditional UFS or zone UFS. This can lead to
> significant performance fluctuations, which is not conducive to
> development and testing. To address this, we have added an option
> zlu_io_enable under sys with the following three modes:
> 1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
> 2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
> 3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
> traditional UFS.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> Signed-off-by: Wu Bo <bo.wu@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [f2fs-dev] [PATCH v5] f2fs:Add write priority option based on zone UFS
2024-07-15 12:34 ` [f2fs-dev] [PATCH v5] " Liao Yuanhong via Linux-f2fs-devel
2024-07-22 1:31 ` Chao Yu
@ 2024-08-05 23:30 ` patchwork-bot+f2fs
1 sibling, 0 replies; 11+ messages in thread
From: patchwork-bot+f2fs @ 2024-08-05 23:30 UTC (permalink / raw)
To: Liao Yuanhong; +Cc: jaegeuk, linux-kernel, bo.wu, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Mon, 15 Jul 2024 20:34:51 +0800 you wrote:
> Currently, we are using a mix of traditional UFS and zone UFS to support
> some functionalities that cannot be achieved on zone UFS alone. However,
> there are some issues with this approach. There exists a significant
> performance difference between traditional UFS and zone UFS. Under normal
> usage, we prioritize writes to zone UFS. However, in critical conditions
> (such as when the entire UFS is almost full), we cannot determine whether
> data will be written to traditional UFS or zone UFS. This can lead to
> significant performance fluctuations, which is not conducive to
> development and testing. To address this, we have added an option
> zlu_io_enable under sys with the following three modes:
> 1) zlu_io_enable == 0:Normal mode, prioritize writing to zone UFS;
> 2) zlu_io_enable == 1:Zone UFS only mode, only allow writing to zone UFS;
> 3) zlu_io_enable == 2:Traditional UFS priority mode, prioritize writing to
> traditional UFS.
>
> [...]
Here is the summary with links:
- [f2fs-dev,v5] f2fs:Add write priority option based on zone UFS
https://git.kernel.org/jaegeuk/f2fs/c/8444ce524947
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 11+ messages in thread