1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2014 Christoph Hellwig.
6 #define TRACE_SYSTEM nfsd
8 #if !defined(_NFSD_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
11 #include <linux/tracepoint.h>
14 TRACE_EVENT(nfsd_compound
,
15 TP_PROTO(const struct svc_rqst
*rqst
,
17 TP_ARGS(rqst
, args_opcnt
),
20 __field(u32
, args_opcnt
)
23 __entry
->xid
= be32_to_cpu(rqst
->rq_xid
);
24 __entry
->args_opcnt
= args_opcnt
;
26 TP_printk("xid=0x%08x opcnt=%u",
27 __entry
->xid
, __entry
->args_opcnt
)
30 TRACE_EVENT(nfsd_compound_status
,
31 TP_PROTO(u32 args_opcnt
,
35 TP_ARGS(args_opcnt
, resp_opcnt
, status
, name
),
37 __field(u32
, args_opcnt
)
38 __field(u32
, resp_opcnt
)
43 __entry
->args_opcnt
= args_opcnt
;
44 __entry
->resp_opcnt
= resp_opcnt
;
45 __entry
->status
= be32_to_cpu(status
);
46 __assign_str(name
, name
);
48 TP_printk("op=%u/%u %s status=%d",
49 __entry
->resp_opcnt
, __entry
->args_opcnt
,
50 __get_str(name
), __entry
->status
)
53 DECLARE_EVENT_CLASS(nfsd_io_class
,
54 TP_PROTO(struct svc_rqst
*rqstp
,
58 TP_ARGS(rqstp
, fhp
, offset
, len
),
62 __field(loff_t
, offset
)
63 __field(unsigned long, len
)
66 __entry
->xid
= be32_to_cpu(rqstp
->rq_xid
);
67 __entry
->fh_hash
= knfsd_fh_hash(&fhp
->fh_handle
);
68 __entry
->offset
= offset
;
71 TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld len=%lu",
72 __entry
->xid
, __entry
->fh_hash
,
73 __entry
->offset
, __entry
->len
)
76 #define DEFINE_NFSD_IO_EVENT(name) \
77 DEFINE_EVENT(nfsd_io_class, nfsd_##name, \
78 TP_PROTO(struct svc_rqst *rqstp, \
82 TP_ARGS(rqstp, fhp, offset, len))
84 DEFINE_NFSD_IO_EVENT(read_start
);
85 DEFINE_NFSD_IO_EVENT(read_splice
);
86 DEFINE_NFSD_IO_EVENT(read_vector
);
87 DEFINE_NFSD_IO_EVENT(read_io_done
);
88 DEFINE_NFSD_IO_EVENT(read_done
);
89 DEFINE_NFSD_IO_EVENT(write_start
);
90 DEFINE_NFSD_IO_EVENT(write_opened
);
91 DEFINE_NFSD_IO_EVENT(write_io_done
);
92 DEFINE_NFSD_IO_EVENT(write_done
);
94 DECLARE_EVENT_CLASS(nfsd_err_class
,
95 TP_PROTO(struct svc_rqst
*rqstp
,
99 TP_ARGS(rqstp
, fhp
, offset
, status
),
102 __field(u32
, fh_hash
)
103 __field(loff_t
, offset
)
107 __entry
->xid
= be32_to_cpu(rqstp
->rq_xid
);
108 __entry
->fh_hash
= knfsd_fh_hash(&fhp
->fh_handle
);
109 __entry
->offset
= offset
;
110 __entry
->status
= status
;
112 TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld status=%d",
113 __entry
->xid
, __entry
->fh_hash
,
114 __entry
->offset
, __entry
->status
)
117 #define DEFINE_NFSD_ERR_EVENT(name) \
118 DEFINE_EVENT(nfsd_err_class, nfsd_##name, \
119 TP_PROTO(struct svc_rqst *rqstp, \
120 struct svc_fh *fhp, \
123 TP_ARGS(rqstp, fhp, offset, len))
125 DEFINE_NFSD_ERR_EVENT(read_err
);
126 DEFINE_NFSD_ERR_EVENT(write_err
);
129 #include "filecache.h"
132 DECLARE_EVENT_CLASS(nfsd_stateid_class
,
133 TP_PROTO(stateid_t
*stp
),
136 __field(u32
, cl_boot
)
139 __field(u32
, si_generation
)
142 __entry
->cl_boot
= stp
->si_opaque
.so_clid
.cl_boot
;
143 __entry
->cl_id
= stp
->si_opaque
.so_clid
.cl_id
;
144 __entry
->si_id
= stp
->si_opaque
.so_id
;
145 __entry
->si_generation
= stp
->si_generation
;
147 TP_printk("client %08x:%08x stateid %08x:%08x",
151 __entry
->si_generation
)
154 #define DEFINE_STATEID_EVENT(name) \
155 DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \
156 TP_PROTO(stateid_t *stp), \
158 DEFINE_STATEID_EVENT(layoutstate_alloc
);
159 DEFINE_STATEID_EVENT(layoutstate_unhash
);
160 DEFINE_STATEID_EVENT(layoutstate_free
);
161 DEFINE_STATEID_EVENT(layout_get_lookup_fail
);
162 DEFINE_STATEID_EVENT(layout_commit_lookup_fail
);
163 DEFINE_STATEID_EVENT(layout_return_lookup_fail
);
164 DEFINE_STATEID_EVENT(layout_recall
);
165 DEFINE_STATEID_EVENT(layout_recall_done
);
166 DEFINE_STATEID_EVENT(layout_recall_fail
);
167 DEFINE_STATEID_EVENT(layout_recall_release
);
169 TRACE_DEFINE_ENUM(NFSD_FILE_HASHED
);
170 TRACE_DEFINE_ENUM(NFSD_FILE_PENDING
);
171 TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_READ
);
172 TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_WRITE
);
173 TRACE_DEFINE_ENUM(NFSD_FILE_REFERENCED
);
175 #define show_nf_flags(val) \
176 __print_flags(val, "|", \
177 { 1 << NFSD_FILE_HASHED, "HASHED" }, \
178 { 1 << NFSD_FILE_PENDING, "PENDING" }, \
179 { 1 << NFSD_FILE_BREAK_READ, "BREAK_READ" }, \
180 { 1 << NFSD_FILE_BREAK_WRITE, "BREAK_WRITE" }, \
181 { 1 << NFSD_FILE_REFERENCED, "REFERENCED"})
183 /* FIXME: This should probably be fleshed out in the future. */
184 #define show_nf_may(val) \
185 __print_flags(val, "|", \
186 { NFSD_MAY_READ, "READ" }, \
187 { NFSD_MAY_WRITE, "WRITE" }, \
188 { NFSD_MAY_NOT_BREAK_LEASE, "NOT_BREAK_LEASE" })
190 DECLARE_EVENT_CLASS(nfsd_file_class
,
191 TP_PROTO(struct nfsd_file
*nf
),
194 __field(unsigned int, nf_hashval
)
195 __field(void *, nf_inode
)
197 __field(unsigned long, nf_flags
)
198 __field(unsigned char, nf_may
)
199 __field(struct file
*, nf_file
)
202 __entry
->nf_hashval
= nf
->nf_hashval
;
203 __entry
->nf_inode
= nf
->nf_inode
;
204 __entry
->nf_ref
= refcount_read(&nf
->nf_ref
);
205 __entry
->nf_flags
= nf
->nf_flags
;
206 __entry
->nf_may
= nf
->nf_may
;
207 __entry
->nf_file
= nf
->nf_file
;
209 TP_printk("hash=0x%x inode=0x%p ref=%d flags=%s may=%s file=%p",
213 show_nf_flags(__entry
->nf_flags
),
214 show_nf_may(__entry
->nf_may
),
218 #define DEFINE_NFSD_FILE_EVENT(name) \
219 DEFINE_EVENT(nfsd_file_class, name, \
220 TP_PROTO(struct nfsd_file *nf), \
223 DEFINE_NFSD_FILE_EVENT(nfsd_file_alloc
);
224 DEFINE_NFSD_FILE_EVENT(nfsd_file_put_final
);
225 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash
);
226 DEFINE_NFSD_FILE_EVENT(nfsd_file_put
);
227 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_release_locked
);
229 TRACE_EVENT(nfsd_file_acquire
,
230 TP_PROTO(struct svc_rqst
*rqstp
, unsigned int hash
,
231 struct inode
*inode
, unsigned int may_flags
,
232 struct nfsd_file
*nf
, __be32 status
),
234 TP_ARGS(rqstp
, hash
, inode
, may_flags
, nf
, status
),
238 __field(unsigned int, hash
)
239 __field(void *, inode
)
240 __field(unsigned int, may_flags
)
242 __field(unsigned long, nf_flags
)
243 __field(unsigned char, nf_may
)
244 __field(struct file
*, nf_file
)
249 __entry
->xid
= be32_to_cpu(rqstp
->rq_xid
);
250 __entry
->hash
= hash
;
251 __entry
->inode
= inode
;
252 __entry
->may_flags
= may_flags
;
253 __entry
->nf_ref
= nf
? refcount_read(&nf
->nf_ref
) : 0;
254 __entry
->nf_flags
= nf
? nf
->nf_flags
: 0;
255 __entry
->nf_may
= nf
? nf
->nf_may
: 0;
256 __entry
->nf_file
= nf
? nf
->nf_file
: NULL
;
257 __entry
->status
= be32_to_cpu(status
);
260 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",
261 __entry
->xid
, __entry
->hash
, __entry
->inode
,
262 show_nf_may(__entry
->may_flags
), __entry
->nf_ref
,
263 show_nf_flags(__entry
->nf_flags
),
264 show_nf_may(__entry
->nf_may
), __entry
->nf_file
,
268 DECLARE_EVENT_CLASS(nfsd_file_search_class
,
269 TP_PROTO(struct inode
*inode
, unsigned int hash
, int found
),
270 TP_ARGS(inode
, hash
, found
),
272 __field(struct inode
*, inode
)
273 __field(unsigned int, hash
)
277 __entry
->inode
= inode
;
278 __entry
->hash
= hash
;
279 __entry
->found
= found
;
281 TP_printk("hash=0x%x inode=0x%p found=%d", __entry
->hash
,
282 __entry
->inode
, __entry
->found
)
285 #define DEFINE_NFSD_FILE_SEARCH_EVENT(name) \
286 DEFINE_EVENT(nfsd_file_search_class, name, \
287 TP_PROTO(struct inode *inode, unsigned int hash, int found), \
288 TP_ARGS(inode, hash, found))
290 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode_sync
);
291 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode
);
292 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_is_cached
);
294 TRACE_EVENT(nfsd_file_fsnotify_handle_event
,
295 TP_PROTO(struct inode
*inode
, u32 mask
),
296 TP_ARGS(inode
, mask
),
298 __field(struct inode
*, inode
)
299 __field(unsigned int, nlink
)
300 __field(umode_t
, mode
)
304 __entry
->inode
= inode
;
305 __entry
->nlink
= inode
->i_nlink
;
306 __entry
->mode
= inode
->i_mode
;
307 __entry
->mask
= mask
;
309 TP_printk("inode=0x%p nlink=%u mode=0%ho mask=0x%x", __entry
->inode
,
310 __entry
->nlink
, __entry
->mode
, __entry
->mask
)
313 #endif /* _NFSD_TRACE_H */
315 #undef TRACE_INCLUDE_PATH
316 #define TRACE_INCLUDE_PATH .
317 #define TRACE_INCLUDE_FILE trace
318 #include <trace/define_trace.h>