iostat.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * linux/fs/nfs/iostat.h
  4. *
  5. * Declarations for NFS client per-mount statistics
  6. *
  7. * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com>
  8. *
  9. */
  10. #ifndef _NFS_IOSTAT
  11. #define _NFS_IOSTAT
  12. #include <linux/percpu.h>
  13. #include <linux/cache.h>
  14. #include <linux/nfs_iostat.h>
  15. struct nfs_iostats {
  16. unsigned long long bytes[__NFSIOS_BYTESMAX];
  17. #ifdef CONFIG_NFS_FSCACHE
  18. unsigned long long fscache[__NFSIOS_FSCACHEMAX];
  19. #endif
  20. unsigned long events[__NFSIOS_COUNTSMAX];
  21. } ____cacheline_aligned;
  22. static inline void nfs_inc_server_stats(const struct nfs_server *server,
  23. enum nfs_stat_eventcounters stat)
  24. {
  25. this_cpu_inc(server->io_stats->events[stat]);
  26. }
  27. static inline void nfs_inc_stats(const struct inode *inode,
  28. enum nfs_stat_eventcounters stat)
  29. {
  30. nfs_inc_server_stats(NFS_SERVER(inode), stat);
  31. }
  32. static inline void nfs_add_server_stats(const struct nfs_server *server,
  33. enum nfs_stat_bytecounters stat,
  34. long addend)
  35. {
  36. this_cpu_add(server->io_stats->bytes[stat], addend);
  37. }
  38. static inline void nfs_add_stats(const struct inode *inode,
  39. enum nfs_stat_bytecounters stat,
  40. long addend)
  41. {
  42. nfs_add_server_stats(NFS_SERVER(inode), stat, addend);
  43. }
  44. #ifdef CONFIG_NFS_FSCACHE
  45. static inline void nfs_add_fscache_stats(struct inode *inode,
  46. enum nfs_stat_fscachecounters stat,
  47. long addend)
  48. {
  49. this_cpu_add(NFS_SERVER(inode)->io_stats->fscache[stat], addend);
  50. }
  51. static inline void nfs_inc_fscache_stats(struct inode *inode,
  52. enum nfs_stat_fscachecounters stat)
  53. {
  54. this_cpu_inc(NFS_SERVER(inode)->io_stats->fscache[stat]);
  55. }
  56. #endif
  57. static inline struct nfs_iostats __percpu *nfs_alloc_iostats(void)
  58. {
  59. return alloc_percpu(struct nfs_iostats);
  60. }
  61. static inline void nfs_free_iostats(struct nfs_iostats __percpu *stats)
  62. {
  63. if (stats != NULL)
  64. free_percpu(stats);
  65. }
  66. #endif /* _NFS_IOSTAT */