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