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