Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] NFSv4: Add lease_time and lease_expired to 'nfs4:' line of mountstats
@ 2019-05-17 21:06 Dave Wysochanski
  2019-05-20 15:10 ` Chuck Lever
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Wysochanski @ 2019-05-17 21:06 UTC (permalink / raw)
  To: linux-nfs

On the NFS client there is no low-impact way to determine the nfs4
lease time or whether the lease is expired, so add these to mountstats
with times displayed in seconds.

If the lease is not expired, display lease_expired=0. Otherwise,
display lease_expired=seconds_since_expired, similar to 'age:' line
in mountstats.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 fs/nfs/super.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index c27ac96..6e52f0c 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -730,6 +730,16 @@ int nfs_show_options(struct seq_file *m, struct dentry *root)
 EXPORT_SYMBOL_GPL(nfs_show_options);
 
 #if IS_ENABLED(CONFIG_NFS_V4)
+static void show_lease(struct seq_file *m, struct nfs_server *server)
+{
+	struct nfs_client *clp = server->nfs_client;
+	unsigned long expire;
+
+	seq_printf(m, ",lease_time=%ld", clp->cl_lease_time / HZ);
+	expire = clp->cl_last_renewal + clp->cl_lease_time;
+	seq_printf(m, ",lease_expired=%ld",
+		   time_after(expire, jiffies) ?  0 : (jiffies - expire) / HZ);
+}
 #ifdef CONFIG_NFS_V4_1
 static void show_sessions(struct seq_file *m, struct nfs_server *server)
 {
@@ -838,6 +848,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)
 		seq_printf(m, ",acl=0x%x", nfss->acl_bitmask);
 		show_sessions(m, nfss);
 		show_pnfs(m, nfss);
+		show_lease(m, nfss);
 	}
 #endif
 
-- 
1.8.3.1


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

* Re: [PATCH] NFSv4: Add lease_time and lease_expired to 'nfs4:' line of mountstats
  2019-05-17 21:06 [PATCH] NFSv4: Add lease_time and lease_expired to 'nfs4:' line of mountstats Dave Wysochanski
@ 2019-05-20 15:10 ` Chuck Lever
  2019-06-12 19:11   ` Dave Wysochanski
  0 siblings, 1 reply; 3+ messages in thread
From: Chuck Lever @ 2019-05-20 15:10 UTC (permalink / raw)
  To: Dave Wysochanski; +Cc: Linux NFS Mailing List



> On May 17, 2019, at 5:06 PM, Dave Wysochanski <dwysocha@redhat.com> wrote:
> 
> On the NFS client there is no low-impact way to determine the nfs4
> lease time or whether the lease is expired, so add these to mountstats
> with times displayed in seconds.
> 
> If the lease is not expired, display lease_expired=0. Otherwise,
> display lease_expired=seconds_since_expired, similar to 'age:' line
> in mountstats.
> 
> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> ---
> fs/nfs/super.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
> 
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index c27ac96..6e52f0c 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -730,6 +730,16 @@ int nfs_show_options(struct seq_file *m, struct dentry *root)
> EXPORT_SYMBOL_GPL(nfs_show_options);
> 
> #if IS_ENABLED(CONFIG_NFS_V4)
> +static void show_lease(struct seq_file *m, struct nfs_server *server)
> +{
> +	struct nfs_client *clp = server->nfs_client;
> +	unsigned long expire;
> +
> +	seq_printf(m, ",lease_time=%ld", clp->cl_lease_time / HZ);
> +	expire = clp->cl_last_renewal + clp->cl_lease_time;
> +	seq_printf(m, ",lease_expired=%ld",
> +		   time_after(expire, jiffies) ?  0 : (jiffies - expire) / HZ);
> +}
> #ifdef CONFIG_NFS_V4_1
> static void show_sessions(struct seq_file *m, struct nfs_server *server)
> {
> @@ -838,6 +848,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)
> 		seq_printf(m, ",acl=0x%x", nfss->acl_bitmask);
> 		show_sessions(m, nfss);
> 		show_pnfs(m, nfss);
> +		show_lease(m, nfss);
> 	}
> #endif
> 
> -- 
> 1.8.3.1
> 

I didn't look closely at the patch content, but IMO this is a good
observability enhancement.


--
Chuck Lever




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

* Re: [PATCH] NFSv4: Add lease_time and lease_expired to 'nfs4:' line of mountstats
  2019-05-20 15:10 ` Chuck Lever
@ 2019-06-12 19:11   ` Dave Wysochanski
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Wysochanski @ 2019-06-12 19:11 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: Linux NFS Mailing List

On Mon, 2019-05-20 at 11:10 -0400, Chuck Lever wrote:
> > On May 17, 2019, at 5:06 PM, Dave Wysochanski <dwysocha@redhat.com>
> > wrote:
> > 
> > On the NFS client there is no low-impact way to determine the nfs4
> > lease time or whether the lease is expired, so add these to
> > mountstats
> > with times displayed in seconds.
> > 
> > If the lease is not expired, display lease_expired=0. Otherwise,
> > display lease_expired=seconds_since_expired, similar to 'age:' line
> > in mountstats.
> > 
> > Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> > ---
> > fs/nfs/super.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> > 
> > diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> > index c27ac96..6e52f0c 100644
> > --- a/fs/nfs/super.c
> > +++ b/fs/nfs/super.c
> > @@ -730,6 +730,16 @@ int nfs_show_options(struct seq_file *m,
> > struct dentry *root)
> > EXPORT_SYMBOL_GPL(nfs_show_options);
> > 
> > #if IS_ENABLED(CONFIG_NFS_V4)
> > +static void show_lease(struct seq_file *m, struct nfs_server
> > *server)
> > +{
> > +	struct nfs_client *clp = server->nfs_client;
> > +	unsigned long expire;
> > +
> > +	seq_printf(m, ",lease_time=%ld", clp->cl_lease_time / HZ);
> > +	expire = clp->cl_last_renewal + clp->cl_lease_time;
> > +	seq_printf(m, ",lease_expired=%ld",
> > +		   time_after(expire, jiffies) ?  0 : (jiffies -
> > expire) / HZ);
> > +}
> > #ifdef CONFIG_NFS_V4_1
> > static void show_sessions(struct seq_file *m, struct nfs_server
> > *server)
> > {
> > @@ -838,6 +848,7 @@ int nfs_show_stats(struct seq_file *m, struct
> > dentry *root)
> > 		seq_printf(m, ",acl=0x%x", nfss->acl_bitmask);
> > 		show_sessions(m, nfss);
> > 		show_pnfs(m, nfss);
> > +		show_lease(m, nfss);
> > 	}
> > #endif
> > 
> > -- 
> > 1.8.3.1
> > 
> 
> I didn't look closely at the patch content, but IMO this is a good
> observability enhancement.
> 
> 
> 

Thanks Chuck.  Trond or Anna do you have any concerns about this patch?

I didn't bump NFS_IOSTAT_VERS as I understand that only covers the
counts not the other lines in nfs_show_stats, correct?

Thanks.




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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 21:06 [PATCH] NFSv4: Add lease_time and lease_expired to 'nfs4:' line of mountstats Dave Wysochanski
2019-05-20 15:10 ` Chuck Lever
2019-06-12 19:11   ` Dave Wysochanski

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org linux-nfs@archiver.kernel.org
	public-inbox-index linux-nfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox