linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: show mounted time
@ 2020-02-26 16:46 Jaegeuk Kim
  2020-02-27  1:29 ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2020-02-26 16:46 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

Let's show mounted time.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 Documentation/ABI/testing/sysfs-fs-f2fs | 5 +++++
 fs/f2fs/debug.c                         | 3 +++
 fs/f2fs/segment.c                       | 2 +-
 fs/f2fs/segment.h                       | 2 +-
 fs/f2fs/sysfs.c                         | 8 ++++++++
 5 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 1a6cd5397129..ddee45e88270 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -318,3 +318,8 @@ Date:		September 2019
 Contact:	"Hridya Valsaraju" <hridya@google.com>
 Description:	Average number of valid blocks.
 		Available when CONFIG_F2FS_STAT_FS=y.
+
+What:		/sys/fs/f2fs/<disk>/mounted_time
+Date:		February 2020
+Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
+Description:	Show the mounted time of this partition.
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index 6b89eae5e4ca..a8cf9626f71f 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -301,6 +301,9 @@ static int stat_show(struct seq_file *s, void *v)
 			   si->ssa_area_segs, si->main_area_segs);
 		seq_printf(s, "(OverProv:%d Resv:%d)]\n\n",
 			   si->overp_segs, si->rsvd_segs);
+		seq_printf(s, "Current Time: %llu s / Mounted Time: %llu s\n\n",
+					ktime_get_boottime_seconds(),
+					SIT_I(si->sbi)->mounted_time);
 		if (test_opt(si->sbi, DISCARD))
 			seq_printf(s, "Utilization: %u%% (%u valid blocks, %u discard blocks)\n",
 				si->utilization, si->valid_count, si->discard_blks);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index fb3e531a36d2..601d67e72c50 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -4073,7 +4073,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
 	sit_i->dirty_sentries = 0;
 	sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
 	sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
