xref: /linux/fs/nfsd/trace.h (revision 6c363eafc4d637ac4bd83d4a7dd06dd3cfbe7c5f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2014 Christoph Hellwig.
4  */
5 #undef TRACE_SYSTEM
6 #define TRACE_SYSTEM nfsd
7 
8 #if !defined(_NFSD_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
9 #define _NFSD_TRACE_H
10 
11 #include <linux/tracepoint.h>
12 #include "export.h"
13 #include "nfsfh.h"
14 
15 #define NFSD_TRACE_PROC_ARG_FIELDS \
16 		__field(unsigned int, netns_ino) \
17 		__field(u32, xid) \
18 		__array(unsigned char, server, sizeof(struct sockaddr_in6)) \
19 		__array(unsigned char, client, sizeof(struct sockaddr_in6))
20 
21 #define NFSD_TRACE_PROC_ARG_ASSIGNMENTS \
22 		do { \
23 			__entry->netns_ino = SVC_NET(rqstp)->ns.inum; \
24 			__entry->xid = be32_to_cpu(rqstp->rq_xid); \
25 			memcpy(__entry->server, &rqstp->rq_xprt->xpt_local, \
26 			       rqstp->rq_xprt->xpt_locallen); \
27 			memcpy(__entry->client, &rqstp->rq_xprt->xpt_remote, \
28 			       rqstp->rq_xprt->xpt_remotelen); \
29 		} while (0);
30 
31 #define NFSD_TRACE_PROC_RES_FIELDS \
32 		__field(unsigned int, netns_ino) \
33 		__field(u32, xid) \
34 		__field(unsigned long, status) \
35 		__array(unsigned char, server, sizeof(struct sockaddr_in6)) \
36 		__array(unsigned char, client, sizeof(struct sockaddr_in6))
37 
38 #define NFSD_TRACE_PROC_RES_ASSIGNMENTS(error) \
39 		do { \
40 			__entry->netns_ino = SVC_NET(rqstp)->ns.inum; \
41 			__entry->xid = be32_to_cpu(rqstp->rq_xid); \
42 			__entry->status = be32_to_cpu(error); \
43 			memcpy(__entry->server, &rqstp->rq_xprt->xpt_local, \
44 			       rqstp->rq_xprt->xpt_locallen); \
45 			memcpy(__entry->client, &rqstp->rq_xprt->xpt_remote, \
46 			       rqstp->rq_xprt->xpt_remotelen); \
47 		} while (0);
48 
49 TRACE_EVENT(nfsd_garbage_args_err,
50 	TP_PROTO(
51 		const struct svc_rqst *rqstp
52 	),
53 	TP_ARGS(rqstp),
54 	TP_STRUCT__entry(
55 		NFSD_TRACE_PROC_ARG_FIELDS
56 
57 		__field(u32, vers)
58 		__field(u32, proc)
59 	),
60 	TP_fast_assign(
61 		NFSD_TRACE_PROC_ARG_ASSIGNMENTS
62 
63 		__entry->vers = rqstp->rq_vers;
64 		__entry->proc = rqstp->rq_proc;
65 	),
66 	TP_printk("xid=0x%08x vers=%u proc=%u",
67 		__entry->xid, __entry->vers, __entry->proc
68 	)
69 );
70 
71 TRACE_EVENT(nfsd_cant_encode_err,
72 	TP_PROTO(
73 		const struct svc_rqst *rqstp
74 	),
75 	TP_ARGS(rqstp),
76 	TP_STRUCT__entry(
77 		NFSD_TRACE_PROC_ARG_FIELDS
78 
79 		__field(u32, vers)
80 		__field(u32, proc)
81 	),
82 	TP_fast_assign(
83 		NFSD_TRACE_PROC_ARG_ASSIGNMENTS
84 
85 		__entry->vers = rqstp->rq_vers;
86 		__entry->proc = rqstp->rq_proc;
87 	),
88 	TP_printk("xid=0x%08x vers=%u proc=%u",
89 		__entry->xid, __entry->vers, __entry->proc
90 	)
91 );
92 
93 #define show_nfsd_may_flags(x)						\
94 	__print_flags(x, "|",						\
95 		{ NFSD_MAY_EXEC,		"EXEC" },		\
96 		{ NFSD_MAY_WRITE,		"WRITE" },		\
97 		{ NFSD_MAY_READ,		"READ" },		\
98 		{ NFSD_MAY_SATTR,		"SATTR" },		\
99 		{ NFSD_MAY_TRUNC,		"TRUNC" },		\
100 		{ NFSD_MAY_LOCK,		"LOCK" },		\
101 		{ NFSD_MAY_OWNER_OVERRIDE,	"OWNER_OVERRIDE" },	\
102 		{ NFSD_MAY_LOCAL_ACCESS,	"LOCAL_ACCESS" },	\
103 		{ NFSD_MAY_BYPASS_GSS_ON_ROOT,	"BYPASS_GSS_ON_ROOT" },	\
104 		{ NFSD_MAY_NOT_BREAK_LEASE,	"NOT_BREAK_LEASE" },	\
105 		{ NFSD_MAY_BYPASS_GSS,		"BYPASS_GSS" },		\
106 		{ NFSD_MAY_READ_IF_EXEC,	"READ_IF_EXEC" },	\
107 		{ NFSD_MAY_64BIT_COOKIE,	"64BIT_COOKIE" })
108 
109 TRACE_EVENT(nfsd_compound,
110 	TP_PROTO(const struct svc_rqst *rqst,
111 		 u32 args_opcnt),
112 	TP_ARGS(rqst, args_opcnt),
113 	TP_STRUCT__entry(
114 		__field(u32, xid)
115 		__field(u32, args_opcnt)
116 	),
117 	TP_fast_assign(
118 		__entry->xid = be32_to_cpu(rqst->rq_xid);
119 		__entry->args_opcnt = args_opcnt;
120 	),
121 	TP_printk("xid=0x%08x opcnt=%u",
122 		__entry->xid, __entry->args_opcnt)
123 )
124 
125 TRACE_EVENT(nfsd_compound_status,
126 	TP_PROTO(u32 args_opcnt,
127 		 u32 resp_opcnt,
128 		 __be32 status,
129 		 const char *name),
130 	TP_ARGS(args_opcnt, resp_opcnt, status, name),
131 	TP_STRUCT__entry(
132 		__field(u32, args_opcnt)
133 		__field(u32, resp_opcnt)
134 		__field(int, status)
135 		__string(name, name)
136 	),
137 	TP_fast_assign(
138 		__entry->args_opcnt = args_opcnt;
139 		__entry->resp_opcnt = resp_opcnt;
140 		__entry->status = be32_to_cpu(status);
141 		__assign_str(name, name);
142 	),
143 	TP_printk("op=%u/%u %s status=%d",
144 		__entry->resp_opcnt, __entry->args_opcnt,
145 		__get_str(name), __entry->status)
146 )
147 
148 TRACE_EVENT(nfsd_compound_decode_err,
149 	TP_PROTO(
150 		const struct svc_rqst *rqstp,
151 		u32 args_opcnt,
152 		u32 resp_opcnt,
153 		u32 opnum,
154 		__be32 status
155 	),
156 	TP_ARGS(rqstp, args_opcnt, resp_opcnt, opnum, status),
157 	TP_STRUCT__entry(
158 		NFSD_TRACE_PROC_RES_FIELDS
159 
160 		__field(u32, args_opcnt)
161 		__field(u32, resp_opcnt)
162 		__field(u32, opnum)
163 	),
164 	TP_fast_assign(
165 		NFSD_TRACE_PROC_RES_ASSIGNMENTS(status)
166 
167 		__entry->args_opcnt = args_opcnt;
168 		__entry->resp_opcnt = resp_opcnt;
169 		__entry->opnum = opnum;
170 	),
171 	TP_printk("op=%u/%u opnum=%u status=%lu",
172 		__entry->resp_opcnt, __entry->args_opcnt,
173 		__entry->opnum, __entry->status)
174 );
175 
176 TRACE_EVENT(nfsd_compound_encode_err,
177 	TP_PROTO(
178 		const struct svc_rqst *rqstp,
179 		u32 opnum,
180 		__be32 status
181 	),
182 	TP_ARGS(rqstp, opnum, status),
183 	TP_STRUCT__entry(
184 		NFSD_TRACE_PROC_RES_FIELDS
185 
186 		__field(u32, opnum)
187 	),
188 	TP_fast_assign(
189 		NFSD_TRACE_PROC_RES_ASSIGNMENTS(status)
190 
191 		__entry->opnum = opnum;
192 	),
193 	TP_printk("opnum=%u status=%lu",
194 		__entry->opnum, __entry->status)
195 );
196 
197 
198 DECLARE_EVENT_CLASS(nfsd_fh_err_class,
199 	TP_PROTO(struct svc_rqst *rqstp,
200 		 struct svc_fh	*fhp,
201 		 int		status),
202 	TP_ARGS(rqstp, fhp, status),
203 	TP_STRUCT__entry(
204 		__field(u32, xid)
205 		__field(u32, fh_hash)
206 		__field(int, status)
207 	),
208 	TP_fast_assign(
209 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
210 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
211 		__entry->status = status;
212 	),
213 	TP_printk("xid=0x%08x fh_hash=0x%08x status=%d",
214 		  __entry->xid, __entry->fh_hash,
215 		  __entry->status)
216 )
217 
218 #define DEFINE_NFSD_FH_ERR_EVENT(name)		\
219 DEFINE_EVENT(nfsd_fh_err_class, nfsd_##name,	\
220 	TP_PROTO(struct svc_rqst *rqstp,	\
221 		 struct svc_fh	*fhp,		\
222 		 int		status),	\
223 	TP_ARGS(rqstp, fhp, status))
224 
225 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport);
226 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle);
227 
228 TRACE_EVENT(nfsd_exp_find_key,
229 	TP_PROTO(const struct svc_expkey *key,
230 		 int status),
231 	TP_ARGS(key, status),
232 	TP_STRUCT__entry(
233 		__field(int, fsidtype)
234 		__array(u32, fsid, 6)
235 		__string(auth_domain, key->ek_client->name)
236 		__field(int, status)
237 	),
238 	TP_fast_assign(
239 		__entry->fsidtype = key->ek_fsidtype;
240 		memcpy(__entry->fsid, key->ek_fsid, 4*6);
241 		__assign_str(auth_domain, key->ek_client->name);
242 		__entry->status = status;
243 	),
244 	TP_printk("fsid=%x::%s domain=%s status=%d",
245 		__entry->fsidtype,
246 		__print_array(__entry->fsid, 6, 4),
247 		__get_str(auth_domain),
248 		__entry->status
249 	)
250 );
251 
252 TRACE_EVENT(nfsd_expkey_update,
253 	TP_PROTO(const struct svc_expkey *key, const char *exp_path),
254 	TP_ARGS(key, exp_path),
255 	TP_STRUCT__entry(
256 		__field(int, fsidtype)
257 		__array(u32, fsid, 6)
258 		__string(auth_domain, key->ek_client->name)
259 		__string(path, exp_path)
260 		__field(bool, cache)
261 	),
262 	TP_fast_assign(
263 		__entry->fsidtype = key->ek_fsidtype;
264 		memcpy(__entry->fsid, key->ek_fsid, 4*6);
265 		__assign_str(auth_domain, key->ek_client->name);
266 		__assign_str(path, exp_path);
267 		__entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
268 	),
269 	TP_printk("fsid=%x::%s domain=%s path=%s cache=%s",
270 		__entry->fsidtype,
271 		__print_array(__entry->fsid, 6, 4),
272 		__get_str(auth_domain),
273 		__get_str(path),
274 		__entry->cache ? "pos" : "neg"
275 	)
276 );
277 
278 TRACE_EVENT(nfsd_exp_get_by_name,
279 	TP_PROTO(const struct svc_export *key,
280 		 int status),
281 	TP_ARGS(key, status),
282 	TP_STRUCT__entry(
283 		__string(path, key->ex_path.dentry->d_name.name)
284 		__string(auth_domain, key->ex_client->name)
285 		__field(int, status)
286 	),
287 	TP_fast_assign(
288 		__assign_str(path, key->ex_path.dentry->d_name.name);
289 		__assign_str(auth_domain, key->ex_client->name);
290 		__entry->status = status;
291 	),
292 	TP_printk("path=%s domain=%s status=%d",
293 		__get_str(path),
294 		__get_str(auth_domain),
295 		__entry->status
296 	)
297 );
298 
299 TRACE_EVENT(nfsd_export_update,
300 	TP_PROTO(const struct svc_export *key),
301 	TP_ARGS(key),
302 	TP_STRUCT__entry(
303 		__string(path, key->ex_path.dentry->d_name.name)
304 		__string(auth_domain, key->ex_client->name)
305 		__field(bool, cache)
306 	),
307 	TP_fast_assign(
308 		__assign_str(path, key->ex_path.dentry->d_name.name);
309 		__assign_str(auth_domain, key->ex_client->name);
310 		__entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
311 	),
312 	TP_printk("path=%s domain=%s cache=%s",
313 		__get_str(path),
314 		__get_str(auth_domain),
315 		__entry->cache ? "pos" : "neg"
316 	)
317 );
318 
319 DECLARE_EVENT_CLASS(nfsd_io_class,
320 	TP_PROTO(struct svc_rqst *rqstp,
321 		 struct svc_fh	*fhp,
322 		 loff_t		offset,
323 		 unsigned long	len),
324 	TP_ARGS(rqstp, fhp, offset, len),
325 	TP_STRUCT__entry(
326 		__field(u32, xid)
327 		__field(u32, fh_hash)
328 		__field(loff_t, offset)
329 		__field(unsigned long, len)
330 	),
331 	TP_fast_assign(
332 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
333 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
334 		__entry->offset = offset;
335 		__entry->len = len;
336 	),
337 	TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld len=%lu",
338 		  __entry->xid, __entry->fh_hash,
339 		  __entry->offset, __entry->len)
340 )
341 
342 #define DEFINE_NFSD_IO_EVENT(name)		\
343 DEFINE_EVENT(nfsd_io_class, nfsd_##name,	\
344 	TP_PROTO(struct svc_rqst *rqstp,	\
345 		 struct svc_fh	*fhp,		\
346 		 loff_t		offset,		\
347 		 unsigned long	len),		\
348 	TP_ARGS(rqstp, fhp, offset, len))
349 
350 DEFINE_NFSD_IO_EVENT(read_start);
351 DEFINE_NFSD_IO_EVENT(read_splice);
352 DEFINE_NFSD_IO_EVENT(read_vector);
353 DEFINE_NFSD_IO_EVENT(read_io_done);
354 DEFINE_NFSD_IO_EVENT(read_done);
355 DEFINE_NFSD_IO_EVENT(write_start);
356 DEFINE_NFSD_IO_EVENT(write_opened);
357 DEFINE_NFSD_IO_EVENT(write_io_done);
358 DEFINE_NFSD_IO_EVENT(write_done);
359 
360 DECLARE_EVENT_CLASS(nfsd_err_class,
361 	TP_PROTO(struct svc_rqst *rqstp,
362 		 struct svc_fh	*fhp,
363 		 loff_t		offset,
364 		 int		status),
365 	TP_ARGS(rqstp, fhp, offset, status),
366 	TP_STRUCT__entry(
367 		__field(u32, xid)
368 		__field(u32, fh_hash)
369 		__field(loff_t, offset)
370 		__field(int, status)
371 	),
372 	TP_fast_assign(
373 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
374 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
375 		__entry->offset = offset;
376 		__entry->status = status;
377 	),
378 	TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld status=%d",
379 		  __entry->xid, __entry->fh_hash,
380 		  __entry->offset, __entry->status)
381 )
382 
383 #define DEFINE_NFSD_ERR_EVENT(name)		\
384 DEFINE_EVENT(nfsd_err_class, nfsd_##name,	\
385 	TP_PROTO(struct svc_rqst *rqstp,	\
386 		 struct svc_fh	*fhp,		\
387 		 loff_t		offset,		\
388 		 int		len),		\
389 	TP_ARGS(rqstp, fhp, offset, len))
390 
391 DEFINE_NFSD_ERR_EVENT(read_err);
392 DEFINE_NFSD_ERR_EVENT(write_err);
393 
394 #include "state.h"
395 #include "filecache.h"
396 #include "vfs.h"
397 
398 DECLARE_EVENT_CLASS(nfsd_stateid_class,
399 	TP_PROTO(stateid_t *stp),
400 	TP_ARGS(stp),
401 	TP_STRUCT__entry(
402 		__field(u32, cl_boot)
403 		__field(u32, cl_id)
404 		__field(u32, si_id)
405 		__field(u32, si_generation)
406 	),
407 	TP_fast_assign(
408 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
409 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
410 		__entry->si_id = stp->si_opaque.so_id;
411 		__entry->si_generation = stp->si_generation;
412 	),
413 	TP_printk("client %08x:%08x stateid %08x:%08x",
414 		__entry->cl_boot,
415 		__entry->cl_id,
416 		__entry->si_id,
417 		__entry->si_generation)
418 )
419 
420 #define DEFINE_STATEID_EVENT(name) \
421 DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \
422 	TP_PROTO(stateid_t *stp), \
423 	TP_ARGS(stp))
424 
425 DEFINE_STATEID_EVENT(layoutstate_alloc);
426 DEFINE_STATEID_EVENT(layoutstate_unhash);
427 DEFINE_STATEID_EVENT(layoutstate_free);
428 DEFINE_STATEID_EVENT(layout_get_lookup_fail);
429 DEFINE_STATEID_EVENT(layout_commit_lookup_fail);
430 DEFINE_STATEID_EVENT(layout_return_lookup_fail);
431 DEFINE_STATEID_EVENT(layout_recall);
432 DEFINE_STATEID_EVENT(layout_recall_done);
433 DEFINE_STATEID_EVENT(layout_recall_fail);
434 DEFINE_STATEID_EVENT(layout_recall_release);
435 
436 DEFINE_STATEID_EVENT(open);
437 DEFINE_STATEID_EVENT(deleg_read);
438 DEFINE_STATEID_EVENT(deleg_break);
439 DEFINE_STATEID_EVENT(deleg_recall);
440 
441 DECLARE_EVENT_CLASS(nfsd_stateseqid_class,
442 	TP_PROTO(u32 seqid, const stateid_t *stp),
443 	TP_ARGS(seqid, stp),
444 	TP_STRUCT__entry(
445 		__field(u32, seqid)
446 		__field(u32, cl_boot)
447 		__field(u32, cl_id)
448 		__field(u32, si_id)
449 		__field(u32, si_generation)
450 	),
451 	TP_fast_assign(
452 		__entry->seqid = seqid;
453 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
454 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
455 		__entry->si_id = stp->si_opaque.so_id;
456 		__entry->si_generation = stp->si_generation;
457 	),
458 	TP_printk("seqid=%u client %08x:%08x stateid %08x:%08x",
459 		__entry->seqid, __entry->cl_boot, __entry->cl_id,
460 		__entry->si_id, __entry->si_generation)
461 )
462 
463 #define DEFINE_STATESEQID_EVENT(name) \
464 DEFINE_EVENT(nfsd_stateseqid_class, nfsd_##name, \
465 	TP_PROTO(u32 seqid, const stateid_t *stp), \
466 	TP_ARGS(seqid, stp))
467 
468 DEFINE_STATESEQID_EVENT(preprocess);
469 DEFINE_STATESEQID_EVENT(open_confirm);
470 
471 DECLARE_EVENT_CLASS(nfsd_clientid_class,
472 	TP_PROTO(const clientid_t *clid),
473 	TP_ARGS(clid),
474 	TP_STRUCT__entry(
475 		__field(u32, cl_boot)
476 		__field(u32, cl_id)
477 	),
478 	TP_fast_assign(
479 		__entry->cl_boot = clid->cl_boot;
480 		__entry->cl_id = clid->cl_id;
481 	),
482 	TP_printk("client %08x:%08x", __entry->cl_boot, __entry->cl_id)
483 )
484 
485 #define DEFINE_CLIENTID_EVENT(name) \
486 DEFINE_EVENT(nfsd_clientid_class, nfsd_clid_##name, \
487 	TP_PROTO(const clientid_t *clid), \
488 	TP_ARGS(clid))
489 
490 DEFINE_CLIENTID_EVENT(expired);
491 DEFINE_CLIENTID_EVENT(purged);
492 DEFINE_CLIENTID_EVENT(renew);
493 DEFINE_CLIENTID_EVENT(stale);
494 
495 DECLARE_EVENT_CLASS(nfsd_net_class,
496 	TP_PROTO(const struct nfsd_net *nn),
497 	TP_ARGS(nn),
498 	TP_STRUCT__entry(
499 		__field(unsigned long long, boot_time)
500 	),
501 	TP_fast_assign(
502 		__entry->boot_time = nn->boot_time;
503 	),
504 	TP_printk("boot_time=%16llx", __entry->boot_time)
505 )
506 
507 #define DEFINE_NET_EVENT(name) \
508 DEFINE_EVENT(nfsd_net_class, nfsd_##name, \
509 	TP_PROTO(const struct nfsd_net *nn), \
510 	TP_ARGS(nn))
511 
512 DEFINE_NET_EVENT(grace_start);
513 DEFINE_NET_EVENT(grace_complete);
514 
515 DECLARE_EVENT_CLASS(nfsd_clid_class,
516 	TP_PROTO(const struct nfsd_net *nn,
517 		 unsigned int namelen,
518 		 const unsigned char *namedata),
519 	TP_ARGS(nn, namelen, namedata),
520 	TP_STRUCT__entry(
521 		__field(unsigned long long, boot_time)
522 		__field(unsigned int, namelen)
523 		__dynamic_array(unsigned char,  name, namelen)
524 	),
525 	TP_fast_assign(
526 		__entry->boot_time = nn->boot_time;
527 		__entry->namelen = namelen;
528 		memcpy(__get_dynamic_array(name), namedata, namelen);
529 	),
530 	TP_printk("boot_time=%16llx nfs4_clientid=%.*s",
531 		__entry->boot_time, __entry->namelen, __get_str(name))
532 )
533 
534 #define DEFINE_CLID_EVENT(name) \
535 DEFINE_EVENT(nfsd_clid_class, nfsd_clid_##name, \
536 	TP_PROTO(const struct nfsd_net *nn, \
537 		 unsigned int namelen, \
538 		 const unsigned char *namedata), \
539 	TP_ARGS(nn, namelen, namedata))
540 
541 DEFINE_CLID_EVENT(find);
542 DEFINE_CLID_EVENT(reclaim);
543 
544 TRACE_EVENT(nfsd_clid_inuse_err,
545 	TP_PROTO(const struct nfs4_client *clp),
546 	TP_ARGS(clp),
547 	TP_STRUCT__entry(
548 		__field(u32, cl_boot)
549 		__field(u32, cl_id)
550 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
551 		__field(unsigned int, namelen)
552 		__dynamic_array(unsigned char, name, clp->cl_name.len)
553 	),
554 	TP_fast_assign(
555 		__entry->cl_boot = clp->cl_clientid.cl_boot;
556 		__entry->cl_id = clp->cl_clientid.cl_id;
557 		memcpy(__entry->addr, &clp->cl_addr,
558 			sizeof(struct sockaddr_in6));
559 		__entry->namelen = clp->cl_name.len;
560 		memcpy(__get_dynamic_array(name), clp->cl_name.data,
561 			clp->cl_name.len);
562 	),
563 	TP_printk("nfs4_clientid %.*s already in use by %pISpc, client %08x:%08x",
564 		__entry->namelen, __get_str(name), __entry->addr,
565 		__entry->cl_boot, __entry->cl_id)
566 )
567 
568 /*
569  * from fs/nfsd/filecache.h
570  */
571 TRACE_DEFINE_ENUM(NFSD_FILE_HASHED);
572 TRACE_DEFINE_ENUM(NFSD_FILE_PENDING);
573 TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_READ);
574 TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_WRITE);
575 TRACE_DEFINE_ENUM(NFSD_FILE_REFERENCED);
576 
577 #define show_nf_flags(val)						\
578 	__print_flags(val, "|",						\
579 		{ 1 << NFSD_FILE_HASHED,	"HASHED" },		\
580 		{ 1 << NFSD_FILE_PENDING,	"PENDING" },		\
581 		{ 1 << NFSD_FILE_BREAK_READ,	"BREAK_READ" },		\
582 		{ 1 << NFSD_FILE_BREAK_WRITE,	"BREAK_WRITE" },	\
583 		{ 1 << NFSD_FILE_REFERENCED,	"REFERENCED"})
584 
585 DECLARE_EVENT_CLASS(nfsd_file_class,
586 	TP_PROTO(struct nfsd_file *nf),
587 	TP_ARGS(nf),
588 	TP_STRUCT__entry(
589 		__field(unsigned int, nf_hashval)
590 		__field(void *, nf_inode)
591 		__field(int, nf_ref)
592 		__field(unsigned long, nf_flags)
593 		__field(unsigned char, nf_may)
594 		__field(struct file *, nf_file)
595 	),
596 	TP_fast_assign(
597 		__entry->nf_hashval = nf->nf_hashval;
598 		__entry->nf_inode = nf->nf_inode;
599 		__entry->nf_ref = refcount_read(&nf->nf_ref);
600 		__entry->nf_flags = nf->nf_flags;
601 		__entry->nf_may = nf->nf_may;
602 		__entry->nf_file = nf->nf_file;
603 	),
604 	TP_printk("hash=0x%x inode=%p ref=%d flags=%s may=%s file=%p",
605 		__entry->nf_hashval,
606 		__entry->nf_inode,
607 		__entry->nf_ref,
608 		show_nf_flags(__entry->nf_flags),
609 		show_nfsd_may_flags(__entry->nf_may),
610 		__entry->nf_file)
611 )
612 
613 #define DEFINE_NFSD_FILE_EVENT(name) \
614 DEFINE_EVENT(nfsd_file_class, name, \
615 	TP_PROTO(struct nfsd_file *nf), \
616 	TP_ARGS(nf))
617 
618 DEFINE_NFSD_FILE_EVENT(nfsd_file_alloc);
619 DEFINE_NFSD_FILE_EVENT(nfsd_file_put_final);
620 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash);
621 DEFINE_NFSD_FILE_EVENT(nfsd_file_put);
622 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_release_locked);
623 
624 TRACE_EVENT(nfsd_file_acquire,
625 	TP_PROTO(struct svc_rqst *rqstp, unsigned int hash,
626 		 struct inode *inode, unsigned int may_flags,
627 		 struct nfsd_file *nf, __be32 status),
628 
629 	TP_ARGS(rqstp, hash, inode, may_flags, nf, status),
630 
631 	TP_STRUCT__entry(
632 		__field(u32, xid)
633 		__field(unsigned int, hash)
634 		__field(void *, inode)
635 		__field(unsigned long, may_flags)
636 		__field(int, nf_ref)
637 		__field(unsigned long, nf_flags)
638 		__field(unsigned long, nf_may)
639 		__field(struct file *, nf_file)
640 		__field(u32, status)
641 	),
642 
643 	TP_fast_assign(
644 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
645 		__entry->hash = hash;
646 		__entry->inode = inode;
647 		__entry->may_flags = may_flags;
648 		__entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0;
649 		__entry->nf_flags = nf ? nf->nf_flags : 0;
650 		__entry->nf_may = nf ? nf->nf_may : 0;
651 		__entry->nf_file = nf ? nf->nf_file : NULL;
652 		__entry->status = be32_to_cpu(status);
653 	),
654 
655 	TP_printk("xid=0x%x hash=0x%x inode=%p may_flags=%s ref=%d nf_flags=%s nf_may=%s nf_file=%p status=%u",
656 			__entry->xid, __entry->hash, __entry->inode,
657 			show_nfsd_may_flags(__entry->may_flags),
658 			__entry->nf_ref, show_nf_flags(__entry->nf_flags),
659 			show_nfsd_may_flags(__entry->nf_may),
660 			__entry->nf_file, __entry->status)
661 );
662 
663 DECLARE_EVENT_CLASS(nfsd_file_search_class,
664 	TP_PROTO(struct inode *inode, unsigned int hash, int found),
665 	TP_ARGS(inode, hash, found),
666 	TP_STRUCT__entry(
667 		__field(struct inode *, inode)
668 		__field(unsigned int, hash)
669 		__field(int, found)
670 	),
671 	TP_fast_assign(
672 		__entry->inode = inode;
673 		__entry->hash = hash;
674 		__entry->found = found;
675 	),
676 	TP_printk("hash=0x%x inode=%p found=%d", __entry->hash,
677 			__entry->inode, __entry->found)
678 );
679 
680 #define DEFINE_NFSD_FILE_SEARCH_EVENT(name)				\
681 DEFINE_EVENT(nfsd_file_search_class, name,				\
682 	TP_PROTO(struct inode *inode, unsigned int hash, int found),	\
683 	TP_ARGS(inode, hash, found))
684 
685 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode_sync);
686 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode);
687 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_is_cached);
688 
689 TRACE_EVENT(nfsd_file_fsnotify_handle_event,
690 	TP_PROTO(struct inode *inode, u32 mask),
691 	TP_ARGS(inode, mask),
692 	TP_STRUCT__entry(
693 		__field(struct inode *, inode)
694 		__field(unsigned int, nlink)
695 		__field(umode_t, mode)
696 		__field(u32, mask)
697 	),
698 	TP_fast_assign(
699 		__entry->inode = inode;
700 		__entry->nlink = inode->i_nlink;
701 		__entry->mode = inode->i_mode;
702 		__entry->mask = mask;
703 	),
704 	TP_printk("inode=%p nlink=%u mode=0%ho mask=0x%x", __entry->inode,
705 			__entry->nlink, __entry->mode, __entry->mask)
706 );
707 
708 #include "cache.h"
709 
710 TRACE_DEFINE_ENUM(RC_DROPIT);
711 TRACE_DEFINE_ENUM(RC_REPLY);
712 TRACE_DEFINE_ENUM(RC_DOIT);
713 
714 #define show_drc_retval(x)						\
715 	__print_symbolic(x,						\
716 		{ RC_DROPIT, "DROPIT" },				\
717 		{ RC_REPLY, "REPLY" },					\
718 		{ RC_DOIT, "DOIT" })
719 
720 TRACE_EVENT(nfsd_drc_found,
721 	TP_PROTO(
722 		const struct nfsd_net *nn,
723 		const struct svc_rqst *rqstp,
724 		int result
725 	),
726 	TP_ARGS(nn, rqstp, result),
727 	TP_STRUCT__entry(
728 		__field(unsigned long long, boot_time)
729 		__field(unsigned long, result)
730 		__field(u32, xid)
731 	),
732 	TP_fast_assign(
733 		__entry->boot_time = nn->boot_time;
734 		__entry->result = result;
735 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
736 	),
737 	TP_printk("boot_time=%16llx xid=0x%08x result=%s",
738 		__entry->boot_time, __entry->xid,
739 		show_drc_retval(__entry->result))
740 
741 );
742 
743 TRACE_EVENT(nfsd_drc_mismatch,
744 	TP_PROTO(
745 		const struct nfsd_net *nn,
746 		const struct svc_cacherep *key,
747 		const struct svc_cacherep *rp
748 	),
749 	TP_ARGS(nn, key, rp),
750 	TP_STRUCT__entry(
751 		__field(unsigned long long, boot_time)
752 		__field(u32, xid)
753 		__field(u32, cached)
754 		__field(u32, ingress)
755 	),
756 	TP_fast_assign(
757 		__entry->boot_time = nn->boot_time;
758 		__entry->xid = be32_to_cpu(key->c_key.k_xid);
759 		__entry->cached = (__force u32)key->c_key.k_csum;
760 		__entry->ingress = (__force u32)rp->c_key.k_csum;
761 	),
762 	TP_printk("boot_time=%16llx xid=0x%08x cached-csum=0x%08x ingress-csum=0x%08x",
763 		__entry->boot_time, __entry->xid, __entry->cached,
764 		__entry->ingress)
765 );
766 
767 TRACE_EVENT(nfsd_cb_args,
768 	TP_PROTO(
769 		const struct nfs4_client *clp,
770 		const struct nfs4_cb_conn *conn
771 	),
772 	TP_ARGS(clp, conn),
773 	TP_STRUCT__entry(
774 		__field(u32, cl_boot)
775 		__field(u32, cl_id)
776 		__field(u32, prog)
777 		__field(u32, ident)
778 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
779 	),
780 	TP_fast_assign(
781 		__entry->cl_boot = clp->cl_clientid.cl_boot;
782 		__entry->cl_id = clp->cl_clientid.cl_id;
783 		__entry->prog = conn->cb_prog;
784 		__entry->ident = conn->cb_ident;
785 		memcpy(__entry->addr, &conn->cb_addr,
786 			sizeof(struct sockaddr_in6));
787 	),
788 	TP_printk("client %08x:%08x callback addr=%pISpc prog=%u ident=%u",
789 		__entry->cl_boot, __entry->cl_id,
790 		__entry->addr, __entry->prog, __entry->ident)
791 );
792 
793 TRACE_EVENT(nfsd_cb_nodelegs,
794 	TP_PROTO(const struct nfs4_client *clp),
795 	TP_ARGS(clp),
796 	TP_STRUCT__entry(
797 		__field(u32, cl_boot)
798 		__field(u32, cl_id)
799 	),
800 	TP_fast_assign(
801 		__entry->cl_boot = clp->cl_clientid.cl_boot;
802 		__entry->cl_id = clp->cl_clientid.cl_id;
803 	),
804 	TP_printk("client %08x:%08x", __entry->cl_boot, __entry->cl_id)
805 )
806 
807 TRACE_DEFINE_ENUM(NFSD4_CB_UP);
808 TRACE_DEFINE_ENUM(NFSD4_CB_UNKNOWN);
809 TRACE_DEFINE_ENUM(NFSD4_CB_DOWN);
810 TRACE_DEFINE_ENUM(NFSD4_CB_FAULT);
811 
812 #define show_cb_state(val)						\
813 	__print_symbolic(val,						\
814 		{ NFSD4_CB_UP,		"UP" },				\
815 		{ NFSD4_CB_UNKNOWN,	"UNKNOWN" },			\
816 		{ NFSD4_CB_DOWN,	"DOWN" },			\
817 		{ NFSD4_CB_FAULT,	"FAULT"})
818 
819 DECLARE_EVENT_CLASS(nfsd_cb_class,
820 	TP_PROTO(const struct nfs4_client *clp),
821 	TP_ARGS(clp),
822 	TP_STRUCT__entry(
823 		__field(unsigned long, state)
824 		__field(u32, cl_boot)
825 		__field(u32, cl_id)
826 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
827 	),
828 	TP_fast_assign(
829 		__entry->state = clp->cl_cb_state;
830 		__entry->cl_boot = clp->cl_clientid.cl_boot;
831 		__entry->cl_id = clp->cl_clientid.cl_id;
832 		memcpy(__entry->addr, &clp->cl_cb_conn.cb_addr,
833 			sizeof(struct sockaddr_in6));
834 	),
835 	TP_printk("addr=%pISpc client %08x:%08x state=%s",
836 		__entry->addr, __entry->cl_boot, __entry->cl_id,
837 		show_cb_state(__entry->state))
838 );
839 
840 #define DEFINE_NFSD_CB_EVENT(name)			\
841 DEFINE_EVENT(nfsd_cb_class, nfsd_cb_##name,		\
842 	TP_PROTO(const struct nfs4_client *clp),	\
843 	TP_ARGS(clp))
844 
845 DEFINE_NFSD_CB_EVENT(setup);
846 DEFINE_NFSD_CB_EVENT(state);
847 DEFINE_NFSD_CB_EVENT(shutdown);
848 
849 TRACE_EVENT(nfsd_cb_setup_err,
850 	TP_PROTO(
851 		const struct nfs4_client *clp,
852 		long error
853 	),
854 	TP_ARGS(clp, error),
855 	TP_STRUCT__entry(
856 		__field(long, error)
857 		__field(u32, cl_boot)
858 		__field(u32, cl_id)
859 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
860 	),
861 	TP_fast_assign(
862 		__entry->error = error;
863 		__entry->cl_boot = clp->cl_clientid.cl_boot;
864 		__entry->cl_id = clp->cl_clientid.cl_id;
865 		memcpy(__entry->addr, &clp->cl_cb_conn.cb_addr,
866 			sizeof(struct sockaddr_in6));
867 	),
868 	TP_printk("addr=%pISpc client %08x:%08x error=%ld",
869 		__entry->addr, __entry->cl_boot, __entry->cl_id, __entry->error)
870 );
871 
872 TRACE_EVENT(nfsd_cb_work,
873 	TP_PROTO(
874 		const struct nfs4_client *clp,
875 		const char *procedure
876 	),
877 	TP_ARGS(clp, procedure),
878 	TP_STRUCT__entry(
879 		__field(u32, cl_boot)
880 		__field(u32, cl_id)
881 		__string(procedure, procedure)
882 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
883 	),
884 	TP_fast_assign(
885 		__entry->cl_boot = clp->cl_clientid.cl_boot;
886 		__entry->cl_id = clp->cl_clientid.cl_id;
887 		__assign_str(procedure, procedure)
888 		memcpy(__entry->addr, &clp->cl_cb_conn.cb_addr,
889 			sizeof(struct sockaddr_in6));
890 	),
891 	TP_printk("addr=%pISpc client %08x:%08x procedure=%s",
892 		__entry->addr, __entry->cl_boot, __entry->cl_id,
893 		__get_str(procedure))
894 );
895 
896 TRACE_EVENT(nfsd_cb_done,
897 	TP_PROTO(
898 		const struct nfs4_client *clp,
899 		int status
900 	),
901 	TP_ARGS(clp, status),
902 	TP_STRUCT__entry(
903 		__field(u32, cl_boot)
904 		__field(u32, cl_id)
905 		__field(int, status)
906 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
907 	),
908 	TP_fast_assign(
909 		__entry->cl_boot = clp->cl_clientid.cl_boot;
910 		__entry->cl_id = clp->cl_clientid.cl_id;
911 		__entry->status = status;
912 		memcpy(__entry->addr, &clp->cl_cb_conn.cb_addr,
913 			sizeof(struct sockaddr_in6));
914 	),
915 	TP_printk("addr=%pISpc client %08x:%08x status=%d",
916 		__entry->addr, __entry->cl_boot, __entry->cl_id,
917 		__entry->status)
918 );
919 
920 #endif /* _NFSD_TRACE_H */
921 
922 #undef TRACE_INCLUDE_PATH
923 #define TRACE_INCLUDE_PATH .
924 #define TRACE_INCLUDE_FILE trace
925 #include <trace/define_trace.h>
926