]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFSD: Record number of flush calls
authorChuck Lever <chuck.lever@oracle.com>
Fri, 8 Jul 2022 18:24:45 +0000 (14:24 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:09 +0000 (16:19 +0200)
[ Upstream commit df2aff524faceaf743b7c5ab0f4fb86cb511f782 ]

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/filecache.c

index e5bd9f06492c8f5630e7c74fd57e564af099917c..b9941d4ef20d6d4338a6ad59a56c95e94c1dac3c 100644 (file)
@@ -45,6 +45,7 @@ static DEFINE_PER_CPU(unsigned long, nfsd_file_cache_hits);
 static DEFINE_PER_CPU(unsigned long, nfsd_file_acquisitions);
 static DEFINE_PER_CPU(unsigned long, nfsd_file_releases);
 static DEFINE_PER_CPU(unsigned long, nfsd_file_total_age);
+static DEFINE_PER_CPU(unsigned long, nfsd_file_pages_flushed);
 static DEFINE_PER_CPU(unsigned long, nfsd_file_evictions);
 
 struct nfsd_fcache_disposal {
@@ -242,7 +243,12 @@ nfsd_file_check_write_error(struct nfsd_file *nf)
 static void
 nfsd_file_flush(struct nfsd_file *nf)
 {
-       if (nf->nf_file && vfs_fsync(nf->nf_file, 1) != 0)
+       struct file *file = nf->nf_file;
+
+       if (!file || !(file->f_mode & FMODE_WRITE))
+               return;
+       this_cpu_add(nfsd_file_pages_flushed, file->f_mapping->nrpages);
+       if (vfs_fsync(file, 1) != 0)
                nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
 }
 
@@ -1069,7 +1075,8 @@ nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
  */
 static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
 {
-       unsigned long hits = 0, acquisitions = 0, releases = 0, evictions = 0;
+       unsigned long releases = 0, pages_flushed = 0, evictions = 0;
+       unsigned long hits = 0, acquisitions = 0;
        unsigned int i, count = 0, longest = 0;
        unsigned long lru = 0, total_age = 0;
 
@@ -1094,6 +1101,7 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
                releases += per_cpu(nfsd_file_releases, i);
                total_age += per_cpu(nfsd_file_total_age, i);
                evictions += per_cpu(nfsd_file_evictions, i);
+               pages_flushed += per_cpu(nfsd_file_pages_flushed, i);
        }
 
        seq_printf(m, "total entries: %u\n", count);
@@ -1107,6 +1115,7 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
                seq_printf(m, "mean age (ms): %ld\n", total_age / releases);
        else
                seq_printf(m, "mean age (ms): -\n");
+       seq_printf(m, "pages flushed: %lu\n", pages_flushed);
        return 0;
 }