aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/stats.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/nfsd/stats.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'fs/nfsd/stats.c')
-rw-r--r--fs/nfsd/stats.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
new file mode 100644
index 000000000000..1cf955bcc526
--- /dev/null
+++ b/fs/nfsd/stats.c
@@ -0,0 +1,101 @@
1/*
2 * linux/fs/nfsd/stats.c
3 *
4 * procfs-based user access to knfsd statistics
5 *
6 * /proc/net/rpc/nfsd
7 *
8 * Format:
9 * rc <hits> <misses> <nocache>
10 * Statistsics for the reply cache
11 * fh <stale> <total-lookups> <anonlookups> <dir-not-in-dcache> <nondir-not-in-dcache>
12 * statistics for filehandle lookup
13 * io <bytes-read> <bytes-writtten>
14 * statistics for IO throughput
15 * th <threads> <fullcnt> <10%-20%> <20%-30%> ... <90%-100%> <100%>
16 * time (seconds) when nfsd thread usage above thresholds
17 * and number of times that all threads were in use
18 * ra cache-size <10% <20% <30% ... <100% not-found
19 * number of times that read-ahead entry was found that deep in
20 * the cache.
21 * plus generic RPC stats (see net/sunrpc/stats.c)
22 *
23 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
24 */
25
26#include <linux/kernel.h>
27#include <linux/time.h>
28#include <linux/proc_fs.h>
29#include <linux/seq_file.h>
30#include <linux/stat.h>
31#include <linux/module.h>
32
33#include <linux/sunrpc/svc.h>
34#include <linux/sunrpc/stats.h>
35#include <linux/nfsd/nfsd.h>
36#include <linux/nfsd/stats.h>
37
38struct nfsd_stats nfsdstats;
39struct svc_stat nfsd_svcstats = {
40 .program = &nfsd_program,
41};
42
43static int nfsd_proc_show(struct seq_file *seq, void *v)
44{
45 int i;
46
47 seq_printf(seq, "rc %u %u %u\nfh %u %u %u %u %u\nio %u %u\n",
48 nfsdstats.rchits,
49 nfsdstats.rcmisses,
50 nfsdstats.rcnocache,
51 nfsdstats.fh_stale,
52 nfsdstats.fh_lookup,
53 nfsdstats.fh_anon,
54 nfsdstats.fh_nocache_dir,
55 nfsdstats.fh_nocache_nondir,
56 nfsdstats.io_read,
57 nfsdstats.io_write);
58 /* thread usage: */
59 seq_printf(seq, "th %u %u", nfsdstats.th_cnt, nfsdstats.th_fullcnt);
60 for (i=0; i<10; i++) {
61 unsigned int jifs = nfsdstats.th_usage[i];
62 unsigned int sec = jifs / HZ, msec = (jifs % HZ)*1000/HZ;
63 seq_printf(seq, " %u.%03u", sec, msec);
64 }
65
66 /* newline and ra-cache */
67 seq_printf(seq, "\nra %u", nfsdstats.ra_size);
68 for (i=0; i<11; i++)
69 seq_printf(seq, " %u", nfsdstats.ra_depth[i]);
70 seq_putc(seq, '\n');
71
72 /* show my rpc info */
73 svc_seq_show(seq, &nfsd_svcstats);
74
75 return 0;
76}
77
78static int nfsd_proc_open(struct inode *inode, struct file *file)
79{
80 return single_open(file, nfsd_proc_show, NULL);
81}
82
83static struct file_operations nfsd_proc_fops = {
84 .owner = THIS_MODULE,
85 .open = nfsd_proc_open,
86 .read = seq_read,
87 .llseek = seq_lseek,
88 .release = single_release,
89};
90
91void
92nfsd_stat_init(void)
93{
94 svc_proc_register(&nfsd_svcstats, &nfsd_proc_fops);
95}
96
97void
98nfsd_stat_shutdown(void)
99{
100 svc_proc_unregister("nfsd");
101}