-	sit_i->mounted_time = ktime_get_real_seconds();
+	sit_i->mounted_time = ktime_get_boottime_seconds();
 	init_rwsem(&sit_i->sentry_lock);
 	return 0;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 459dc3901a57..7a83bd530812 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -756,7 +756,7 @@ static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi,
 						bool base_time)
 {
 	struct sit_info *sit_i = SIT_I(sbi);
-	time64_t diff, now = ktime_get_real_seconds();
+	time64_t diff, now = ktime_get_boottime_seconds();
 
 	if (now >= sit_i->mounted_time)
 		return sit_i->elapsed_time + now - sit_i->mounted_time;
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 4e8aae03f26c..7bfbead98c04 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -187,6 +187,12 @@ static ssize_t encoding_show(struct f2fs_attr *a,
 	return sprintf(buf, "(none)");
 }
 
+static ssize_t mounted_time_show(struct f2fs_attr *a,
+		struct f2fs_sb_info *sbi, char *buf)
+{
+	return sprintf(buf, "%llu", SIT_I(sbi)->mounted_time);
+}
+
 #ifdef CONFIG_F2FS_STAT_FS
 static ssize_t moved_blocks_foreground_show(struct f2fs_attr *a,
 				struct f2fs_sb_info *sbi, char *buf)
@@ -546,6 +552,7 @@ F2FS_GENERAL_RO_ATTR(features);
 F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
 F2FS_GENERAL_RO_ATTR(unusable);
 F2FS_GENERAL_RO_ATTR(encoding);
+F2FS_GENERAL_RO_ATTR(mounted_time);
 #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);
@@ -623,6 +630,7 @@ static struct attribute *f2fs_attrs[] = {
 	ATTR_LIST(reserved_blocks),
 	ATTR_LIST(current_reserved_blocks),
 	ATTR_LIST(encoding),
+	ATTR_LIST(mounted_time),
 #ifdef CONFIG_F2FS_STAT_FS
 	ATTR_LIST(cp_foreground_calls),
 	ATTR_LIST(cp_background_calls),
-- 
2.25.1.481.gfbce0eb801-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: show mounted time
  2020-02-26 16:46 [PATCH] f2fs: show mounted time Jaegeuk Kim
@ 2020-02-27  1:29 ` Chao Yu
  2020-02-27 17:59   ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2020-02-27  1:29 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2020/2/27 0:46, Jaegeuk Kim wrote:
> Let's show mounted time.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  Documentation/ABI/testing/sysfs-fs-f2fs | 5 +++++
>  fs/f2fs/debug.c                         | 3 +++
>  fs/f2fs/segment.c                       | 2 +-
>  fs/f2fs/segment.h                       | 2 +-
>  fs/f2fs/sysfs.c                         | 8 ++++++++
>  5 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index 1a6cd5397129..ddee45e88270 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -318,3 +318,8 @@ Date:		September 2019
>  Contact:	"Hridya Valsaraju" <hridya@google.com>
>  Description:	Average number of valid blocks.
>  		Available when CONFIG_F2FS_STAT_FS=y.
> +
> +What:		/sys/fs/f2fs/<disk>/mounted_time
> +Date:		February 2020
> +Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
> +Description:	Show the mounted time of this partition.

It's better to describe its unit: second, otherwise, it looks good to me.

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
> index 6b89eae5e4ca..a8cf9626f71f 100644
> --- a/fs/f2fs/debug.c
> +++ b/fs/f2fs/debug.c
> @@ -301,6 +301,9 @@ static int stat_show(struct seq_file *s, void *v)
>  			   si->ssa_area_segs, si->main_area_segs);
>  		seq_printf(s, "(OverProv:%d Resv:%d)]\n\n",
>  			   si->overp_segs, si->rsvd_segs);
> +		seq_printf(s, "Current Time: %llu s / Mounted Time: %llu s\n\n",
> +					ktime_get_boottime_seconds(),
> +					SIT_I(si->sbi)->mounted_time);
>  		if (test_opt(si->sbi, DISCARD))
>  			seq_printf(s, "Utilization: %u%% (%u valid blocks, %u discard blocks)\n",
>  				si->utilization, si->valid_count, si->discard_blks);
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index fb3e531a36d2..601d67e72c50 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -4073,7 +4073,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
>  	sit_i->dirty_sentries = 0;
>  	sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
>  	sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
> -	sit_i->mounted_time = ktime_get_real_seconds();
> +	sit_i->mounted_time = ktime_get_boottime_seconds();
>  	init_rwsem(&sit_i->sentry_lock);
>  	return 0;
>  }
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index 459dc3901a57..7a83bd530812 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -756,7 +756,7 @@ static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi,
>  						bool base_time)
>  {
>  	struct sit_info *sit_i = SIT_I(sbi);
> -	time64_t diff, now = ktime_get_real_seconds();
> +	time64_t diff, now = ktime_get_boottime_seconds();
>  
>  	if (now >= sit_i->mounted_time)
>  		return sit_i->elapsed_time + now - sit_i->mounted_time;
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index 4e8aae03f26c..7bfbead98c04 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -187,6 +187,12 @@ static ssize_t encoding_show(struct f2fs_attr *a,
>  	return sprintf(buf, "(none)");
>  }
>  
> +static ssize_t mounted_time_show(struct f2fs_attr *a,
> +		struct f2fs_sb_info *sbi, char *buf)
> +{
> +	return sprintf(buf, "%llu", SIT_I(sbi)->mounted_time);
> +}
> +
>  #ifdef CONFIG_F2FS_STAT_FS
>  static ssize_t moved_blocks_foreground_show(struct f2fs_attr *a,
>  				struct f2fs_sb_info *sbi, char *buf)
> @@ -546,6 +552,7 @@ F2FS_GENERAL_RO_ATTR(features);
>  F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
>  F2FS_GENERAL_RO_ATTR(unusable);
>  F2FS_GENERAL_RO_ATTR(encoding);
> +F2FS_GENERAL_RO_ATTR(mounted_time);
>  #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);
> @@ -623,6 +630,7 @@ static struct attribute *f2fs_attrs[] = {
>  	ATTR_LIST(reserved_blocks),
>  	ATTR_LIST(current_reserved_blocks),
>  	ATTR_LIST(encoding),
> +	ATTR_LIST(mounted_time),
>  #ifdef CONFIG_F2FS_STAT_FS
>  	ATTR_LIST(cp_foreground_calls),
>  	ATTR_LIST(cp_background_calls),
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: show mounted time
  2020-02-27  1:29 ` [f2fs-dev] " Chao Yu
@ 2020-02-27 17:59   ` Jaegeuk Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2020-02-27 17:59 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 02/27, Chao Yu wrote:
> On 2020/2/27 0:46, Jaegeuk Kim wrote:
> > Let's show mounted time.
> > 
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >  Documentation/ABI/testing/sysfs-fs-f2fs | 5 +++++
> >  fs/f2fs/debug.c                         | 3 +++
> >  fs/f2fs/segment.c                       | 2 +-
> >  fs/f2fs/segment.h                       | 2 +-
> >  fs/f2fs/sysfs.c                         | 8 ++++++++
> >  5 files changed, 18 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> > index 1a6cd5397129..ddee45e88270 100644
> > --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> > @@ -318,3 +318,8 @@ Date:		September 2019
> >  Contact:	"Hridya Valsaraju" <hridya@google.com>
> >  Description:	Average number of valid blocks.
> >  		Available when CONFIG_F2FS_STAT_FS=y.
> > +
> > +What:		/sys/fs/f2fs/<disk>/mounted_time
> > +Date:		February 2020
> > +Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
> > +Description:	Show the mounted time of this partition.
> 
> It's better to describe its unit: second, otherwise, it looks good to me.

I've added it. Thanks.

> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
> Thanks,
> 
> > diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
> > index 6b89eae5e4ca..a8cf9626f71f 100644
> > --- a/fs/f2fs/debug.c
> > +++ b/fs/f2fs/debug.c
> > @@ -301,6 +301,9 @@ static int stat_show(struct seq_file *s, void *v)
> >  			   si->ssa_area_segs, si->main_area_segs);
> >  		seq_printf(s, "(OverProv:%d Resv:%d)]\n\n",
> >  			   si->overp_segs, si->rsvd_segs);
> > +		seq_printf(s, "Current Time: %llu s / Mounted Time: %llu s\n\n",
> > +					ktime_get_boottime_seconds(),
> > +					SIT_I(si->sbi)->mounted_time);
> >  		if (test_opt(si->sbi, DISCARD))
> >  			seq_printf(s, "Utilization: %u%% (%u valid blocks, %u discard blocks)\n",
> >  				si->utilization, si->valid_count, si->discard_blks);
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index fb3e531a36d2..601d67e72c50 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -4073,7 +4073,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
> >  	sit_i->dirty_sentries = 0;
> >  	sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
> >  	sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
> > -	sit_i->mounted_time = ktime_get_real_seconds();
> > +	sit_i->mounted_time = ktime_get_boottime_seconds();
> >  	init_rwsem(&sit_i->sentry_lock);
> >  	return 0;
> >  }
> > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> > index 459dc3901a57..7a83bd530812 100644
> > --- a/fs/f2fs/segment.h
> > +++ b/fs/f2fs/segment.h
> > @@ -756,7 +756,7 @@ static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi,
> >  						bool base_time)
> >  {
> >  	struct sit_info *sit_i = SIT_I(sbi);
> > -	time64_t diff, now = ktime_get_real_seconds();
> > +	time64_t diff, now = ktime_get_boottime_seconds();
> >  
> >  	if (now >= sit_i->mounted_time)
> >  		return sit_i->elapsed_time + now - sit_i->mounted_time;
> > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> > index 4e8aae03f26c..7bfbead98c04 100644
> > --- a/fs/f2fs/sysfs.c
> > +++ b/fs/f2fs/sysfs.c
> > @@ -187,6 +187,12 @@ static ssize_t encoding_show(struct f2fs_attr *a,
> >  	return sprintf(buf, "(none)");
> >  }
> >  
> > +static ssize_t mounted_time_show(struct f2fs_attr *a,
> > +		struct f2fs_sb_info *sbi, char *buf)
> > +{
> > +	return sprintf(buf, "%llu", SIT_I(sbi)->mounted_time);
> > +}
> > +
> >  #ifdef CONFIG_F2FS_STAT_FS
> >  static ssize_t moved_blocks_foreground_show(struct f2fs_attr *a,
> >  				struct f2fs_sb_info *sbi, char *buf)
> > @@ -546,6 +552,7 @@ F2FS_GENERAL_RO_ATTR(features);
> >  F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
> >  F2FS_GENERAL_RO_ATTR(unusable);
> >  F2FS_GENERAL_RO_ATTR(encoding);
> > +F2FS_GENERAL_RO_ATTR(mounted_time);
> >  #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);
> > @@ -623,6 +630,7 @@ static struct attribute *f2fs_attrs[] = {
> >  	ATTR_LIST(reserved_blocks),
> >  	ATTR_LIST(current_reserved_blocks),
> >  	ATTR_LIST(encoding),
> > +	ATTR_LIST(mounted_time),
> >  #ifdef CONFIG_F2FS_STAT_FS
> >  	ATTR_LIST(cp_foreground_calls),
> >  	ATTR_LIST(cp_background_calls),
> > 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-27 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 16:46 [PATCH] f2fs: show mounted time Jaegeuk Kim
2020-02-27  1:29 ` [f2fs-dev] " Chao Yu
2020-02-27 17:59   ` Jaegeuk Kim

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).