2 * procfs-based user access to knfsd statistics
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
19 * plus generic RPC stats (see net/sunrpc/stats.c)
21 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
24 #include <linux/seq_file.h>
25 #include <linux/module.h>
26 #include <linux/sunrpc/stats.h>
27 #include <net/net_namespace.h>
31 struct nfsd_stats nfsdstats
;
32 struct svc_stat nfsd_svcstats
= {
33 .program
= &nfsd_program
,
36 static int nfsd_proc_show(struct seq_file
*seq
, void *v
)
40 seq_printf(seq
, "rc %u %u %u\nfh %u %u %u %u %u\nio %u %u\n",
47 nfsdstats
.fh_nocache_dir
,
48 nfsdstats
.fh_nocache_nondir
,
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
);
59 /* newline and ra-cache */
60 seq_printf(seq
, "\nra %u", nfsdstats
.ra_size
);
62 seq_printf(seq
, " %u", nfsdstats
.ra_depth
[i
]);
65 /* show my rpc info */
66 svc_seq_show(seq
, &nfsd_svcstats
);
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
]);
81 static int nfsd_proc_open(struct inode
*inode
, struct file
*file
)
83 return single_open(file
, nfsd_proc_show
, NULL
);
86 static const struct file_operations nfsd_proc_fops
= {
87 .open
= nfsd_proc_open
,
90 .release
= single_release
,
96 svc_proc_register(&init_net
, &nfsd_svcstats
, &nfsd_proc_fops
);
100 nfsd_stat_shutdown(void)
102 svc_proc_unregister(&init_net
, "nfsd");