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