iostat.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #endif
  51. static inline struct nfs_iostats __percpu *nfs_alloc_iostats(void)
  52. {
  53. return alloc_percpu(struct nfs_iostats);
  54. }
  55. static inline void nfs_free_iostats(struct nfs_iostats __percpu *stats)
  56. {
  57. if (stats != NULL)
  58. free_percpu(stats);
  59. }
  60. #endif /* _NFS_IOSTAT */