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>
15 TRACE_EVENT(nfsd_compound
,
16 TP_PROTO(const struct svc_rqst
*rqst
,
18 TP_ARGS(rqst
, args_opcnt
),
21 __field(u32
, args_opcnt
)
24 __entry
->xid
= be32_to_cpu(rqst
->rq_xid
);
25 __entry
->args_opcnt
= args_opcnt
;
27 TP_printk("xid=0x%08x opcnt=%u",
28 __entry
->xid
, __entry
->args_opcnt
)
31 TRACE_EVENT(nfsd_compound_status
,
32 TP_PROTO(u32 args_opcnt
,
36 TP_ARGS(args_opcnt
, resp_opcnt
, status
, name
),
38 __field(u32
, args_opcnt
)
39 __field(u32
, resp_opcnt
)
44 __entry
->args_opcnt
= args_opcnt
;
45 __entry
->resp_opcnt
= resp_opcnt
;
46 __entry
->status
= be32_to_cpu(status
);
47 __assign_str(name
, name
);
49 TP_printk("op=%u/%u %s status=%d",
50 __entry
->resp_opcnt
, __entry
->args_opcnt
,
51 __get_str(name
), __entry
->status
)
54 DECLARE_EVENT_CLASS(nfsd_fh_err_class
,
55 TP_PROTO(struct svc_rqst
*rqstp
,
58 TP_ARGS(rqstp
, fhp
, status
),
65 __entry
->xid
= be32_to_cpu(rqstp
->rq_xid
);
66 __entry
->fh_hash
= knfsd_fh_hash(&fhp
->fh_handle
);
67 __entry
->status
= status
;
69 TP_printk("xid=0x%08x fh_hash=0x%08x status=%d",
70 __entry
->xid
, __entry
->fh_hash
,
74 #define DEFINE_NFSD_FH_ERR_EVENT(name) \
75 DEFINE_EVENT(nfsd_fh_err_class, nfsd_##name, \
76 TP_PROTO(struct svc_rqst *rqstp, \
79 TP_ARGS(rqstp, fhp, status))
81 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport
);
82 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle
);
84 TRACE_EVENT(nfsd_exp_find_key
,
85 TP_PROTO(const struct svc_expkey
*key
,
89 __field(int, fsidtype
)
91 __string(auth_domain
, key
->ek_client
->name
)
95 __entry
->fsidtype
= key
->ek_fsidtype
;
96 memcpy(__entry
->fsid
, key
->ek_fsid
, 4*6);
97 __assign_str(auth_domain
, key
->ek_client
->name
);
98 __entry
->status
= status
;
100 TP_printk("fsid=%x::%s domain=%s status=%d",
102 __print_array(__entry
->fsid
, 6, 4),
103 __get_str(auth_domain
),
108 TRACE_EVENT(nfsd_expkey_update
,
109 TP_PROTO(const struct svc_expkey
*key
, const char *exp_path
),
110 TP_ARGS(key
, exp_path
),
112 __field(int, fsidtype
)
113 __array(u32
, fsid
, 6)
114 __string(auth_domain
, key
->ek_client
->name
)
115 __string(path
, exp_path
)
119 __entry
->fsidtype
= key
->ek_fsidtype
;
120 memcpy(__entry
->fsid
, key
->ek_fsid
, 4*6);
121 __assign_str(auth_domain
, key
->ek_client
->name
);
122 __assign_str(path
, exp_path
);
123 __entry
->cache
= !test_bit(CACHE_NEGATIVE
, &key
->h
.flags
);
125 TP_printk("fsid=%x::%s domain=%s path=%s cache=%s",
127 __print_array(__entry
->fsid
, 6, 4),
128 __get_str(auth_domain
),
130 __entry
->cache
? "pos" : "neg"
134 TRACE_EVENT(nfsd_exp_get_by_name
,
135 TP_PROTO(const struct svc_export
*key
,
137 TP_ARGS(key
, status
),
139 __string(path
, key
->ex_path
.dentry
->d_name
.name
)
140 __string(auth_domain
, key
->ex_client
->name
)
144 __assign_str(path
, key
->ex_path
.dentry
->d_name
.name
);
145 __assign_str(auth_domain
, key
->ex_client
->name
);
146 __entry
->status
= status
;
148 TP_printk("path=%s domain=%s status=%d",
150 __get_str(auth_domain
),
155 TRACE_EVENT(nfsd_export_update
,
156 TP_PROTO(const struct svc_export
*key
),
159 __string(path
, key
->ex_path
.dentry
->d_name
.name
)
160 __string(auth_domain
, key
->ex_client
->name
)
164 __assign_str(path
, key
->ex_path
.dentry
->d_name
.name
);
165 __assign_str(auth_domain
, key
->ex_client
->name
);
166 __entry
->cache
= !test_bit(CACHE_NEGATIVE
, &key
->h
.flags
);
168 TP_printk("path=%s domain=%s cache=%s",
170 __get_str(auth_domain
),
171 __entry
->cache
? "pos" : "neg"
175 DECLARE_EVENT_CLASS(nfsd_io_class
,
176 TP_PROTO(struct svc_rqst
*rqstp
,
180 TP_ARGS(rqstp
, fhp
, offset
, len
),
183 __field(u32
, fh_hash
)
184 __field(loff_t
, offset
)
185 __field(unsigned long, len
)
188 __entry
->xid
= be32_to_cpu(rqstp
->rq_xid
);
189 __entry
->fh_hash
= knfsd_fh_hash(&fhp
->fh_handle
);
190 __entry
->offset
= offset
;
193 TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld len=%lu",
194 __entry
->xid
, __entry
->fh_hash
,
195 __entry
->offset
, __entry
->len
)
198 #define DEFINE_NFSD_IO_EVENT(name) \
199 DEFINE_EVENT(nfsd_io_class, nfsd_##name, \
200 TP_PROTO(struct svc_rqst *rqstp, \
201 struct svc_fh *fhp, \
203 unsigned long len), \
204 TP_ARGS(rqstp, fhp, offset, len))
206 DEFINE_NFSD_IO_EVENT(read_start
);
207 DEFINE_NFSD_IO_EVENT(read_splice
);
208 DEFINE_NFSD_IO_EVENT(read_vector
);
209 DEFINE_NFSD_IO_EVENT(read_io_done
);
210 DEFINE_NFSD_IO_EVENT(read_done
);
211 DEFINE_NFSD_IO_EVENT(write_start
);
212 DEFINE_NFSD_IO_EVENT(write_opened
);
213 DEFINE_NFSD_IO_EVENT(write_io_done
);
214 DEFINE_NFSD_IO_EVENT(write_done
);
216 DECLARE_EVENT_CLASS(nfsd_err_class
,
217 TP_PROTO(struct svc_rqst
*rqstp
,
221 TP_ARGS(rqstp
, fhp
, offset
, status
),
224 __field(u32
, fh_hash
)
225 __field(loff_t
, offset
)
229 __entry
->xid
= be32_to_cpu(rqstp
->rq_xid
);
230 __entry
->fh_hash
= knfsd_fh_hash(&fhp
->fh_handle
);
231 __entry
->offset
= offset
;
232 __entry
->status
= status
;
234 TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld status=%d",
235 __entry
->xid
, __entry
->fh_hash
,
236 __entry
->offset
, __entry
->status
)
239 #define DEFINE_NFSD_ERR_EVENT(name) \
240 DEFINE_EVENT(nfsd_err_class, nfsd_##name, \
241 TP_PROTO(struct svc_rqst *rqstp, \
242 struct svc_fh *fhp, \
245 TP_ARGS(rqstp, fhp, offset, len))
247 DEFINE_NFSD_ERR_EVENT(read_err
);
248 DEFINE_NFSD_ERR_EVENT(write_err
);
251 #include "filecache.h"
254 DECLARE_EVENT_CLASS(nfsd_stateid_class
,
255 TP_PROTO(stateid_t
*stp
),
258 __field(u32
, cl_boot
)
261 __field(u32
, si_generation
)
264 __entry
->cl_boot
= stp
->si_opaque
.so_clid
.cl_boot
;
265 __entry
->cl_id
= stp
->si_opaque
.so_clid
.cl_id
;
266 __entry
->si_id
= stp
->si_opaque
.so_id
;
267 __entry
->si_generation
= stp
->si_generation
;
269 TP_printk("client %08x:%08x stateid %08x:%08x",
273 __entry
->si_generation
)
276 #define DEFINE_STATEID_EVENT(name) \
277 DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \
278 TP_PROTO(stateid_t *stp), \
280 DEFINE_STATEID_EVENT(layoutstate_alloc
);
281 DEFINE_STATEID_EVENT(layoutstate_unhash
);
282 DEFINE_STATEID_EVENT(layoutstate_free
);
283 DEFINE_STATEID_EVENT(layout_get_lookup_fail
);
284 DEFINE_STATEID_EVENT(layout_commit_lookup_fail
);
285 DEFINE_STATEID_EVENT(layout_return_lookup_fail
);
286 DEFINE_STATEID_EVENT(layout_recall
);
287 DEFINE_STATEID_EVENT(layout_recall_done
);
288 DEFINE_STATEID_EVENT(layout_recall_fail
);
289 DEFINE_STATEID_EVENT(layout_recall_release
);
291 TRACE_DEFINE_ENUM(NFSD_FILE_HASHED
);
292 TRACE_DEFINE_ENUM(NFSD_FILE_PENDING
);
293 TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_READ
);
294 TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_WRITE
);
295 TRACE_DEFINE_ENUM(NFSD_FILE_REFERENCED
);
297 #define show_nf_flags(val) \
298 __print_flags(val, "|", \
299 { 1 << NFSD_FILE_HASHED, "HASHED" }, \
300 { 1 << NFSD_FILE_PENDING, "PENDING" }, \
301 { 1 << NFSD_FILE_BREAK_READ, "BREAK_READ" }, \
302 { 1 << NFSD_FILE_BREAK_WRITE, "BREAK_WRITE" }, \
303 { 1 << NFSD_FILE_REFERENCED, "REFERENCED"})
305 /* FIXME: This should probably be fleshed out in the future. */
306 #define show_nf_may(val) \
307 __print_flags(val, "|", \
308 { NFSD_MAY_READ, "READ" }, \
309 { NFSD_MAY_WRITE, "WRITE" }, \
310 { NFSD_MAY_NOT_BREAK_LEASE, "NOT_BREAK_LEASE" })
312 DECLARE_EVENT_CLASS(nfsd_file_class
,
313 TP_PROTO(struct nfsd_file
*nf
),
316 __field(unsigned int, nf_hashval
)
317 __field(void *, nf_inode
)
319 __field(unsigned long, nf_flags
)
320 __field(unsigned char, nf_may
)
321 __field(struct file
*, nf_file
)
324 __entry
->nf_hashval
= nf
->nf_hashval
;
325 __entry
->nf_inode
= nf
->nf_inode
;
326 __entry
->nf_ref
= refcount_read(&nf
->nf_ref
);
327 __entry
->nf_flags
= nf
->nf_flags
;
328 __entry
->nf_may
= nf
->nf_may
;
329 __entry
->nf_file
= nf
->nf_file
;
331 TP_printk("hash=0x%x inode=0x%p ref=%d flags=%s may=%s file=%p",
335 show_nf_flags(__entry
->nf_flags
),
336 show_nf_may(__entry
->nf_may
),
340 #define DEFINE_NFSD_FILE_EVENT(name) \
341 DEFINE_EVENT(nfsd_file_class, name, \
342 TP_PROTO(struct nfsd_file *nf), \
345 DEFINE_NFSD_FILE_EVENT(nfsd_file_alloc
);
346 DEFINE_NFSD_FILE_EVENT(nfsd_file_put_final
);
347 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash
);
348 DEFINE_NFSD_FILE_EVENT(nfsd_file_put
);
349 DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_release_locked
);
351 TRACE_EVENT(nfsd_file_acquire
,
352 TP_PROTO(struct svc_rqst
*rqstp
, unsigned int hash
,
353 struct inode
*inode
, unsigned int may_flags
,
354 struct nfsd_file
*nf
, __be32 status
),
356 TP_ARGS(rqstp
, hash
, inode
, may_flags
, nf
, status
),
360 __field(unsigned int, hash
)
361 __field(void *, inode
)
362 __field(unsigned int, may_flags
)
364 __field(unsigned long, nf_flags
)
365 __field(unsigned char, nf_may
)
366 __field(struct file
*, nf_file
)
371 __entry
->xid
= be32_to_cpu(rqstp
->rq_xid
);
372 __entry
->hash
= hash
;
373 __entry
->inode
= inode
;
374 __entry
->may_flags
= may_flags
;
375 __entry
->nf_ref
= nf
? refcount_read(&nf
->nf_ref
) : 0;
376 __entry
->nf_flags
= nf
? nf
->nf_flags
: 0;
377 __entry
->nf_may
= nf
? nf
->nf_may
: 0;
378 __entry
->nf_file
= nf
? nf
->nf_file
: NULL
;
379 __entry
->status
= be32_to_cpu(status
);
382 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",
383 __entry
->xid
, __entry
->hash
, __entry
->inode
,
384 show_nf_may(__entry
->may_flags
), __entry
->nf_ref
,
385 show_nf_flags(__entry
->nf_flags
),
386 show_nf_may(__entry
->nf_may
), __entry
->nf_file
,
390 DECLARE_EVENT_CLASS(nfsd_file_search_class
,
391 TP_PROTO(struct inode
*inode
, unsigned int hash
, int found
),
392 TP_ARGS(inode
, hash
, found
),
394 __field(struct inode
*, inode
)
395 __field(unsigned int, hash
)
399 __entry
->inode
= inode
;
400 __entry
->hash
= hash
;
401 __entry
->found
= found
;
403 TP_printk("hash=0x%x inode=0x%p found=%d", __entry
->hash
,
404 __entry
->inode
, __entry
->found
)
407 #define DEFINE_NFSD_FILE_SEARCH_EVENT(name) \
408 DEFINE_EVENT(nfsd_file_search_class, name, \
409 TP_PROTO(struct inode *inode, unsigned int hash, int found), \
410 TP_ARGS(inode, hash, found))
412 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode_sync
);
413 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode
);
414 DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_is_cached
);
416 TRACE_EVENT(nfsd_file_fsnotify_handle_event
,
417 TP_PROTO(struct inode
*inode
, u32 mask
),
418 TP_ARGS(inode
, mask
),
420 __field(struct inode
*, inode
)
421 __field(unsigned int, nlink
)
422 __field(umode_t
, mode
)
426 __entry
->inode
= inode
;
427 __entry
->nlink
= inode
->i_nlink
;
428 __entry
->mode
= inode
->i_mode
;
429 __entry
->mask
= mask
;
431 TP_printk("inode=0x%p nlink=%u mode=0%ho mask=0x%x", __entry
->inode
,
432 __entry
->nlink
, __entry
->mode
, __entry
->mask
)
435 #endif /* _NFSD_TRACE_H */
437 #undef TRACE_INCLUDE_PATH
438 #define TRACE_INCLUDE_PATH .
439 #define TRACE_INCLUDE_FILE trace
440 #include <trace/define_trace.h>