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