xref: /OK3568_Linux_fs/kernel/include/linux/nfs_iostat.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  User-space visible declarations for NFS client per-mount
4*4882a593Smuzhiyun  *  point statistics
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  *  Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  *  NFS client per-mount statistics provide information about the
9*4882a593Smuzhiyun  *  health of the NFS client and the health of each NFS mount point.
10*4882a593Smuzhiyun  *  Generally these are not for detailed problem diagnosis, but
11*4882a593Smuzhiyun  *  simply to indicate that there is a problem.
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  *  These counters are not meant to be human-readable, but are meant
14*4882a593Smuzhiyun  *  to be integrated into system monitoring tools such as "sar" and
15*4882a593Smuzhiyun  *  "iostat".  As such, the counters are sampled by the tools over
16*4882a593Smuzhiyun  *  time, and are never zeroed after a file system is mounted.
17*4882a593Smuzhiyun  *  Moving averages can be computed by the tools by taking the
18*4882a593Smuzhiyun  *  difference between two instantaneous samples  and dividing that
19*4882a593Smuzhiyun  *  by the time between the samples.
20*4882a593Smuzhiyun  */
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #ifndef _LINUX_NFS_IOSTAT
23*4882a593Smuzhiyun #define _LINUX_NFS_IOSTAT
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #define NFS_IOSTAT_VERS		"1.1"
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /*
28*4882a593Smuzhiyun  * NFS byte counters
29*4882a593Smuzhiyun  *
30*4882a593Smuzhiyun  * 1.  SERVER - the number of payload bytes read from or written
31*4882a593Smuzhiyun  *     to the server by the NFS client via an NFS READ or WRITE
32*4882a593Smuzhiyun  *     request.
33*4882a593Smuzhiyun  *
34*4882a593Smuzhiyun  * 2.  NORMAL - the number of bytes read or written by applications
35*4882a593Smuzhiyun  *     via the read(2) and write(2) system call interfaces.
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  * 3.  DIRECT - the number of bytes read or written from files
38*4882a593Smuzhiyun  *     opened with the O_DIRECT flag.
39*4882a593Smuzhiyun  *
40*4882a593Smuzhiyun  * These counters give a view of the data throughput into and out
41*4882a593Smuzhiyun  * of the NFS client.  Comparing the number of bytes requested by
42*4882a593Smuzhiyun  * an application with the number of bytes the client requests from
43*4882a593Smuzhiyun  * the server can provide an indication of client efficiency
44*4882a593Smuzhiyun  * (per-op, cache hits, etc).
45*4882a593Smuzhiyun  *
46*4882a593Smuzhiyun  * These counters can also help characterize which access methods
47*4882a593Smuzhiyun  * are in use.  DIRECT by itself shows whether there is any O_DIRECT
48*4882a593Smuzhiyun  * traffic.  NORMAL + DIRECT shows how much data is going through
49*4882a593Smuzhiyun  * the system call interface.  A large amount of SERVER traffic
50*4882a593Smuzhiyun  * without much NORMAL or DIRECT traffic shows that applications
51*4882a593Smuzhiyun  * are using mapped files.
52*4882a593Smuzhiyun  *
53*4882a593Smuzhiyun  * NFS page counters
54*4882a593Smuzhiyun  *
55*4882a593Smuzhiyun  * These count the number of pages read or written via nfs_readpage(),
56*4882a593Smuzhiyun  * nfs_readpages(), or their write equivalents.
57*4882a593Smuzhiyun  *
58*4882a593Smuzhiyun  * NB: When adding new byte counters, please include the measured
59*4882a593Smuzhiyun  * units in the name of each byte counter to help users of this
60*4882a593Smuzhiyun  * interface determine what exactly is being counted.
61*4882a593Smuzhiyun  */
62*4882a593Smuzhiyun enum nfs_stat_bytecounters {
63*4882a593Smuzhiyun 	NFSIOS_NORMALREADBYTES = 0,
64*4882a593Smuzhiyun 	NFSIOS_NORMALWRITTENBYTES,
65*4882a593Smuzhiyun 	NFSIOS_DIRECTREADBYTES,
66*4882a593Smuzhiyun 	NFSIOS_DIRECTWRITTENBYTES,
67*4882a593Smuzhiyun 	NFSIOS_SERVERREADBYTES,
68*4882a593Smuzhiyun 	NFSIOS_SERVERWRITTENBYTES,
69*4882a593Smuzhiyun 	NFSIOS_READPAGES,
70*4882a593Smuzhiyun 	NFSIOS_WRITEPAGES,
71*4882a593Smuzhiyun 	__NFSIOS_BYTESMAX,
72*4882a593Smuzhiyun };
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /*
75*4882a593Smuzhiyun  * NFS event counters
76*4882a593Smuzhiyun  *
77*4882a593Smuzhiyun  * These counters provide a low-overhead way of monitoring client
78*4882a593Smuzhiyun  * activity without enabling NFS trace debugging.  The counters
79*4882a593Smuzhiyun  * show the rate at which VFS requests are made, and how often the
80*4882a593Smuzhiyun  * client invalidates its data and attribute caches.  This allows
81*4882a593Smuzhiyun  * system administrators to monitor such things as how close-to-open
82*4882a593Smuzhiyun  * is working, and answer questions such as "why are there so many
83*4882a593Smuzhiyun  * GETATTR requests on the wire?"
84*4882a593Smuzhiyun  *
85*4882a593Smuzhiyun  * They also count anamolous events such as short reads and writes,
86*4882a593Smuzhiyun  * silly renames due to close-after-delete, and operations that
87*4882a593Smuzhiyun  * change the size of a file (such operations can often be the
88*4882a593Smuzhiyun  * source of data corruption if applications aren't using file
89*4882a593Smuzhiyun  * locking properly).
90*4882a593Smuzhiyun  */
91*4882a593Smuzhiyun enum nfs_stat_eventcounters {
92*4882a593Smuzhiyun 	NFSIOS_INODEREVALIDATE = 0,
93*4882a593Smuzhiyun 	NFSIOS_DENTRYREVALIDATE,
94*4882a593Smuzhiyun 	NFSIOS_DATAINVALIDATE,
95*4882a593Smuzhiyun 	NFSIOS_ATTRINVALIDATE,
96*4882a593Smuzhiyun 	NFSIOS_VFSOPEN,
97*4882a593Smuzhiyun 	NFSIOS_VFSLOOKUP,
98*4882a593Smuzhiyun 	NFSIOS_VFSACCESS,
99*4882a593Smuzhiyun 	NFSIOS_VFSUPDATEPAGE,
100*4882a593Smuzhiyun 	NFSIOS_VFSREADPAGE,
101*4882a593Smuzhiyun 	NFSIOS_VFSREADPAGES,
102*4882a593Smuzhiyun 	NFSIOS_VFSWRITEPAGE,
103*4882a593Smuzhiyun 	NFSIOS_VFSWRITEPAGES,
104*4882a593Smuzhiyun 	NFSIOS_VFSGETDENTS,
105*4882a593Smuzhiyun 	NFSIOS_VFSSETATTR,
106*4882a593Smuzhiyun 	NFSIOS_VFSFLUSH,
107*4882a593Smuzhiyun 	NFSIOS_VFSFSYNC,
108*4882a593Smuzhiyun 	NFSIOS_VFSLOCK,
109*4882a593Smuzhiyun 	NFSIOS_VFSRELEASE,
110*4882a593Smuzhiyun 	NFSIOS_CONGESTIONWAIT,
111*4882a593Smuzhiyun 	NFSIOS_SETATTRTRUNC,
112*4882a593Smuzhiyun 	NFSIOS_EXTENDWRITE,
113*4882a593Smuzhiyun 	NFSIOS_SILLYRENAME,
114*4882a593Smuzhiyun 	NFSIOS_SHORTREAD,
115*4882a593Smuzhiyun 	NFSIOS_SHORTWRITE,
116*4882a593Smuzhiyun 	NFSIOS_DELAY,
117*4882a593Smuzhiyun 	NFSIOS_PNFS_READ,
118*4882a593Smuzhiyun 	NFSIOS_PNFS_WRITE,
119*4882a593Smuzhiyun 	__NFSIOS_COUNTSMAX,
120*4882a593Smuzhiyun };
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun /*
123*4882a593Smuzhiyun  * NFS local caching servicing counters
124*4882a593Smuzhiyun  */
125*4882a593Smuzhiyun enum nfs_stat_fscachecounters {
126*4882a593Smuzhiyun 	NFSIOS_FSCACHE_PAGES_READ_OK,
127*4882a593Smuzhiyun 	NFSIOS_FSCACHE_PAGES_READ_FAIL,
128*4882a593Smuzhiyun 	NFSIOS_FSCACHE_PAGES_WRITTEN_OK,
129*4882a593Smuzhiyun 	NFSIOS_FSCACHE_PAGES_WRITTEN_FAIL,
130*4882a593Smuzhiyun 	NFSIOS_FSCACHE_PAGES_UNCACHED,
131*4882a593Smuzhiyun 	__NFSIOS_FSCACHEMAX,
132*4882a593Smuzhiyun };
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun #endif	/* _LINUX_NFS_IOSTAT */
135