NFSv4: Add lease_time and lease_expired to 'nfs4:' line of mountstats
authorDave Wysochanski <dwysocha@redhat.com>
Fri, 17 May 2019 21:06:41 +0000 (17:06 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 6 Jul 2019 18:54:52 +0000 (14:54 -0400)
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>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/super.c

index bd3ba1d323ea1054b26a6216919841c8fe078311..d01def299d4044e0e1c3246ef5c3c9e674958734 100644 (file)
@@ -742,6 +742,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)
 {
@@ -850,6 +860,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