f2fs: introduce discard_io_aware_gran sysfs node
PATCH v2 1/1 f2fs: introduce discard_io_aware_gran sysfs node
The current discard_io_aware_gran is a fixed value, change it to be configurable through the sys node.
Signed-off-by Yangtao Li <[email protected]>
---
v2:
- allow 0
Documentation/ABI/testing/sysfs-fs-f2fs | 9 +++++++++ fs/f2fs/f2fs.h | 3 +++ fs/f2fs/segment.c | 3 ++- fs/f2fs/sysfs.c | 13 +++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-fs-f2fs +9 -0
@@ -669,3 +669,12 @@ Contact: "Ping Xiong" <[email protected]> Description: When DATA SEPARATION is on, it controls the age threshold to indicate the data blocks as warm. By default it was initialized as 2621440 blocks (equals to 10GB). + +What: /sys/fs/f2fs/<disk>/discard_io_aware_gran +Date: December 2022 +Contact: "Yangtao Li" <[email protected]> +Description: Controls background discard granularity of inner discard thread + when is not in idle. Inner thread will not issue discards with size that + is smaller than granularity. The unit size is one block(4KB), now only + support configuring in range of [0, 512]. + Default: 512
fs/f2fs/f2fs.h +3 -0
@@ -332,6 +332,8 @@ struct discard_entry {#define DEFAULT_DISCARD_GRANULARITY 16/* default maximum discard granularity of ordered discard, unit: block count */ #define DEFAULT_MAX_ORDERED_DISCARD_GRANULARITY 16 +/* default minimum granularity discard not be aware of I/O, unit: block count */ +#define DEFAULT_IO_AWARE_DISCARD_GRANULARITY 512/* max discard pend list number */ #define MAX_PLIST_NUM 512
@@ -410,6 +412,7 @@ struct discard_cmd_control {unsigned int min_discard_issue_time;/* min. interval between discard issue */ unsigned int mid_discard_issue_time;/* mid. interval between discard issue */ unsigned int max_discard_issue_time;/* max. interval between discard issue */ +unsigned int discard_io_aware_gran;/* minimum discard granularity not be aware of I/O */ unsigned int discard_urgent_util;/* utilization which issue discard proactively */ unsigned int discard_granularity;/* discard granularity */ unsigned int max_ordered_discard;/* maximum discard granularity issued by lba order */
fs/f2fs/segment.c +2 -1
@@ -1060,7 +1060,7 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi, dpolicy->granularity = granularity; dpolicy->max_requests = dcc->max_discard_request; - dpolicy->io_aware_gran =MAX_PLIST_NUM ; + dpolicy->io_aware_gran = dcc->discard_io_aware_gran; dpolicy->timeout = false;if (discard_type ==DPOLICY_BG ) {
@@ -2066,6 +2066,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)if (!dcc)return -ENOMEM ; + dcc->discard_io_aware_gran =DEFAULT_IO_AWARE_DISCARD_GRANULARITY ; dcc->discard_granularity =DEFAULT_DISCARD_GRANULARITY ; dcc->max_ordered_discard =DEFAULT_MAX_ORDERED_DISCARD_GRANULARITY ;if (F2FS_OPTION (sbi).discard_unit ==DISCARD_UNIT_SEGMENT )
fs/f2fs/sysfs.c +13 -0
@@ -473,6 +473,17 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return count; } +if (!strcmp (a->attr.name,"discard_io_aware_gran" )) { +if (t >MAX_PLIST_NUM ) +return -EINVAL ; +if (!f2fs_block_unit_discard (sbi)) +return -EINVAL ; +if (t == *ui) +return count; + *ui = t; +return count; + } +if (!strcmp (a->attr.name,"discard_granularity" )) {if (t ==0 || t >MAX_PLIST_NUM )return -EINVAL ;
@@ -825,6 +836,7 @@ F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_request, max_discard_reqF2FS_RW_ATTR (DCC_INFO , discard_cmd_control, min_discard_issue_time, min_discard_issue_time);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, mid_discard_issue_time, mid_discard_issue_time);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, max_discard_issue_time, max_discard_issue_time); +F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, discard_io_aware_gran, discard_io_aware_gran);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, discard_urgent_util, discard_urgent_util);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, discard_granularity, discard_granularity);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, max_ordered_discard, max_ordered_discard);
@@ -960,6 +972,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (min_discard_issue_time),ATTR_LIST (mid_discard_issue_time),ATTR_LIST (max_discard_issue_time), +ATTR_LIST (discard_io_aware_gran),ATTR_LIST (discard_urgent_util),ATTR_LIST (discard_granularity), ATTR_LIST(max_ordered_discard),
Signature · 1 line
2.25.1
Jaegeuk Kim
maintainerQuoted 35 lines · Yangtao Li
The current
discard_io_aware_granis a fixed value, change it to be configurable through the sys node.Signed-off-by Yangtao Li <[email protected]>---
v2:
- allow 0Documentation/ABI/testing/sysfs-fs-f2fs | 9 +++++++++ fs/f2fs/f2fs.h | 3 +++ fs/f2fs/segment.c | 3 ++- fs/f2fs/sysfs.c | 13 +++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-fs-f2fs +9
-0@@ -669,3 +669,12 @@ Contact: "Ping Xiong" <[email protected]> Description: When DATA SEPARATION is on, it controls the age threshold to indicate the data blocks as warm. By default it was initialized as 2621440 blocks (equals to 10GB). + +What: /sys/fs/f2fs/<disk>/discard_io_aware_gran +Date: December 2022 +Contact: "Yangtao Li" <[email protected]> +Description: Controls background discard granularity of inner discard thread + when is not in idle. Inner thread will not issue discards with size that + is smaller than granularity. The unit size is one block(4KB), now only + support configuring in range of [0, 512]. + Default: 512fs/f2fs/f2fs.h +0
-0
fs/f2fs/f2fs.h struct discard_entry { · line 336
Quoted 5 lines
fs/f2fs/f2fs.h +2
-0@@ -332,6 +332,8 @@ struct discard_entry {#define DEFAULT_DISCARD_GRANULARITY 16/* default maximum discard granularity of ordered discard, unit: block count */ #define DEFAULT_MAX_ORDERED_DISCARD_GRANULARITY 16 +/* default minimum granularity discard not be aware of I/O, unit: block count */ +#define DEFAULT_IO_AWARE_DISCARD_GRANULARITY 512
It seems we don't need to add another dependency between this and MAX_PLIST_NUM. Can we use one?
Quoted 72 lines
fs/f2fs/f2fs.h +1
-0/* max discard pend list number */ #define MAX_PLIST_NUM 512@@ -410,6 +412,7 @@ struct discard_cmd_control {unsigned int min_discard_issue_time;/* min. interval between discard issue */ unsigned int mid_discard_issue_time;/* mid. interval between discard issue */ unsigned int max_discard_issue_time;/* max. interval between discard issue */ +unsigned int discard_io_aware_gran;/* minimum discard granularity not be aware of I/O */ unsigned int discard_urgent_util;/* utilization which issue discard proactively */ unsigned int discard_granularity;/* discard granularity */ unsigned int max_ordered_discard;/* maximum discard granularity issued by lba order */ fs/f2fs/segment.c +2
-1@@ -1060,7 +1060,7 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi, dpolicy->granularity = granularity; dpolicy->max_requests = dcc->max_discard_request; - dpolicy->io_aware_gran =MAX_PLIST_NUM ; + dpolicy->io_aware_gran = dcc->discard_io_aware_gran; dpolicy->timeout = false;if (discard_type ==DPOLICY_BG ) {@@ -2066,6 +2066,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)if (!dcc)return -ENOMEM ; + dcc->discard_io_aware_gran =DEFAULT_IO_AWARE_DISCARD_GRANULARITY ; dcc->discard_granularity =DEFAULT_DISCARD_GRANULARITY ; dcc->max_ordered_discard =DEFAULT_MAX_ORDERED_DISCARD_GRANULARITY ;if (F2FS_OPTION (sbi).discard_unit ==DISCARD_UNIT_SEGMENT )fs/f2fs/sysfs.c +13
-0@@ -473,6 +473,17 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return count; } +if (!strcmp (a->attr.name,"discard_io_aware_gran" )) { +if (t >MAX_PLIST_NUM ) +return -EINVAL ; +if (!f2fs_block_unit_discard (sbi)) +return -EINVAL ; +if (t == *ui) +return count; + *ui = t; +return count; + } +if (!strcmp (a->attr.name,"discard_granularity" )) {if (t ==0 || t >MAX_PLIST_NUM )return -EINVAL ;@@ -825,6 +836,7 @@ F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_request, max_discard_reqF2FS_RW_ATTR (DCC_INFO , discard_cmd_control, min_discard_issue_time, min_discard_issue_time);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, mid_discard_issue_time, mid_discard_issue_time);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, max_discard_issue_time, max_discard_issue_time); +F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, discard_io_aware_gran, discard_io_aware_gran);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, discard_urgent_util, discard_urgent_util);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, discard_granularity, discard_granularity);F2FS_RW_ATTR (DCC_INFO , discard_cmd_control, max_ordered_discard, max_ordered_discard);@@ -960,6 +972,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (min_discard_issue_time),ATTR_LIST (mid_discard_issue_time),ATTR_LIST (max_discard_issue_time), +ATTR_LIST (discard_io_aware_gran),ATTR_LIST (discard_urgent_util),ATTR_LIST (discard_granularity), ATTR_LIST(max_ordered_discard),Signature · 1 line
2.25.1