iostat.h 1.8 KB

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