1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <linux/seq_file.h>
26#include <linux/module.h>
27#include <linux/sunrpc/stats.h>
28#include <net/net_namespace.h>
29
30#include "nfsd.h"
31
32struct nfsd_stats nfsdstats;
33struct svc_stat nfsd_svcstats = {
34 .program = &nfsd_program,
35};
36
37static int nfsd_proc_show(struct seq_file *seq, void *v)
38{
39 int i;
40
41 seq_printf(seq, "rc %u %u %u\nfh %u %u %u %u %u\nio %u %u\n",
42 nfsdstats.rchits,
43 nfsdstats.rcmisses,
44 nfsdstats.rcnocache,
45 nfsdstats.fh_stale,
46 nfsdstats.fh_lookup,
47 nfsdstats.fh_anon,
48 nfsdstats.fh_nocache_dir,
49 nfsdstats.fh_nocache_nondir,
50 nfsdstats.io_read,
51 nfsdstats.io_write);
52
53 seq_printf(seq, "th %u %u", nfsdstats.th_cnt, nfsdstats.th_fullcnt);
54 for (i=0; i<10; i++) {
55 unsigned int jifs = nfsdstats.th_usage[i];
56 unsigned int sec = jifs / HZ, msec = (jifs % HZ)*1000/HZ;
57 seq_printf(seq, " %u.%03u", sec, msec);
58 }
59
60
61 seq_printf(seq, "\nra %u", nfsdstats.ra_size);
62 for (i=0; i<11; i++)
63 seq_printf(seq, " %u", nfsdstats.ra_depth[i]);
64 seq_putc(seq, '\n');
65
66
67 svc_seq_show(seq, &nfsd_svcstats);
68
69#ifdef CONFIG_NFSD_V4
70
71
72 seq_printf(seq,"proc4ops %u", LAST_NFS4_OP + 1);
73 for (i = 0; i <= LAST_NFS4_OP; i++)
74 seq_printf(seq, " %u", nfsdstats.nfs4_opcount[i]);
75
76 seq_putc(seq, '\n');
77#endif
78
79 return 0;
80}
81
82static int nfsd_proc_open(struct inode *inode, struct file *file)
83{
84 return single_open(file, nfsd_proc_show, NULL);
85}
86
87static const struct file_operations nfsd_proc_fops = {
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(&init_net, &nfsd_svcstats, &nfsd_proc_fops);
98}
99
100void
101nfsd_stat_shutdown(void)
102{
103 svc_proc_unregister(&init_net, "nfsd");
104}
105