blob: 9abd1591a841cba1fb36b68b2ae48a1d203acabb [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Christoph Hellwig31ef83d2014-08-16 19:02:22 -05002/*
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>
Jeff Layton6e8b50d2015-11-17 06:52:23 -050012#include "nfsfh.h"
13
Chuck Leverfff40802018-03-27 10:53:54 -040014TRACE_EVENT(nfsd_compound,
15 TP_PROTO(const struct svc_rqst *rqst,
16 u32 args_opcnt),
17 TP_ARGS(rqst, args_opcnt),
18 TP_STRUCT__entry(
19 __field(u32, xid)
20 __field(u32, args_opcnt)
21 ),
22 TP_fast_assign(
23 __entry->xid = be32_to_cpu(rqst->rq_xid);
24 __entry->args_opcnt = args_opcnt;
25 ),
26 TP_printk("xid=0x%08x opcnt=%u",
27 __entry->xid, __entry->args_opcnt)
28)
29
30TRACE_EVENT(nfsd_compound_status,
31 TP_PROTO(u32 args_opcnt,
32 u32 resp_opcnt,
33 __be32 status,
34 const char *name),
35 TP_ARGS(args_opcnt, resp_opcnt, status, name),
36 TP_STRUCT__entry(
37 __field(u32, args_opcnt)
38 __field(u32, resp_opcnt)
39 __field(int, status)
40 __string(name, name)
41 ),
42 TP_fast_assign(
43 __entry->args_opcnt = args_opcnt;
44 __entry->resp_opcnt = resp_opcnt;
45 __entry->status = be32_to_cpu(status);
46 __assign_str(name, name);
47 ),
48 TP_printk("op=%u/%u %s status=%d",
49 __entry->resp_opcnt, __entry->args_opcnt,
50 __get_str(name), __entry->status)
51)
52
Trond Myklebustf01274a2020-03-01 18:21:39 -050053DECLARE_EVENT_CLASS(nfsd_fh_err_class,
54 TP_PROTO(struct svc_rqst *rqstp,
55 struct svc_fh *fhp,
56 int status),
57 TP_ARGS(rqstp, fhp, status),
58 TP_STRUCT__entry(
59 __field(u32, xid)
60 __field(u32, fh_hash)
61 __field(int, status)
62 ),
63 TP_fast_assign(
64 __entry->xid = be32_to_cpu(rqstp->rq_xid);
65 __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
66 __entry->status = status;
67 ),
68 TP_printk("xid=0x%08x fh_hash=0x%08x status=%d",
69 __entry->xid, __entry->fh_hash,
70 __entry->status)
71)
72
73#define DEFINE_NFSD_FH_ERR_EVENT(name) \
74DEFINE_EVENT(nfsd_fh_err_class, nfsd_##name, \
75 TP_PROTO(struct svc_rqst *rqstp, \
76 struct svc_fh *fhp, \
77 int status), \
78 TP_ARGS(rqstp, fhp, status))
79
80DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport);
81DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle);
82
Jeff Layton6e8b50d2015-11-17 06:52:23 -050083DECLARE_EVENT_CLASS(nfsd_io_class,
84 TP_PROTO(struct svc_rqst *rqstp,
85 struct svc_fh *fhp,
86 loff_t offset,
Chuck Lever79e0b4e2018-03-27 10:52:57 -040087 unsigned long len),
Jeff Layton6e8b50d2015-11-17 06:52:23 -050088 TP_ARGS(rqstp, fhp, offset, len),
89 TP_STRUCT__entry(
Chuck Leverafa720a2018-03-27 10:52:43 -040090 __field(u32, xid)
91 __field(u32, fh_hash)
Jeff Layton6e8b50d2015-11-17 06:52:23 -050092 __field(loff_t, offset)
Chuck Lever79e0b4e2018-03-27 10:52:57 -040093 __field(unsigned long, len)
Jeff Layton6e8b50d2015-11-17 06:52:23 -050094 ),
95 TP_fast_assign(
Chuck Leverafa720a2018-03-27 10:52:43 -040096 __entry->xid = be32_to_cpu(rqstp->rq_xid);
Chuck Lever79e0b4e2018-03-27 10:52:57 -040097 __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
Jeff Layton6e8b50d2015-11-17 06:52:23 -050098 __entry->offset = offset;
99 __entry->len = len;
100 ),
Chuck Lever79e0b4e2018-03-27 10:52:57 -0400101 TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld len=%lu",
Chuck Leverafa720a2018-03-27 10:52:43 -0400102 __entry->xid, __entry->fh_hash,
Jeff Layton6e8b50d2015-11-17 06:52:23 -0500103 __entry->offset, __entry->len)
104)
105
106#define DEFINE_NFSD_IO_EVENT(name) \
Chuck Leverf394b622018-03-27 10:53:11 -0400107DEFINE_EVENT(nfsd_io_class, nfsd_##name, \
Jeff Layton6e8b50d2015-11-17 06:52:23 -0500108 TP_PROTO(struct svc_rqst *rqstp, \
109 struct svc_fh *fhp, \
110 loff_t offset, \
Chuck Lever79e0b4e2018-03-27 10:52:57 -0400111 unsigned long len), \
Jeff Layton6e8b50d2015-11-17 06:52:23 -0500112 TP_ARGS(rqstp, fhp, offset, len))
113
114DEFINE_NFSD_IO_EVENT(read_start);
Chuck Lever87c59422018-03-28 13:29:11 -0400115DEFINE_NFSD_IO_EVENT(read_splice);
116DEFINE_NFSD_IO_EVENT(read_vector);
Jeff Layton6e8b50d2015-11-17 06:52:23 -0500117DEFINE_NFSD_IO_EVENT(read_io_done);
118DEFINE_NFSD_IO_EVENT(read_done);
119DEFINE_NFSD_IO_EVENT(write_start);
120DEFINE_NFSD_IO_EVENT(write_opened);
121DEFINE_NFSD_IO_EVENT(write_io_done);
122DEFINE_NFSD_IO_EVENT(write_done);
Christoph Hellwig31ef83d2014-08-16 19:02:22 -0500123
Chuck Leverd890be12018-03-27 10:53:27 -0400124DECLARE_EVENT_CLASS(nfsd_err_class,
125 TP_PROTO(struct svc_rqst *rqstp,
126 struct svc_fh *fhp,
127 loff_t offset,
128 int status),
129 TP_ARGS(rqstp, fhp, offset, status),
130 TP_STRUCT__entry(
131 __field(u32, xid)
132 __field(u32, fh_hash)
133 __field(loff_t, offset)
134 __field(int, status)
135 ),
136 TP_fast_assign(
137 __entry->xid = be32_to_cpu(rqstp->rq_xid);
138 __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
139 __entry->offset = offset;
140 __entry->status = status;
141 ),
142 TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld status=%d",
143 __entry->xid, __entry->fh_hash,
144 __entry->offset, __entry->status)
145)
146
147#define DEFINE_NFSD_ERR_EVENT(name) \
148DEFINE_EVENT(nfsd_err_class, nfsd_##name, \
149 TP_PROTO(struct svc_rqst *rqstp, \
150 struct svc_fh *fhp, \
151 loff_t offset, \
152 int len), \
153 TP_ARGS(rqstp, fhp, offset, len))
154
Chuck Lever87c59422018-03-28 13:29:11 -0400155DEFINE_NFSD_ERR_EVENT(read_err);
Chuck Leverd890be12018-03-27 10:53:27 -0400156DEFINE_NFSD_ERR_EVENT(write_err);
157
Jeff Layton825213e2015-10-03 08:19:57 -0400158#include "state.h"
Jeff Layton65294c12019-08-18 14:18:48 -0400159#include "filecache.h"
160#include "vfs.h"
Jeff Layton825213e2015-10-03 08:19:57 -0400161
Christoph Hellwig31ef83d2014-08-16 19:02:22 -0500162DECLARE_EVENT_CLASS(nfsd_stateid_class,
163 TP_PROTO(stateid_t *stp),
164 TP_ARGS(stp),
165 TP_STRUCT__entry(
166 __field(u32, cl_boot)
167 __field(u32, cl_id)
168 __field(u32, si_id)
169 __field(u32, si_generation)
170 ),
171 TP_fast_assign(
172 __entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
173 __entry->cl_id = stp->si_opaque.so_clid.cl_id;
174 __entry->si_id = stp->si_opaque.so_id;
175 __entry->si_generation = stp->si_generation;
176 ),
177 TP_printk("client %08x:%08x stateid %08x:%08x",
178 __entry->cl_boot,
179 __entry->cl_id,
180 __entry->si_id,
181 __entry->si_generation)
182)
183
184#define DEFINE_STATEID_EVENT(name) \
Chuck Leverf394b622018-03-27 10:53:11 -0400185DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \
Christoph Hellwig31ef83d2014-08-16 19:02:22 -0500186 TP_PROTO(stateid_t *stp), \
187 TP_ARGS(stp))
188DEFINE_STATEID_EVENT(layoutstate_alloc);
189DEFINE_STATEID_EVENT(layoutstate_unhash);
190DEFINE_STATEID_EVENT(layoutstate_free);
191DEFINE_STATEID_EVENT(layout_get_lookup_fail);
192DEFINE_STATEID_EVENT(layout_commit_lookup_fail);
193DEFINE_STATEID_EVENT(layout_return_lookup_fail);
194DEFINE_STATEID_EVENT(layout_recall);
195DEFINE_STATEID_EVENT(layout_recall_done);
196DEFINE_STATEID_EVENT(layout_recall_fail);
197DEFINE_STATEID_EVENT(layout_recall_release);
198
Trond Myklebustc1928552020-01-14 12:00:22 -0500199TRACE_DEFINE_ENUM(NFSD_FILE_HASHED);
200TRACE_DEFINE_ENUM(NFSD_FILE_PENDING);
201TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_READ);
202TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_WRITE);
203TRACE_DEFINE_ENUM(NFSD_FILE_REFERENCED);
204
Jeff Layton65294c12019-08-18 14:18:48 -0400205#define show_nf_flags(val) \
206 __print_flags(val, "|", \
207 { 1 << NFSD_FILE_HASHED, "HASHED" }, \
208 { 1 << NFSD_FILE_PENDING, "PENDING" }, \
209 { 1 << NFSD_FILE_BREAK_READ, "BREAK_READ" }, \
210 { 1 << NFSD_FILE_BREAK_WRITE, "BREAK_WRITE" }, \
211 { 1 << NFSD_FILE_REFERENCED, "REFERENCED"})
212
213/* FIXME: This should probably be fleshed out in the future. */
214#define show_nf_may(val) \
215 __print_flags(val, "|", \
216 { NFSD_MAY_READ, "READ" }, \
217 { NFSD_MAY_WRITE, "WRITE" }, \
218 { NFSD_MAY_NOT_BREAK_LEASE, "NOT_BREAK_LEASE" })
219
220DECLARE_EVENT_CLASS(nfsd_file_class,
221 TP_PROTO(struct nfsd_file *nf),
222 TP_ARGS(nf),
223 TP_STRUCT__entry(
224 __field(unsigned int, nf_hashval)
225 __field(void *, nf_inode)
226 __field(int, nf_ref)
227 __field(unsigned long, nf_flags)
228 __field(unsigned char, nf_may)
229 __field(struct file *, nf_file)
230 ),
231 TP_fast_assign(
232 __entry->nf_hashval = nf->nf_hashval;
233 __entry->nf_inode = nf->nf_inode;
Trond Myklebust689827c2020-01-14 12:02:44 -0500234 __entry->nf_ref = refcount_read(&nf->nf_ref);
Jeff Layton65294c12019-08-18 14:18:48 -0400235 __entry->nf_flags = nf->nf_flags;
236 __entry->nf_may = nf->nf_may;
237 __entry->nf_file = nf->nf_file;
238 ),
239 TP_printk("hash=0x%x inode=0x%p ref=%d flags=%s may=%s file=%p",
240 __entry->nf_hashval,
241 __entry->nf_inode,
242 __entry->nf_ref,
243 show_nf_flags(__entry->nf_flags),
244 show_nf_may(__entry->nf_may),
245 __entry->nf_file)
246)
247
248#define DEFINE_NFSD_FILE_EVENT(name) \
249DEFINE_EVENT(nfsd_file_class, name, \
250 TP_PROTO(struct nfsd_file *nf), \
251 TP_ARGS(nf))
252
253DEFINE_NFSD_FILE_EVENT(nfsd_file_alloc);
254DEFINE_NFSD_FILE_EVENT(nfsd_file_put_final);
255DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash);
256DEFINE_NFSD_FILE_EVENT(nfsd_file_put);
257DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_release_locked);
258
259TRACE_EVENT(nfsd_file_acquire,
260 TP_PROTO(struct svc_rqst *rqstp, unsigned int hash,
261 struct inode *inode, unsigned int may_flags,
262 struct nfsd_file *nf, __be32 status),
263
264 TP_ARGS(rqstp, hash, inode, may_flags, nf, status),
265
266 TP_STRUCT__entry(
Trond Myklebusta9ceb0602020-01-14 12:00:21 -0500267 __field(u32, xid)
Jeff Layton65294c12019-08-18 14:18:48 -0400268 __field(unsigned int, hash)
269 __field(void *, inode)
270 __field(unsigned int, may_flags)
271 __field(int, nf_ref)
272 __field(unsigned long, nf_flags)
273 __field(unsigned char, nf_may)
274 __field(struct file *, nf_file)
Trond Myklebusta9ceb0602020-01-14 12:00:21 -0500275 __field(u32, status)
Jeff Layton65294c12019-08-18 14:18:48 -0400276 ),
277
278 TP_fast_assign(
Trond Myklebusta9ceb0602020-01-14 12:00:21 -0500279 __entry->xid = be32_to_cpu(rqstp->rq_xid);
Jeff Layton65294c12019-08-18 14:18:48 -0400280 __entry->hash = hash;
281 __entry->inode = inode;
282 __entry->may_flags = may_flags;
Trond Myklebust689827c2020-01-14 12:02:44 -0500283 __entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0;
Jeff Layton65294c12019-08-18 14:18:48 -0400284 __entry->nf_flags = nf ? nf->nf_flags : 0;
285 __entry->nf_may = nf ? nf->nf_may : 0;
286 __entry->nf_file = nf ? nf->nf_file : NULL;
Trond Myklebusta9ceb0602020-01-14 12:00:21 -0500287 __entry->status = be32_to_cpu(status);
Jeff Layton65294c12019-08-18 14:18:48 -0400288 ),
289
290 TP_printk("xid=0x%x hash=0x%x inode=0x%p may_flags=%s ref=%d nf_flags=%s nf_may=%s nf_file=0x%p status=%u",
Trond Myklebusta9ceb0602020-01-14 12:00:21 -0500291 __entry->xid, __entry->hash, __entry->inode,
Jeff Layton65294c12019-08-18 14:18:48 -0400292 show_nf_may(__entry->may_flags), __entry->nf_ref,
293 show_nf_flags(__entry->nf_flags),
294 show_nf_may(__entry->nf_may), __entry->nf_file,
Trond Myklebusta9ceb0602020-01-14 12:00:21 -0500295 __entry->status)
Jeff Layton65294c12019-08-18 14:18:48 -0400296);
297
298DECLARE_EVENT_CLASS(nfsd_file_search_class,
299 TP_PROTO(struct inode *inode, unsigned int hash, int found),
300 TP_ARGS(inode, hash, found),
301 TP_STRUCT__entry(
302 __field(struct inode *, inode)
303 __field(unsigned int, hash)
304 __field(int, found)
305 ),
306 TP_fast_assign(
307 __entry->inode = inode;
308 __entry->hash = hash;
309 __entry->found = found;
310 ),
311 TP_printk("hash=0x%x inode=0x%p found=%d", __entry->hash,
312 __entry->inode, __entry->found)
313);
314
315#define DEFINE_NFSD_FILE_SEARCH_EVENT(name) \
316DEFINE_EVENT(nfsd_file_search_class, name, \
317 TP_PROTO(struct inode *inode, unsigned int hash, int found), \
318 TP_ARGS(inode, hash, found))
319
320DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode_sync);
321DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode);
322DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_is_cached);
323
324TRACE_EVENT(nfsd_file_fsnotify_handle_event,
325 TP_PROTO(struct inode *inode, u32 mask),
326 TP_ARGS(inode, mask),
327 TP_STRUCT__entry(
328 __field(struct inode *, inode)
329 __field(unsigned int, nlink)
330 __field(umode_t, mode)
331 __field(u32, mask)
332 ),
333 TP_fast_assign(
334 __entry->inode = inode;
335 __entry->nlink = inode->i_nlink;
336 __entry->mode = inode->i_mode;
337 __entry->mask = mask;
338 ),
339 TP_printk("inode=0x%p nlink=%u mode=0%ho mask=0x%x", __entry->inode,
340 __entry->nlink, __entry->mode, __entry->mask)
341);
342
Christoph Hellwig31ef83d2014-08-16 19:02:22 -0500343#endif /* _NFSD_TRACE_H */
344
345#undef TRACE_INCLUDE_PATH
346#define TRACE_INCLUDE_PATH .
347#define TRACE_INCLUDE_FILE trace
348#include <trace/define_trace.h>