Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 | 2 | /* |
1da177e4 LT |
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 | |
1b76d1df | 10 | * fh <stale> <deprecated filehandle cache stats> |
1da177e4 | 11 | * statistics for filehandle lookup |
70f23fd6 | 12 | * io <bytes-read> <bytes-written> |
1da177e4 | 13 | * statistics for IO throughput |
1b76d1df AG |
14 | * th <threads> <deprecated thread usage histogram stats> |
15 | * number of threads | |
16 | * ra <deprecated ra-cache stats> | |
17 | * | |
1da177e4 LT |
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 | ||
1da177e4 | 23 | #include <linux/seq_file.h> |
1da177e4 | 24 | #include <linux/module.h> |
1da177e4 | 25 | #include <linux/sunrpc/stats.h> |
246590f5 | 26 | #include <net/net_namespace.h> |
1da177e4 | 27 | |
9a74af21 BH |
28 | #include "nfsd.h" |
29 | ||
0cfb0c42 | 30 | static int nfsd_show(struct seq_file *seq, void *v) |
1da177e4 | 31 | { |
4b148854 JB |
32 | struct net *net = pde_data(file_inode(seq->file)); |
33 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | |
1da177e4 LT |
34 | int i; |
35 | ||
e567b98c | 36 | seq_printf(seq, "rc %lld %lld %lld\nfh %lld 0 0 0 0\nio %lld %lld\n", |
4b148854 JB |
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])); | |
1b76d1df | 43 | |
1da177e4 | 44 | /* thread usage: */ |
e41ee44c | 45 | seq_printf(seq, "th %u 0", atomic_read(&nfsd_th_cnt)); |
1b76d1df AG |
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 | ||
1da177e4 | 54 | /* show my rpc info */ |
16fb9808 | 55 | svc_seq_show(seq, &nn->nfsd_svcstats); |
1da177e4 | 56 | |
e2b20950 SA |
57 | #ifdef CONFIG_NFSD_V4 |
58 | /* Show count for individual nfsv4 operations */ | |
59 | /* Writing operation numbers 0 1 2 also for maintaining uniformity */ | |
0e5559eb | 60 | seq_printf(seq, "proc4ops %u", LAST_NFS4_OP + 1); |
e567b98c AG |
61 | for (i = 0; i <= LAST_NFS4_OP; i++) { |
62 | seq_printf(seq, " %lld", | |
4b148854 | 63 | percpu_counter_sum_positive(&nn->counter[NFSD_STATS_NFS4_OP(i)])); |
e567b98c | 64 | } |
fd19ca36 | 65 | seq_printf(seq, "\nwdeleg_getattr %lld", |
4b148854 | 66 | percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR])); |
e2b20950 SA |
67 | |
68 | seq_putc(seq, '\n'); | |
69 | #endif | |
70 | ||
1da177e4 LT |
71 | return 0; |
72 | } | |
73 | ||
0cfb0c42 | 74 | DEFINE_PROC_SHOW_ATTRIBUTE(nfsd); |
1da177e4 | 75 | |
93483ac5 | 76 | void nfsd_proc_stat_init(struct net *net) |
e567b98c | 77 | { |
16fb9808 JB |
78 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
79 | ||
80 | svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops); | |
1da177e4 LT |
81 | } |
82 | ||
93483ac5 | 83 | void nfsd_proc_stat_shutdown(struct net *net) |
1da177e4 | 84 | { |
93483ac5 | 85 | svc_proc_unregister(net, "nfsd"); |
1da177e4 | 86 | } |