stats.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  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
  10. * fh <stale> <deprecated filehandle cache stats>
  11. * statistics for filehandle lookup
  12. * io <bytes-read> <bytes-written>
  13. * statistics for IO throughput
  14. * th <threads> <deprecated thread usage histogram stats>
  15. * number of threads
  16. * ra <deprecated ra-cache stats>
  17. *
  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. #include <linux/seq_file.h>
  23. #include <linux/module.h>
  24. #include <linux/sunrpc/stats.h>
  25. #include <net/net_namespace.h>
  26. #include "nfsd.h"
  27. static int nfsd_show(struct seq_file *seq, void *v)
  28. {
  29. struct net *net = pde_data(file_inode(seq->file));
  30. struct nfsd_net *nn = net_generic(net, nfsd_net_id);
  31. int i;
  32. seq_printf(seq, "rc %lld %lld %lld\nfh %lld 0 0 0 0\nio %lld %lld\n",
  33. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS]),
  34. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSES]),
  35. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCACHE]),
  36. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_FH_STALE]),
  37. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_READ]),
  38. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_WRITE]));
  39. /* thread usage: */
  40. seq_printf(seq, "th %u 0", atomic_read(&nfsd_th_cnt));
  41. /* deprecated thread usage histogram stats */
  42. for (i = 0; i < 10; i++)
  43. seq_puts(seq, " 0.000");
  44. /* deprecated ra-cache stats */
  45. seq_puts(seq, "\nra 0 0 0 0 0 0 0 0 0 0 0 0\n");
  46. /* show my rpc info */
  47. svc_seq_show(seq, &nn->nfsd_svcstats);
  48. #ifdef CONFIG_NFSD_V4
  49. /* Show count for individual nfsv4 operations */
  50. /* Writing operation numbers 0 1 2 also for maintaining uniformity */
  51. seq_printf(seq, "proc4ops %u", LAST_NFS4_OP + 1);
  52. for (i = 0; i <= LAST_NFS4_OP; i++) {
  53. seq_printf(seq, " %lld",
  54. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_NFS4_OP(i)]));
  55. }
  56. seq_printf(seq, "\nwdeleg_getattr %lld",
  57. percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));
  58. seq_putc(seq, '\n');
  59. #endif
  60. return 0;
  61. }
  62. DEFINE_PROC_SHOW_ATTRIBUTE(nfsd);
  63. struct proc_dir_entry *nfsd_proc_stat_init(struct net *net)
  64. {
  65. struct nfsd_net *nn = net_generic(net, nfsd_net_id);
  66. return svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops);
  67. }
  68. void nfsd_proc_stat_shutdown(struct net *net)
  69. {
  70. svc_proc_unregister(net, "nfsd");
  71. }