Skip to contentSkip to conversation

f2fs: export gc_mode in debugfs

PATCH In review Yangtao Li 2 participants 3 messages Apr 12, 2023 – Apr 13, 2023 F2FS file system

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 f2fs: export gc_mode in debugfs

This patch exports gc_mode to debugfs. Since gc_urgent and gc_idle nodes can get gc mode, so remove gc_mode node.

---
 Documentation/ABI/testing/sysfs-fs-f2fs |  6 ------
 fs/f2fs/debug.c                         | 13 ++++++++++++-
 fs/f2fs/sysfs.c                         | 18 ------------------
 3 files changed, 12 insertions(+), 25 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +0 -6
index 8140fc98f5ae..3b78b8324263 100644
@@ -643,12 +643,6 @@ 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.
-
 What:		/sys/fs/f2fs/<disk>/discard_urgent_util
 Date:		November 2022
 Contact:	"Yangtao Li" <[email protected]>
fs/f2fs/debug.c +12 -1
index 61c35b59126e..5172b2417c08 100644
@@ -366,6 +366,16 @@ static const char *ipu_mode_names[F2FS_IPU_MAX] = {
 	[F2FS_IPU_HONOR_OPU_WRITE]	= "HONOR_OPU_WRITE",
 };
 
+static const char *gc_mode_names[MAX_GC_MODE] = {
+	[GC_NORMAL]		= "GC_NORMAL",
+	[GC_IDLE_CB]		= "GC_IDLE_CB",
+	[GC_IDLE_GREEDY]	= "GC_IDLE_GREEDY",
+	[GC_IDLE_AT]		= "GC_IDLE_AT",
+	[GC_URGENT_HIGH]	= "GC_URGENT_HIGH",
+	[GC_URGENT_LOW]		= "GC_URGENT_LOW",
+	[GC_URGENT_MID]		= "GC_URGENT_MID",
+};
+
 static int stat_show(struct seq_file *s, void *v)
 {
 	struct f2fs_stat_info *si;
@@ -409,7 +419,8 @@ static int stat_show(struct seq_file *s, void *v)
 			for_each_set_bit(j, &policy, F2FS_IPU_MAX)
 				seq_printf(s, " %s", ipu_mode_names[j]);
 		}
-		seq_puts(s, " ]\n\n");
+		seq_puts(s, " ]\n");
+		seq_printf(s, "  - GC: [ %s ]\n\n", gc_mode_names[sbi->gc_mode]);
 
 		if (test_opt(sbi, DISCARD))
 			seq_printf(s, "Utilization: %u%% (%u valid blocks, %u discard blocks)\n",
fs/f2fs/sysfs.c +0 -18
index 4d6263e556fa..c2873a94f7b2 100644
@@ -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 *a, struct f2fs_sb_info *sbi, char *buf);
@@ -143,12 +133,6 @@ 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 sysfs_emit(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)
 {
@@ -916,7 +900,6 @@ 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);
@@ -1008,7 +991,6 @@ static struct attribute *f2fs_attrs[] = {
 	ATTR_LIST(discard_granularity),
 	ATTR_LIST(max_ordered_discard),
 	ATTR_LIST(pending_discard),
-	ATTR_LIST(gc_mode),
 	ATTR_LIST(ipu_policy),
 	ATTR_LIST(min_ipu_util),
 	ATTR_LIST(min_fsync_blocks),
Signature · 8 lines
2.35.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#1 lore raw
Quoted 2 lines · Yangtao Li

This patch exports gc_mode to debugfs. Since gc_urgent and gc_idle nodes can get gc mode, so remove gc_mode node.

What if some app/script is using gc_mode....it breaks its use.

Thanks,

Quoted 106 lines
---
  Documentation/ABI/testing/sysfs-fs-f2fs |  6 ------
  fs/f2fs/debug.c                         | 13 ++++++++++++-
  fs/f2fs/sysfs.c                         | 18 ------------------
  3 files changed, 12 insertions(+), 25 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +0 -6
index 8140fc98f5ae..3b78b8324263 100644
@@ -643,12 +643,6 @@ 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.
-
  What:		/sys/fs/f2fs/<disk>/discard_urgent_util
  Date:		November 2022
  Contact:	"Yangtao Li" <[email protected]>
fs/f2fs/debug.c +12 -1
index 61c35b59126e..5172b2417c08 100644
@@ -366,6 +366,16 @@ static const char *ipu_mode_names[F2FS_IPU_MAX] = {
  	[F2FS_IPU_HONOR_OPU_WRITE]	= "HONOR_OPU_WRITE",
  };
 
+static const char *gc_mode_names[MAX_GC_MODE] = {
+	[GC_NORMAL]		= "GC_NORMAL",
+	[GC_IDLE_CB]		= "GC_IDLE_CB",
+	[GC_IDLE_GREEDY]	= "GC_IDLE_GREEDY",
+	[GC_IDLE_AT]		= "GC_IDLE_AT",
+	[GC_URGENT_HIGH]	= "GC_URGENT_HIGH",
+	[GC_URGENT_LOW]		= "GC_URGENT_LOW",
+	[GC_URGENT_MID]		= "GC_URGENT_MID",
+};
+
  static int stat_show(struct seq_file *s, void *v)
  {
  	struct f2fs_stat_info *si;
@@ -409,7 +419,8 @@ static int stat_show(struct seq_file *s, void *v)
  			for_each_set_bit(j, &policy, F2FS_IPU_MAX)
  				seq_printf(s, " %s", ipu_mode_names[j]);
  		}
-		seq_puts(s, " ]\n\n");
+		seq_puts(s, " ]\n");
+		seq_printf(s, "  - GC: [ %s ]\n\n", gc_mode_names[sbi->gc_mode]);
 
  		if (test_opt(sbi, DISCARD))
  			seq_printf(s, "Utilization: %u%% (%u valid blocks, %u discard blocks)\n",
fs/f2fs/sysfs.c +0 -18
index 4d6263e556fa..c2873a94f7b2 100644
@@ -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 *a, struct f2fs_sb_info *sbi, char *buf);
@@ -143,12 +133,6 @@ 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 sysfs_emit(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)
  {
@@ -916,7 +900,6 @@ 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);
@@ -1008,7 +991,6 @@ static struct attribute *f2fs_attrs[] = {
  	ATTR_LIST(discard_granularity),
  	ATTR_LIST(max_ordered_discard),
  	ATTR_LIST(pending_discard),
-	ATTR_LIST(gc_mode),
  	ATTR_LIST(ipu_policy),
  	ATTR_LIST(min_ipu_util),
  	ATTR_LIST(min_fsync_blocks),
author
#2 lore raw
Quoted 1 line

What if some app/script is using gc_mode....it breaks its use.

Similar words, you said before.

https://lore.kernel.org/lkml/[email protected]/

The instructions for these nodes are in the Documentation/ABI/testing/ directory, not the Documentation/ABI/stable directory.

So, we can still remove unnecessary nodes, right?

Thx,
Yangtao