xref: /linux/fs/nfsd/trace.h (revision 4b660dbd9ee2059850fd30e0df420ca7a38a1856)
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 <linux/sunrpc/clnt.h>
13 #include <linux/sunrpc/xprt.h>
14 #include <trace/misc/nfs.h>
15 #include <trace/misc/sunrpc.h>
16 
17 #include "export.h"
18 #include "nfsfh.h"
19 #include "xdr4.h"
20 
21 #define NFSD_TRACE_PROC_RES_FIELDS \
22 		__field(unsigned int, netns_ino) \
23 		__field(u32, xid) \
24 		__field(unsigned long, status) \
25 		__array(unsigned char, server, sizeof(struct sockaddr_in6)) \
26 		__array(unsigned char, client, sizeof(struct sockaddr_in6))
27 
28 #define NFSD_TRACE_PROC_RES_ASSIGNMENTS(error) \
29 		do { \
30 			__entry->netns_ino = SVC_NET(rqstp)->ns.inum; \
31 			__entry->xid = be32_to_cpu(rqstp->rq_xid); \
32 			__entry->status = be32_to_cpu(error); \
33 			memcpy(__entry->server, &rqstp->rq_xprt->xpt_local, \
34 			       rqstp->rq_xprt->xpt_locallen); \
35 			memcpy(__entry->client, &rqstp->rq_xprt->xpt_remote, \
36 			       rqstp->rq_xprt->xpt_remotelen); \
37 		} while (0);
38 
39 DECLARE_EVENT_CLASS(nfsd_xdr_err_class,
40 	TP_PROTO(
41 		const struct svc_rqst *rqstp
42 	),
43 	TP_ARGS(rqstp),
44 	TP_STRUCT__entry(
45 		__field(unsigned int, netns_ino)
46 		__field(u32, xid)
47 		__field(u32, vers)
48 		__field(u32, proc)
49 		__sockaddr(server, rqstp->rq_xprt->xpt_locallen)
50 		__sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
51 	),
52 	TP_fast_assign(
53 		const struct svc_xprt *xprt = rqstp->rq_xprt;
54 
55 		__entry->netns_ino = xprt->xpt_net->ns.inum;
56 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
57 		__entry->vers = rqstp->rq_vers;
58 		__entry->proc = rqstp->rq_proc;
59 		__assign_sockaddr(server, &xprt->xpt_local, xprt->xpt_locallen);
60 		__assign_sockaddr(client, &xprt->xpt_remote, xprt->xpt_remotelen);
61 	),
62 	TP_printk("xid=0x%08x vers=%u proc=%u",
63 		__entry->xid, __entry->vers, __entry->proc
64 	)
65 );
66 
67 #define DEFINE_NFSD_XDR_ERR_EVENT(name) \
68 DEFINE_EVENT(nfsd_xdr_err_class, nfsd_##name##_err, \
69 	TP_PROTO(const struct svc_rqst *rqstp), \
70 	TP_ARGS(rqstp))
71 
72 DEFINE_NFSD_XDR_ERR_EVENT(garbage_args);
73 DEFINE_NFSD_XDR_ERR_EVENT(cant_encode);
74 
75 #define show_nfsd_may_flags(x)						\
76 	__print_flags(x, "|",						\
77 		{ NFSD_MAY_EXEC,		"EXEC" },		\
78 		{ NFSD_MAY_WRITE,		"WRITE" },		\
79 		{ NFSD_MAY_READ,		"READ" },		\
80 		{ NFSD_MAY_SATTR,		"SATTR" },		\
81 		{ NFSD_MAY_TRUNC,		"TRUNC" },		\
82 		{ NFSD_MAY_LOCK,		"LOCK" },		\
83 		{ NFSD_MAY_OWNER_OVERRIDE,	"OWNER_OVERRIDE" },	\
84 		{ NFSD_MAY_LOCAL_ACCESS,	"LOCAL_ACCESS" },	\
85 		{ NFSD_MAY_BYPASS_GSS_ON_ROOT,	"BYPASS_GSS_ON_ROOT" },	\
86 		{ NFSD_MAY_NOT_BREAK_LEASE,	"NOT_BREAK_LEASE" },	\
87 		{ NFSD_MAY_BYPASS_GSS,		"BYPASS_GSS" },		\
88 		{ NFSD_MAY_READ_IF_EXEC,	"READ_IF_EXEC" },	\
89 		{ NFSD_MAY_64BIT_COOKIE,	"64BIT_COOKIE" })
90 
91 TRACE_EVENT(nfsd_compound,
92 	TP_PROTO(
93 		const struct svc_rqst *rqst,
94 		const char *tag,
95 		u32 taglen,
96 		u32 opcnt
97 	),
98 	TP_ARGS(rqst, tag, taglen, opcnt),
99 	TP_STRUCT__entry(
100 		__field(u32, xid)
101 		__field(u32, opcnt)
102 		__string_len(tag, tag, taglen)
103 	),
104 	TP_fast_assign(
105 		__entry->xid = be32_to_cpu(rqst->rq_xid);
106 		__entry->opcnt = opcnt;
107 		__assign_str(tag, tag);
108 	),
109 	TP_printk("xid=0x%08x opcnt=%u tag=%s",
110 		__entry->xid, __entry->opcnt, __get_str(tag)
111 	)
112 )
113 
114 TRACE_EVENT(nfsd_compound_status,
115 	TP_PROTO(u32 args_opcnt,
116 		 u32 resp_opcnt,
117 		 __be32 status,
118 		 const char *name),
119 	TP_ARGS(args_opcnt, resp_opcnt, status, name),
120 	TP_STRUCT__entry(
121 		__field(u32, args_opcnt)
122 		__field(u32, resp_opcnt)
123 		__field(int, status)
124 		__string(name, name)
125 	),
126 	TP_fast_assign(
127 		__entry->args_opcnt = args_opcnt;
128 		__entry->resp_opcnt = resp_opcnt;
129 		__entry->status = be32_to_cpu(status);
130 		__assign_str(name, name);
131 	),
132 	TP_printk("op=%u/%u %s status=%d",
133 		__entry->resp_opcnt, __entry->args_opcnt,
134 		__get_str(name), __entry->status)
135 )
136 
137 TRACE_EVENT(nfsd_compound_decode_err,
138 	TP_PROTO(
139 		const struct svc_rqst *rqstp,
140 		u32 args_opcnt,
141 		u32 resp_opcnt,
142 		u32 opnum,
143 		__be32 status
144 	),
145 	TP_ARGS(rqstp, args_opcnt, resp_opcnt, opnum, status),
146 	TP_STRUCT__entry(
147 		NFSD_TRACE_PROC_RES_FIELDS
148 
149 		__field(u32, args_opcnt)
150 		__field(u32, resp_opcnt)
151 		__field(u32, opnum)
152 	),
153 	TP_fast_assign(
154 		NFSD_TRACE_PROC_RES_ASSIGNMENTS(status)
155 
156 		__entry->args_opcnt = args_opcnt;
157 		__entry->resp_opcnt = resp_opcnt;
158 		__entry->opnum = opnum;
159 	),
160 	TP_printk("op=%u/%u opnum=%u status=%lu",
161 		__entry->resp_opcnt, __entry->args_opcnt,
162 		__entry->opnum, __entry->status)
163 );
164 
165 TRACE_EVENT(nfsd_compound_encode_err,
166 	TP_PROTO(
167 		const struct svc_rqst *rqstp,
168 		u32 opnum,
169 		__be32 status
170 	),
171 	TP_ARGS(rqstp, opnum, status),
172 	TP_STRUCT__entry(
173 		NFSD_TRACE_PROC_RES_FIELDS
174 
175 		__field(u32, opnum)
176 	),
177 	TP_fast_assign(
178 		NFSD_TRACE_PROC_RES_ASSIGNMENTS(status)
179 
180 		__entry->opnum = opnum;
181 	),
182 	TP_printk("opnum=%u status=%lu",
183 		__entry->opnum, __entry->status)
184 );
185 
186 #define show_fs_file_type(x) \
187 	__print_symbolic(x, \
188 		{ S_IFLNK,		"LNK" }, \
189 		{ S_IFREG,		"REG" }, \
190 		{ S_IFDIR,		"DIR" }, \
191 		{ S_IFCHR,		"CHR" }, \
192 		{ S_IFBLK,		"BLK" }, \
193 		{ S_IFIFO,		"FIFO" }, \
194 		{ S_IFSOCK,		"SOCK" })
195 
196 TRACE_EVENT(nfsd_fh_verify,
197 	TP_PROTO(
198 		const struct svc_rqst *rqstp,
199 		const struct svc_fh *fhp,
200 		umode_t type,
201 		int access
202 	),
203 	TP_ARGS(rqstp, fhp, type, access),
204 	TP_STRUCT__entry(
205 		__field(unsigned int, netns_ino)
206 		__sockaddr(server, rqstp->rq_xprt->xpt_remotelen)
207 		__sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
208 		__field(u32, xid)
209 		__field(u32, fh_hash)
210 		__field(const void *, inode)
211 		__field(unsigned long, type)
212 		__field(unsigned long, access)
213 	),
214 	TP_fast_assign(
215 		__entry->netns_ino = SVC_NET(rqstp)->ns.inum;
216 		__assign_sockaddr(server, &rqstp->rq_xprt->xpt_local,
217 		       rqstp->rq_xprt->xpt_locallen);
218 		__assign_sockaddr(client, &rqstp->rq_xprt->xpt_remote,
219 				  rqstp->rq_xprt->xpt_remotelen);
220 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
221 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
222 		__entry->inode = d_inode(fhp->fh_dentry);
223 		__entry->type = type;
224 		__entry->access = access;
225 	),
226 	TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s",
227 		__entry->xid, __entry->fh_hash,
228 		show_fs_file_type(__entry->type),
229 		show_nfsd_may_flags(__entry->access)
230 	)
231 );
232 
233 TRACE_EVENT_CONDITION(nfsd_fh_verify_err,
234 	TP_PROTO(
235 		const struct svc_rqst *rqstp,
236 		const struct svc_fh *fhp,
237 		umode_t type,
238 		int access,
239 		__be32 error
240 	),
241 	TP_ARGS(rqstp, fhp, type, access, error),
242 	TP_CONDITION(error),
243 	TP_STRUCT__entry(
244 		__field(unsigned int, netns_ino)
245 		__sockaddr(server, rqstp->rq_xprt->xpt_remotelen)
246 		__sockaddr(client, rqstp->rq_xprt->xpt_remotelen)
247 		__field(u32, xid)
248 		__field(u32, fh_hash)
249 		__field(const void *, inode)
250 		__field(unsigned long, type)
251 		__field(unsigned long, access)
252 		__field(int, error)
253 	),
254 	TP_fast_assign(
255 		__entry->netns_ino = SVC_NET(rqstp)->ns.inum;
256 		__assign_sockaddr(server, &rqstp->rq_xprt->xpt_local,
257 		       rqstp->rq_xprt->xpt_locallen);
258 		__assign_sockaddr(client, &rqstp->rq_xprt->xpt_remote,
259 				  rqstp->rq_xprt->xpt_remotelen);
260 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
261 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
262 		if (fhp->fh_dentry)
263 			__entry->inode = d_inode(fhp->fh_dentry);
264 		else
265 			__entry->inode = NULL;
266 		__entry->type = type;
267 		__entry->access = access;
268 		__entry->error = be32_to_cpu(error);
269 	),
270 	TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s error=%d",
271 		__entry->xid, __entry->fh_hash,
272 		show_fs_file_type(__entry->type),
273 		show_nfsd_may_flags(__entry->access),
274 		__entry->error
275 	)
276 );
277 
278 DECLARE_EVENT_CLASS(nfsd_fh_err_class,
279 	TP_PROTO(struct svc_rqst *rqstp,
280 		 struct svc_fh	*fhp,
281 		 int		status),
282 	TP_ARGS(rqstp, fhp, status),
283 	TP_STRUCT__entry(
284 		__field(u32, xid)
285 		__field(u32, fh_hash)
286 		__field(int, status)
287 	),
288 	TP_fast_assign(
289 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
290 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
291 		__entry->status = status;
292 	),
293 	TP_printk("xid=0x%08x fh_hash=0x%08x status=%d",
294 		  __entry->xid, __entry->fh_hash,
295 		  __entry->status)
296 )
297 
298 #define DEFINE_NFSD_FH_ERR_EVENT(name)		\
299 DEFINE_EVENT(nfsd_fh_err_class, nfsd_##name,	\
300 	TP_PROTO(struct svc_rqst *rqstp,	\
301 		 struct svc_fh	*fhp,		\
302 		 int		status),	\
303 	TP_ARGS(rqstp, fhp, status))
304 
305 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport);
306 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle);
307 
308 TRACE_EVENT(nfsd_exp_find_key,
309 	TP_PROTO(const struct svc_expkey *key,
310 		 int status),
311 	TP_ARGS(key, status),
312 	TP_STRUCT__entry(
313 		__field(int, fsidtype)
314 		__array(u32, fsid, 6)
315 		__string(auth_domain, key->ek_client->name)
316 		__field(int, status)
317 	),
318 	TP_fast_assign(
319 		__entry->fsidtype = key->ek_fsidtype;
320 		memcpy(__entry->fsid, key->ek_fsid, 4*6);
321 		__assign_str(auth_domain, key->ek_client->name);
322 		__entry->status = status;
323 	),
324 	TP_printk("fsid=%x::%s domain=%s status=%d",
325 		__entry->fsidtype,
326 		__print_array(__entry->fsid, 6, 4),
327 		__get_str(auth_domain),
328 		__entry->status
329 	)
330 );
331 
332 TRACE_EVENT(nfsd_expkey_update,
333 	TP_PROTO(const struct svc_expkey *key, const char *exp_path),
334 	TP_ARGS(key, exp_path),
335 	TP_STRUCT__entry(
336 		__field(int, fsidtype)
337 		__array(u32, fsid, 6)
338 		__string(auth_domain, key->ek_client->name)
339 		__string(path, exp_path)
340 		__field(bool, cache)
341 	),
342 	TP_fast_assign(
343 		__entry->fsidtype = key->ek_fsidtype;
344 		memcpy(__entry->fsid, key->ek_fsid, 4*6);
345 		__assign_str(auth_domain, key->ek_client->name);
346 		__assign_str(path, exp_path);
347 		__entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
348 	),
349 	TP_printk("fsid=%x::%s domain=%s path=%s cache=%s",
350 		__entry->fsidtype,
351 		__print_array(__entry->fsid, 6, 4),
352 		__get_str(auth_domain),
353 		__get_str(path),
354 		__entry->cache ? "pos" : "neg"
355 	)
356 );
357 
358 TRACE_EVENT(nfsd_exp_get_by_name,
359 	TP_PROTO(const struct svc_export *key,
360 		 int status),
361 	TP_ARGS(key, status),
362 	TP_STRUCT__entry(
363 		__string(path, key->ex_path.dentry->d_name.name)
364 		__string(auth_domain, key->ex_client->name)
365 		__field(int, status)
366 	),
367 	TP_fast_assign(
368 		__assign_str(path, key->ex_path.dentry->d_name.name);
369 		__assign_str(auth_domain, key->ex_client->name);
370 		__entry->status = status;
371 	),
372 	TP_printk("path=%s domain=%s status=%d",
373 		__get_str(path),
374 		__get_str(auth_domain),
375 		__entry->status
376 	)
377 );
378 
379 TRACE_EVENT(nfsd_export_update,
380 	TP_PROTO(const struct svc_export *key),
381 	TP_ARGS(key),
382 	TP_STRUCT__entry(
383 		__string(path, key->ex_path.dentry->d_name.name)
384 		__string(auth_domain, key->ex_client->name)
385 		__field(bool, cache)
386 	),
387 	TP_fast_assign(
388 		__assign_str(path, key->ex_path.dentry->d_name.name);
389 		__assign_str(auth_domain, key->ex_client->name);
390 		__entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
391 	),
392 	TP_printk("path=%s domain=%s cache=%s",
393 		__get_str(path),
394 		__get_str(auth_domain),
395 		__entry->cache ? "pos" : "neg"
396 	)
397 );
398 
399 DECLARE_EVENT_CLASS(nfsd_io_class,
400 	TP_PROTO(struct svc_rqst *rqstp,
401 		 struct svc_fh	*fhp,
402 		 u64		offset,
403 		 u32		len),
404 	TP_ARGS(rqstp, fhp, offset, len),
405 	TP_STRUCT__entry(
406 		__field(u32, xid)
407 		__field(u32, fh_hash)
408 		__field(u64, offset)
409 		__field(u32, len)
410 	),
411 	TP_fast_assign(
412 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
413 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
414 		__entry->offset = offset;
415 		__entry->len = len;
416 	),
417 	TP_printk("xid=0x%08x fh_hash=0x%08x offset=%llu len=%u",
418 		  __entry->xid, __entry->fh_hash,
419 		  __entry->offset, __entry->len)
420 )
421 
422 #define DEFINE_NFSD_IO_EVENT(name)		\
423 DEFINE_EVENT(nfsd_io_class, nfsd_##name,	\
424 	TP_PROTO(struct svc_rqst *rqstp,	\
425 		 struct svc_fh	*fhp,		\
426 		 u64		offset,		\
427 		 u32		len),		\
428 	TP_ARGS(rqstp, fhp, offset, len))
429 
430 DEFINE_NFSD_IO_EVENT(read_start);
431 DEFINE_NFSD_IO_EVENT(read_splice);
432 DEFINE_NFSD_IO_EVENT(read_vector);
433 DEFINE_NFSD_IO_EVENT(read_io_done);
434 DEFINE_NFSD_IO_EVENT(read_done);
435 DEFINE_NFSD_IO_EVENT(write_start);
436 DEFINE_NFSD_IO_EVENT(write_opened);
437 DEFINE_NFSD_IO_EVENT(write_io_done);
438 DEFINE_NFSD_IO_EVENT(write_done);
439 
440 DECLARE_EVENT_CLASS(nfsd_err_class,
441 	TP_PROTO(struct svc_rqst *rqstp,
442 		 struct svc_fh	*fhp,
443 		 loff_t		offset,
444 		 int		status),
445 	TP_ARGS(rqstp, fhp, offset, status),
446 	TP_STRUCT__entry(
447 		__field(u32, xid)
448 		__field(u32, fh_hash)
449 		__field(loff_t, offset)
450 		__field(int, status)
451 	),
452 	TP_fast_assign(
453 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
454 		__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
455 		__entry->offset = offset;
456 		__entry->status = status;
457 	),
458 	TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld status=%d",
459 		  __entry->xid, __entry->fh_hash,
460 		  __entry->offset, __entry->status)
461 )
462 
463 #define DEFINE_NFSD_ERR_EVENT(name)		\
464 DEFINE_EVENT(nfsd_err_class, nfsd_##name,	\
465 	TP_PROTO(struct svc_rqst *rqstp,	\
466 		 struct svc_fh	*fhp,		\
467 		 loff_t		offset,		\
468 		 int		len),		\
469 	TP_ARGS(rqstp, fhp, offset, len))
470 
471 DEFINE_NFSD_ERR_EVENT(read_err);
472 DEFINE_NFSD_ERR_EVENT(write_err);
473 
474 TRACE_EVENT(nfsd_dirent,
475 	TP_PROTO(struct svc_fh *fhp,
476 		 u64 ino,
477 		 const char *name,
478 		 int namlen),
479 	TP_ARGS(fhp, ino, name, namlen),
480 	TP_STRUCT__entry(
481 		__field(u32, fh_hash)
482 		__field(u64, ino)
483 		__string_len(name, name, namlen)
484 	),
485 	TP_fast_assign(
486 		__entry->fh_hash = fhp ? knfsd_fh_hash(&fhp->fh_handle) : 0;
487 		__entry->ino = ino;
488 		__assign_str(name, name);
489 	),
490 	TP_printk("fh_hash=0x%08x ino=%llu name=%s",
491 		__entry->fh_hash, __entry->ino, __get_str(name)
492 	)
493 )
494 
495 DECLARE_EVENT_CLASS(nfsd_copy_err_class,
496 	TP_PROTO(struct svc_rqst *rqstp,
497 		 struct svc_fh	*src_fhp,
498 		 loff_t		src_offset,
499 		 struct svc_fh	*dst_fhp,
500 		 loff_t		dst_offset,
501 		 u64		count,
502 		 int		status),
503 	TP_ARGS(rqstp, src_fhp, src_offset, dst_fhp, dst_offset, count, status),
504 	TP_STRUCT__entry(
505 		__field(u32, xid)
506 		__field(u32, src_fh_hash)
507 		__field(loff_t, src_offset)
508 		__field(u32, dst_fh_hash)
509 		__field(loff_t, dst_offset)
510 		__field(u64, count)
511 		__field(int, status)
512 	),
513 	TP_fast_assign(
514 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
515 		__entry->src_fh_hash = knfsd_fh_hash(&src_fhp->fh_handle);
516 		__entry->src_offset = src_offset;
517 		__entry->dst_fh_hash = knfsd_fh_hash(&dst_fhp->fh_handle);
518 		__entry->dst_offset = dst_offset;
519 		__entry->count = count;
520 		__entry->status = status;
521 	),
522 	TP_printk("xid=0x%08x src_fh_hash=0x%08x src_offset=%lld "
523 			"dst_fh_hash=0x%08x dst_offset=%lld "
524 			"count=%llu status=%d",
525 		  __entry->xid, __entry->src_fh_hash, __entry->src_offset,
526 		  __entry->dst_fh_hash, __entry->dst_offset,
527 		  (unsigned long long)__entry->count,
528 		  __entry->status)
529 )
530 
531 #define DEFINE_NFSD_COPY_ERR_EVENT(name)		\
532 DEFINE_EVENT(nfsd_copy_err_class, nfsd_##name,		\
533 	TP_PROTO(struct svc_rqst	*rqstp,		\
534 		 struct svc_fh		*src_fhp,	\
535 		 loff_t			src_offset,	\
536 		 struct svc_fh		*dst_fhp,	\
537 		 loff_t			dst_offset,	\
538 		 u64			count,		\
539 		 int			status),	\
540 	TP_ARGS(rqstp, src_fhp, src_offset, dst_fhp, dst_offset, \
541 		count, status))
542 
543 DEFINE_NFSD_COPY_ERR_EVENT(clone_file_range_err);
544 
545 #include "state.h"
546 #include "filecache.h"
547 #include "vfs.h"
548 
549 TRACE_EVENT(nfsd_delegret_wakeup,
550 	TP_PROTO(
551 		const struct svc_rqst *rqstp,
552 		const struct inode *inode,
553 		long timeo
554 	),
555 	TP_ARGS(rqstp, inode, timeo),
556 	TP_STRUCT__entry(
557 		__field(u32, xid)
558 		__field(const void *, inode)
559 		__field(long, timeo)
560 	),
561 	TP_fast_assign(
562 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
563 		__entry->inode = inode;
564 		__entry->timeo = timeo;
565 	),
566 	TP_printk("xid=0x%08x inode=%p%s",
567 		  __entry->xid, __entry->inode,
568 		  __entry->timeo == 0 ? " (timed out)" : ""
569 	)
570 );
571 
572 DECLARE_EVENT_CLASS(nfsd_stateid_class,
573 	TP_PROTO(stateid_t *stp),
574 	TP_ARGS(stp),
575 	TP_STRUCT__entry(
576 		__field(u32, cl_boot)
577 		__field(u32, cl_id)
578 		__field(u32, si_id)
579 		__field(u32, si_generation)
580 	),
581 	TP_fast_assign(
582 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
583 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
584 		__entry->si_id = stp->si_opaque.so_id;
585 		__entry->si_generation = stp->si_generation;
586 	),
587 	TP_printk("client %08x:%08x stateid %08x:%08x",
588 		__entry->cl_boot,
589 		__entry->cl_id,
590 		__entry->si_id,
591 		__entry->si_generation)
592 )
593 
594 #define DEFINE_STATEID_EVENT(name) \
595 DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \
596 	TP_PROTO(stateid_t *stp), \
597 	TP_ARGS(stp))
598 
599 DEFINE_STATEID_EVENT(layoutstate_alloc);
600 DEFINE_STATEID_EVENT(layoutstate_unhash);
601 DEFINE_STATEID_EVENT(layoutstate_free);
602 DEFINE_STATEID_EVENT(layout_get_lookup_fail);
603 DEFINE_STATEID_EVENT(layout_commit_lookup_fail);
604 DEFINE_STATEID_EVENT(layout_return_lookup_fail);
605 DEFINE_STATEID_EVENT(layout_recall);
606 DEFINE_STATEID_EVENT(layout_recall_done);
607 DEFINE_STATEID_EVENT(layout_recall_fail);
608 DEFINE_STATEID_EVENT(layout_recall_release);
609 
610 DEFINE_STATEID_EVENT(open);
611 DEFINE_STATEID_EVENT(deleg_read);
612 DEFINE_STATEID_EVENT(deleg_write);
613 DEFINE_STATEID_EVENT(deleg_return);
614 DEFINE_STATEID_EVENT(deleg_recall);
615 
616 DECLARE_EVENT_CLASS(nfsd_stateseqid_class,
617 	TP_PROTO(u32 seqid, const stateid_t *stp),
618 	TP_ARGS(seqid, stp),
619 	TP_STRUCT__entry(
620 		__field(u32, seqid)
621 		__field(u32, cl_boot)
622 		__field(u32, cl_id)
623 		__field(u32, si_id)
624 		__field(u32, si_generation)
625 	),
626 	TP_fast_assign(
627 		__entry->seqid = seqid;
628 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
629 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
630 		__entry->si_id = stp->si_opaque.so_id;
631 		__entry->si_generation = stp->si_generation;
632 	),
633 	TP_printk("seqid=%u client %08x:%08x stateid %08x:%08x",
634 		__entry->seqid, __entry->cl_boot, __entry->cl_id,
635 		__entry->si_id, __entry->si_generation)
636 )
637 
638 #define DEFINE_STATESEQID_EVENT(name) \
639 DEFINE_EVENT(nfsd_stateseqid_class, nfsd_##name, \
640 	TP_PROTO(u32 seqid, const stateid_t *stp), \
641 	TP_ARGS(seqid, stp))
642 
643 DEFINE_STATESEQID_EVENT(preprocess);
644 DEFINE_STATESEQID_EVENT(open_confirm);
645 
646 #define show_stid_type(x)						\
647 	__print_flags(x, "|",						\
648 		{ SC_TYPE_OPEN,		"OPEN" },		\
649 		{ SC_TYPE_LOCK,		"LOCK" },		\
650 		{ SC_TYPE_DELEG,		"DELEG" },		\
651 		{ SC_TYPE_LAYOUT,		"LAYOUT" })
652 
653 #define show_stid_status(x)						\
654 	__print_flags(x, "|",						\
655 		{ SC_STATUS_CLOSED,		"CLOSED" },		\
656 		{ SC_STATUS_REVOKED,		"REVOKED" },		\
657 		{ SC_STATUS_ADMIN_REVOKED,	"ADMIN_REVOKED" })
658 
659 DECLARE_EVENT_CLASS(nfsd_stid_class,
660 	TP_PROTO(
661 		const struct nfs4_stid *stid
662 	),
663 	TP_ARGS(stid),
664 	TP_STRUCT__entry(
665 		__field(unsigned long, sc_type)
666 		__field(unsigned long, sc_status)
667 		__field(int, sc_count)
668 		__field(u32, cl_boot)
669 		__field(u32, cl_id)
670 		__field(u32, si_id)
671 		__field(u32, si_generation)
672 	),
673 	TP_fast_assign(
674 		const stateid_t *stp = &stid->sc_stateid;
675 
676 		__entry->sc_type = stid->sc_type;
677 		__entry->sc_status = stid->sc_status;
678 		__entry->sc_count = refcount_read(&stid->sc_count);
679 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
680 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
681 		__entry->si_id = stp->si_opaque.so_id;
682 		__entry->si_generation = stp->si_generation;
683 	),
684 	TP_printk("client %08x:%08x stateid %08x:%08x ref=%d type=%s state=%s",
685 		__entry->cl_boot, __entry->cl_id,
686 		__entry->si_id, __entry->si_generation,
687 		__entry->sc_count, show_stid_type(__entry->sc_type),
688 		show_stid_status(__entry->sc_status)
689 	)
690 );
691 
692 #define DEFINE_STID_EVENT(name)					\
693 DEFINE_EVENT(nfsd_stid_class, nfsd_stid_##name,			\
694 	TP_PROTO(const struct nfs4_stid *stid),			\
695 	TP_ARGS(stid))
696 
697 DEFINE_STID_EVENT(revoke);
698 
699 TRACE_EVENT(nfsd_stateowner_replay,
700 	TP_PROTO(
701 		u32 opnum,
702 		const struct nfs4_replay *rp
703 	),
704 	TP_ARGS(opnum, rp),
705 	TP_STRUCT__entry(
706 		__field(unsigned long, status)
707 		__field(u32, opnum)
708 	),
709 	TP_fast_assign(
710 		__entry->status = be32_to_cpu(rp->rp_status);
711 		__entry->opnum = opnum;
712 	),
713 	TP_printk("opnum=%u status=%lu",
714 		__entry->opnum, __entry->status)
715 );
716 
717 TRACE_EVENT_CONDITION(nfsd_seq4_status,
718 	TP_PROTO(
719 		const struct svc_rqst *rqstp,
720 		const struct nfsd4_sequence *sequence
721 	),
722 	TP_ARGS(rqstp, sequence),
723 	TP_CONDITION(sequence->status_flags),
724 	TP_STRUCT__entry(
725 		__field(unsigned int, netns_ino)
726 		__field(u32, xid)
727 		__field(u32, cl_boot)
728 		__field(u32, cl_id)
729 		__field(u32, seqno)
730 		__field(u32, reserved)
731 		__field(unsigned long, status_flags)
732 	),
733 	TP_fast_assign(
734 		const struct nfsd4_sessionid *sid =
735 			(struct nfsd4_sessionid *)&sequence->sessionid;
736 
737 		__entry->netns_ino = SVC_NET(rqstp)->ns.inum;
738 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
739 		__entry->cl_boot = sid->clientid.cl_boot;
740 		__entry->cl_id = sid->clientid.cl_id;
741 		__entry->seqno = sid->sequence;
742 		__entry->reserved = sid->reserved;
743 		__entry->status_flags = sequence->status_flags;
744 	),
745 	TP_printk("xid=0x%08x sessionid=%08x:%08x:%08x:%08x status_flags=%s",
746 		__entry->xid, __entry->cl_boot, __entry->cl_id,
747 		__entry->seqno, __entry->reserved,
748 		show_nfs4_seq4_status(__entry->status_flags)
749 	)
750 );
751 
752 DECLARE_EVENT_CLASS(nfsd_clientid_class,
753 	TP_PROTO(const clientid_t *clid),
754 	TP_ARGS(clid),
755 	TP_STRUCT__entry(
756 		__field(u32, cl_boot)
757 		__field(u32, cl_id)
758 	),
759 	TP_fast_assign(
760 		__entry->cl_boot = clid->cl_boot;
761 		__entry->cl_id = clid->cl_id;
762 	),
763 	TP_printk("client %08x:%08x", __entry->cl_boot, __entry->cl_id)
764 )
765 
766 #define DEFINE_CLIENTID_EVENT(name) \
767 DEFINE_EVENT(nfsd_clientid_class, nfsd_clid_##name, \
768 	TP_PROTO(const clientid_t *clid), \
769 	TP_ARGS(clid))
770 
771 DEFINE_CLIENTID_EVENT(expire_unconf);
772 DEFINE_CLIENTID_EVENT(reclaim_complete);
773 DEFINE_CLIENTID_EVENT(confirmed);
774 DEFINE_CLIENTID_EVENT(destroyed);
775 DEFINE_CLIENTID_EVENT(admin_expired);
776 DEFINE_CLIENTID_EVENT(replaced);
777 DEFINE_CLIENTID_EVENT(purged);
778 DEFINE_CLIENTID_EVENT(renew);
779 DEFINE_CLIENTID_EVENT(stale);
780 
781 DECLARE_EVENT_CLASS(nfsd_net_class,
782 	TP_PROTO(const struct nfsd_net *nn),
783 	TP_ARGS(nn),
784 	TP_STRUCT__entry(
785 		__field(unsigned long long, boot_time)
786 	),
787 	TP_fast_assign(
788 		__entry->boot_time = nn->boot_time;
789 	),
790 	TP_printk("boot_time=%16llx", __entry->boot_time)
791 )
792 
793 #define DEFINE_NET_EVENT(name) \
794 DEFINE_EVENT(nfsd_net_class, nfsd_##name, \
795 	TP_PROTO(const struct nfsd_net *nn), \
796 	TP_ARGS(nn))
797 
798 DEFINE_NET_EVENT(grace_start);
799 DEFINE_NET_EVENT(grace_complete);
800 
801 TRACE_EVENT(nfsd_writeverf_reset,
802 	TP_PROTO(
803 		const struct nfsd_net *nn,
804 		const struct svc_rqst *rqstp,
805 		int error
806 	),
807 	TP_ARGS(nn, rqstp, error),
808 	TP_STRUCT__entry(
809 		__field(unsigned long long, boot_time)
810 		__field(u32, xid)
811 		__field(int, error)
812 		__array(unsigned char, verifier, NFS4_VERIFIER_SIZE)
813 	),
814 	TP_fast_assign(
815 		__entry->boot_time = nn->boot_time;
816 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
817 		__entry->error = error;
818 
819 		/* avoid seqlock inside TP_fast_assign */
820 		memcpy(__entry->verifier, nn->writeverf,
821 		       NFS4_VERIFIER_SIZE);
822 	),
823 	TP_printk("boot_time=%16llx xid=0x%08x error=%d new verifier=0x%s",
824 		__entry->boot_time, __entry->xid, __entry->error,
825 		__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
826 	)
827 );
828 
829 TRACE_EVENT(nfsd_clid_cred_mismatch,
830 	TP_PROTO(
831 		const struct nfs4_client *clp,
832 		const struct svc_rqst *rqstp
833 	),
834 	TP_ARGS(clp, rqstp),
835 	TP_STRUCT__entry(
836 		__field(u32, cl_boot)
837 		__field(u32, cl_id)
838 		__field(unsigned long, cl_flavor)
839 		__field(unsigned long, new_flavor)
840 		__sockaddr(addr, rqstp->rq_xprt->xpt_remotelen)
841 	),
842 	TP_fast_assign(
843 		__entry->cl_boot = clp->cl_clientid.cl_boot;
844 		__entry->cl_id = clp->cl_clientid.cl_id;
845 		__entry->cl_flavor = clp->cl_cred.cr_flavor;
846 		__entry->new_flavor = rqstp->rq_cred.cr_flavor;
847 		__assign_sockaddr(addr, &rqstp->rq_xprt->xpt_remote,
848 				  rqstp->rq_xprt->xpt_remotelen);
849 	),
850 	TP_printk("client %08x:%08x flavor=%s, conflict=%s from addr=%pISpc",
851 		__entry->cl_boot, __entry->cl_id,
852 		show_nfsd_authflavor(__entry->cl_flavor),
853 		show_nfsd_authflavor(__entry->new_flavor),
854 		__get_sockaddr(addr)
855 	)
856 )
857 
858 TRACE_EVENT(nfsd_clid_verf_mismatch,
859 	TP_PROTO(
860 		const struct nfs4_client *clp,
861 		const struct svc_rqst *rqstp,
862 		const nfs4_verifier *verf
863 	),
864 	TP_ARGS(clp, rqstp, verf),
865 	TP_STRUCT__entry(
866 		__field(u32, cl_boot)
867 		__field(u32, cl_id)
868 		__array(unsigned char, cl_verifier, NFS4_VERIFIER_SIZE)
869 		__array(unsigned char, new_verifier, NFS4_VERIFIER_SIZE)
870 		__sockaddr(addr, rqstp->rq_xprt->xpt_remotelen)
871 	),
872 	TP_fast_assign(
873 		__entry->cl_boot = clp->cl_clientid.cl_boot;
874 		__entry->cl_id = clp->cl_clientid.cl_id;
875 		memcpy(__entry->cl_verifier, (void *)&clp->cl_verifier,
876 		       NFS4_VERIFIER_SIZE);
877 		memcpy(__entry->new_verifier, (void *)verf,
878 		       NFS4_VERIFIER_SIZE);
879 		__assign_sockaddr(addr, &rqstp->rq_xprt->xpt_remote,
880 				  rqstp->rq_xprt->xpt_remotelen);
881 	),
882 	TP_printk("client %08x:%08x verf=0x%s, updated=0x%s from addr=%pISpc",
883 		__entry->cl_boot, __entry->cl_id,
884 		__print_hex_str(__entry->cl_verifier, NFS4_VERIFIER_SIZE),
885 		__print_hex_str(__entry->new_verifier, NFS4_VERIFIER_SIZE),
886 		__get_sockaddr(addr)
887 	)
888 );
889 
890 DECLARE_EVENT_CLASS(nfsd_clid_class,
891 	TP_PROTO(const struct nfs4_client *clp),
892 	TP_ARGS(clp),
893 	TP_STRUCT__entry(
894 		__field(u32, cl_boot)
895 		__field(u32, cl_id)
896 		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
897 		__field(unsigned long, flavor)
898 		__array(unsigned char, verifier, NFS4_VERIFIER_SIZE)
899 		__string_len(name, clp->cl_name.data, clp->cl_name.len)
900 	),
901 	TP_fast_assign(
902 		__entry->cl_boot = clp->cl_clientid.cl_boot;
903 		__entry->cl_id = clp->cl_clientid.cl_id;
904 		memcpy(__entry->addr, &clp->cl_addr,
905 			sizeof(struct sockaddr_in6));
906 		__entry->flavor = clp->cl_cred.cr_flavor;
907 		memcpy(__entry->verifier, (void *)&clp->cl_verifier,
908 		       NFS4_VERIFIER_SIZE);
909 		__assign_str(name, clp->cl_name.data);
910 	),
911 	TP_printk("addr=%pISpc name='%s' verifier=0x%s flavor=%s client=%08x:%08x",
912 		__entry->addr, __get_str(name),
913 		__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE),
914 		show_nfsd_authflavor(__entry->flavor),
915 		__entry->cl_boot, __entry->cl_id)
916 );
917 
918 #define DEFINE_CLID_EVENT(name) \
919 DEFINE_EVENT(nfsd_clid_class, nfsd_clid_##name, \
920 	TP_PROTO(const struct nfs4_client *clp), \
921 	TP_ARGS(clp))
922 
923 DEFINE_CLID_EVENT(fresh);
924 DEFINE_CLID_EVENT(confirmed_r);
925 
926 /*
927  * from fs/nfsd/filecache.h
928  */
929 #define show_nf_flags(val)						\
930 	__print_flags(val, "|",						\
931 		{ 1 << NFSD_FILE_HASHED,	"HASHED" },		\
932 		{ 1 << NFSD_FILE_PENDING,	"PENDING" },		\
933 		{ 1 << NFSD_FILE_REFERENCED,	"REFERENCED" },		\
934 		{ 1 << NFSD_FILE_GC,		"GC" })
935 
936 DECLARE_EVENT_CLASS(nfsd_file_class,
937 	TP_PROTO(struct nfsd_file *nf),
938 	TP_ARGS(nf),
939 	TP_STRUCT__entry(
940 		__field(void *, nf_inode)
941 		__field(int, nf_ref)
942 		__field(unsigned long, nf_flags)
943 		__field(unsigned char, nf_may)
944 		__field(struct file *, nf_file)
945 	),
946 	TP_fast_assign(
947 		__entry->nf_inode = nf->nf_inode;
948 		__entry->nf_ref = refcount_read(&nf->nf_ref);
949 		__entry->nf_flags = nf->nf_flags;
950 		__entry->nf_may = nf->nf_may;
951 		__entry->nf_file = nf->nf_file;
952 	),
953 	TP_printk("inode=%p ref=%d flags=%s may=%s nf_file=%p",
954 		__entry->nf_inode,
955 		__entry->nf_ref,
956 		show_nf_flags(__entry->nf_flags),
957 		show_nfsd_may_flags(__entry->nf_may),
958 		__entry->nf_file)
959 )
960 
961 #define DEFINE_NFSD_FILE_EVENT(name) \
962 DEFINE_EVENT(nfsd_file_class, name, \
963 	TP_PROTO(struct nfsd_file *nf), \
964 	TP_ARGS(nf))
965 
966 DEFINE_NFSD_FILE_EVENT(nfsd_file_free);
967 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash);
968 DEFINE_NFSD_FILE_EVENT(nfsd_file_put);
969 DEFINE_NFSD_FILE_EVENT(nfsd_file_closing);
970 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_queue);
971 
972 TRACE_EVENT(nfsd_file_alloc,
973 	TP_PROTO(
974 		const struct nfsd_file *nf
975 	),
976 	TP_ARGS(nf),
977 	TP_STRUCT__entry(
978 		__field(const void *, nf_inode)
979 		__field(unsigned long, nf_flags)
980 		__field(unsigned long, nf_may)
981 		__field(unsigned int, nf_ref)
982 	),
983 	TP_fast_assign(
984 		__entry->nf_inode = nf->nf_inode;
985 		__entry->nf_flags = nf->nf_flags;
986 		__entry->nf_ref = refcount_read(&nf->nf_ref);
987 		__entry->nf_may = nf->nf_may;
988 	),
989 	TP_printk("inode=%p ref=%u flags=%s may=%s",
990 		__entry->nf_inode, __entry->nf_ref,
991 		show_nf_flags(__entry->nf_flags),
992 		show_nfsd_may_flags(__entry->nf_may)
993 	)
994 );
995 
996 TRACE_EVENT(nfsd_file_acquire,
997 	TP_PROTO(
998 		const struct svc_rqst *rqstp,
999 		const struct inode *inode,
1000 		unsigned int may_flags,
1001 		const struct nfsd_file *nf,
1002 		__be32 status
1003 	),
1004 
1005 	TP_ARGS(rqstp, inode, may_flags, nf, status),
1006 
1007 	TP_STRUCT__entry(
1008 		__field(u32, xid)
1009 		__field(const void *, inode)
1010 		__field(unsigned long, may_flags)
1011 		__field(unsigned int, nf_ref)
1012 		__field(unsigned long, nf_flags)
1013 		__field(unsigned long, nf_may)
1014 		__field(const void *, nf_file)
1015 		__field(u32, status)
1016 	),
1017 
1018 	TP_fast_assign(
1019 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
1020 		__entry->inode = inode;
1021 		__entry->may_flags = may_flags;
1022 		__entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0;
1023 		__entry->nf_flags = nf ? nf->nf_flags : 0;
1024 		__entry->nf_may = nf ? nf->nf_may : 0;
1025 		__entry->nf_file = nf ? nf->nf_file : NULL;
1026 		__entry->status = be32_to_cpu(status);
1027 	),
1028 
1029 	TP_printk("xid=0x%x inode=%p may_flags=%s ref=%u nf_flags=%s nf_may=%s nf_file=%p status=%u",
1030 			__entry->xid, __entry->inode,
1031 			show_nfsd_may_flags(__entry->may_flags),
1032 			__entry->nf_ref, show_nf_flags(__entry->nf_flags),
1033 			show_nfsd_may_flags(__entry->nf_may),
1034 			__entry->nf_file, __entry->status
1035 	)
1036 );
1037 
1038 TRACE_EVENT(nfsd_file_insert_err,
1039 	TP_PROTO(
1040 		const struct svc_rqst *rqstp,
1041 		const struct inode *inode,
1042 		unsigned int may_flags,
1043 		long error
1044 	),
1045 	TP_ARGS(rqstp, inode, may_flags, error),
1046 	TP_STRUCT__entry(
1047 		__field(u32, xid)
1048 		__field(const void *, inode)
1049 		__field(unsigned long, may_flags)
1050 		__field(long, error)
1051 	),
1052 	TP_fast_assign(
1053 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
1054 		__entry->inode = inode;
1055 		__entry->may_flags = may_flags;
1056 		__entry->error = error;
1057 	),
1058 	TP_printk("xid=0x%x inode=%p may_flags=%s error=%ld",
1059 		__entry->xid, __entry->inode,
1060 		show_nfsd_may_flags(__entry->may_flags),
1061 		__entry->error
1062 	)
1063 );
1064 
1065 TRACE_EVENT(nfsd_file_cons_err,
1066 	TP_PROTO(
1067 		const struct svc_rqst *rqstp,
1068 		const struct inode *inode,
1069 		unsigned int may_flags,
1070 		const struct nfsd_file *nf
1071 	),
1072 	TP_ARGS(rqstp, inode, may_flags, nf),
1073 	TP_STRUCT__entry(
1074 		__field(u32, xid)
1075 		__field(const void *, inode)
1076 		__field(unsigned long, may_flags)
1077 		__field(unsigned int, nf_ref)
1078 		__field(unsigned long, nf_flags)
1079 		__field(unsigned long, nf_may)
1080 		__field(const void *, nf_file)
1081 	),
1082 	TP_fast_assign(
1083 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
1084 		__entry->inode = inode;
1085 		__entry->may_flags = may_flags;
1086 		__entry->nf_ref = refcount_read(&nf->nf_ref);
1087 		__entry->nf_flags = nf->nf_flags;
1088 		__entry->nf_may = nf->nf_may;
1089 		__entry->nf_file = nf->nf_file;
1090 	),
1091 	TP_printk("xid=0x%x inode=%p may_flags=%s ref=%u nf_flags=%s nf_may=%s nf_file=%p",
1092 		__entry->xid, __entry->inode,
1093 		show_nfsd_may_flags(__entry->may_flags), __entry->nf_ref,
1094 		show_nf_flags(__entry->nf_flags),
1095 		show_nfsd_may_flags(__entry->nf_may), __entry->nf_file
1096 	)
1097 );
1098 
1099 DECLARE_EVENT_CLASS(nfsd_file_open_class,
1100 	TP_PROTO(const struct nfsd_file *nf, __be32 status),
1101 	TP_ARGS(nf, status),
1102 	TP_STRUCT__entry(
1103 		__field(void *, nf_inode)	/* cannot be dereferenced */
1104 		__field(int, nf_ref)
1105 		__field(unsigned long, nf_flags)
1106 		__field(unsigned long, nf_may)
1107 		__field(void *, nf_file)	/* cannot be dereferenced */
1108 	),
1109 	TP_fast_assign(
1110 		__entry->nf_inode = nf->nf_inode;
1111 		__entry->nf_ref = refcount_read(&nf->nf_ref);
1112 		__entry->nf_flags = nf->nf_flags;
1113 		__entry->nf_may = nf->nf_may;
1114 		__entry->nf_file = nf->nf_file;
1115 	),
1116 	TP_printk("inode=%p ref=%d flags=%s may=%s file=%p",
1117 		__entry->nf_inode,
1118 		__entry->nf_ref,
1119 		show_nf_flags(__entry->nf_flags),
1120 		show_nfsd_may_flags(__entry->nf_may),
1121 		__entry->nf_file)
1122 )
1123 
1124 #define DEFINE_NFSD_FILE_OPEN_EVENT(name)					\
1125 DEFINE_EVENT(nfsd_file_open_class, name,					\
1126 	TP_PROTO(							\
1127 		const struct nfsd_file *nf,				\
1128 		__be32 status						\
1129 	),								\
1130 	TP_ARGS(nf, status))
1131 
1132 DEFINE_NFSD_FILE_OPEN_EVENT(nfsd_file_open);
1133 DEFINE_NFSD_FILE_OPEN_EVENT(nfsd_file_opened);
1134 
1135 TRACE_EVENT(nfsd_file_is_cached,
1136 	TP_PROTO(
1137 		const struct inode *inode,
1138 		int found
1139 	),
1140 	TP_ARGS(inode, found),
1141 	TP_STRUCT__entry(
1142 		__field(const struct inode *, inode)
1143 		__field(int, found)
1144 	),
1145 	TP_fast_assign(
1146 		__entry->inode = inode;
1147 		__entry->found = found;
1148 	),
1149 	TP_printk("inode=%p is %scached",
1150 		__entry->inode,
1151 		__entry->found ? "" : "not "
1152 	)
1153 );
1154 
1155 TRACE_EVENT(nfsd_file_fsnotify_handle_event,
1156 	TP_PROTO(struct inode *inode, u32 mask),
1157 	TP_ARGS(inode, mask),
1158 	TP_STRUCT__entry(
1159 		__field(struct inode *, inode)
1160 		__field(unsigned int, nlink)
1161 		__field(umode_t, mode)
1162 		__field(u32, mask)
1163 	),
1164 	TP_fast_assign(
1165 		__entry->inode = inode;
1166 		__entry->nlink = inode->i_nlink;
1167 		__entry->mode = inode->i_mode;
1168 		__entry->mask = mask;
1169 	),
1170 	TP_printk("inode=%p nlink=%u mode=0%ho mask=0x%x", __entry->inode,
1171 			__entry->nlink, __entry->mode, __entry->mask)
1172 );
1173 
1174 DECLARE_EVENT_CLASS(nfsd_file_gc_class,
1175 	TP_PROTO(
1176 		const struct nfsd_file *nf
1177 	),
1178 	TP_ARGS(nf),
1179 	TP_STRUCT__entry(
1180 		__field(void *, nf_inode)
1181 		__field(void *, nf_file)
1182 		__field(int, nf_ref)
1183 		__field(unsigned long, nf_flags)
1184 	),
1185 	TP_fast_assign(
1186 		__entry->nf_inode = nf->nf_inode;
1187 		__entry->nf_file = nf->nf_file;
1188 		__entry->nf_ref = refcount_read(&nf->nf_ref);
1189 		__entry->nf_flags = nf->nf_flags;
1190 	),
1191 	TP_printk("inode=%p ref=%d nf_flags=%s nf_file=%p",
1192 		__entry->nf_inode, __entry->nf_ref,
1193 		show_nf_flags(__entry->nf_flags),
1194 		__entry->nf_file
1195 	)
1196 );
1197 
1198 #define DEFINE_NFSD_FILE_GC_EVENT(name)					\
1199 DEFINE_EVENT(nfsd_file_gc_class, name,					\
1200 	TP_PROTO(							\
1201 		const struct nfsd_file *nf				\
1202 	),								\
1203 	TP_ARGS(nf))
1204 
1205 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add);
1206 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add_disposed);
1207 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del);
1208 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del_disposed);
1209 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_in_use);
1210 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_writeback);
1211 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_referenced);
1212 DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_disposed);
1213 
1214 DECLARE_EVENT_CLASS(nfsd_file_lruwalk_class,
1215 	TP_PROTO(
1216 		unsigned long removed,
1217 		unsigned long remaining
1218 	),
1219 	TP_ARGS(removed, remaining),
1220 	TP_STRUCT__entry(
1221 		__field(unsigned long, removed)
1222 		__field(unsigned long, remaining)
1223 	),
1224 	TP_fast_assign(
1225 		__entry->removed = removed;
1226 		__entry->remaining = remaining;
1227 	),
1228 	TP_printk("%lu entries removed, %lu remaining",
1229 		__entry->removed, __entry->remaining)
1230 );
1231 
1232 #define DEFINE_NFSD_FILE_LRUWALK_EVENT(name)				\
1233 DEFINE_EVENT(nfsd_file_lruwalk_class, name,				\
1234 	TP_PROTO(							\
1235 		unsigned long removed,					\
1236 		unsigned long remaining					\
1237 	),								\
1238 	TP_ARGS(removed, remaining))
1239 
1240 DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_removed);
1241 DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_shrinker_removed);
1242 
1243 TRACE_EVENT(nfsd_file_close,
1244 	TP_PROTO(
1245 		const struct inode *inode
1246 	),
1247 	TP_ARGS(inode),
1248 	TP_STRUCT__entry(
1249 		__field(const void *, inode)
1250 	),
1251 	TP_fast_assign(
1252 		__entry->inode = inode;
1253 	),
1254 	TP_printk("inode=%p",
1255 		__entry->inode
1256 	)
1257 );
1258 
1259 #include "cache.h"
1260 
1261 TRACE_DEFINE_ENUM(RC_DROPIT);
1262 TRACE_DEFINE_ENUM(RC_REPLY);
1263 TRACE_DEFINE_ENUM(RC_DOIT);
1264 
1265 #define show_drc_retval(x)						\
1266 	__print_symbolic(x,						\
1267 		{ RC_DROPIT, "DROPIT" },				\
1268 		{ RC_REPLY, "REPLY" },					\
1269 		{ RC_DOIT, "DOIT" })
1270 
1271 TRACE_EVENT(nfsd_drc_found,
1272 	TP_PROTO(
1273 		const struct nfsd_net *nn,
1274 		const struct svc_rqst *rqstp,
1275 		int result
1276 	),
1277 	TP_ARGS(nn, rqstp, result),
1278 	TP_STRUCT__entry(
1279 		__field(unsigned long long, boot_time)
1280 		__field(unsigned long, result)
1281 		__field(u32, xid)
1282 	),
1283 	TP_fast_assign(
1284 		__entry->boot_time = nn->boot_time;
1285 		__entry->result = result;
1286 		__entry->xid = be32_to_cpu(rqstp->rq_xid);
1287 	),
1288 	TP_printk("boot_time=%16llx xid=0x%08x result=%s",
1289 		__entry->boot_time, __entry->xid,
1290 		show_drc_retval(__entry->result))
1291 
1292 );
1293 
1294 TRACE_EVENT(nfsd_drc_mismatch,
1295 	TP_PROTO(
1296 		const struct nfsd_net *nn,
1297 		const struct nfsd_cacherep *key,
1298 		const struct nfsd_cacherep *rp
1299 	),
1300 	TP_ARGS(nn, key, rp),
1301 	TP_STRUCT__entry(
1302 		__field(unsigned long long, boot_time)
1303 		__field(u32, xid)
1304 		__field(u32, cached)
1305 		__field(u32, ingress)
1306 	),
1307 	TP_fast_assign(
1308 		__entry->boot_time = nn->boot_time;
1309 		__entry->xid = be32_to_cpu(key->c_key.k_xid);
1310 		__entry->cached = (__force u32)key->c_key.k_csum;
1311 		__entry->ingress = (__force u32)rp->c_key.k_csum;
1312 	),
1313 	TP_printk("boot_time=%16llx xid=0x%08x cached-csum=0x%08x ingress-csum=0x%08x",
1314 		__entry->boot_time, __entry->xid, __entry->cached,
1315 		__entry->ingress)
1316 );
1317 
1318 TRACE_EVENT(nfsd_cb_args,
1319 	TP_PROTO(
1320 		const struct nfs4_client *clp,
1321 		const struct nfs4_cb_conn *conn
1322 	),
1323 	TP_ARGS(clp, conn),
1324 	TP_STRUCT__entry(
1325 		__field(u32, cl_boot)
1326 		__field(u32, cl_id)
1327 		__field(u32, prog)
1328 		__field(u32, ident)
1329 		__sockaddr(addr, conn->cb_addrlen)
1330 	),
1331 	TP_fast_assign(
1332 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1333 		__entry->cl_id = clp->cl_clientid.cl_id;
1334 		__entry->prog = conn->cb_prog;
1335 		__entry->ident = conn->cb_ident;
1336 		__assign_sockaddr(addr, &conn->cb_addr, conn->cb_addrlen);
1337 	),
1338 	TP_printk("addr=%pISpc client %08x:%08x prog=%u ident=%u",
1339 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1340 		__entry->prog, __entry->ident)
1341 );
1342 
1343 TRACE_EVENT(nfsd_cb_nodelegs,
1344 	TP_PROTO(const struct nfs4_client *clp),
1345 	TP_ARGS(clp),
1346 	TP_STRUCT__entry(
1347 		__field(u32, cl_boot)
1348 		__field(u32, cl_id)
1349 	),
1350 	TP_fast_assign(
1351 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1352 		__entry->cl_id = clp->cl_clientid.cl_id;
1353 	),
1354 	TP_printk("client %08x:%08x", __entry->cl_boot, __entry->cl_id)
1355 )
1356 
1357 #define show_cb_state(val)						\
1358 	__print_symbolic(val,						\
1359 		{ NFSD4_CB_UP,		"UP" },				\
1360 		{ NFSD4_CB_UNKNOWN,	"UNKNOWN" },			\
1361 		{ NFSD4_CB_DOWN,	"DOWN" },			\
1362 		{ NFSD4_CB_FAULT,	"FAULT"})
1363 
1364 DECLARE_EVENT_CLASS(nfsd_cb_class,
1365 	TP_PROTO(const struct nfs4_client *clp),
1366 	TP_ARGS(clp),
1367 	TP_STRUCT__entry(
1368 		__field(unsigned long, state)
1369 		__field(u32, cl_boot)
1370 		__field(u32, cl_id)
1371 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1372 	),
1373 	TP_fast_assign(
1374 		__entry->state = clp->cl_cb_state;
1375 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1376 		__entry->cl_id = clp->cl_clientid.cl_id;
1377 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1378 				  clp->cl_cb_conn.cb_addrlen)
1379 	),
1380 	TP_printk("addr=%pISpc client %08x:%08x state=%s",
1381 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1382 		show_cb_state(__entry->state))
1383 );
1384 
1385 #define DEFINE_NFSD_CB_EVENT(name)			\
1386 DEFINE_EVENT(nfsd_cb_class, nfsd_cb_##name,		\
1387 	TP_PROTO(const struct nfs4_client *clp),	\
1388 	TP_ARGS(clp))
1389 
1390 DEFINE_NFSD_CB_EVENT(start);
1391 DEFINE_NFSD_CB_EVENT(new_state);
1392 DEFINE_NFSD_CB_EVENT(probe);
1393 DEFINE_NFSD_CB_EVENT(lost);
1394 DEFINE_NFSD_CB_EVENT(shutdown);
1395 
1396 TRACE_DEFINE_ENUM(RPC_AUTH_NULL);
1397 TRACE_DEFINE_ENUM(RPC_AUTH_UNIX);
1398 TRACE_DEFINE_ENUM(RPC_AUTH_GSS);
1399 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5);
1400 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5I);
1401 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5P);
1402 
1403 #define show_nfsd_authflavor(val)					\
1404 	__print_symbolic(val,						\
1405 		{ RPC_AUTH_NULL,		"none" },		\
1406 		{ RPC_AUTH_UNIX,		"sys" },		\
1407 		{ RPC_AUTH_GSS,			"gss" },		\
1408 		{ RPC_AUTH_GSS_KRB5,		"krb5" },		\
1409 		{ RPC_AUTH_GSS_KRB5I,		"krb5i" },		\
1410 		{ RPC_AUTH_GSS_KRB5P,		"krb5p" })
1411 
1412 TRACE_EVENT(nfsd_cb_setup,
1413 	TP_PROTO(const struct nfs4_client *clp,
1414 		 const char *netid,
1415 		 rpc_authflavor_t authflavor
1416 	),
1417 	TP_ARGS(clp, netid, authflavor),
1418 	TP_STRUCT__entry(
1419 		__field(u32, cl_boot)
1420 		__field(u32, cl_id)
1421 		__field(unsigned long, authflavor)
1422 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1423 		__string(netid, netid)
1424 	),
1425 	TP_fast_assign(
1426 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1427 		__entry->cl_id = clp->cl_clientid.cl_id;
1428 		__assign_str(netid, netid);
1429 		__entry->authflavor = authflavor;
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 proto=%s flavor=%s",
1434 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1435 		__get_str(netid), show_nfsd_authflavor(__entry->authflavor))
1436 );
1437 
1438 TRACE_EVENT(nfsd_cb_setup_err,
1439 	TP_PROTO(
1440 		const struct nfs4_client *clp,
1441 		long error
1442 	),
1443 	TP_ARGS(clp, error),
1444 	TP_STRUCT__entry(
1445 		__field(long, error)
1446 		__field(u32, cl_boot)
1447 		__field(u32, cl_id)
1448 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1449 	),
1450 	TP_fast_assign(
1451 		__entry->error = error;
1452 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1453 		__entry->cl_id = clp->cl_clientid.cl_id;
1454 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1455 				  clp->cl_cb_conn.cb_addrlen)
1456 	),
1457 	TP_printk("addr=%pISpc client %08x:%08x error=%ld",
1458 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1459 		__entry->error)
1460 );
1461 
1462 DECLARE_EVENT_CLASS(nfsd_cb_lifetime_class,
1463 	TP_PROTO(
1464 		const struct nfs4_client *clp,
1465 		const struct nfsd4_callback *cb
1466 	),
1467 	TP_ARGS(clp, cb),
1468 	TP_STRUCT__entry(
1469 		__field(u32, cl_boot)
1470 		__field(u32, cl_id)
1471 		__field(const void *, cb)
1472 		__field(bool, need_restart)
1473 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1474 	),
1475 	TP_fast_assign(
1476 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1477 		__entry->cl_id = clp->cl_clientid.cl_id;
1478 		__entry->cb = cb;
1479 		__entry->need_restart = cb->cb_need_restart;
1480 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1481 				  clp->cl_cb_conn.cb_addrlen)
1482 	),
1483 	TP_printk("addr=%pISpc client %08x:%08x cb=%p%s",
1484 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1485 		__entry->cb, __entry->need_restart ?
1486 			" (need restart)" : " (first try)"
1487 	)
1488 );
1489 
1490 #define DEFINE_NFSD_CB_LIFETIME_EVENT(name)		\
1491 DEFINE_EVENT(nfsd_cb_lifetime_class, nfsd_cb_##name,	\
1492 	TP_PROTO(					\
1493 		const struct nfs4_client *clp,		\
1494 		const struct nfsd4_callback *cb		\
1495 	),						\
1496 	TP_ARGS(clp, cb))
1497 
1498 DEFINE_NFSD_CB_LIFETIME_EVENT(queue);
1499 DEFINE_NFSD_CB_LIFETIME_EVENT(destroy);
1500 DEFINE_NFSD_CB_LIFETIME_EVENT(restart);
1501 DEFINE_NFSD_CB_LIFETIME_EVENT(bc_update);
1502 DEFINE_NFSD_CB_LIFETIME_EVENT(bc_shutdown);
1503 
1504 TRACE_EVENT(nfsd_cb_seq_status,
1505 	TP_PROTO(
1506 		const struct rpc_task *task,
1507 		const struct nfsd4_callback *cb
1508 	),
1509 	TP_ARGS(task, cb),
1510 	TP_STRUCT__entry(
1511 		__field(unsigned int, task_id)
1512 		__field(unsigned int, client_id)
1513 		__field(u32, cl_boot)
1514 		__field(u32, cl_id)
1515 		__field(u32, seqno)
1516 		__field(u32, reserved)
1517 		__field(int, tk_status)
1518 		__field(int, seq_status)
1519 	),
1520 	TP_fast_assign(
1521 		const struct nfs4_client *clp = cb->cb_clp;
1522 		const struct nfsd4_session *session = clp->cl_cb_session;
1523 		const struct nfsd4_sessionid *sid =
1524 			(struct nfsd4_sessionid *)&session->se_sessionid;
1525 
1526 		__entry->task_id = task->tk_pid;
1527 		__entry->client_id = task->tk_client ?
1528 				     task->tk_client->cl_clid : -1;
1529 		__entry->cl_boot = sid->clientid.cl_boot;
1530 		__entry->cl_id = sid->clientid.cl_id;
1531 		__entry->seqno = sid->sequence;
1532 		__entry->reserved = sid->reserved;
1533 		__entry->tk_status = task->tk_status;
1534 		__entry->seq_status = cb->cb_seq_status;
1535 	),
1536 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1537 		" sessionid=%08x:%08x:%08x:%08x tk_status=%d seq_status=%d\n",
1538 		__entry->task_id, __entry->client_id,
1539 		__entry->cl_boot, __entry->cl_id,
1540 		__entry->seqno, __entry->reserved,
1541 		__entry->tk_status, __entry->seq_status
1542 	)
1543 );
1544 
1545 TRACE_EVENT(nfsd_cb_free_slot,
1546 	TP_PROTO(
1547 		const struct rpc_task *task,
1548 		const struct nfsd4_callback *cb
1549 	),
1550 	TP_ARGS(task, cb),
1551 	TP_STRUCT__entry(
1552 		__field(unsigned int, task_id)
1553 		__field(unsigned int, client_id)
1554 		__field(u32, cl_boot)
1555 		__field(u32, cl_id)
1556 		__field(u32, seqno)
1557 		__field(u32, reserved)
1558 		__field(u32, slot_seqno)
1559 	),
1560 	TP_fast_assign(
1561 		const struct nfs4_client *clp = cb->cb_clp;
1562 		const struct nfsd4_session *session = clp->cl_cb_session;
1563 		const struct nfsd4_sessionid *sid =
1564 			(struct nfsd4_sessionid *)&session->se_sessionid;
1565 
1566 		__entry->task_id = task->tk_pid;
1567 		__entry->client_id = task->tk_client ?
1568 				     task->tk_client->cl_clid : -1;
1569 		__entry->cl_boot = sid->clientid.cl_boot;
1570 		__entry->cl_id = sid->clientid.cl_id;
1571 		__entry->seqno = sid->sequence;
1572 		__entry->reserved = sid->reserved;
1573 		__entry->slot_seqno = session->se_cb_seq_nr;
1574 	),
1575 	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1576 		" sessionid=%08x:%08x:%08x:%08x new slot seqno=%u\n",
1577 		__entry->task_id, __entry->client_id,
1578 		__entry->cl_boot, __entry->cl_id,
1579 		__entry->seqno, __entry->reserved,
1580 		__entry->slot_seqno
1581 	)
1582 );
1583 
1584 TRACE_EVENT_CONDITION(nfsd_cb_recall,
1585 	TP_PROTO(
1586 		const struct nfs4_stid *stid
1587 	),
1588 	TP_ARGS(stid),
1589 	TP_CONDITION(stid->sc_client),
1590 	TP_STRUCT__entry(
1591 		__field(u32, cl_boot)
1592 		__field(u32, cl_id)
1593 		__field(u32, si_id)
1594 		__field(u32, si_generation)
1595 		__sockaddr(addr, stid->sc_client->cl_cb_conn.cb_addrlen)
1596 	),
1597 	TP_fast_assign(
1598 		const stateid_t *stp = &stid->sc_stateid;
1599 		const struct nfs4_client *clp = stid->sc_client;
1600 
1601 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
1602 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
1603 		__entry->si_id = stp->si_opaque.so_id;
1604 		__entry->si_generation = stp->si_generation;
1605 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1606 				  clp->cl_cb_conn.cb_addrlen)
1607 	),
1608 	TP_printk("addr=%pISpc client %08x:%08x stateid %08x:%08x",
1609 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1610 		__entry->si_id, __entry->si_generation)
1611 );
1612 
1613 TRACE_EVENT(nfsd_cb_notify_lock,
1614 	TP_PROTO(
1615 		const struct nfs4_lockowner *lo,
1616 		const struct nfsd4_blocked_lock *nbl
1617 	),
1618 	TP_ARGS(lo, nbl),
1619 	TP_STRUCT__entry(
1620 		__field(u32, cl_boot)
1621 		__field(u32, cl_id)
1622 		__field(u32, fh_hash)
1623 		__sockaddr(addr, lo->lo_owner.so_client->cl_cb_conn.cb_addrlen)
1624 	),
1625 	TP_fast_assign(
1626 		const struct nfs4_client *clp = lo->lo_owner.so_client;
1627 
1628 		__entry->cl_boot = clp->cl_clientid.cl_boot;
1629 		__entry->cl_id = clp->cl_clientid.cl_id;
1630 		__entry->fh_hash = knfsd_fh_hash(&nbl->nbl_fh);
1631 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1632 				  clp->cl_cb_conn.cb_addrlen)
1633 	),
1634 	TP_printk("addr=%pISpc client %08x:%08x fh_hash=0x%08x",
1635 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1636 		__entry->fh_hash)
1637 );
1638 
1639 TRACE_EVENT(nfsd_cb_offload,
1640 	TP_PROTO(
1641 		const struct nfs4_client *clp,
1642 		const stateid_t *stp,
1643 		const struct knfsd_fh *fh,
1644 		u64 count,
1645 		__be32 status
1646 	),
1647 	TP_ARGS(clp, stp, fh, count, status),
1648 	TP_STRUCT__entry(
1649 		__field(u32, cl_boot)
1650 		__field(u32, cl_id)
1651 		__field(u32, si_id)
1652 		__field(u32, si_generation)
1653 		__field(u32, fh_hash)
1654 		__field(int, status)
1655 		__field(u64, count)
1656 		__sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
1657 	),
1658 	TP_fast_assign(
1659 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
1660 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
1661 		__entry->si_id = stp->si_opaque.so_id;
1662 		__entry->si_generation = stp->si_generation;
1663 		__entry->fh_hash = knfsd_fh_hash(fh);
1664 		__entry->status = be32_to_cpu(status);
1665 		__entry->count = count;
1666 		__assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
1667 				  clp->cl_cb_conn.cb_addrlen)
1668 	),
1669 	TP_printk("addr=%pISpc client %08x:%08x stateid %08x:%08x fh_hash=0x%08x count=%llu status=%d",
1670 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1671 		__entry->si_id, __entry->si_generation,
1672 		__entry->fh_hash, __entry->count, __entry->status)
1673 );
1674 
1675 TRACE_EVENT(nfsd_cb_recall_any,
1676 	TP_PROTO(
1677 		const struct nfsd4_cb_recall_any *ra
1678 	),
1679 	TP_ARGS(ra),
1680 	TP_STRUCT__entry(
1681 		__field(u32, cl_boot)
1682 		__field(u32, cl_id)
1683 		__field(u32, keep)
1684 		__field(unsigned long, bmval0)
1685 		__sockaddr(addr, ra->ra_cb.cb_clp->cl_cb_conn.cb_addrlen)
1686 	),
1687 	TP_fast_assign(
1688 		__entry->cl_boot = ra->ra_cb.cb_clp->cl_clientid.cl_boot;
1689 		__entry->cl_id = ra->ra_cb.cb_clp->cl_clientid.cl_id;
1690 		__entry->keep = ra->ra_keep;
1691 		__entry->bmval0 = ra->ra_bmval[0];
1692 		__assign_sockaddr(addr, &ra->ra_cb.cb_clp->cl_addr,
1693 				  ra->ra_cb.cb_clp->cl_cb_conn.cb_addrlen);
1694 	),
1695 	TP_printk("addr=%pISpc client %08x:%08x keep=%u bmval0=%s",
1696 		__get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
1697 		__entry->keep, show_rca_mask(__entry->bmval0)
1698 	)
1699 );
1700 
1701 DECLARE_EVENT_CLASS(nfsd_cb_done_class,
1702 	TP_PROTO(
1703 		const stateid_t *stp,
1704 		const struct rpc_task *task
1705 	),
1706 	TP_ARGS(stp, task),
1707 	TP_STRUCT__entry(
1708 		__field(u32, cl_boot)
1709 		__field(u32, cl_id)
1710 		__field(u32, si_id)
1711 		__field(u32, si_generation)
1712 		__field(int, status)
1713 	),
1714 	TP_fast_assign(
1715 		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
1716 		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
1717 		__entry->si_id = stp->si_opaque.so_id;
1718 		__entry->si_generation = stp->si_generation;
1719 		__entry->status = task->tk_status;
1720 	),
1721 	TP_printk("client %08x:%08x stateid %08x:%08x status=%d",
1722 		__entry->cl_boot, __entry->cl_id, __entry->si_id,
1723 		__entry->si_generation, __entry->status
1724 	)
1725 );
1726 
1727 #define DEFINE_NFSD_CB_DONE_EVENT(name)			\
1728 DEFINE_EVENT(nfsd_cb_done_class, name,			\
1729 	TP_PROTO(					\
1730 		const stateid_t *stp,			\
1731 		const struct rpc_task *task		\
1732 	),						\
1733 	TP_ARGS(stp, task))
1734 
1735 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_recall_done);
1736 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_notify_lock_done);
1737 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_layout_done);
1738 DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_offload_done);
1739 
1740 TRACE_EVENT(nfsd_cb_recall_any_done,
1741 	TP_PROTO(
1742 		const struct nfsd4_callback *cb,
1743 		const struct rpc_task *task
1744 	),
1745 	TP_ARGS(cb, task),
1746 	TP_STRUCT__entry(
1747 		__field(u32, cl_boot)
1748 		__field(u32, cl_id)
1749 		__field(int, status)
1750 	),
1751 	TP_fast_assign(
1752 		__entry->status = task->tk_status;
1753 		__entry->cl_boot = cb->cb_clp->cl_clientid.cl_boot;
1754 		__entry->cl_id = cb->cb_clp->cl_clientid.cl_id;
1755 	),
1756 	TP_printk("client %08x:%08x status=%d",
1757 		__entry->cl_boot, __entry->cl_id, __entry->status
1758 	)
1759 );
1760 
1761 TRACE_EVENT(nfsd_ctl_unlock_ip,
1762 	TP_PROTO(
1763 		const struct net *net,
1764 		const char *address
1765 	),
1766 	TP_ARGS(net, address),
1767 	TP_STRUCT__entry(
1768 		__field(unsigned int, netns_ino)
1769 		__string(address, address)
1770 	),
1771 	TP_fast_assign(
1772 		__entry->netns_ino = net->ns.inum;
1773 		__assign_str(address, address);
1774 	),
1775 	TP_printk("address=%s",
1776 		__get_str(address)
1777 	)
1778 );
1779 
1780 TRACE_EVENT(nfsd_ctl_unlock_fs,
1781 	TP_PROTO(
1782 		const struct net *net,
1783 		const char *path
1784 	),
1785 	TP_ARGS(net, path),
1786 	TP_STRUCT__entry(
1787 		__field(unsigned int, netns_ino)
1788 		__string(path, path)
1789 	),
1790 	TP_fast_assign(
1791 		__entry->netns_ino = net->ns.inum;
1792 		__assign_str(path, path);
1793 	),
1794 	TP_printk("path=%s",
1795 		__get_str(path)
1796 	)
1797 );
1798 
1799 TRACE_EVENT(nfsd_ctl_filehandle,
1800 	TP_PROTO(
1801 		const struct net *net,
1802 		const char *domain,
1803 		const char *path,
1804 		int maxsize
1805 	),
1806 	TP_ARGS(net, domain, path, maxsize),
1807 	TP_STRUCT__entry(
1808 		__field(unsigned int, netns_ino)
1809 		__field(int, maxsize)
1810 		__string(domain, domain)
1811 		__string(path, path)
1812 	),
1813 	TP_fast_assign(
1814 		__entry->netns_ino = net->ns.inum;
1815 		__entry->maxsize = maxsize;
1816 		__assign_str(domain, domain);
1817 		__assign_str(path, path);
1818 	),
1819 	TP_printk("domain=%s path=%s maxsize=%d",
1820 		__get_str(domain), __get_str(path), __entry->maxsize
1821 	)
1822 );
1823 
1824 TRACE_EVENT(nfsd_ctl_threads,
1825 	TP_PROTO(
1826 		const struct net *net,
1827 		int newthreads
1828 	),
1829 	TP_ARGS(net, newthreads),
1830 	TP_STRUCT__entry(
1831 		__field(unsigned int, netns_ino)
1832 		__field(int, newthreads)
1833 	),
1834 	TP_fast_assign(
1835 		__entry->netns_ino = net->ns.inum;
1836 		__entry->newthreads = newthreads;
1837 	),
1838 	TP_printk("newthreads=%d",
1839 		__entry->newthreads
1840 	)
1841 );
1842 
1843 TRACE_EVENT(nfsd_ctl_pool_threads,
1844 	TP_PROTO(
1845 		const struct net *net,
1846 		int pool,
1847 		int nrthreads
1848 	),
1849 	TP_ARGS(net, pool, nrthreads),
1850 	TP_STRUCT__entry(
1851 		__field(unsigned int, netns_ino)
1852 		__field(int, pool)
1853 		__field(int, nrthreads)
1854 	),
1855 	TP_fast_assign(
1856 		__entry->netns_ino = net->ns.inum;
1857 		__entry->pool = pool;
1858 		__entry->nrthreads = nrthreads;
1859 	),
1860 	TP_printk("pool=%d nrthreads=%d",
1861 		__entry->pool, __entry->nrthreads
1862 	)
1863 );
1864 
1865 TRACE_EVENT(nfsd_ctl_version,
1866 	TP_PROTO(
1867 		const struct net *net,
1868 		const char *mesg
1869 	),
1870 	TP_ARGS(net, mesg),
1871 	TP_STRUCT__entry(
1872 		__field(unsigned int, netns_ino)
1873 		__string(mesg, mesg)
1874 	),
1875 	TP_fast_assign(
1876 		__entry->netns_ino = net->ns.inum;
1877 		__assign_str(mesg, mesg);
1878 	),
1879 	TP_printk("%s",
1880 		__get_str(mesg)
1881 	)
1882 );
1883 
1884 TRACE_EVENT(nfsd_ctl_ports_addfd,
1885 	TP_PROTO(
1886 		const struct net *net,
1887 		int fd
1888 	),
1889 	TP_ARGS(net, fd),
1890 	TP_STRUCT__entry(
1891 		__field(unsigned int, netns_ino)
1892 		__field(int, fd)
1893 	),
1894 	TP_fast_assign(
1895 		__entry->netns_ino = net->ns.inum;
1896 		__entry->fd = fd;
1897 	),
1898 	TP_printk("fd=%d",
1899 		__entry->fd
1900 	)
1901 );
1902 
1903 TRACE_EVENT(nfsd_ctl_ports_addxprt,
1904 	TP_PROTO(
1905 		const struct net *net,
1906 		const char *transport,
1907 		int port
1908 	),
1909 	TP_ARGS(net, transport, port),
1910 	TP_STRUCT__entry(
1911 		__field(unsigned int, netns_ino)
1912 		__field(int, port)
1913 		__string(transport, transport)
1914 	),
1915 	TP_fast_assign(
1916 		__entry->netns_ino = net->ns.inum;
1917 		__entry->port = port;
1918 		__assign_str(transport, transport);
1919 	),
1920 	TP_printk("transport=%s port=%d",
1921 		__get_str(transport), __entry->port
1922 	)
1923 );
1924 
1925 TRACE_EVENT(nfsd_ctl_maxblksize,
1926 	TP_PROTO(
1927 		const struct net *net,
1928 		int bsize
1929 	),
1930 	TP_ARGS(net, bsize),
1931 	TP_STRUCT__entry(
1932 		__field(unsigned int, netns_ino)
1933 		__field(int, bsize)
1934 	),
1935 	TP_fast_assign(
1936 		__entry->netns_ino = net->ns.inum;
1937 		__entry->bsize = bsize;
1938 	),
1939 	TP_printk("bsize=%d",
1940 		__entry->bsize
1941 	)
1942 );
1943 
1944 TRACE_EVENT(nfsd_ctl_maxconn,
1945 	TP_PROTO(
1946 		const struct net *net,
1947 		int maxconn
1948 	),
1949 	TP_ARGS(net, maxconn),
1950 	TP_STRUCT__entry(
1951 		__field(unsigned int, netns_ino)
1952 		__field(int, maxconn)
1953 	),
1954 	TP_fast_assign(
1955 		__entry->netns_ino = net->ns.inum;
1956 		__entry->maxconn = maxconn;
1957 	),
1958 	TP_printk("maxconn=%d",
1959 		__entry->maxconn
1960 	)
1961 );
1962 
1963 TRACE_EVENT(nfsd_ctl_time,
1964 	TP_PROTO(
1965 		const struct net *net,
1966 		const char *name,
1967 		size_t namelen,
1968 		int time
1969 	),
1970 	TP_ARGS(net, name, namelen, time),
1971 	TP_STRUCT__entry(
1972 		__field(unsigned int, netns_ino)
1973 		__field(int, time)
1974 		__string_len(name, name, namelen)
1975 	),
1976 	TP_fast_assign(
1977 		__entry->netns_ino = net->ns.inum;
1978 		__entry->time = time;
1979 		__assign_str(name, name);
1980 	),
1981 	TP_printk("file=%s time=%d\n",
1982 		__get_str(name), __entry->time
1983 	)
1984 );
1985 
1986 TRACE_EVENT(nfsd_ctl_recoverydir,
1987 	TP_PROTO(
1988 		const struct net *net,
1989 		const char *recdir
1990 	),
1991 	TP_ARGS(net, recdir),
1992 	TP_STRUCT__entry(
1993 		__field(unsigned int, netns_ino)
1994 		__string(recdir, recdir)
1995 	),
1996 	TP_fast_assign(
1997 		__entry->netns_ino = net->ns.inum;
1998 		__assign_str(recdir, recdir);
1999 	),
2000 	TP_printk("recdir=%s",
2001 		__get_str(recdir)
2002 	)
2003 );
2004 
2005 TRACE_EVENT(nfsd_end_grace,
2006 	TP_PROTO(
2007 		const struct net *net
2008 	),
2009 	TP_ARGS(net),
2010 	TP_STRUCT__entry(
2011 		__field(unsigned int, netns_ino)
2012 	),
2013 	TP_fast_assign(
2014 		__entry->netns_ino = net->ns.inum;
2015 	),
2016 	TP_printk("nn=%d", __entry->netns_ino
2017 	)
2018 );
2019 
2020 DECLARE_EVENT_CLASS(nfsd_copy_class,
2021 	TP_PROTO(
2022 		const struct nfsd4_copy *copy
2023 	),
2024 	TP_ARGS(copy),
2025 	TP_STRUCT__entry(
2026 		__field(bool, intra)
2027 		__field(bool, async)
2028 		__field(u32, src_cl_boot)
2029 		__field(u32, src_cl_id)
2030 		__field(u32, src_so_id)
2031 		__field(u32, src_si_generation)
2032 		__field(u32, dst_cl_boot)
2033 		__field(u32, dst_cl_id)
2034 		__field(u32, dst_so_id)
2035 		__field(u32, dst_si_generation)
2036 		__field(u64, src_cp_pos)
2037 		__field(u64, dst_cp_pos)
2038 		__field(u64, cp_count)
2039 		__sockaddr(addr, sizeof(struct sockaddr_in6))
2040 	),
2041 	TP_fast_assign(
2042 		const stateid_t *src_stp = &copy->cp_src_stateid;
2043 		const stateid_t *dst_stp = &copy->cp_dst_stateid;
2044 
2045 		__entry->intra = test_bit(NFSD4_COPY_F_INTRA, &copy->cp_flags);
2046 		__entry->async = !test_bit(NFSD4_COPY_F_SYNCHRONOUS, &copy->cp_flags);
2047 		__entry->src_cl_boot = src_stp->si_opaque.so_clid.cl_boot;
2048 		__entry->src_cl_id = src_stp->si_opaque.so_clid.cl_id;
2049 		__entry->src_so_id = src_stp->si_opaque.so_id;
2050 		__entry->src_si_generation = src_stp->si_generation;
2051 		__entry->dst_cl_boot = dst_stp->si_opaque.so_clid.cl_boot;
2052 		__entry->dst_cl_id = dst_stp->si_opaque.so_clid.cl_id;
2053 		__entry->dst_so_id = dst_stp->si_opaque.so_id;
2054 		__entry->dst_si_generation = dst_stp->si_generation;
2055 		__entry->src_cp_pos = copy->cp_src_pos;
2056 		__entry->dst_cp_pos = copy->cp_dst_pos;
2057 		__entry->cp_count = copy->cp_count;
2058 		__assign_sockaddr(addr, &copy->cp_clp->cl_addr,
2059 				sizeof(struct sockaddr_in6));
2060 	),
2061 	TP_printk("client=%pISpc intra=%d async=%d "
2062 		"src_stateid[si_generation:0x%x cl_boot:0x%x cl_id:0x%x so_id:0x%x] "
2063 		"dst_stateid[si_generation:0x%x cl_boot:0x%x cl_id:0x%x so_id:0x%x] "
2064 		"cp_src_pos=%llu cp_dst_pos=%llu cp_count=%llu",
2065 		__get_sockaddr(addr), __entry->intra, __entry->async,
2066 		__entry->src_si_generation, __entry->src_cl_boot,
2067 		__entry->src_cl_id, __entry->src_so_id,
2068 		__entry->dst_si_generation, __entry->dst_cl_boot,
2069 		__entry->dst_cl_id, __entry->dst_so_id,
2070 		__entry->src_cp_pos, __entry->dst_cp_pos, __entry->cp_count
2071 	)
2072 );
2073 
2074 #define DEFINE_COPY_EVENT(name)				\
2075 DEFINE_EVENT(nfsd_copy_class, nfsd_copy_##name,	\
2076 	TP_PROTO(const struct nfsd4_copy *copy),	\
2077 	TP_ARGS(copy))
2078 
2079 DEFINE_COPY_EVENT(inter);
2080 DEFINE_COPY_EVENT(intra);
2081 DEFINE_COPY_EVENT(do_async);
2082 
2083 TRACE_EVENT(nfsd_copy_done,
2084 	TP_PROTO(
2085 		const struct nfsd4_copy *copy,
2086 		__be32 status
2087 	),
2088 	TP_ARGS(copy, status),
2089 	TP_STRUCT__entry(
2090 		__field(int, status)
2091 		__field(bool, intra)
2092 		__field(bool, async)
2093 		__sockaddr(addr, sizeof(struct sockaddr_in6))
2094 	),
2095 	TP_fast_assign(
2096 		__entry->status = be32_to_cpu(status);
2097 		__entry->intra = test_bit(NFSD4_COPY_F_INTRA, &copy->cp_flags);
2098 		__entry->async = !test_bit(NFSD4_COPY_F_SYNCHRONOUS, &copy->cp_flags);
2099 		__assign_sockaddr(addr, &copy->cp_clp->cl_addr,
2100 				sizeof(struct sockaddr_in6));
2101 	),
2102 	TP_printk("addr=%pISpc status=%d intra=%d async=%d ",
2103 		__get_sockaddr(addr), __entry->status, __entry->intra, __entry->async
2104 	)
2105 );
2106 
2107 #endif /* _NFSD_TRACE_H */
2108 
2109 #undef TRACE_INCLUDE_PATH
2110 #define TRACE_INCLUDE_PATH .
2111 #define TRACE_INCLUDE_FILE trace
2112 #include <trace/define_trace.h>
2113