Linux Audio

Check our new training course

Loading...
v3.1
 
  1/*
  2 * procfs-based user access to knfsd statistics
  3 *
  4 * /proc/net/rpc/nfsd
  5 *
  6 * Format:
  7 *	rc <hits> <misses> <nocache>
  8 *			Statistsics for the reply cache
  9 *	fh <stale> <total-lookups> <anonlookups> <dir-not-in-dcache> <nondir-not-in-dcache>
 10 *			statistics for filehandle lookup
 11 *	io <bytes-read> <bytes-written>
 12 *			statistics for IO throughput
 13 *	th <threads> <fullcnt> <10%-20%> <20%-30%> ... <90%-100%> <100%> 
 14 *			time (seconds) when nfsd thread usage above thresholds
 15 *			and number of times that all threads were in use
 16 *	ra cache-size  <10%  <20%  <30% ... <100% not-found
 17 *			number of times that read-ahead entry was found that deep in
 18 *			the cache.
 19 *	plus generic RPC stats (see net/sunrpc/stats.c)
 20 *
 21 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
 22 */
 23
 24#include <linux/seq_file.h>
 25#include <linux/module.h>
 26#include <linux/sunrpc/stats.h>
 27#include <linux/nfsd/stats.h>
 28
 29#include "nfsd.h"
 30
 31struct nfsd_stats	nfsdstats;
 32struct svc_stat		nfsd_svcstats = {
 33	.program	= &nfsd_program,
 34};
 35
 36static int nfsd_proc_show(struct seq_file *seq, void *v)
 37{
 
 
 38	int i;
 39
 40	seq_printf(seq, "rc %u %u %u\nfh %u %u %u %u %u\nio %u %u\n",
 41		      nfsdstats.rchits,
 42		      nfsdstats.rcmisses,
 43		      nfsdstats.rcnocache,
 44		      nfsdstats.fh_stale,
 45		      nfsdstats.fh_lookup,
 46		      nfsdstats.fh_anon,
 47		      nfsdstats.fh_nocache_dir,
 48		      nfsdstats.fh_nocache_nondir,
 49		      nfsdstats.io_read,
 50		      nfsdstats.io_write);
 51	/* thread usage: */
 52	seq_printf(seq, "th %u %u", nfsdstats.th_cnt, nfsdstats.th_fullcnt);
 53	for (i=0; i<10; i++) {
 54		unsigned int jifs = nfsdstats.th_usage[i];
 55		unsigned int sec = jifs / HZ, msec = (jifs % HZ)*1000/HZ;
 56		seq_printf(seq, " %u.%03u", sec, msec);
 57	}
 
 
 58
 59	/* newline and ra-cache */
 60	seq_printf(seq, "\nra %u", nfsdstats.ra_size);
 61	for (i=0; i<11; i++)
 62		seq_printf(seq, " %u", nfsdstats.ra_depth[i]);
 63	seq_putc(seq, '\n');
 64	
 65	/* show my rpc info */
 66	svc_seq_show(seq, &nfsd_svcstats);
 67
 68#ifdef CONFIG_NFSD_V4
 69	/* Show count for individual nfsv4 operations */
 70	/* Writing operation numbers 0 1 2 also for maintaining uniformity */
 71	seq_printf(seq,"proc4ops %u", LAST_NFS4_OP + 1);
 72	for (i = 0; i <= LAST_NFS4_OP; i++)
 73		seq_printf(seq, " %u", nfsdstats.nfs4_opcount[i]);
 
 
 
 
 74
 75	seq_putc(seq, '\n');
 76#endif
 77
 78	return 0;
 79}
 80
 81static int nfsd_proc_open(struct inode *inode, struct file *file)
 82{
 83	return single_open(file, nfsd_proc_show, NULL);
 84}
 85
 86static const struct file_operations nfsd_proc_fops = {
 87	.owner = THIS_MODULE,
 88	.open = nfsd_proc_open,
 89	.read  = seq_read,
 90	.llseek = seq_lseek,
 91	.release = single_release,
 92};
 93
 94void
 95nfsd_stat_init(void)
 96{
 97	svc_proc_register(&nfsd_svcstats, &nfsd_proc_fops);
 
 
 98}
 99
100void
101nfsd_stat_shutdown(void)
102{
103	svc_proc_unregister("nfsd");
104}
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * procfs-based user access to knfsd statistics
 4 *
 5 * /proc/net/rpc/nfsd
 6 *
 7 * Format:
 8 *	rc <hits> <misses> <nocache>
 9 *			Statistsics for the reply cache
10 *	fh <stale> <deprecated filehandle cache stats>
11 *			statistics for filehandle lookup
12 *	io <bytes-read> <bytes-written>
13 *			statistics for IO throughput
14 *	th <threads> <deprecated thread usage histogram stats>
15 *			number of threads
16 *	ra <deprecated ra-cache stats>
17 *
 
 
18 *	plus generic RPC stats (see net/sunrpc/stats.c)
19 *
20 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
21 */
22
23#include <linux/seq_file.h>
24#include <linux/module.h>
25#include <linux/sunrpc/stats.h>
26#include <net/net_namespace.h>
27
28#include "nfsd.h"
29
30static int nfsd_show(struct seq_file *seq, void *v)
 
 
 
 
 
31{
32	struct net *net = pde_data(file_inode(seq->file));
33	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
34	int i;
35
36	seq_printf(seq, "rc %lld %lld %lld\nfh %lld 0 0 0 0\nio %lld %lld\n",
37		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS]),
38		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSES]),
39		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCACHE]),
40		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_FH_STALE]),
41		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_READ]),
42		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_WRITE]));
43
 
 
 
44	/* thread usage: */
45	seq_printf(seq, "th %u 0", atomic_read(&nfsd_th_cnt));
46
47	/* deprecated thread usage histogram stats */
48	for (i = 0; i < 10; i++)
49		seq_puts(seq, " 0.000");
50
51	/* deprecated ra-cache stats */
52	seq_puts(seq, "\nra 0 0 0 0 0 0 0 0 0 0 0 0\n");
53
 
 
 
 
 
 
54	/* show my rpc info */
55	svc_seq_show(seq, &nn->nfsd_svcstats);
56
57#ifdef CONFIG_NFSD_V4
58	/* Show count for individual nfsv4 operations */
59	/* Writing operation numbers 0 1 2 also for maintaining uniformity */
60	seq_printf(seq, "proc4ops %u", LAST_NFS4_OP + 1);
61	for (i = 0; i <= LAST_NFS4_OP; i++) {
62		seq_printf(seq, " %lld",
63			   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_NFS4_OP(i)]));
64	}
65	seq_printf(seq, "\nwdeleg_getattr %lld",
66		percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));
67
68	seq_putc(seq, '\n');
69#endif
70
71	return 0;
72}
73
74DEFINE_PROC_SHOW_ATTRIBUTE(nfsd);
 
 
 
 
 
 
 
 
 
 
 
75
76void nfsd_proc_stat_init(struct net *net)
 
77{
78	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
79
80	svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops);
81}
82
83void nfsd_proc_stat_shutdown(struct net *net)
 
84{
85	svc_proc_unregister(net, "nfsd");
86}