diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2008-06-12 12:32:25 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-07-09 12:09:17 -0400 |
commit | 34e8f92831cb5c40b3137e47a3daf4c09016ef02 (patch) | |
tree | 7351733689914353b1636b5f21aca6d7b0236a79 | |
parent | 46cb650c224bb8e64a749090105d74b9e8eda669 (diff) |
NFS: Move fs/nfs/iostat.h to include/linux
The fs/nfs/iostat.h header has definitions that were designed to be exposed
to user space. Move these definitions under include/linux so user space can
use the definitions in applications that read /proc/self/mountstats.
Also address a handful of coding style issues called out by checkpatch.pl in
fs/nfs/iostat.h.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/iostat.h | 119 | ||||
-rw-r--r-- | include/linux/nfs_iostat.h | 119 |
2 files changed, 132 insertions, 106 deletions
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h index 6350ecbde589..2ec65e12bfed 100644 --- a/fs/nfs/iostat.h +++ b/fs/nfs/iostat.h | |||
@@ -5,135 +5,41 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> | 6 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> |
7 | * | 7 | * |
8 | * NFS client per-mount statistics provide information about the health of | ||
9 | * the NFS client and the health of each NFS mount point. Generally these | ||
10 | * are not for detailed problem diagnosis, but simply to indicate that there | ||
11 | * is a problem. | ||
12 | * | ||
13 | * These counters are not meant to be human-readable, but are meant to be | ||
14 | * integrated into system monitoring tools such as "sar" and "iostat". As | ||
15 | * such, the counters are sampled by the tools over time, and are never | ||
16 | * zeroed after a file system is mounted. Moving averages can be computed | ||
17 | * by the tools by taking the difference between two instantaneous samples | ||
18 | * and dividing that by the time between the samples. | ||
19 | */ | 8 | */ |
20 | 9 | ||
21 | #ifndef _NFS_IOSTAT | 10 | #ifndef _NFS_IOSTAT |
22 | #define _NFS_IOSTAT | 11 | #define _NFS_IOSTAT |
23 | 12 | ||
24 | #define NFS_IOSTAT_VERS "1.0" | ||
25 | |||
26 | /* | ||
27 | * NFS byte counters | ||
28 | * | ||
29 | * 1. SERVER - the number of payload bytes read from or written to the | ||
30 | * server by the NFS client via an NFS READ or WRITE request. | ||
31 | * | ||
32 | * 2. NORMAL - the number of bytes read or written by applications via | ||
33 | * the read(2) and write(2) system call interfaces. | ||
34 | * | ||
35 | * 3. DIRECT - the number of bytes read or written from files opened | ||
36 | * with the O_DIRECT flag. | ||
37 | * | ||
38 | * These counters give a view of the data throughput into and out of the NFS | ||
39 | * client. Comparing the number of bytes requested by an application with the | ||
40 | * number of bytes the client requests from the server can provide an | ||
41 | * indication of client efficiency (per-op, cache hits, etc). | ||
42 | * | ||
43 | * These counters can also help characterize which access methods are in | ||
44 | * use. DIRECT by itself shows whether there is any O_DIRECT traffic. | ||
45 | * NORMAL + DIRECT shows how much data is going through the system call | ||
46 | * interface. A large amount of SERVER traffic without much NORMAL or | ||
47 | * DIRECT traffic shows that applications are using mapped files. | ||
48 | * | ||
49 | * NFS page counters | ||
50 | * | ||
51 | * These count the number of pages read or written via nfs_readpage(), | ||
52 | * nfs_readpages(), or their write equivalents. | ||
53 | */ | ||
54 | enum nfs_stat_bytecounters { | ||
55 | NFSIOS_NORMALREADBYTES = 0, | ||
56 | NFSIOS_NORMALWRITTENBYTES, | ||
57 | NFSIOS_DIRECTREADBYTES, | ||
58 | NFSIOS_DIRECTWRITTENBYTES, | ||
59 | NFSIOS_SERVERREADBYTES, | ||
60 | NFSIOS_SERVERWRITTENBYTES, | ||
61 | NFSIOS_READPAGES, | ||
62 | NFSIOS_WRITEPAGES, | ||
63 | __NFSIOS_BYTESMAX, | ||
64 | }; | ||
65 | |||
66 | /* | ||
67 | * NFS event counters | ||
68 | * | ||
69 | * These counters provide a low-overhead way of monitoring client activity | ||
70 | * without enabling NFS trace debugging. The counters show the rate at | ||
71 | * which VFS requests are made, and how often the client invalidates its | ||
72 | * data and attribute caches. This allows system administrators to monitor | ||
73 | * such things as how close-to-open is working, and answer questions such | ||
74 | * as "why are there so many GETATTR requests on the wire?" | ||
75 | * | ||
76 | * They also count anamolous events such as short reads and writes, silly | ||
77 | * renames due to close-after-delete, and operations that change the size | ||
78 | * of a file (such operations can often be the source of data corruption | ||
79 | * if applications aren't using file locking properly). | ||
80 | */ | ||
81 | enum nfs_stat_eventcounters { | ||
82 | NFSIOS_INODEREVALIDATE = 0, | ||
83 | NFSIOS_DENTRYREVALIDATE, | ||
84 | NFSIOS_DATAINVALIDATE, | ||
85 | NFSIOS_ATTRINVALIDATE, | ||
86 | NFSIOS_VFSOPEN, | ||
87 | NFSIOS_VFSLOOKUP, | ||
88 | NFSIOS_VFSACCESS, | ||
89 | NFSIOS_VFSUPDATEPAGE, | ||
90 | NFSIOS_VFSREADPAGE, | ||
91 | NFSIOS_VFSREADPAGES, | ||
92 | NFSIOS_VFSWRITEPAGE, | ||
93 | NFSIOS_VFSWRITEPAGES, | ||
94 | NFSIOS_VFSGETDENTS, | ||
95 | NFSIOS_VFSSETATTR, | ||
96 | NFSIOS_VFSFLUSH, | ||
97 | NFSIOS_VFSFSYNC, | ||
98 | NFSIOS_VFSLOCK, | ||
99 | NFSIOS_VFSRELEASE, | ||
100 | NFSIOS_CONGESTIONWAIT, | ||
101 | NFSIOS_SETATTRTRUNC, | ||
102 | NFSIOS_EXTENDWRITE, | ||
103 | NFSIOS_SILLYRENAME, | ||
104 | NFSIOS_SHORTREAD, | ||
105 | NFSIOS_SHORTWRITE, | ||
106 | NFSIOS_DELAY, | ||
107 | __NFSIOS_COUNTSMAX, | ||
108 | }; | ||
109 | |||
110 | #ifdef __KERNEL__ | ||
111 | |||
112 | #include <linux/percpu.h> | 13 | #include <linux/percpu.h> |
113 | #include <linux/cache.h> | 14 | #include <linux/cache.h> |
15 | #include <linux/nfs_iostat.h> | ||
114 | 16 | ||
115 | struct nfs_iostats { | 17 | struct nfs_iostats { |
116 | unsigned long long bytes[__NFSIOS_BYTESMAX]; | 18 | unsigned long long bytes[__NFSIOS_BYTESMAX]; |
117 | unsigned long events[__NFSIOS_COUNTSMAX]; | 19 | unsigned long events[__NFSIOS_COUNTSMAX]; |
118 | } ____cacheline_aligned; | 20 | } ____cacheline_aligned; |
119 | 21 | ||
120 | static inline void nfs_inc_server_stats(struct nfs_server *server, enum nfs_stat_eventcounters stat) | 22 | static inline void nfs_inc_server_stats(struct nfs_server *server, |
23 | enum nfs_stat_eventcounters stat) | ||
121 | { | 24 | { |
122 | struct nfs_iostats *iostats; | 25 | struct nfs_iostats *iostats; |
123 | int cpu; | 26 | int cpu; |
124 | 27 | ||
125 | cpu = get_cpu(); | 28 | cpu = get_cpu(); |
126 | iostats = per_cpu_ptr(server->io_stats, cpu); | 29 | iostats = per_cpu_ptr(server->io_stats, cpu); |
127 | iostats->events[stat] ++; | 30 | iostats->events[stat]++; |
128 | put_cpu_no_resched(); | 31 | put_cpu_no_resched(); |
129 | } | 32 | } |
130 | 33 | ||
131 | static inline void nfs_inc_stats(struct inode *inode, enum nfs_stat_eventcounters stat) | 34 | static inline void nfs_inc_stats(struct inode *inode, |
35 | enum nfs_stat_eventcounters stat) | ||
132 | { | 36 | { |
133 | nfs_inc_server_stats(NFS_SERVER(inode), stat); | 37 | nfs_inc_server_stats(NFS_SERVER(inode), stat); |
134 | } | 38 | } |
135 | 39 | ||
136 | static inline void nfs_add_server_stats(struct nfs_server *server, enum nfs_stat_bytecounters stat, unsigned long addend) | 40 | static inline void nfs_add_server_stats(struct nfs_server *server, |
41 | enum nfs_stat_bytecounters stat, | ||
42 | unsigned long addend) | ||
137 | { | 43 | { |
138 | struct nfs_iostats *iostats; | 44 | struct nfs_iostats *iostats; |
139 | int cpu; | 45 | int cpu; |
@@ -144,7 +50,9 @@ static inline void nfs_add_server_stats(struct nfs_server *server, enum nfs_stat | |||
144 | put_cpu_no_resched(); | 50 | put_cpu_no_resched(); |
145 | } | 51 | } |
146 | 52 | ||
147 | static inline void nfs_add_stats(struct inode *inode, enum nfs_stat_bytecounters stat, unsigned long addend) | 53 | static inline void nfs_add_stats(struct inode *inode, |
54 | enum nfs_stat_bytecounters stat, | ||
55 | unsigned long addend) | ||
148 | { | 56 | { |
149 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); | 57 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); |
150 | } | 58 | } |
@@ -160,5 +68,4 @@ static inline void nfs_free_iostats(struct nfs_iostats *stats) | |||
160 | free_percpu(stats); | 68 | free_percpu(stats); |
161 | } | 69 | } |
162 | 70 | ||
163 | #endif | 71 | #endif /* _NFS_IOSTAT */ |
164 | #endif | ||
diff --git a/include/linux/nfs_iostat.h b/include/linux/nfs_iostat.h new file mode 100644 index 000000000000..1cb9a3fed2b3 --- /dev/null +++ b/include/linux/nfs_iostat.h | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * User-space visible declarations for NFS client per-mount | ||
3 | * point statistics | ||
4 | * | ||
5 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> | ||
6 | * | ||
7 | * NFS client per-mount statistics provide information about the | ||
8 | * health of the NFS client and the health of each NFS mount point. | ||
9 | * Generally these are not for detailed problem diagnosis, but | ||
10 | * simply to indicate that there is a problem. | ||
11 | * | ||
12 | * These counters are not meant to be human-readable, but are meant | ||
13 | * to be integrated into system monitoring tools such as "sar" and | ||
14 | * "iostat". As such, the counters are sampled by the tools over | ||
15 | * time, and are never zeroed after a file system is mounted. | ||
16 | * Moving averages can be computed by the tools by taking the | ||
17 | * difference between two instantaneous samples and dividing that | ||
18 | * by the time between the samples. | ||
19 | */ | ||
20 | |||
21 | #ifndef _LINUX_NFS_IOSTAT | ||
22 | #define _LINUX_NFS_IOSTAT | ||
23 | |||
24 | #define NFS_IOSTAT_VERS "1.0" | ||
25 | |||
26 | /* | ||
27 | * NFS byte counters | ||
28 | * | ||
29 | * 1. SERVER - the number of payload bytes read from or written | ||
30 | * to the server by the NFS client via an NFS READ or WRITE | ||
31 | * request. | ||
32 | * | ||
33 | * 2. NORMAL - the number of bytes read or written by applications | ||
34 | * via the read(2) and write(2) system call interfaces. | ||
35 | * | ||
36 | * 3. DIRECT - the number of bytes read or written from files | ||
37 | * opened with the O_DIRECT flag. | ||
38 | * | ||
39 | * These counters give a view of the data throughput into and out | ||
40 | * of the NFS client. Comparing the number of bytes requested by | ||
41 | * an application with the number of bytes the client requests from | ||
42 | * the server can provide an indication of client efficiency | ||
43 | * (per-op, cache hits, etc). | ||
44 | * | ||
45 | * These counters can also help characterize which access methods | ||
46 | * are in use. DIRECT by itself shows whether there is any O_DIRECT | ||
47 | * traffic. NORMAL + DIRECT shows how much data is going through | ||
48 | * the system call interface. A large amount of SERVER traffic | ||
49 | * without much NORMAL or DIRECT traffic shows that applications | ||
50 | * are using mapped files. | ||
51 | * | ||
52 | * NFS page counters | ||
53 | * | ||
54 | * These count the number of pages read or written via nfs_readpage(), | ||
55 | * nfs_readpages(), or their write equivalents. | ||
56 | * | ||
57 | * NB: When adding new byte counters, please include the measured | ||
58 | * units in the name of each byte counter to help users of this | ||
59 | * interface determine what exactly is being counted. | ||
60 | */ | ||
61 | enum nfs_stat_bytecounters { | ||
62 | NFSIOS_NORMALREADBYTES = 0, | ||
63 | NFSIOS_NORMALWRITTENBYTES, | ||
64 | NFSIOS_DIRECTREADBYTES, | ||
65 | NFSIOS_DIRECTWRITTENBYTES, | ||
66 | NFSIOS_SERVERREADBYTES, | ||
67 | NFSIOS_SERVERWRITTENBYTES, | ||
68 | NFSIOS_READPAGES, | ||
69 | NFSIOS_WRITEPAGES, | ||
70 | __NFSIOS_BYTESMAX, | ||
71 | }; | ||
72 | |||
73 | /* | ||
74 | * NFS event counters | ||
75 | * | ||
76 | * These counters provide a low-overhead way of monitoring client | ||
77 | * activity without enabling NFS trace debugging. The counters | ||
78 | * show the rate at which VFS requests are made, and how often the | ||
79 | * client invalidates its data and attribute caches. This allows | ||
80 | * system administrators to monitor such things as how close-to-open | ||
81 | * is working, and answer questions such as "why are there so many | ||
82 | * GETATTR requests on the wire?" | ||
83 | * | ||
84 | * They also count anamolous events such as short reads and writes, | ||
85 | * silly renames due to close-after-delete, and operations that | ||
86 | * change the size of a file (such operations can often be the | ||
87 | * source of data corruption if applications aren't using file | ||
88 | * locking properly). | ||
89 | */ | ||
90 | enum nfs_stat_eventcounters { | ||
91 | NFSIOS_INODEREVALIDATE = 0, | ||
92 | NFSIOS_DENTRYREVALIDATE, | ||
93 | NFSIOS_DATAINVALIDATE, | ||
94 | NFSIOS_ATTRINVALIDATE, | ||
95 | NFSIOS_VFSOPEN, | ||
96 | NFSIOS_VFSLOOKUP, | ||
97 | NFSIOS_VFSACCESS, | ||
98 | NFSIOS_VFSUPDATEPAGE, | ||
99 | NFSIOS_VFSREADPAGE, | ||
100 | NFSIOS_VFSREADPAGES, | ||
101 | NFSIOS_VFSWRITEPAGE, | ||
102 | NFSIOS_VFSWRITEPAGES, | ||
103 | NFSIOS_VFSGETDENTS, | ||
104 | NFSIOS_VFSSETATTR, | ||
105 | NFSIOS_VFSFLUSH, | ||
106 | NFSIOS_VFSFSYNC, | ||
107 | NFSIOS_VFSLOCK, | ||
108 | NFSIOS_VFSRELEASE, | ||
109 | NFSIOS_CONGESTIONWAIT, | ||
110 | NFSIOS_SETATTRTRUNC, | ||
111 | NFSIOS_EXTENDWRITE, | ||
112 | NFSIOS_SILLYRENAME, | ||
113 | NFSIOS_SHORTREAD, | ||
114 | NFSIOS_SHORTWRITE, | ||
115 | NFSIOS_DELAY, | ||
116 | __NFSIOS_COUNTSMAX, | ||
117 | }; | ||
118 | |||
119 | #endif /* _LINUX_NFS_IOSTAT */ | ||