iostat.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. unsigned long events[__NFSIOS_COUNTSMAX];
  18. } ____cacheline_aligned;
  19. static inline void nfs_inc_server_stats(const struct nfs_server *server,
  20. enum nfs_stat_eventcounters stat)
  21. {
  22. this_cpu_inc(server->io_stats->events[stat]);
  23. }
  24. static inline void nfs_inc_stats(const struct inode *inode,
  25. enum nfs_stat_eventcounters stat)
  26. {
  27. nfs_inc_server_stats(NFS_SERVER(inode), stat);
  28. }
  29. static inline void nfs_add_server_stats(const struct nfs_server *server,
  30. enum nfs_stat_bytecounters stat,
  31. long addend)
  32. {
  33. this_cpu_add(server->io_stats->bytes[stat], addend);
  34. }
  35. static inline void nfs_add_stats(const struct inode *inode,
  36. enum nfs_stat_bytecounters stat,
  37. long addend)
  38. {
  39. nfs_add_server_stats(NFS_SERVER(inode), stat, addend);
  40. }
  41. /*
  42. * This specialized allocator has to be a macro for its allocations to be
  43. * accounted separately (to have a separate alloc_tag).
  44. */
  45. #define nfs_alloc_iostats() alloc_percpu(struct nfs_iostats)
  46. static inline void nfs_free_iostats(struct nfs_iostats __percpu *stats)
  47. {
  48. if (stats != NULL)
  49. free_percpu(stats);
  50. }
  51. #endif /* _NFS_IOSTAT */