aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/iostat.h
diff options
context:
space:
mode:
authorChuck Lever <cel@netapp.com>2006-03-20 13:44:13 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:13 -0500
commitd9ef5a8c26aab09762afce43df64736720b4860e (patch)
tree01ec0e16b19d7e418f26f1218113bb0f90b1a2e1 /fs/nfs/iostat.h
parentc8bded96aa8735823e53c95a26177987ebb19a90 (diff)
NFS: introduce mechanism for tracking NFS client metrics
Add a per-superblock performance counter facility to the NFS client. This facility mimics the counters available for block devices and for networking. Expose these new counters via the new /proc/self/mountstats interface. Thanks to Andrew Morton and Trond Myklebust for their review and comments. Test plan: fsx and iozone on UP and SMP systems, with and without pre-emption. Watch for memory overwrite bugs, and performance loss (significantly more CPU required per op). Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/iostat.h')
-rw-r--r--fs/nfs/iostat.h152
1 files changed, 152 insertions, 0 deletions
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h
new file mode 100644
index 000000000000..dc080e50ec57
--- /dev/null
+++ b/fs/nfs/iostat.h
@@ -0,0 +1,152 @@
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 * 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 */
20
21#ifndef _NFS_IOSTAT
22#define _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 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 */
54enum 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 */
81enum 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_COUNTSMAX,
107};
108
109#ifdef __KERNEL__
110
111#include <linux/percpu.h>
112#include <linux/cache.h>
113
114struct nfs_iostats {
115 unsigned long long bytes[__NFSIOS_BYTESMAX];
116 unsigned long events[__NFSIOS_COUNTSMAX];
117} ____cacheline_aligned;
118
119static inline void nfs_inc_stats(struct inode *inode, enum nfs_stat_eventcounters stat)
120{
121 struct nfs_iostats *iostats;
122 int cpu;
123
124 cpu = get_cpu();
125 iostats = per_cpu_ptr(NFS_SERVER(inode)->io_stats, cpu);
126 iostats->events[stat] ++;
127 put_cpu_no_resched();
128}
129
130static inline void nfs_add_stats(struct inode *inode, enum nfs_stat_bytecounters stat, unsigned long addend)
131{
132 struct nfs_iostats *iostats;
133 int cpu;
134
135 cpu = get_cpu();
136 iostats = per_cpu_ptr(NFS_SERVER(inode)->io_stats, cpu);
137 iostats->bytes[stat] += addend;
138 put_cpu_no_resched();
139}
140
141static inline struct nfs_iostats *nfs_alloc_iostats(void)
142{
143 return alloc_percpu(struct nfs_iostats);
144}
145
146static inline void nfs_free_iostats(struct nfs_iostats *stats)
147{
148 free_percpu(stats);
149}
150
151#endif
152#endif