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