f2fs: Revert "f2fs: make gc_urgent and gc_segment_mode sysfs node readable"
PATCH 1/2 f2fs: Revert "f2fs: make gc_urgent and gc_segment_mode sysfs node readable"
This change breaks forward compatibility of gc_idle interface, so reverts commit it.
--- fs/f2fs/sysfs.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
fs/f2fs/sysfs.c +1 -16
@@ -41,16 +41,6 @@ enum { ATGC_INFO, /* struct atgc_management */ }; -static const char *gc_mode_names[MAX_GC_MODE ] = { -"GC_NORMAL" , -"GC_IDLE_CB" , -"GC_IDLE_GREEDY" , -"GC_IDLE_AT" , -"GC_URGENT_HIGH" , -"GC_URGENT_LOW" , -"GC_URGENT_MID" -}; -struct f2fs_attr {struct attribute attr;ssize_t (*show)(struct f2fs_attr *,struct f2fs_sb_info *,char *);
@@ -332,13 +322,8 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,return sysfs_emit (buf,"%u\n" , sbi->compr_new_inode);#endif -if (!strcmp (a->attr.name,"gc_urgent" )) -return sysfs_emit (buf,"%s\n" , - gc_mode_names[sbi->gc_mode]); -if (!strcmp (a->attr.name,"gc_segment_mode" )) -return sysfs_emit (buf,"%s\n" , - gc_mode_names[sbi->gc_segment_mode]); +return sysfs_emit (buf,"%u\n" , sbi->gc_segment_mode);if (!strcmp (a->attr.name,"gc_reclaimed_segments" )) { return sysfs_emit(buf, "%u\n",
Signature · 1 line
2.25.1
PATCH 2/2 f2fs: introduce gc_mode sysfs node
gc_mode sysfs node can show the current gc_mode as a string. Introducing it increases readability.
--- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/f2fs.h | 1 + fs/f2fs/sysfs.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+)
Documentation/ABI/testing/sysfs-fs-f2fs +6 -0
@@ -634,3 +634,9 @@ Date: July 2022 Contact: "Daeho Jeong" <[email protected]> Description: Show the accumulated total revoked atomic write block count after boot. If you write "0" here, you can initialize to "0". + +What: /sys/fs/f2fs/<disk>/gc_mode +Date: October 2022 +Contact: "Yangtao Li" <[email protected]> +Description: Show the current gc_mode as a string. + This is a read-only entry.
fs/f2fs/f2fs.h +1 -0
@@ -1318,6 +1318,7 @@ enum { MAX_TIME, }; +/* Note that you need to keep synchronization with this gc_mode_names array */ enum {GC_NORMAL ,GC_IDLE_CB ,
fs/f2fs/sysfs.c +18 -0
@@ -41,6 +41,16 @@ enum { ATGC_INFO, /* struct atgc_management */ }; +static const char *gc_mode_names[MAX_GC_MODE ] = { +"GC_NORMAL" , +"GC_IDLE_CB" , +"GC_IDLE_GREEDY" , +"GC_IDLE_AT" , +"GC_URGENT_HIGH" , +"GC_URGENT_LOW" , +"GC_URGENT_MID" +}; +struct f2fs_attr {struct attribute attr;ssize_t (*show)(struct f2fs_attr *,struct f2fs_sb_info *,char *);
@@ -133,6 +143,12 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, &SM_I(sbi)->dcc_info->discard_cmd_cnt)); } +static ssize_t gc_mode_show (struct f2fs_attr *a, +struct f2fs_sb_info *sbi,char *buf) +{ +return sprintf (buf,"%s\n" , gc_mode_names[sbi->gc_mode]); +} +static ssize_t features_show (struct f2fs_attr *a,struct f2fs_sb_info *sbi,char *buf) {
@@ -823,6 +839,7 @@ F2FS_GENERAL_RO_ATTR(encoding);F2FS_GENERAL_RO_ATTR (mounted_time_sec);F2FS_GENERAL_RO_ATTR (main_blkaddr);F2FS_GENERAL_RO_ATTR (pending_discard); +F2FS_GENERAL_RO_ATTR (gc_mode);#ifdef CONFIG_F2FS_STAT_FS F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info, cp_foreground_calls, cp_count);F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info, cp_background_calls, bg_cp_count);
@@ -904,6 +921,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (max_discard_issue_time),ATTR_LIST (discard_granularity),ATTR_LIST (pending_discard), +ATTR_LIST (gc_mode),ATTR_LIST (batched_trim_sections),ATTR_LIST (ipu_policy), ATTR_LIST(min_ipu_util),
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerRe: [PATCH 2/2] f2fs: introduce gc_mode sysfs node
Hi,
I merged two patches and modified a bit. Please take a look.
Quoted 88 lines · Yangtao Li
gc_modesysfs node can show the currentgc_modeas a string. Introducing it increases readability.Signed-off-by Yangtao Li <[email protected]>--- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/f2fs.h | 1 + fs/f2fs/sysfs.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+)Documentation/ABI/testing/sysfs-fs-f2fs +6
-0@@ -634,3 +634,9 @@ Date: July 2022 Contact: "Daeho Jeong" <[email protected]> Description: Show the accumulated total revoked atomic write block count after boot. If you write "0" here, you can initialize to "0". + +What: /sys/fs/f2fs/<disk>/gc_mode +Date: October 2022 +Contact: "Yangtao Li" <[email protected]> +Description: Show the current gc_mode as a string. + This is a read-only entry.fs/f2fs/f2fs.h +1
-0@@ -1318,6 +1318,7 @@ enum { MAX_TIME, }; +/* Note that you need to keep synchronization with this gc_mode_names array */ enum {GC_NORMAL ,GC_IDLE_CB ,fs/f2fs/sysfs.c +18
-0@@ -41,6 +41,16 @@ enum { ATGC_INFO, /* struct atgc_management */ }; +static const char *gc_mode_names[MAX_GC_MODE ] = { +"GC_NORMAL" , +"GC_IDLE_CB" , +"GC_IDLE_GREEDY" , +"GC_IDLE_AT" , +"GC_URGENT_HIGH" , +"GC_URGENT_LOW" , +"GC_URGENT_MID" +}; +struct f2fs_attr {struct attribute attr;ssize_t (*show)(struct f2fs_attr *,struct f2fs_sb_info *,char *);@@ -133,6 +143,12 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, &SM_I(sbi)->dcc_info->discard_cmd_cnt)); } +static ssize_t gc_mode_show (struct f2fs_attr *a, +struct f2fs_sb_info *sbi,char *buf) +{ +return sprintf (buf,"%s\n" , gc_mode_names[sbi->gc_mode]); +} +static ssize_t features_show (struct f2fs_attr *a,struct f2fs_sb_info *sbi,char *buf) {@@ -823,6 +839,7 @@ F2FS_GENERAL_RO_ATTR(encoding);F2FS_GENERAL_RO_ATTR (mounted_time_sec);F2FS_GENERAL_RO_ATTR (main_blkaddr);F2FS_GENERAL_RO_ATTR (pending_discard); +F2FS_GENERAL_RO_ATTR (gc_mode);#ifdef CONFIG_F2FS_STAT_FS F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info, cp_foreground_calls, cp_count);F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info, cp_background_calls, bg_cp_count);@@ -904,6 +921,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (max_discard_issue_time),ATTR_LIST (discard_granularity),ATTR_LIST (pending_discard), +ATTR_LIST (gc_mode),ATTR_LIST (batched_trim_sections),ATTR_LIST (ipu_policy), ATTR_LIST(min_ipu_util),Signature · 1 line
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerRe: [PATCH 2/2] f2fs: introduce gc_mode sysfs node
In reply to Yangtao LiMinor comments below.
Quoted 2 lines · Yangtao Li
gc_modesysfs node can show the currentgc_modeas a string. Introducing it increases readability.
Introducing it to increase readability.
Quoted 27 lines
Signed-off-by Yangtao Li <[email protected]>--- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/f2fs.h | 1 + fs/f2fs/sysfs.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+)Documentation/ABI/testing/sysfs-fs-f2fs +6
-0@@ -634,3 +634,9 @@ Date: July 2022 Contact: "Daeho Jeong" <[email protected]> Description: Show the accumulated total revoked atomic write block count after boot. If you write "0" here, you can initialize to "0". + +What: /sys/fs/f2fs/<disk>/gc_mode +Date: October 2022 +Contact: "Yangtao Li" <[email protected]> +Description: Show the current gc_mode as a string. + This is a read-only entry.fs/f2fs/f2fs.h +0
-0
fs/f2fs/f2fs.h enum { · line 1321
Quoted 4 lines
fs/f2fs/f2fs.h +1
-0@@ -1318,6 +1318,7 @@ enum { MAX_TIME, }; +/* Note that you need to keep synchronization with this gc_mode_names array */
Good point.
/* Modification on enum should be synchronized with gc_mode_names array */
Quoted 53 lines
fs/f2fs/f2fs.h +0
-0enum {GC_NORMAL ,GC_IDLE_CB ,fs/f2fs/sysfs.c +18
-0@@ -41,6 +41,16 @@ enum { ATGC_INFO, /* struct atgc_management */ }; +static const char *gc_mode_names[MAX_GC_MODE ] = { +"GC_NORMAL" , +"GC_IDLE_CB" , +"GC_IDLE_GREEDY" , +"GC_IDLE_AT" , +"GC_URGENT_HIGH" , +"GC_URGENT_LOW" , +"GC_URGENT_MID" +}; +struct f2fs_attr {struct attribute attr;ssize_t (*show)(struct f2fs_attr *,struct f2fs_sb_info *,char *);@@ -133,6 +143,12 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, &SM_I(sbi)->dcc_info->discard_cmd_cnt)); } +static ssize_t gc_mode_show (struct f2fs_attr *a, +struct f2fs_sb_info *sbi,char *buf) +{ +return sprintf (buf,"%s\n" , gc_mode_names[sbi->gc_mode]); +} +static ssize_t features_show (struct f2fs_attr *a,struct f2fs_sb_info *sbi,char *buf) {@@ -823,6 +839,7 @@ F2FS_GENERAL_RO_ATTR(encoding);F2FS_GENERAL_RO_ATTR (mounted_time_sec);F2FS_GENERAL_RO_ATTR (main_blkaddr);F2FS_GENERAL_RO_ATTR (pending_discard); +F2FS_GENERAL_RO_ATTR (gc_mode);#ifdef CONFIG_F2FS_STAT_FS F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info, cp_foreground_calls, cp_count);F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info, cp_background_calls, bg_cp_count);@@ -904,6 +921,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (max_discard_issue_time),ATTR_LIST (discard_granularity),ATTR_LIST (pending_discard), +ATTR_LIST (gc_mode),ATTR_LIST (batched_trim_sections),ATTR_LIST (ipu_policy), ATTR_LIST(min_ipu_util),