linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: show more discard stat by sysfs
@ 2023-11-24  1:08 Zhiguo Niu
  2023-11-28  2:13 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Zhiguo Niu @ 2023-11-24  1:08 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: hongyu.jin, zhiguo.niu, niuzhiguo84, linux-kernel,
	linux-f2fs-devel

The current pending_discard attr just only shows the discard_cmd_cnt
information, which is not very meaningful. More discard information
can be shown so that we can check them through sysfs when needed.

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
 fs/f2fs/sysfs.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 417fae96..f98e680 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -134,13 +134,22 @@ static ssize_t cp_status_show(struct f2fs_attr *a,
 	return sysfs_emit(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_flags));
 }
 
-static ssize_t pending_discard_show(struct f2fs_attr *a,
+static ssize_t discard_stat_show(struct f2fs_attr *a,
 		struct f2fs_sb_info *sbi, char *buf)
 {
-	if (!SM_I(sbi)->dcc_info)
+	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
+
+	if (!dcc)
 		return -EINVAL;
-	return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read(
-				&SM_I(sbi)->dcc_info->discard_cmd_cnt));
+
+	return sysfs_emit(buf, "%llu, %llu, %llu, %u\n",
+			(unsigned long long)atomic_read(
+				&dcc->discard_cmd_cnt),
+			(unsigned long long)atomic_read(
+				&dcc->issued_discard),
+			(unsigned long long)atomic_read(
+				&dcc->queued_discard),
+			dcc->undiscard_blks);
 }
 
 static ssize_t gc_mode_show(struct f2fs_attr *a,
@@ -1016,7 +1025,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
 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(discard_stat);
 F2FS_GENERAL_RO_ATTR(gc_mode);
 #ifdef CONFIG_F2FS_STAT_FS
 F2FS_GENERAL_RO_ATTR(moved_blocks_background);
@@ -1074,7 +1083,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
 	ATTR_LIST(discard_urgent_util),
 	ATTR_LIST(discard_granularity),
 	ATTR_LIST(max_ordered_discard),
-	ATTR_LIST(pending_discard),
+	ATTR_LIST(discard_stat),
 	ATTR_LIST(gc_mode),
 	ATTR_LIST(ipu_policy),
 	ATTR_LIST(min_ipu_util),
-- 
1.9.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] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: show more discard stat by sysfs
  2023-11-24  1:08 [f2fs-dev] [PATCH] f2fs: show more discard stat by sysfs Zhiguo Niu
@ 2023-11-28  2:13 ` Chao Yu
  2023-11-28  2:45   ` Zhiguo Niu
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2023-11-28  2:13 UTC (permalink / raw)
  To: Zhiguo Niu, jaegeuk
  Cc: hongyu.jin, niuzhiguo84, linux-kernel, linux-f2fs-devel

On 2023/11/24 9:08, Zhiguo Niu wrote:
> The current pending_discard attr just only shows the discard_cmd_cnt
> information, which is not very meaningful. More discard information
> can be shown so that we can check them through sysfs when needed.

What about adding this entry to /sys/fs/f2fs/<dev>/stat/?

> 
> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> ---
>   fs/f2fs/sysfs.c | 21 +++++++++++++++------
>   1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index 417fae96..f98e680 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -134,13 +134,22 @@ static ssize_t cp_status_show(struct f2fs_attr *a,
>   	return sysfs_emit(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_flags));
>   }
>   
> -static ssize_t pending_discard_show(struct f2fs_attr *a,
> +static ssize_t discard_stat_show(struct f2fs_attr *a,
>   		struct f2fs_sb_info *sbi, char *buf)
>   {
> -	if (!SM_I(sbi)->dcc_info)
> +	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
> +
> +	if (!dcc)
>   		return -EINVAL;
> -	return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read(
> -				&SM_I(sbi)->dcc_info->discard_cmd_cnt));

It's better to keep the old one for any potential user.

> +
> +	return sysfs_emit(buf, "%llu, %llu, %llu, %u\n",
> +			(unsigned long long)atomic_read(
> +				&dcc->discard_cmd_cnt),
> +			(unsigned long long)atomic_read(
> +				&dcc->issued_discard),
> +			(unsigned long long)atomic_read(
> +				&dcc->queued_discard),
> +			dcc->undiscard_blks);
>   }
>   
>   static ssize_t gc_mode_show(struct f2fs_attr *a,
> @@ -1016,7 +1025,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
>   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(discard_stat);

It needs to adjust Documentation/ABI/testing/sysfs-fs-f2fs.

Thanks,

>   F2FS_GENERAL_RO_ATTR(gc_mode);
>   #ifdef CONFIG_F2FS_STAT_FS
>   F2FS_GENERAL_RO_ATTR(moved_blocks_background);
> @@ -1074,7 +1083,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
>   	ATTR_LIST(discard_urgent_util),
>   	ATTR_LIST(discard_granularity),
>   	ATTR_LIST(max_ordered_discard),
> -	ATTR_LIST(pending_discard),
> +	ATTR_LIST(discard_stat),
>   	ATTR_LIST(gc_mode),
>   	ATTR_LIST(ipu_policy),
>   	ATTR_LIST(min_ipu_util),


_______________________________________________
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] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: show more discard stat by sysfs
  2023-11-28  2:13 ` Chao Yu
@ 2023-11-28  2:45   ` Zhiguo Niu
  0 siblings, 0 replies; 3+ messages in thread
