Linux-2.3.3 and a short hiatus..
[davej-history.git] / fs / nfsd / stats.c
blobaccd0aadc3dfc3a3ed27fa698f0418c60bc5a69c
1 /*
2 * linux/fs/nfsd/stats.c
4 * procfs-based user access to knfsd statistics
6 * /proc/net/rpc/nfsd
8 * Format:
9 * rc <hits> <misses> <nocache>
10 * Statistsics for the reply cache
11 * plus generic RPC stats (see net/sunrpc/stats.c)
13 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
16 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/proc_fs.h>
19 #include <linux/stat.h>
21 #include <linux/sunrpc/svc.h>
22 #include <linux/sunrpc/stats.h>
23 #include <linux/nfsd/nfsd.h>
24 #include <linux/nfsd/stats.h>
26 struct nfsd_stats nfsdstats;
27 struct svc_stat nfsd_svcstats = { &nfsd_program, };
29 static int
30 nfsd_proc_read(char *buffer, char **start, off_t offset, int count,
31 int *eof, void *data)
33 int len;
35 len = sprintf(buffer, "rc %d %d %d %d %d %d %d %d\n",
36 nfsdstats.rchits,
37 nfsdstats.rcmisses,
38 nfsdstats.rcnocache,
39 nfsdstats.fh_cached,
40 nfsdstats.fh_valid,
41 nfsdstats.fh_fixup,
42 nfsdstats.fh_lookup,
43 nfsdstats.fh_stale);
45 /* Assume we haven't hit EOF yet. Will be set by svc_proc_read. */
46 *eof = 0;
49 * Append generic nfsd RPC statistics if there's room for it.
51 if (len <= offset) {
52 len = svc_proc_read(buffer, start, offset - len, count,
53 eof, data);
54 return len;
57 if (len < count) {
58 len += svc_proc_read(buffer + len, start, 0, count - len,
59 eof, data);
62 if (offset >= len) {
63 *start = buffer;
64 return 0;
67 *start = buffer + offset;
68 if ((len -= offset) > count)
69 return count;
70 return len;
73 void
74 nfsd_stat_init(void)
76 struct proc_dir_entry *ent;
78 if ((ent = svc_proc_register(&nfsd_svcstats)) != 0) {
79 ent->read_proc = nfsd_proc_read;
80 #ifdef MODULE
81 ent->fill_inode = nfsd_modcount;
82 #endif
86 void
87 nfsd_stat_shutdown(void)
89 svc_proc_unregister("nfsd");