xref: /openbmc/linux/fs/nfsd/trace.h (revision fb4a5dfc)
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 
13 #include "export.h"
14 #include "nfsfh.h"
15 
16 #define NFSD_TRACE_PROC_RES_FIELDS \
17 		__field(unsigned int, netns_ino) \
18 		__field(u32, xid) \
19 		__field(unsigned long, status) \
20 		__array(unsigned char, server, sizeof(struct sockaddr_in6)) \
21 		__array(unsigned char, client, sizeof(struct sockaddr_in6))
22 
23 #define NFSD_TRACE_PROC_RES_ASSIGNMENTS(error) \
24 		do { \
25 			__entry->netns_ino = SVC_NET(rqstp)->ns.inum; \
26 			__entry->xid = be32_to_cpu(rqstp->rq_xid); \
27 			__entry->status = be32_to_cpu(error); \
28 			memcpy(__entry->server, &rqstp->rq_xprt->xpt_local, \
29 			       rqstp->rq_xprt->xpt_locallen); \
30 			memcpy(__entry->client, &rqstp->rq_xprt->xpt_remote, \
31 			       rqstp->rq_xprt->xpt_remotelen); \
32 		} while (0);
33 
34 DECLARE_EVENT_CLASS(nfsd_xdr_err_class,
35 	TP_PROTO(
36 		const struct svc_rqst *rqstp
37 	),
38 	TP_ARGS(rqstp),
39 	TP_STRUCT__entry(
40 		__field(unsigned int, netns_ino)
41 		__field(u32, xid)
42 		__field(u32, vers)
43 		__field(u32, proc)
44 		__sockaddr(server, rqstp->rq_xprt->xpt_locallen)
45 		__sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
46 	),
47 	TP_fast_assign(
48 		const struct svc_xprt *xprt = rqstp->rq_xprt;
49 
50 		__entry->netns_ino = xprt->xpt_net->ns.inum;
51 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
52 		__entry->vers = rqstp->rq_vers;
53 		__entry->proc = rqstp->rq_proc;
54 		__assign_sockaddr(server, &xprt->xpt_local, xprt->xpt_locallen);
55 		__assign_sockaddr(client, &xprt->xpt_remote, xprt->xpt_remotelen);
56 	),
57 	TP_printk("xid=0x%08x vers=%u proc=%u",
58 		__entry->xid, __entry->vers, __entry->proc
59 	)
60 );
61 
62 #define DEFINE_NFSD_XDR_ERR_EVENT(name) \
63 DEFINE_EVENT(nfsd_xdr_err_class, nfsd_##name##_err, \
64 	TP_PROTO(const struct svc_rqst *rqstp), \
65 	TP_ARGS(rqstp))
66 
67 DEFINE_NFSD_XDR_ERR_EVENT(garbage_args);
68 DEFINE_NFSD_XDR_ERR_EVENT(cant_encode);
69 
70 #define show_nfsd_may_flags(x)						\
71 	__print_flags(x, "|",						\
72 		{ NFSD_MAY_EXEC,		"EXEC" },		\
73 		{ NFSD_MAY_WRITE,		"WRITE" },		\
74 		{ NFSD_MAY_READ,		"READ" },		\
75 		{ NFSD_MAY_SATTR,		"SATTR" },		\
76 		{ NFSD_MAY_TRUNC,		"TRUNC" },		\
77 		{ NFSD_MAY_LOCK,		"LOCK" },		\
78 		{ NFSD_MAY_OWNER_OVERRIDE,	"OWNER_OVERRIDE" },	\
79 		{ NFSD_MAY_LOCAL_ACCESS,	"LOCAL_ACCESS" },	\
80 		{ NFSD_MAY_BYPASS_GSS_ON_ROOT,	"BYPASS_GSS_ON_ROOT" },	\
81 		{ NFSD_MAY_NOT_BREAK_LEASE,	"NOT_BREAK_LEASE" },	\
82 		{ NFSD_MAY_BYPASS_GSS,		"BYPASS_GSS" },		\
83 		{ NFSD_MAY_READ_IF_EXEC,	"READ_IF_EXEC" },	\
84 		{ NFSD_MAY_64BIT_COOKIE,	"64BIT_COOKIE" })
85 
86 TRACE_EVENT(nfsd_compound,
87 	TP_PROTO(
88 		const struct svc_rqst *rqst,
89 		const char *tag,
90 		u32 taglen,
91 		u32 opcnt
92 	),
93 	TP_ARGS(rqst, tag, taglen, opcnt),
94 	TP_STRUCT__entry(
95 		__field(u32, xid)
96 		__field(u32, opcnt)
97 		__string_len(tag, tag, taglen)
98 	),
99 	TP_fast_assign(
100 		__entry->xid = be32_to_cpu(rqst->rq_xid);
101 		__entry->opcnt = opcnt;
102 		__assign_str_len(tag, tag, taglen);
103 	),
104 	TP_printk("xid=0x%08x opcnt=%u tag=%s",
105 		__entry->xid, __entry->opcnt, __get_str(tag)
106 	)
107 )
108 
109 TRACE_EVENT(nfsd_compound_status,
110 	TP_PROTO(u32 args_opcnt,
111 		 u32 resp_opcnt,
112 		 __be32 status,
113 		 const char *name),
114 	TP_ARGS(args_opcnt, resp_opcnt, status, name),
115 	TP_STRUCT__entry(
116 		__field(u32, args_opcnt)
117 		__field(u32, resp_opcnt)
118 		__field(int, status)
119 		__string(name, name)
120 	),
121 	TP_fast_assign(
122 		__entry->args_opcnt = args_opcnt;
123 		__entry->resp_opcnt = resp_opcnt;
124 		__entry->status = be32_to_cpu(status);
125 		__assign_str(name, name);
126 	),
127 	TP_printk("op=%u/%u %s status=%d",
128 		__entry->resp_opcnt, __entry->args_opcnt,
129 		__get_str(name), __entry->status)
130 )
131 
132 TRACE_EVENT(nfsd_compound_decode_err,
133 	TP_PROTO(
134 		const struct svc_rqst *rqstp,
135 		u32 args_opcnt,
136 		u32 resp_opcnt,
137 		u32 opnum,
138 		__be32 status
139 	),
140 	TP_ARGS(rqstp, args_opcnt, resp_opcnt, opnum, status),
141 	TP_STRUCT__entry(
142 		NFSD_TRACE_PROC_RES_FIELDS
143 
144 		__field(u32, args_opcnt)
145 		__field(u32, resp_opcnt)
146 		__field(u32, opnum)
147 	),
148 	TP_fast_assign(
149 		NFSD_TRACE_PROC_RES_ASSIGNMENTS(status)
150 
151 		__entry->args_opcnt = args_opcnt;
152 		__entry->resp_opcnt = resp_opcnt;
153 		__entry->opnum = opnum;
154 	),
155 	TP_printk("op=%u/%u opnum=%u status=%lu",
156 		__entry->resp_opcnt, __entry->args_opcnt,
157 		__entry->opnum, __entry->status)
158 );
159 
160 TRACE_EVENT(nfsd_compound_encode_err,
161 	TP_PROTO(
162 		const struct svc_rqst *rqstp,
163 		u32 opnum,
164 		__be32 status
165 	),
166 	TP_ARGS(rqstp, opnum, status),
167 	TP_STRUCT__entry(
168 		NFSD_TRACE_PROC_RES_FIELDS
169 
170 		__field(u32, opnum)
171 	),
172 	TP_fast_assign(
173 		NFSD_TRACE_PROC_RES_ASSIGNMENTS(status)
174 
175 		__entry->opnum = opnum;
176 	),
177 	TP_printk("opnum=%u status=%lu",
178 		__entry->opnum, __entry->status)
179 );
180 
181 #define show_fs_file_type(x) \
182 	__print_symbolic(x, \
183 		{ S_IFLNK,		"LNK" }, \
184 		{ S_IFREG,		"REG" }, \
185 		{ S_IFDIR,		"DIR" }, \
186 		{ S_IFCHR,		"CHR" }, \
187 		{ S_IFBLK,		"BLK" }, \
188 		{ S_IFIFO,		"FIFO" }, \
189 		{ S_IFSOCK,		"SOCK" })
190 
191 TRACE_EVENT(nfsd_fh_verify,
192 	TP_PROTO(
193 		const struct svc_rqst *rqstp,
194 		const struct svc_fh *fhp,
195 		umode_t type,
196 		int access
197 	),
198 	TP_ARGS(rqstp, fhp, type, access),
199 	TP_STRUCT__entry(
200 		__field(unsigned int, netns_ino)
201 		__sockaddr(server, rqstp->rq_xprt->xpt_remotelen)
202 		__sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
203 		__field(u32, xid)
204 		__field(u32, fh_hash)
205 		__field(const void *, inode)
206 		__field(unsigned long, type)
207 		__field(unsigned long, access)
208 	),
209 	TP_fast_assign(
210 		__entry->netns_ino = SVC_NET(rqstp)->ns.inum;
211 		__assign_sockaddr(server, &rqstp->rq_xprt->xpt_local,
212 		       rqstp->rq_xprt->xpt_locallen);
213 		__assign_sockaddr(client, &rqstp->rq_xprt->xpt_remote,
214 				  rqstp->rq_xprt->xpt_remotelen);
215 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
216 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
217 		__entry->inode = d_inode(fhp->fh_dentry);
218 		__entry->type = type;
219 		__entry->access = access;
220 	),
221 	TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s",
222 		__entry->xid, __entry->fh_hash,
223 		show_fs_file_type(__entry->type),
224 		show_nfsd_may_flags(__entry->access)
225 	)
226 );
227 
228 TRACE_EVENT_CONDITION(nfsd_fh_verify_err,
229 	TP_PROTO(
230 		const struct svc_rqst *rqstp,
231 		const struct svc_fh *fhp,
232 		umode_t type,
233 		int access,
234 		__be32 error
235 	),
236 	TP_ARGS(rqstp, fhp, type, access, error),
237 	TP_CONDITION(error),
238 	TP_STRUCT__entry(
239 		__field(unsigned int, netns_ino)
240 		__sockaddr(server, rqstp->rq_xprt->xpt_remotelen)
241 		__sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
242 		__field(u32, xid)
243 		__field(u32, fh_hash)
244 		__field(const void *, inode)
245 		__field(unsigned long, type)
246 		__field(unsigned long, access)
247 		__field(int, error)
248 	),
249 	TP_fast_assign(
250 		__entry->netns_ino = SVC_NET(rqstp)->ns.inum;
251 		__assign_sockaddr(server, &rqstp->rq_xprt->xpt_local,
252 		       rqstp->rq_xprt->xpt_locallen);
253 		__assign_sockaddr(client, &rqstp->rq_xprt->xpt_remote,
254 				  rqstp->rq_xprt->xpt_remotelen);
255 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
256 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
257 		__entry->inode = d_inode(fhp->fh_dentry);
258 		__entry->type = type;
259 		__entry->access = access;
260 		__entry->error = be32_to_cpu(error);
261 	),
262 	TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s error=%d",
263 		__entry->xid, __entry->fh_hash,
264 		show_fs_file_type(__entry->type),
265 		show_nfsd_may_flags(__entry->access),
266 		__entry->error
267 	)
268 );
269 
270 DECLARE_EVENT_CLASS(nfsd_fh_err_class,
271 	TP_PROTO(struct svc_rqst *rqstp,
272 		 struct svc_fh	*fhp,
273 		 int		status),
274 	TP_ARGS(rqstp, fhp, status),
275 	TP_STRUCT__entry(
276 		__field(u32, xid)
277 		__field(u32, fh_hash)
278 		__field(int, status)
279 	),
280 	TP_fast_assign(
281 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
282 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
283 		__entry->status = status;
284 	),
285 	TP_printk("xid=0x%08x fh_hash=0x%08x status=%d",
286 		  __entry->xid, __entry->fh_hash,
287 		  __entry->status)
288 )
289 
290 #define DEFINE_NFSD_FH_ERR_EVENT(name)		\
291 DEFINE_EVENT(nfsd_fh_err_class, nfsd_##name,	\
292 	TP_PROTO(struct svc_rqst *rqstp,	\
293 		 struct svc_fh	*fhp,		\
294 		 int		status),	\
295 	TP_ARGS(rqstp, fhp, status))
296 
297 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport);
298 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle);
299 
300 TRACE_EVENT(nfsd_exp_find_key,
301 	TP_PROTO(const struct svc_expkey *key,
302 		 int status),
303 	TP_ARGS(key, status),
304 	TP_STRUCT__entry(
305 		__field(int, fsidtype)
306 		__array(u32, fsid, 6)
307 		__string(auth_domain, key->ek_client->name)
308 		__field(int, status)
309 	),
310 	TP_fast_assign(
311 		__entry->fsidtype = key->ek_fsidtype;
312 		memcpy(__entry->fsid, key->ek_fsid, 4*6);
313 		__assign_str(auth_domain, key->ek_client->name);
314 		__entry->status = status;
315 	),
316 	TP_printk("fsid=%x::%s domain=%s status=%d",
317 		__entry->fsidtype,
318 		__print_array(__entry->fsid, 6, 4),
319 		__get_str(auth_domain),
320 		__entry->status
321 	)
322 );
323 
324 TRACE_EVENT(nfsd_expkey_update,
325 	TP_PROTO(const struct svc_expkey *key, const char *exp_path),
326 	TP_ARGS(key, exp_path),
327 	TP_STRUCT__entry(
328 		__field(int, fsidtype)
329 		__array(u32, fsid, 6)
330 		__string(auth_domain, key->ek_client->name)
331 		__string(path, exp_path)
332 		__field(bool, cache)
333 	),
334 	TP_fast_assign(
335 		__entry->fsidtype = key->ek_fsidtype;
336 		memcpy(__entry->fsid, key->ek_fsid, 4*6);
337 		__assign_str(auth_domain, key->ek_client->name);
338 		__assign_str(path, exp_path);
339 		__entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
340 	),
341 	TP_printk("fsid=%x::%s domain=%s path=%s cache=%s",
342 		__entry->fsidtype,
343 		__print_array(__entry->fsid, 6, 4),
344 		__get_str(auth_domain),
345 		__get_str(path),
346 		__entry->cache ? "pos" : "neg"
347 	)
348 );
349 
350 TRACE_EVENT(nfsd_exp_get_by_name,
351 	TP_PROTO(const struct svc_export *key,
352 		 int status),
353 	TP_ARGS(key, status),
354 	TP_STRUCT__entry(
355 		__string(path, key->ex_path.dentry->d_name.name)
356 		__string(auth_domain, key->ex_client->name)
357 		__field(int, status)
358 	),
359 	TP_fast_assign(
360 		__assign_str(path, key->ex_path.dentry->d_name.name);
361 		__assign_str(auth_domain, key->ex_client->name);
362 		__entry->status = status;
363 	),
364 	TP_printk("path=%s domain=%s status=%d",
365 		__get_str(path),
366 		__get_str(auth_domain),
367 		__entry->status
368 	)
369 );
370 
371 TRACE_EVENT(nfsd_export_update,
372 	TP_PROTO(const struct svc_export *key),
373 	TP_ARGS(key),
374 	TP_STRUCT__entry(
375 		__string(path, key->ex_path.dentry->d_name.name)
376 		__string(auth_domain, key->ex_client->name)
377 		__field(bool, cache)
378 	),
379 	TP_fast_assign(
380 		__assign_str(path, key->ex_path.dentry->d_name.name);
381 		__assign_str(auth_domain, key->ex_client->name);
382 		__entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
383 	),
384 	TP_printk("path=%s domain=%s cache=%s",
385 		__get_str(path),
386 		__get_str(auth_domain),
387 		__entry->cache ? "pos" : "neg"
388 	)
389 );
390 
391 DECLARE_EVENT_CLASS(nfsd_io_class,
392 	TP_PROTO(struct svc_rqst *rqstp,
393 		 struct svc_fh	*fhp,
394 		 u64		offset,
395 		 u32		len),
396 	TP_ARGS(rqstp, fhp, offset, len),
397 	TP_STRUCT__entry(
398 		__field(u32, xid)
399 		__field(u32, fh_hash)
400 		__field(u64, offset)
401 		__field(u32, len)
402 	),
403 	TP_fast_assign(
404 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
405 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
406 		__entry->offset = offset;
407 		__entry->len = len;
408 	),
409 	TP_printk("xid=0x%08x fh_hash=0x%08x offset=%llu len=%u",
410 		  __entry->xid, __entry->fh_hash,
411 		  __entry->offset, __entry->len)
412 )
413 
414 #define DEFINE_NFSD_IO_EVENT(name)		\
415 DEFINE_EVENT(nfsd_io_class, nfsd_##name,	\
416 	TP_PROTO(struct svc_rqst *rqstp,	\
417 		 struct svc_fh	*fhp,		\
418 		 u64		offset,		\
419 		 u32		len),		\
420 	TP_ARGS(rqstp, fhp, offset, len))
421 
422 DEFINE_NFSD_IO_EVENT(read_start);
423 DEFINE_NFSD_IO_EVENT(read_splice);
424 DEFINE_NFSD_IO_EVENT(read_vector);
425 DEFINE_NFSD_IO_EVENT(read_io_done);
426 DEFINE_NFSD_IO_EVENT(read_done);
427 DEFINE_NFSD_IO_EVENT(write_start);
428 DEFINE_NFSD_IO_EVENT(write_opened);
429 DEFINE_NFSD_IO_EVENT(write_io_done);
430 DEFINE_NFSD_IO_EVENT(write_done);
431 
432 DECLARE_EVENT_CLASS(nfsd_err_class,
433 	TP_PROTO(struct svc_rqst *rqstp,
434 		 struct svc_fh	*fhp,
435 		 loff_t		offset,
436 		 int		status),
437 	TP_ARGS(rqstp, fhp, offset, status),
438 	TP_STRUCT__entry(
439 		__field(u32, xid)
440 		__field(u32, fh_hash)
441 		__field(loff_t, offset)
442 		__field(int, status)
443 	),
444 	TP_fast_assign(
445 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
446 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
447 		__entry->offset = offset;
448 		__entry->status = status;
449 	),
450 	TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld status=%d",
451 		  __entry->xid, __entry->fh_hash,
452 		  __entry->offset, __entry->status)
453 )
454 
455 #define DEFINE_NFSD_ERR_EVENT(name)		\
456 DEFINE_EVENT(nfsd_err_class, nfsd_##name,	\
457 	TP_PROTO(struct svc_rqst *rqstp,	\
458 		 struct svc_fh	*fhp,		\
459 		 loff_t		offset,		\
460 		 int		len),		\
461 	TP_ARGS(rqstp, fhp, offset, len))
462 
463 DEFINE_NFSD_ERR_EVENT(read_err);
464 DEFINE_NFSD_ERR_EVENT(write_err);
465 
466 TRACE_EVENT(nfsd_dirent,
467 	TP_PROTO(struct svc_fh *fhp,
468 		 u64 ino,
469 		 const char *name,
470 		 int namlen),
471 	TP_ARGS(fhp, ino, name, namlen),
472 	TP_STRUCT__entry(
473 		__field(u32, fh_hash)
474 		__field(u64, ino)
475 		__string_len(name, name, namlen)
476 	),
477 	TP_fast_assign(
478 		__entry->fh_hash = fhp ? knfsd_fh_hash(&fhp->fh_handle) : 0;
479 		__entry->ino = ino;
480 		__assign_str_len(name, name, namlen)
481 	),
482 	TP_printk("fh_hash=0x%08x ino=%llu name=%s",
483 		__entry->fh_hash, __entry->ino, __get_str(name)
484 	)
485 )
486 
487 DECLARE_EVENT_CLASS(nfsd_copy_err_class,
488 	TP_PROTO(struct svc_rqst *rqstp,
489 		 struct svc_fh	*src_fhp,
490 		 loff_t		src_offset,
491 		 struct svc_fh	*dst_fhp,
492 		 loff_t		dst_offset,
493 		 u64		count,
494 		 int		status),
495 	TP_ARGS(rqstp, src_fhp, src_offset, dst_fhp, dst_offset, count, status),
496 	TP_STRUCT__entry(
497 		__field(u32, xid)
498 		__field(u32, src_fh_hash)
499 		__field(loff_t, src_offset)
500 		__field(u32, dst_fh_hash)
501 		__field(loff_t, dst_offset)
502 		__field(u64, count)
503 		__field(int, status)
504 	),
505 	TP_fast_assign(
506 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
507 		__entry->src_fh_hash = knfsd_fh_hash(&src_fhp->fh_handle);
508 		__entry->src_offset = src_offset;
509 		__entry->dst_fh_hash = knfsd_fh_hash(&dst_fhp->fh_handle);
510 		__entry->dst_offset = dst_offset;
511 		__entry->count = count;
512 		__entry->status = status;
513 	),
514 	TP_printk("xid=0x%08x src_fh_hash=0x%08x src_offset=%lld "
515 			"dst_fh_hash=0x%08x dst_offset=%lld "
516 			"count=%llu status=%d",
517 		  __entry->xid, __entry->src_fh_hash, __entry->src_offset,
518 		  __entry->dst_fh_hash, __entry->dst_offset,
519 		  (unsigned long long)__entry->count,
520 		  __entry->status)
521 )
522 
523 #define DEFINE_NFSD_COPY_ERR_EVENT(name)		\
524 DEFINE_EVENT(nfsd_copy_err_class, nfsd_##name,		\
525 	TP_PROTO(struct svc_rqst	*rqstp,		\
526 		 struct svc_fh		*src_fhp,	\
527 		 loff_t			src_offset,	\
528 		 struct svc_fh		*dst_fhp,	\
529 		 loff_t			dst_offset,	\
530 		 u64			count,		\
531 		 int			status),	\
532 	TP_ARGS(rqstp, src_fhp, src_offset, dst_fhp, dst_offset, \
533 		count, status))
534 
535 DEFINE_NFSD_COPY_ERR_EVENT(clone_file_range_err);
536 
537 #include "state.h"
538 #include "filecache.h"
539 #include "vfs.h"
540 
541 TRACE_EVENT(nfsd_delegret_wakeup,
542 	TP_PROTO(
543 		const struct svc_rqst *rqstp,
544 		const struct inode *inode,
545 		long timeo
546 	),
547 	TP_ARGS(rqstp, inode, timeo),
548 	TP_STRUCT__entry(
549 		__field(u32, xid)
550 		__field(const void *, inode)
551 		__field(long, timeo)
552 	),
553 	TP_fast_assign(
554 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
555 		__entry->inode = inode;
556 		__entry->timeo = timeo;
557 	),
558 	TP_printk("xid=0x%08x inode=%p%s",
559 		  __entry->xid, __entry->inode,
560 		  __entry->timeo == 0 ? " (timed out)" : ""
561 	)
562 );
563 
564 DECLARE_EVENT_CLASS(nfsd_stateid_class,
565 	TP_PROTO(stateid_t *stp),
566 	TP_ARGS(stp),
567 	TP_STRUCT__entry(
568 		__field(u32, cl_boot)
569 		__field(u32, cl_id)
570 		__field(u32, si_id)
571 		__field(u32, si_generation)
572 	),
573 	TP_fast_assign(
574 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
575 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
576 		__entry->si_id = stp->si_opaque.so_id;
577 		__entry->si_generation = stp->si_generation;
578 	),
579 	TP_printk("client %08x:%08x stateid %08x:%08x",
580 		__entry->cl_boot,
581 		__entry->cl_id,
582 		__entry->si_id,
583 		__entry->si_generation)
584 )
585 
586 #define DEFINE_STATEID_EVENT(name) \
587 DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \
588 	TP_PROTO(stateid_t *stp), \
589 	TP_ARGS(stp))
590 
591 DEFINE_STATEID_EVENT(layoutstate_alloc);
592 DEFINE_STATEID_EVENT(layoutstate_unhash);
593 DEFINE_STATEID_EVENT(layoutstate_free);
594 DEFINE_STATEID_EVENT(layout_get_lookup_fail);
595 DEFINE_STATEID_EVENT(layout_commit_lookup_fail);
596 DEFINE_STATEID_EVENT(layout_return_lookup_fail);
597 DEFINE_STATEID_EVENT(layout_recall);
598 DEFINE_STATEID_EVENT(layout_recall_done);
599 DEFINE_STATEID_EVENT(layout_recall_fail);
600 DEFINE_STATEID_EVENT(layout_recall_release);
601 
602 DEFINE_STATEID_EVENT(open);
603 DEFINE_STATEID_EVENT(deleg_read);
604 DEFINE_STATEID_EVENT(deleg_recall);
605 
606 DECLARE_EVENT_CLASS(nfsd_stateseqid_class,
607 	TP_PROTO(u32 seqid, const stateid_t *stp),
608 	TP_ARGS(seqid, stp),
609 	TP_STRUCT__entry(
610 		__field(u32, seqid)
611 		__field(u32, cl_boot)
612 		__field(u32, cl_id)
613 		__field(u32, si_id)
614 		__field(u32, si_generation)
615 	),
616 	TP_fast_assign(
617 		__entry->seqid = seqid;
618 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
619 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
620 		__entry->si_id = stp->si_opaque.so_id;
621 		__entry->si_generation = stp->si_generation;
622 	),
623 	TP_printk("seqid=%u client %08x:%08x stateid %08x:%08x",
624 		__entry->seqid, __entry->cl_boot, __entry->cl_id,
625 		__entry->si_id, __entry->si_generation)
626 )
627 
628 #define DEFINE_STATESEQID_EVENT(name) \
629 DEFINE_EVENT(nfsd_stateseqid_class, nfsd_##name, \
630 	TP_PROTO(u32 seqid, const stateid_t *stp), \
631 	TP_ARGS(seqid, stp))
632 
633 DEFINE_STATESEQID_EVENT(preprocess);
634 DEFINE_STATESEQID_EVENT(open_confirm);
635 
636 DECLARE_EVENT_CLASS(nfsd_clientid_class,
637 	TP_PROTO(const clientid_t *clid),
638 	TP_ARGS(clid),
639 	TP_STRUCT__entry(
640 		__field(u32, cl_boot)
641 		__field(u32, cl_id)
642 	),
643 	TP_fast_assign(
644 		__entry->cl_boot = clid->cl_boot;
645 		__entry->cl_id = clid->cl_id;
646 	),
647 	TP_printk("client %08x:%08x", __entry->cl_boot, __entry->cl_id)
648 )
649 
650 #define DEFINE_CLIENTID_EVENT(name) \
651 DEFINE_EVENT(nfsd_clientid_class, nfsd_clid_##name, \
652 	TP_PROTO(const clientid_t *clid), \
653 	TP_ARGS(clid))
654 
655 DEFINE_CLIENTID_EVENT(expire_unconf);
656 DEFINE_CLIENTID_EVENT(reclaim_complete);
657 DEFINE_CLIENTID_EVENT(confirmed);
658 DEFINE_CLIENTID_EVENT(destroyed);
659 DEFINE_CLIENTID_EVENT(admin_expired);
660 DEFINE_CLIENTID_EVENT(replaced);
661 DEFINE_CLIENTID_EVENT(purged);
662 DEFINE_CLIENTID_EVENT(renew);
663 DEFINE_CLIENTID_EVENT(stale);
664 
665 DECLARE_EVENT_CLASS(nfsd_net_class,
666 	TP_PROTO(const struct nfsd_net *nn),
667 	TP_ARGS(nn),
668 	TP_STRUCT__entry(
669 		__field(unsigned long long, boot_time)
670 	),
671 	TP_fast_assign(
672 		__entry->boot_time = nn->boot_time;
673 	),
674 	TP_printk("boot_time=%16llx", __entry->boot_time)
675 )
676 
677 #define DEFINE_NET_EVENT(name) \
678 DEFINE_EVENT(nfsd_net_class, nfsd_##name, \
679 	TP_PROTO(const struct nfsd_net *nn), \
680 	TP_ARGS(nn))
681 
682 DEFINE_NET_EVENT(grace_start);
683 DEFINE_NET_EVENT(grace_complete);
684 
685 TRACE_EVENT(nfsd_writeverf_reset,
686 	TP_PROTO(
687 		const struct nfsd_net *nn,
688 		const struct svc_rqst *rqstp,
689 		int error
690 	),
691 	TP_ARGS(nn, rqstp, error),
692 	TP_STRUCT__entry(
693 		__field(unsigned long long, boot_time)
694 		__field(u32, xid)
695 		__field(int, error)
696 		__array(unsigned char, verifier, NFS4_VERIFIER_SIZE)
697 	),
698 	TP_fast_assign(
699 		__entry->boot_time = nn->boot_time;
700 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
701 		__entry->error = error;
702 
703 		/* avoid seqlock inside TP_fast_assign */
704 		memcpy(__entry->verifier, nn->writeverf,
705 		       NFS4_VERIFIER_SIZE);
706 	),
707 	TP_printk("boot_time=%16llx xid=0x%08x error=%d new verifier=0x%s",
708 		__entry->boot_time, __entry->xid, __entry->error,
709 		__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
710 	)
711 );
712 
713 TRACE_EVENT(nfsd_clid_cred_mismatch,
714 	TP_PROTO(
715 		const struct nfs4_client *clp,
716 		const struct svc_rqst *rqstp
717 	),
718 	TP_ARGS(clp, rqstp),
719 	TP_STRUCT__entry(
720 		__field(u32, cl_boot)
721 		__field(u32, cl_id)
722 		__field(unsigned long, cl_flavor)
723 		__field(unsigned long, new_flavor)
724 		__sockaddr(addr, rqstp->rq_xprt->xpt_remotelen)
725 	),
726 	TP_fast_assign(
727 		__entry->cl_boot = clp->cl_clientid.cl_boot;
728 		__entry->cl_id = clp->cl_clientid.cl_id;
729 		__entry->cl_flavor = clp->cl_cred.cr_flavor;
730 		__entry->new_flavor = rqstp->rq_cred.cr_flavor;
731 		__assign_sockaddr(addr, &rqstp->rq_xprt->xpt_remote,
732 				  rqstp->rq_xprt->xpt_remotelen);
733 	),
734 	TP_printk("client %08x:%08x flavor=%s, conflict=%s from addr=%pISpc",
735 		__entry->cl_boot, __entry->cl_id,
736 		show_nfsd_authflavor(__entry->cl_flavor),
737 		show_nfsd_authflavor(__entry->new_flavor),
738 		__get_sockaddr(addr)
739 	)
740 )
741 
742 TRACE_EVENT(nfsd_clid_verf_mismatch,
743 	TP_PROTO(
744 		const struct nfs4_client *clp,
745 		const struct svc_rqst *rqstp,
746 		const nfs4_verifier *verf
747 	),
748 	TP_ARGS(clp, rqstp, verf),
749 	TP_STRUCT__entry(
750 		__field(u32, cl_boot)
751 		__field(u32, cl_id)
752 		__array(unsigned char, cl_verifier, NFS4_VERIFIER_SIZE)
753 		__array(unsigned char, new_verifier, NFS4_VERIFIER_SIZE)
754 		__sockaddr(addr, rqstp->rq_xprt->xpt_remotelen)
755 	),
756 	TP_fast_assign(
757 		__entry->cl_boot = clp->cl_clientid.cl_boot;
758 		__entry->cl_id = clp->cl_clientid.cl_id;
759 		memcpy(__entry->cl_verifier, (void *)&clp->cl_verifier,
760 		       NFS4_VERIFIER_SIZE);
761 		memcpy(__entry->new_verifier, (void *)verf,
762 		       NFS4_VERIFIER_SIZE);
763 		__assign_sockaddr(addr, &rqstp->rq_xprt->xpt_remote,
764 				  rqstp->rq_xprt->xpt_remotelen);
765 	),
766 	TP_printk("client %08x:%08x verf=0x%s, updated=0x%s from addr=%pISpc",
767 		__entry->cl_boot, __entry->cl_id,
768 		__print_hex_str(__entry->cl_verifier, NFS4_VERIFIER_SIZE),
769 		__print_hex_str(__entry->new_verifier, NFS4_VERIFIER_SIZE),
770 		__get_sockaddr(addr)
771 	)
772 );
773 
774 DECLARE_EVENT_CLASS(nfsd_clid_class,
775 	TP_PROTO(const struct nfs4_client *clp),
776 	TP_ARGS(clp),
777 	TP_STRUCT__entry(
778 		__field(u32, cl_boot)
779 		__field(u32, cl_id)
780 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
781 		__field(unsigned long, flavor)
782 		__array(unsigned char, verifier, NFS4_VERIFIER_SIZE)
783 		__string_len(name, name, clp->cl_name.len)
784 	),
785 	TP_fast_assign(
786 		__entry->cl_boot = clp->cl_clientid.cl_boot;
787 		__entry->cl_id = clp->cl_clientid.cl_id;
788 		memcpy(__entry->addr, &clp->cl_addr,
789 			sizeof(struct sockaddr_in6));
790 		__entry->flavor = clp->cl_cred.cr_flavor;
791 		memcpy(__entry->verifier, (void *)&clp->cl_verifier,
792 		       NFS4_VERIFIER_SIZE);
793 		__assign_str_len(name, clp->cl_name.data, clp->cl_name.len);
794 	),
795 	TP_printk("addr=%pISpc name='%s' verifier=0x%s flavor=%s client=%08x:%08x",
796 		__entry->addr, __get_str(name),
797 		__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE),
798 		show_nfsd_authflavor(__entry->flavor),
799 		__entry->cl_boot, __entry->cl_id)
800 );
801 
802 #define DEFINE_CLID_EVENT(name) \
803 DEFINE_EVENT(nfsd_clid_class, nfsd_clid_##name, \
804 	TP_PROTO(const struct nfs4_client *clp), \
805 	TP_ARGS(clp))
806 
807 DEFINE_CLID_EVENT(fresh);
808 DEFINE_CLID_EVENT(confirmed_r);
809 
810 /*
811  * from fs/nfsd/filecache.h
812  */
813 #define show_nf_flags(val)						\
814 	__print_flags(val, "|",						\
815 		{ 1 << NFSD_FILE_HASHED,	"HASHED" },		\
816 		{ 1 << NFSD_FILE_PENDING,	"PENDING" },		\
817 		{ 1 << NFSD_FILE_REFERENCED,	"REFERENCED"})
818 
819 DECLARE_EVENT_CLASS(nfsd_file_class,
820 	TP_PROTO(struct nfsd_file *nf),
821 	TP_ARGS(nf),
822 	TP_STRUCT__entry(
823 		__field(void *, nf_inode)
824 		__field(int, nf_ref)
825 		__field(unsigned long, nf_flags)
826 		__field(unsigned char, nf_may)
827 		__field(struct file *, nf_file)
828 	),
829 	TP_fast_assign(
830 		__entry->nf_inode = nf->nf_inode;
831 		__entry->nf_ref = refcount_read(&nf->nf_ref);
832 		__entry->nf_flags = nf->nf_flags;
833 		__entry->nf_may = nf->nf_may;
834 		__entry->nf_file = nf->nf_file;
835 	),
836 	TP_printk("inode=%p ref=%d flags=%s may=%s nf_file=%p",
837 		__entry->nf_inode,
838 		__entry->nf_ref,
839 		show_nf_flags(__entry->nf_flags),
840 		show_nfsd_may_flags(__entry->nf_may),
841 		__entry->nf_file)
842 )
843 
844 #define DEFINE_NFSD_FILE_EVENT(name) \
845 DEFINE_EVENT(nfsd_file_class, name, \
846 	TP_PROTO(struct nfsd_file *nf), \
847 	TP_ARGS(nf))
848 
849 DEFINE_NFSD_FILE_EVENT(nfsd_file_put_final);
850 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash);
851 DEFINE_NFSD_FILE_EVENT(nfsd_file_put);
852 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_dispose);
853 
854 TRACE_EVENT(nfsd_file_alloc,
855 	TP_PROTO(
856 		const struct nfsd_file *nf
857 	),
858 	TP_ARGS(nf),
859 	TP_STRUCT__entry(
860 		__field(const void *, nf_inode)
861 		__field(unsigned long, nf_flags)
862 		__field(unsigned long, nf_may)
863 		__field(unsigned int, nf_ref)
864 	),
865 	TP_fast_assign(
866 		__entry->nf_inode = nf->nf_inode;
867 		__entry->nf_flags = nf->nf_flags;
868 		__entry->nf_ref = refcount_read(&nf->nf_ref);
869 		__entry->nf_may = nf->nf_may;
870 	),
871 	TP_printk("inode=%p ref=%u flags=%s may=%s",
872 		__entry->nf_inode, __entry->nf_ref,
873 		show_nf_flags(__entry->nf_flags),
874 		show_nfsd_may_flags(__entry->nf_may)
875 	)
876 );
877 
878 TRACE_EVENT(nfsd_file_acquire,
879 	TP_PROTO(
880 		const struct svc_rqst *rqstp,
881 		const struct inode *inode,
882 		unsigned int may_flags,
883 		const struct nfsd_file *nf,
884 		__be32 status
885 	),
886 
887 	TP_ARGS(rqstp, inode, may_flags, nf, status),
888 
889 	TP_STRUCT__entry(
890 		__field(u32, xid)
891 		__field(const void *, inode)
892 		__field(unsigned long, may_flags)
893 		__field(unsigned int, nf_ref)
894 		__field(unsigned long, nf_flags)
895 		__field(unsigned long, nf_may)
896 		__field(const void *, nf_file)
897 		__field(u32, status)
898 	),
899 
900 	TP_fast_assign(
901 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
902 		__entry->inode = inode;
903 		__entry->may_flags = may_flags;
904 		__entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0;
905 		__entry->nf_flags = nf ? nf->nf_flags : 0;
906 		__entry->nf_may = nf ? nf->nf_may : 0;
907 		__entry->nf_file = nf ? nf->nf_file : NULL;
908 		__entry->status = be32_to_cpu(status);
909 	),
910 
911 	TP_printk("xid=0x%x inode=%p may_flags=%s ref=%u nf_flags=%s nf_may=%s nf_file=%p status=%u",
912 			__entry->xid, __entry->inode,
913 			show_nfsd_may_flags(__entry->may_flags),
914 			__entry->nf_ref, show_nf_flags(__entry->nf_flags),
915 			show_nfsd_may_flags(__entry->nf_may),
916 			__entry->nf_file, __entry->status
917 	)
918 );
919 
920 TRACE_EVENT(nfsd_file_create,
921 	TP_PROTO(
922 		const struct svc_rqst *rqstp,
923 		unsigned int may_flags,
924 		const struct nfsd_file *nf
925 	),
926 
927 	TP_ARGS(rqstp, may_flags, nf),
928 
929 	TP_STRUCT__entry(
930 		__field(const void *, nf_inode)
931 		__field(const void *, nf_file)
932 		__field(unsigned long, may_flags)
933 		__field(unsigned long, nf_flags)
934 		__field(unsigned long, nf_may)
935 		__field(unsigned int, nf_ref)
936 		__field(u32, xid)
937 	),
938 
939 	TP_fast_assign(
940 		__entry->nf_inode = nf->nf_inode;
941 		__entry->nf_file = nf->nf_file;
942 		__entry->may_flags = may_flags;
943 		__entry->nf_flags = nf->nf_flags;
944 		__entry->nf_may = nf->nf_may;
945 		__entry->nf_ref = refcount_read(&nf->nf_ref);
946 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
947 	),
948 
949 	TP_printk("xid=0x%x inode=%p may_flags=%s ref=%u nf_flags=%s nf_may=%s nf_file=%p",
950 		__entry->xid, __entry->nf_inode,
951 		show_nfsd_may_flags(__entry->may_flags),
952 		__entry->nf_ref, show_nf_flags(__entry->nf_flags),
953 		show_nfsd_may_flags(__entry->nf_may), __entry->nf_file
954 	)
955 );
956 
957 TRACE_EVENT(nfsd_file_insert_err,
958 	TP_PROTO(
959 		const struct svc_rqst *rqstp,
960 		const struct inode *inode,
961 		unsigned int may_flags,
962 		long error
963 	),
964 	TP_ARGS(rqstp, inode, may_flags, error),
965 	TP_STRUCT__entry(
966 		__field(u32, xid)
967 		__field(const void *, inode)
968 		__field(unsigned long, may_flags)
969 		__field(long, error)
970 	),
971 	TP_fast_assign(
972 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
973 		__entry->inode = inode;
974 		__entry->may_flags = may_flags;
975 		__entry->error = error;
976 	),
977 	TP_printk("xid=0x%x inode=%p may_flags=%s error=%ld",
978 		__entry->xid, __entry->inode,
979 		show_nfsd_may_flags(__entry->may_flags),
980 		__entry->error
981 	)
982 );
983 
984 TRACE_EVENT(nfsd_file_cons_err,
985 	TP_PROTO(
986 		const struct svc_rqst *rqstp,
987 		const struct inode *inode,
988 		unsigned int may_flags,
989 		const struct nfsd_file *nf
990 	),
991 	TP_ARGS(rqstp, inode, may_flags, nf),
992 	TP_STRUCT__entry(
993 		__field(u32, xid)
994 		__field(const void *, inode)
995 		__field(unsigned long, may_flags)
996 		__field(unsigned int, nf_ref)
997 		__field(unsigned long, nf_flags)
998 		__field(unsigned long, nf_may)
999 		__field(const void *, nf_file)
1000 	),
1001 	TP_fast_assign(
1002 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
1003 		__entry->inode = inode;
1004 		__entry->may_flags = may_flags;
1005 		__entry->nf_ref = refcount_read(&nf->nf_ref);
1006 		__entry->nf_flags = nf->nf_flags;
1007 		__entry->nf_may = nf->nf_may;
1008 		__entry->nf_file = nf->nf_file;
1009 	),
1010 	TP_printk("xid=0x%x inode=%p may_flags=%s ref=%u nf_flags=%s nf_may=%s nf_file=%p",
1011 		__entry->xid, __entry->inode,
1012 		show_nfsd_may_flags(__entry->may_flags), __entry->nf_ref,
1013 		show_nf_flags(__entry->nf_flags),
1014 		show_nfsd_may_flags(__entry->nf_may), __entry->nf_file
1015 	)
1016 );
1017 
1018 TRACE_EVENT(nfsd_file_open,
1019 	TP_PROTO(struct nfsd_file *nf, __be32 status),
1020 	TP_ARGS(nf, status),
1021 	TP_STRUCT__entry(
1022 		__field(void *, nf_inode)	/* cannot be dereferenced */
1023 		__field(int, nf_ref)
1024 		__field(unsigned long, nf_flags)
1025 		__field(unsigned long, nf_may)
1026 		__field(void *, nf_file)	/* cannot be dereferenced */
1027 	),
1028 	TP_fast_assign(
1029 		__entry->nf_inode = nf->nf_inode;
1030 		__entry->nf_ref = refcount_read(&nf->nf_ref);
1031 		__entry->nf_flags = nf->nf_flags;
1032 		__entry->nf_may = nf->nf_may;
1033 		__entry->nf_file = nf->nf_file;
1034 	),
1035 	TP_printk("inode=%p ref=%d flags=%s may=%s file=%p",
1036 		__entry->nf_inode,
1037 		__entry->nf_ref,
1038 		show_nf_flags(__entry->nf_flags),
1039 		show_nfsd_may_flags(__entry->nf_may),
1040 		__entry->nf_file)
1041 )
1042 
1043 DECLARE_EVENT_CLASS(nfsd_file_search_class,
1044 	TP_PROTO(
1045 		const struct inode *inode,
1046 		unsigned int count
1047 	),
1048 	TP_ARGS(inode, count),
1049 	TP_STRUCT__entry(
1050 		__field(const struct inode *, inode)
1051 		__field(unsigned int, count)
1052 	),
1053 	TP_fast_assign(
1054 		__entry->inode = inode;
1055 		__entry->count = count;
1056 	),
1057 	TP_printk("inode=%p count=%u",
1058 		__entry->inode, __entry->count)
1059 );
1060 
1061 #define DEFINE_NFSD_FILE_SEARCH_EVENT(name)				\
1062 DEFINE_EVENT(nfsd_file_search_class, name,				\
1063 	TP_PROTO(							\
1064 		const struct inode *inode,				\
1065 		unsigned int count					\
1066 	),								\
1067 	TP_ARGS(inode, count))
1068 
1069 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode_sync);
1070 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode);
1071 
1072 TRACE_EVENT(nfsd_file_is_cached,
1073 	TP_PROTO(
1074 		const struct inode *inode,
1075 		int found
1076 	),
1077 	TP_ARGS(inode, found),
1078 	TP_STRUCT__entry(
1079 		__field(const struct inode *, inode)
1080 		__field(int, found)
1081 	),
1082 	TP_fast_assign(
1083 		__entry->inode = inode;
1084 		__entry->found = found;
1085 	),
1086 	TP_printk("inode=%p is %scached",
1087 		__entry->inode,
1088 		__entry->found ? "" : "not "
1089 	)
1090 );
1091 
1092 TRACE_EVENT(nfsd_file_fsnotify_handle_event,
1093 	TP_PROTO(struct inode *inode, u32 mask),
1094 	TP_ARGS(inode, mask),
1095 	TP_STRUCT__entry(
1096 		__field(struct inode *, inode)
1097 		__field(unsigned int, nlink)
1098 		__field(umode_t, mode)
1099 		__field(u32, mask)
1100 	),
1101 	TP_fast_assign(
1102 		__entry->inode = inode;
1103 		__entry->nlink = inode->i_nlink;
1104 		__entry->mode = inode->i_mode;
1105 		__entry->mask = mask;
1106 	),
1107 	TP_printk("inode=%p nlink=%u mode=0%ho mask=0x%x", __entry->inode,
1108 			__entry->nlink, __entry->mode, __entry->mask)
1109 );
1110 
1111 DECLARE_EVENT_CLASS(nfsd_file_gc_class,
1112 	TP_PROTO(
1113 		const struct nfsd_file *nf
1114 	),
1115 	TP_ARGS(nf),
1116 	TP_STRUCT__entry(
1117 		__field(void *, nf_inode)
1118 		__field(void *, nf_file)
1119 		__field(int, nf_ref)
1120 		__field(unsigned long, nf_flags)
1121 	),
1122 	TP_fast_assign(
1123 		__entry->nf_inode = nf->nf_inode;
1124 		__entry->nf_file = nf->nf_file;
1125 		__entry->nf_ref = refcount_read(&nf->nf_ref);
1126 		__entry->nf_flags = nf->nf_flags;
1127 	),
1128 	TP_printk("inode=%p ref=%d nf_flags=%s nf_file=%p",
1129 		__entry->nf_inode, __entry->nf_ref,
1130 		show_nf_flags(__entry->nf_flags),
1131 		__entry->nf_file
1132 	)
1133 );
1134 
1135 #define DEFINE_NFSD_FILE_GC_EVENT(name)					\
1136 DEFINE_EVENT(nfsd_file_gc_class, name,					\
1137 	TP_PROTO(							\
1138 		const struct nfsd_file *nf				\
1139 	),								\
1140 	TP_ARGS(nf))
1141 
1142 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add);
1143 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add_disposed);
1144 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del);
1145 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del_disposed);
1146 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_in_use);
1147 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_writeback);
1148 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_referenced);
1149 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_hashed);
1150 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_disposed);
1151 
1152 DECLARE_EVENT_CLASS(nfsd_file_lruwalk_class,
1153 	TP_PROTO(
1154 		unsigned long removed,
1155 		unsigned long remaining
1156 	),
1157 	TP_ARGS(removed, remaining),
1158 	TP_STRUCT__entry(
1159 		__field(unsigned long, removed)
1160 		__field(unsigned long, remaining)
1161 	),
1162 	TP_fast_assign(
1163 		__entry->removed = removed;
1164 		__entry->remaining = remaining;
1165 	),
1166 	TP_printk("%lu entries removed, %lu remaining",
1167 		__entry->removed, __entry->remaining)
1168 );
1169 
1170 #define DEFINE_NFSD_FILE_LRUWALK_EVENT(name)				\
1171 DEFINE_EVENT(nfsd_file_lruwalk_class, name,				\
1172 	TP_PROTO(							\
1173 		unsigned long removed,					\
1174 		unsigned long remaining					\
1175 	),								\
1176 	TP_ARGS(removed, remaining))
1177 
1178 DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_removed);
1179 DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_shrinker_removed);
1180 
1181 #include "cache.h"
1182 
1183 TRACE_DEFINE_ENUM(RC_DROPIT);
1184 TRACE_DEFINE_ENUM(RC_REPLY);
1185 TRACE_DEFINE_ENUM(RC_DOIT);
1186 
1187 #define show_drc_retval(x)						\
1188 	__print_symbolic(x,						\
1189 		{ RC_DROPIT, "DROPIT" },				\
1190 		{ RC_REPLY, "REPLY" },					\
1191 		{ RC_DOIT, "DOIT" })
1192 
1193 TRACE_EVENT(nfsd_drc_found,
1194 	TP_PROTO(
1195 		const struct nfsd_net *nn,
1196 		const struct svc_rqst *rqstp,
1197 		int result
1198 	),
1199 	TP_ARGS(nn, rqstp, result),
1200 	TP_STRUCT__entry(
1201 		__field(unsigned long long, boot_time)
1202 		__field(unsigned long, result)
1203 		__field(u32, xid)
1204 	),
1205 	TP_fast_assign(
1206 		__entry->boot_time = nn->boot_time;
1207 		__entry->result = result;
1208 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
1209 	),
1210 	TP_printk("boot_time=%16llx xid=0x%08x result=%s",
1211 		__entry->boot_time, __entry->xid,
1212 		show_drc_retval(__entry->result))
1213 
1214 );
1215 
1216 TRACE_EVENT(nfsd_drc_mismatch,
1217 	TP_PROTO(
1218 		const struct nfsd_net *nn,
1219 		const struct svc_cacherep *key,
1220 		const struct svc_cacherep *rp
1221 	),
1222 	TP_ARGS(nn, key, rp),
1223 	TP_STRUCT__entry(
1224 		__field(unsigned long long, boot_time)
1225 		__field(u32, xid)
1226 		__field(u32, cached)
1227 		__field(u32, ingress)
1228 	),
1229 	TP_fast_assign(
1230 		__entry->boot_time = nn->boot_time;
1231 		__entry->xid = be32_to_cpu(key->c_key.k_xid);
1232 		__entry->cached = (__force u32)key->c_key.k_csum;
1233 		__entry->ingress = (__force u32)rp->c_key.k_csum;
1234 	),
1235 	TP_printk("boot_time=%16llx xid=0x%08x cached-csum=0x%08x ingress-csum=0x%08x",
1236 		__entry->boot_time, __entry->xid, __entry->cached,
1237 		__entry->ingress)
1238 );
1239 
1240 TRACE_EVENT(nfsd_cb_args,
1241 	TP_PROTO(
1242 		const struct nfs4_client *clp,
1243 		const struct nfs4_cb_conn *conn
1244 	),
1245 	TP_ARGS(clp, conn),
1246 	TP_STRUCT__entry(
1247 		__field(u32, cl_boot)
1248 		__field(u32, cl_id)
1249 		__field(u32, prog)
1250 		__field(u32, ident)
1251 		__sockaddr(addr, conn->cb_addrlen)
1252 	),
1253 	TP_fast_assign(
1254 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1255 		__entry->cl_id = clp->cl_clientid.cl_id;
1256 		__entry->prog = conn->cb_prog;
1257 		__entry->ident = conn->cb_ident;
1258 		__assign_sockaddr(addr, &conn->cb_addr, conn->cb_addrlen);
1259 	),
1260 	TP_printk("addr=%pISpc client %08x:%08x prog=%u ident=%u",
1261 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1262 		__entry->prog, __entry->ident)
1263 );
1264 
1265 TRACE_EVENT(nfsd_cb_nodelegs,
1266 	TP_PROTO(const struct nfs4_client *clp),
1267 	TP_ARGS(clp),
1268 	TP_STRUCT__entry(
1269 		__field(u32, cl_boot)
1270 		__field(u32, cl_id)
1271 	),
1272 	TP_fast_assign(
1273 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1274 		__entry->cl_id = clp->cl_clientid.cl_id;
1275 	),
1276 	TP_printk("client %08x:%08x", __entry->cl_boot, __entry->cl_id)
1277 )
1278 
1279 #define show_cb_state(val)						\
1280 	__print_symbolic(val,						\
1281 		{ NFSD4_CB_UP,		"UP" },				\
1282 		{ NFSD4_CB_UNKNOWN,	"UNKNOWN" },			\
1283 		{ NFSD4_CB_DOWN,	"DOWN" },			\
1284 		{ NFSD4_CB_FAULT,	"FAULT"})
1285 
1286 DECLARE_EVENT_CLASS(nfsd_cb_class,
1287 	TP_PROTO(const struct nfs4_client *clp),
1288 	TP_ARGS(clp),
1289 	TP_STRUCT__entry(
1290 		__field(unsigned long, state)
1291 		__field(u32, cl_boot)
1292 		__field(u32, cl_id)
1293 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1294 	),
1295 	TP_fast_assign(
1296 		__entry->state = clp->cl_cb_state;
1297 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1298 		__entry->cl_id = clp->cl_clientid.cl_id;
1299 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1300 				  clp->cl_cb_conn.cb_addrlen)
1301 	),
1302 	TP_printk("addr=%pISpc client %08x:%08x state=%s",
1303 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1304 		show_cb_state(__entry->state))
1305 );
1306 
1307 #define DEFINE_NFSD_CB_EVENT(name)			\
1308 DEFINE_EVENT(nfsd_cb_class, nfsd_cb_##name,		\
1309 	TP_PROTO(const struct nfs4_client *clp),	\
1310 	TP_ARGS(clp))
1311 
1312 DEFINE_NFSD_CB_EVENT(state);
1313 DEFINE_NFSD_CB_EVENT(probe);
1314 DEFINE_NFSD_CB_EVENT(lost);
1315 DEFINE_NFSD_CB_EVENT(shutdown);
1316 
1317 TRACE_DEFINE_ENUM(RPC_AUTH_NULL);
1318 TRACE_DEFINE_ENUM(RPC_AUTH_UNIX);
1319 TRACE_DEFINE_ENUM(RPC_AUTH_GSS);
1320 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5);
1321 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5I);
1322 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5P);
1323 
1324 #define show_nfsd_authflavor(val)					\
1325 	__print_symbolic(val,						\
1326 		{ RPC_AUTH_NULL,		"none" },		\
1327 		{ RPC_AUTH_UNIX,		"sys" },		\
1328 		{ RPC_AUTH_GSS,			"gss" },		\
1329 		{ RPC_AUTH_GSS_KRB5,		"krb5" },		\
1330 		{ RPC_AUTH_GSS_KRB5I,		"krb5i" },		\
1331 		{ RPC_AUTH_GSS_KRB5P,		"krb5p" })
1332 
1333 TRACE_EVENT(nfsd_cb_setup,
1334 	TP_PROTO(const struct nfs4_client *clp,
1335 		 const char *netid,
1336 		 rpc_authflavor_t authflavor
1337 	),
1338 	TP_ARGS(clp, netid, authflavor),
1339 	TP_STRUCT__entry(
1340 		__field(u32, cl_boot)
1341 		__field(u32, cl_id)
1342 		__field(unsigned long, authflavor)
1343 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1344 		__array(unsigned char, netid, 8)
1345 	),
1346 	TP_fast_assign(
1347 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1348 		__entry->cl_id = clp->cl_clientid.cl_id;
1349 		strlcpy(__entry->netid, netid, sizeof(__entry->netid));
1350 		__entry->authflavor = authflavor;
1351 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1352 				  clp->cl_cb_conn.cb_addrlen)
1353 	),
1354 	TP_printk("addr=%pISpc client %08x:%08x proto=%s flavor=%s",
1355 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1356 		__entry->netid, show_nfsd_authflavor(__entry->authflavor))
1357 );
1358 
1359 TRACE_EVENT(nfsd_cb_setup_err,
1360 	TP_PROTO(
1361 		const struct nfs4_client *clp,
1362 		long error
1363 	),
1364 	TP_ARGS(clp, error),
1365 	TP_STRUCT__entry(
1366 		__field(long, error)
1367 		__field(u32, cl_boot)
1368 		__field(u32, cl_id)
1369 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1370 	),
1371 	TP_fast_assign(
1372 		__entry->error = error;
1373 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1374 		__entry->cl_id = clp->cl_clientid.cl_id;
1375 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1376 				  clp->cl_cb_conn.cb_addrlen)
1377 	),
1378 	TP_printk("addr=%pISpc client %08x:%08x error=%ld",
1379 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1380 		__entry->error)
1381 );
1382 
1383 TRACE_EVENT_CONDITION(nfsd_cb_recall,
1384 	TP_PROTO(
1385 		const struct nfs4_stid *stid
1386 	),
1387 	TP_ARGS(stid),
1388 	TP_CONDITION(stid->sc_client),
1389 	TP_STRUCT__entry(
1390 		__field(u32, cl_boot)
1391 		__field(u32, cl_id)
1392 		__field(u32, si_id)
1393 		__field(u32, si_generation)
1394 		__sockaddr(addr, stid->sc_client->cl_cb_conn.cb_addrlen)
1395 	),
1396 	TP_fast_assign(
1397 		const stateid_t *stp = &stid->sc_stateid;
1398 		const struct nfs4_client *clp = stid->sc_client;
1399 
1400 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
1401 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
1402 		__entry->si_id = stp->si_opaque.so_id;
1403 		__entry->si_generation = stp->si_generation;
1404 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1405 				  clp->cl_cb_conn.cb_addrlen)
1406 	),
1407 	TP_printk("addr=%pISpc client %08x:%08x stateid %08x:%08x",
1408 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1409 		__entry->si_id, __entry->si_generation)
1410 );
1411 
1412 TRACE_EVENT(nfsd_cb_notify_lock,
1413 	TP_PROTO(
1414 		const struct nfs4_lockowner *lo,
1415 		const struct nfsd4_blocked_lock *nbl
1416 	),
1417 	TP_ARGS(lo, nbl),
1418 	TP_STRUCT__entry(
1419 		__field(u32, cl_boot)
1420 		__field(u32, cl_id)
1421 		__field(u32, fh_hash)
1422 		__sockaddr(addr, lo->lo_owner.so_client->cl_cb_conn.cb_addrlen)
1423 	),
1424 	TP_fast_assign(
1425 		const struct nfs4_client *clp = lo->lo_owner.so_client;
1426 
1427 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1428 		__entry->cl_id = clp->cl_clientid.cl_id;
1429 		__entry->fh_hash = knfsd_fh_hash(&nbl->nbl_fh);
1430 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1431 				  clp->cl_cb_conn.cb_addrlen)
1432 	),
1433 	TP_printk("addr=%pISpc client %08x:%08x fh_hash=0x%08x",
1434 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1435 		__entry->fh_hash)
1436 );
1437 
1438 TRACE_EVENT(nfsd_cb_offload,
1439 	TP_PROTO(
1440 		const struct nfs4_client *clp,
1441 		const stateid_t *stp,
1442 		const struct knfsd_fh *fh,
1443 		u64 count,
1444 		__be32 status
1445 	),
1446 	TP_ARGS(clp, stp, fh, count, status),
1447 	TP_STRUCT__entry(
1448 		__field(u32, cl_boot)
1449 		__field(u32, cl_id)
1450 		__field(u32, si_id)
1451 		__field(u32, si_generation)
1452 		__field(u32, fh_hash)
1453 		__field(int, status)
1454 		__field(u64, count)
1455 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1456 	),
1457 	TP_fast_assign(
1458 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
1459 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
1460 		__entry->si_id = stp->si_opaque.so_id;
1461 		__entry->si_generation = stp->si_generation;
1462 		__entry->fh_hash = knfsd_fh_hash(fh);
1463 		__entry->status = be32_to_cpu(status);
1464 		__entry->count = count;
1465 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1466 				  clp->cl_cb_conn.cb_addrlen)
1467 	),
1468 	TP_printk("addr=%pISpc client %08x:%08x stateid %08x:%08x fh_hash=0x%08x count=%llu status=%d",
1469 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1470 		__entry->si_id, __entry->si_generation,
1471 		__entry->fh_hash, __entry->count, __entry->status)
1472 );
1473 
1474 DECLARE_EVENT_CLASS(nfsd_cb_done_class,
1475 	TP_PROTO(
1476 		const stateid_t *stp,
1477 		const struct rpc_task *task
1478 	),
1479 	TP_ARGS(stp, task),
1480 	TP_STRUCT__entry(
1481 		__field(u32, cl_boot)
1482 		__field(u32, cl_id)
1483 		__field(u32, si_id)
1484 		__field(u32, si_generation)
1485 		__field(int, status)
1486 	),
1487 	TP_fast_assign(
1488 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
1489 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
1490 		__entry->si_id = stp->si_opaque.so_id;
1491 		__entry->si_generation = stp->si_generation;
1492 		__entry->status = task->tk_status;
1493 	),
1494 	TP_printk("client %08x:%08x stateid %08x:%08x status=%d",
1495 		__entry->cl_boot, __entry->cl_id, __entry->si_id,
1496 		__entry->si_generation, __entry->status
1497 	)
1498 );
1499 
1500 #define DEFINE_NFSD_CB_DONE_EVENT(name)			\
1501 DEFINE_EVENT(nfsd_cb_done_class, name,			\
1502 	TP_PROTO(					\
1503 		const stateid_t *stp,			\
1504 		const struct rpc_task *task		\
1505 	),						\
1506 	TP_ARGS(stp, task))
1507 
1508 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_recall_done);
1509 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_notify_lock_done);
1510 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_layout_done);
1511 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_offload_done);
1512 
1513 #endif /* _NFSD_TRACE_H */
1514 
1515 #undef TRACE_INCLUDE_PATH
1516 #define TRACE_INCLUDE_PATH .
1517 #define TRACE_INCLUDE_FILE trace
1518 #include <trace/define_trace.h>
1519