From: Zhiguo Niu @ 2023-11-28  2:45 UTC (permalink / raw)
  To: Chao Yu; +Cc: hongyu.jin, jaegeuk, Zhiguo Niu, linux-kernel, linux-f2fs-devel

Dear Chao,

On Tue, Nov 28, 2023 at 10:13 AM Chao Yu <chao@kernel.org> wrote:
>
> On 2023/11/24 9:08, Zhiguo Niu wrote:
> > The current pending_discard attr just only shows the discard_cmd_cnt
> > information, which is not very meaningful. More discard information
> > can be shown so that we can check them through sysfs when needed.
>
> What about adding this entry to /sys/fs/f2fs/<dev>/stat/?
I think it is ok!
The purpose of this patch is to obtain f2fs discard related status
when necessary.
Because sys/kernel/debug/f2fs/status cannot be used on the user version,
I will change it according to your suggestion.
>
> >
> > Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> > ---
> >   fs/f2fs/sysfs.c | 21 +++++++++++++++------
> >   1 file changed, 15 insertions(+), 6 deletions(-)
> >
> > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> > index 417fae96..f98e680 100644
> > --- a/fs/f2fs/sysfs.c
> > +++ b/fs/f2fs/sysfs.c
> > @@ -134,13 +134,22 @@ static ssize_t cp_status_show(struct f2fs_attr *a,
> >       return sysfs_emit(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_flags));
> >   }
> >
> > -static ssize_t pending_discard_show(struct f2fs_attr *a,
> > +static ssize_t discard_stat_show(struct f2fs_attr *a,
> >               struct f2fs_sb_info *sbi, char *buf)
> >   {
> > -     if (!SM_I(sbi)->dcc_info)
> > +     struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
> > +
> > +     if (!dcc)
> >               return -EINVAL;
> > -     return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read(
> > -                             &SM_I(sbi)->dcc_info->discard_cmd_cnt));
>
> It's better to keep the old one for any potential user.
>
> > +
> > +     return sysfs_emit(buf, "%llu, %llu, %llu, %u\n",
> > +                     (unsigned long long)atomic_read(
> > +                             &dcc->discard_cmd_cnt),
> > +                     (unsigned long long)atomic_read(
> > +                             &dcc->issued_discard),
> > +                     (unsigned long long)atomic_read(
> > +                             &dcc->queued_discard),
> > +                     dcc->undiscard_blks);
> >   }
> >
> >   static ssize_t gc_mode_show(struct f2fs_attr *a,
> > @@ -1016,7 +1025,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
> >   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(discard_stat);
>
> It needs to adjust Documentation/ABI/testing/sysfs-fs-f2fs.
>
> Thanks,
>
> >   F2FS_GENERAL_RO_ATTR(gc_mode);
> >   #ifdef CONFIG_F2FS_STAT_FS
> >   F2FS_GENERAL_RO_ATTR(moved_blocks_background);
> > @@ -1074,7 +1083,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
> >       ATTR_LIST(discard_urgent_util),
> >       ATTR_LIST(discard_granularity),
> >       ATTR_LIST(max_ordered_discard),
> > -     ATTR_LIST(pending_discard),
> > +     ATTR_LIST(discard_stat),
> >       ATTR_LIST(gc_mode),
> >       ATTR_LIST(ipu_policy),
> >       ATTR_LIST(min_ipu_util),


_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2023-11-28  2:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-24  1:08 [f2fs-dev] [PATCH] f2fs: show more discard stat by sysfs Zhiguo Niu
2023-11-28  2:13 ` Chao Yu
2023-11-28  2:45   ` Zhiguo Niu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).