xref: /illumos-gate/usr/src/cmd/fs.d/nfs/dtrace/nfs-trace.d (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1 #!/usr/sbin/dtrace -s
2 
3 /*
4  * This file and its contents are supplied under the terms of the
5  * Common Development and Distribution License ("CDDL"), version 1.0.
6  * You may only use this file in accordance with the terms of version
7  * 1.0 of the CDDL.
8  *
9  * A full copy of the text of the CDDL should have accompanied this
10  * source.  A copy of the CDDL is also available via the Internet at
11  * http://www.illumos.org/license/CDDL.
12  */
13 
14 /*
15  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
16  */
17 
18 /*
19  * Print input and output values for each NFSv3 andf NFSv4 operation,
20  * optionally for a specified client, share and zone.
21  *
22  * Usage: nfs-trace.d [<client ip>|all [<share path>|all] [<zone id>]]]
23  *
24  * example: nfs_trace.d 192.168.123.1 /mypool/fs1  0
25  *
26  * It is valid to specify <client ip> or <share path> as "all"
27  * to quantize data for all clients and/or all shares.
28  * Omitting <zone id> will quantize data for all zones.
29  */
30 
31 /*
32  * Unfortunately, trying to write this script using wildcards, for example:
33  *	nfsv3:::op-*-start {}
34  *	nfsv3:::op-*-done {}
35  * prints the operation-specific args[2] structure as the incorrect type.
36  * Until this is resolved it is necessary to explicitly list each operation.
37  *
38  * See nfs-time.d for an example of using the wildcard format when there are
39  * no operation-specific args (args[2]) being traced.
40  */
41 
42 #pragma D option flowindent
43 #pragma D option defaultargs
44 
45 dtrace:::BEGIN
46 {
47 	all_clients = (($$1 == NULL) || ($$1 == "all")) ? 1 : 0;
48 	all_shares = (($$2 == NULL) || ($$2 == "all")) ? 1 : 0;
49 	all_zones = ($$3 == NULL) ? 1 : 0;
50 
51 	client = $$1;
52 	share = $$2;
53 	zoneid = $3;
54 
55 	printf("%Y - client=%s share=%s zone=%s)\n", walltimestamp,
56 	    (all_clients) ? "all" : client,
57 	    (all_shares) ? "all" : share,
58 	    (all_zones) ? "all" : $$3);
59 }
60 
61 nfsv3:::op-getattr-start,
62 nfsv3:::op-setattr-start,
63 nfsv3:::op-lookup-start,
64 nfsv3:::op-access-start,
65 nfsv3:::op-commit-start,
66 nfsv3:::op-create-start,
67 nfsv3:::op-fsinfo-start,
68 nfsv3:::op-fsstat-start,
69 nfsv3:::op-link-start,
70 nfsv3:::op-mkdir-start,
71 nfsv3:::op-mknod-start,
72 nfsv3:::op-pathconf-start,
73 nfsv3:::op-read-start,
74 nfsv3:::op-readdir-start,
75 nfsv3:::op-readdirplus-start,
76 nfsv3:::op-readlink-start,
77 nfsv3:::op-remove-start,
78 nfsv3:::op-rename-start,
79 nfsv3:::op-rmdir-start,
80 nfsv3:::op-symlink-start,
81 nfsv3:::op-write-start
82 / ((all_clients) || (args[0]->ci_remote == client)) &&
83    ((all_shares) || (args[1]->noi_shrpath == share)) &&
84    ((all_zones) || (args[1]->noi_zoneid == zoneid)) /
85 {
86 	printf("\n");
87 	print(*args[0]);
88 	printf("\n");
89 	print(*args[1]);
90 	printf("\n");
91 	print(*args[2]);
92 	printf("\n");
93 }
94 
95 nfsv3:::op-getattr-done,
96 nfsv3:::op-setattr-done,
97 nfsv3:::op-lookup-done,
98 nfsv3:::op-access-done,
99 nfsv3:::op-commit-done,
100 nfsv3:::op-create-done,
101 nfsv3:::op-fsinfo-done,
102 nfsv3:::op-fsstat-done,
103 nfsv3:::op-link-done,
104 nfsv3:::op-mkdir-done,
105 nfsv3:::op-mknod-done,
106 nfsv3:::op-pathconf-done,
107 nfsv3:::op-read-done,
108 nfsv3:::op-readdir-done,
109 nfsv3:::op-readdirplus-done,
110 nfsv3:::op-readlink-done,
111 nfsv3:::op-remove-done,
112 nfsv3:::op-rename-done,
113 nfsv3:::op-rmdir-done,
114 nfsv3:::op-symlink-done,
115 nfsv3:::op-write-done
116 / ((all_clients) || (args[0]->ci_remote == client)) &&
117    ((all_shares) || (args[1]->noi_shrpath == share)) &&
118    ((all_zones) || (args[1]->noi_zoneid == zoneid)) /
119 {
120 	/*
121 	printf("\n");
122 	print(*args[0]);
123 	printf("\n");
124 	print(*args[1]);
125 	*/
126 	printf("\n");
127 	print(*args[2]);
128 	printf("\n");
129 }
130 
131 nfsv4:::op-access-start,
132 nfsv4:::op-close-start,
133 nfsv4:::op-commit-start,
134 nfsv4:::op-create-start,
135 nfsv4:::op-delegpurge-start,
136 nfsv4:::op-delegreturn-start,
137 nfsv4:::op-getattr-start,
138 nfsv4:::op-link-start,
139 nfsv4:::op-lock-start,
140 nfsv4:::op-lockt-start,
141 nfsv4:::op-locku-start,
142 nfsv4:::op-lookup-start,
143 nfsv4:::op-nverify-start,
144 nfsv4:::op-open-start,
145 nfsv4:::op-open-confirm-start,
146 nfsv4:::op-open-downgrade-start,
147 nfsv4:::op-openattr-start,
148 nfsv4:::op-putfh-start,
149 nfsv4:::op-read-start,
150 nfsv4:::op-readdir-start,
151 nfsv4:::op-release-lockowner-start,
152 nfsv4:::op-remove-start,
153 nfsv4:::op-rename-start,
154 nfsv4:::op-renew-start,
155 nfsv4:::op-secinfo-start,
156 nfsv4:::op-setattr-start,
157 nfsv4:::op-setclientid-start,
158 nfsv4:::op-setclientid-confirm-start,
159 nfsv4:::op-verify-start,
160 nfsv4:::op-write-start
161 / ((all_clients) || (args[0]->ci_remote == client)) &&
162    ((all_shares) || (args[1]->noi_shrpath == share)) &&
163    ((all_zones) || (args[1]->noi_zoneid == zoneid)) /
164 {
165 	printf("\n");
166 	print(*args[0]);
167 	printf("\n");
168 	print(*args[1]);
169 	printf("\n");
170 	print(*args[2]);
171 	printf("\n");
172 }
173 
174 /* These operations do not have args[2] */
175 nfsv4:::op-getfh-start,
176 nfsv4:::op-lookupp-start,
177 nfsv4:::op-putpubfh-start,
178 nfsv4:::op-putrootfh-start,
179 nfsv4:::op-readlink-start,
180 nfsv4:::op-restorefh-start,
181 nfsv4:::op-savefh-start
182 / ((all_clients) || (args[0]->ci_remote == client)) &&
183    ((all_shares) || (args[1]->noi_shrpath == share)) &&
184    ((all_zones) || (args[1]->noi_zoneid == zoneid)) /
185 {
186 	printf("\n");
187 	print(*args[0]);
188 	printf("\n");
189 	print(*args[1]);
190 	printf("\n");
191 }
192 
193 
194 nfsv4:::op-access-done,
195 nfsv4:::op-close-done,
196 nfsv4:::op-commit-done,
197 nfsv4:::op-create-done,
198 nfsv4:::op-delegpurge-done,
199 nfsv4:::op-delegreturn-done,
200 nfsv4:::op-getattr-done,
201 nfsv4:::op-getfh-done,
202 nfsv4:::op-link-done,
203 nfsv4:::op-lock-done,
204 nfsv4:::op-lockt-done,
205 nfsv4:::op-locku-done,
206 nfsv4:::op-lookup-done,
207 nfsv4:::op-lookupp-done,
208 nfsv4:::op-nverify-done,
209 nfsv4:::op-open-done,
210 nfsv4:::op-open-confirm-done,
211 nfsv4:::op-open-downgrade-done,
212 nfsv4:::op-openattr-done,
213 nfsv4:::op-putfh-done,
214 nfsv4:::op-putpubfh-done,
215 nfsv4:::op-putrootfh-done,
216 nfsv4:::op-read-done,
217 nfsv4:::op-readdir-done,
218 nfsv4:::op-readlink-done,
219 nfsv4:::op-release-lockowner-done,
220 nfsv4:::op-remove-done,
221 nfsv4:::op-rename-done,
222 nfsv4:::op-renew-done,
223 nfsv4:::op-restorefh-done,
224 nfsv4:::op-savefh-done,
225 nfsv4:::op-secinfo-done,
226 nfsv4:::op-setattr-done,
227 nfsv4:::op-setclientid-done,
228 nfsv4:::op-setclientid-confirm-done,
229 nfsv4:::op-verify-done,
230 nfsv4:::op-write-done
231 / ((all_clients) || (args[0]->ci_remote == client)) &&
232    ((all_shares) || (args[1]->noi_shrpath == share)) &&
233    ((all_zones) || (args[1]->noi_zoneid == zoneid)) /
234 {
235 	/*
236 	printf("\n");
237 	print(*args[0]);
238 	printf("\n");
239 	print(*args[1]);
240 	*/
241 	printf("\n");
242 	print(*args[2]);
243 	printf("\n");
244 }
245 
246 dtrace:::END
247 {
248 }
249