Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Christoph Hellwig | 31ef83d | 2014-08-16 19:02:22 -0500 | [diff] [blame] | 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> |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 12 | #include "nfsfh.h" |
| 13 | |
Chuck Lever | fff4080 | 2018-03-27 10:53:54 -0400 | [diff] [blame] | 14 | TRACE_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 | |
| 30 | TRACE_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 Myklebust | f01274a | 2020-03-01 18:21:39 -0500 | [diff] [blame^] | 53 | DECLARE_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) \ |
| 74 | DEFINE_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 | |
| 80 | DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport); |
| 81 | DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle); |
| 82 | |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 83 | DECLARE_EVENT_CLASS(nfsd_io_class, |
| 84 | TP_PROTO(struct svc_rqst *rqstp, |
| 85 | struct svc_fh *fhp, |
| 86 | loff_t offset, |
Chuck Lever | 79e0b4e | 2018-03-27 10:52:57 -0400 | [diff] [blame] | 87 | unsigned long len), |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 88 | TP_ARGS(rqstp, fhp, offset, len), |
| 89 | TP_STRUCT__entry( |
Chuck Lever | afa720a | 2018-03-27 10:52:43 -0400 | [diff] [blame] | 90 | __field(u32, xid) |
| 91 | __field(u32, fh_hash) |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 92 | __field(loff_t, offset) |
Chuck Lever | 79e0b4e | 2018-03-27 10:52:57 -0400 | [diff] [blame] | 93 | __field(unsigned long, len) |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 94 | ), |
| 95 | TP_fast_assign( |
Chuck Lever | afa720a | 2018-03-27 10:52:43 -0400 | [diff] [blame] | 96 | __entry->xid = be32_to_cpu(rqstp->rq_xid); |
Chuck Lever | 79e0b4e | 2018-03-27 10:52:57 -0400 | [diff] [blame] | 97 | __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle); |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 98 | __entry->offset = offset; |
| 99 | __entry->len = len; |
| 100 | ), |
Chuck Lever | 79e0b4e | 2018-03-27 10:52:57 -0400 | [diff] [blame] | 101 | TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld len=%lu", |
Chuck Lever | afa720a | 2018-03-27 10:52:43 -0400 | [diff] [blame] | 102 | __entry->xid, __entry->fh_hash, |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 103 | __entry->offset, __entry->len) |
| 104 | ) |
| 105 | |
| 106 | #define DEFINE_NFSD_IO_EVENT(name) \ |
Chuck Lever | f394b62 | 2018-03-27 10:53:11 -0400 | [diff] [blame] | 107 | DEFINE_EVENT(nfsd_io_class, nfsd_##name, \ |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 108 | TP_PROTO(struct svc_rqst *rqstp, \ |
| 109 | struct svc_fh *fhp, \ |
| 110 | loff_t offset, \ |
Chuck Lever | 79e0b4e | 2018-03-27 10:52:57 -0400 | [diff] [blame] | 111 | unsigned long len), \ |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 112 | TP_ARGS(rqstp, fhp, offset, len)) |
| 113 | |
| 114 | DEFINE_NFSD_IO_EVENT(read_start); |
Chuck Lever | 87c5942 | 2018-03-28 13:29:11 -0400 | [diff] [blame] | 115 | DEFINE_NFSD_IO_EVENT(read_splice); |
| 116 | DEFINE_NFSD_IO_EVENT(read_vector); |
Jeff Layton | 6e8b50d | 2015-11-17 06:52:23 -0500 | [diff] [blame] | 117 | DEFINE_NFSD_IO_EVENT(read_io_done); |
| 118 | DEFINE_NFSD_IO_EVENT(read_done); |
| 119 | DEFINE_NFSD_IO_EVENT(write_start); |
| 120 | DEFINE_NFSD_IO_EVENT(write_opened); |
| 121 | DEFINE_NFSD_IO_EVENT(write_io_done); |
| 122 | DEFINE_NFSD_IO_EVENT(write_done); |
Christoph Hellwig | 31ef83d | 2014-08-16 19:02:22 -0500 | [diff] [blame] | 123 | |
Chuck Lever | d890be1 | 2018-03-27 10:53:27 -0400 | [diff] [blame] | 124 | DECLARE_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) \ |
| 148 | DEFINE_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 Lever | 87c5942 | 2018-03-28 13:29:11 -0400 | [diff] [blame] | 155 | DEFINE_NFSD_ERR_EVENT(read_err); |
Chuck Lever | d890be1 | 2018-03-27 10:53:27 -0400 | [diff] [blame] | 156 | DEFINE_NFSD_ERR_EVENT(write_err); |
| 157 | |
Jeff Layton | 825213e | 2015-10-03 08:19:57 -0400 | [diff] [blame] | 158 | #include "state.h" |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 159 | #include "filecache.h" |
| 160 | #include "vfs.h" |
Jeff Layton | 825213e | 2015-10-03 08:19:57 -0400 | [diff] [blame] | 161 | |
Christoph Hellwig | 31ef83d | 2014-08-16 19:02:22 -0500 | [diff] [blame] | 162 | DECLARE_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 Lever | f394b62 | 2018-03-27 10:53:11 -0400 | [diff] [blame] | 185 | DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \ |
Christoph Hellwig | 31ef83d | 2014-08-16 19:02:22 -0500 | [diff] [blame] | 186 | TP_PROTO(stateid_t *stp), \ |
| 187 | TP_ARGS(stp)) |
| 188 | DEFINE_STATEID_EVENT(layoutstate_alloc); |
| 189 | DEFINE_STATEID_EVENT(layoutstate_unhash); |
| 190 | DEFINE_STATEID_EVENT(layoutstate_free); |
| 191 | DEFINE_STATEID_EVENT(layout_get_lookup_fail); |
| 192 | DEFINE_STATEID_EVENT(layout_commit_lookup_fail); |
| 193 | DEFINE_STATEID_EVENT(layout_return_lookup_fail); |
| 194 | DEFINE_STATEID_EVENT(layout_recall); |
| 195 | DEFINE_STATEID_EVENT(layout_recall_done); |
| 196 | DEFINE_STATEID_EVENT(layout_recall_fail); |
| 197 | DEFINE_STATEID_EVENT(layout_recall_release); |
| 198 | |
Trond Myklebust | c192855 | 2020-01-14 12:00:22 -0500 | [diff] [blame] | 199 | TRACE_DEFINE_ENUM(NFSD_FILE_HASHED); |
| 200 | TRACE_DEFINE_ENUM(NFSD_FILE_PENDING); |
| 201 | TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_READ); |
| 202 | TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_WRITE); |
| 203 | TRACE_DEFINE_ENUM(NFSD_FILE_REFERENCED); |
| 204 | |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 205 | #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 | |
| 220 | DECLARE_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 Myklebust | 689827c | 2020-01-14 12:02:44 -0500 | [diff] [blame] | 234 | __entry->nf_ref = refcount_read(&nf->nf_ref); |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 235 | __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) \ |
| 249 | DEFINE_EVENT(nfsd_file_class, name, \ |
| 250 | TP_PROTO(struct nfsd_file *nf), \ |
| 251 | TP_ARGS(nf)) |
| 252 | |
| 253 | DEFINE_NFSD_FILE_EVENT(nfsd_file_alloc); |
| 254 | DEFINE_NFSD_FILE_EVENT(nfsd_file_put_final); |
| 255 | DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash); |
| 256 | DEFINE_NFSD_FILE_EVENT(nfsd_file_put); |
| 257 | DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_release_locked); |
| 258 | |
| 259 | TRACE_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 Myklebust | a9ceb060 | 2020-01-14 12:00:21 -0500 | [diff] [blame] | 267 | __field(u32, xid) |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 268 | __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 Myklebust | a9ceb060 | 2020-01-14 12:00:21 -0500 | [diff] [blame] | 275 | __field(u32, status) |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 276 | ), |
| 277 | |
| 278 | TP_fast_assign( |
Trond Myklebust | a9ceb060 | 2020-01-14 12:00:21 -0500 | [diff] [blame] | 279 | __entry->xid = be32_to_cpu(rqstp->rq_xid); |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 280 | __entry->hash = hash; |
| 281 | __entry->inode = inode; |
| 282 | __entry->may_flags = may_flags; |
Trond Myklebust | 689827c | 2020-01-14 12:02:44 -0500 | [diff] [blame] | 283 | __entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0; |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 284 | __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 Myklebust | a9ceb060 | 2020-01-14 12:00:21 -0500 | [diff] [blame] | 287 | __entry->status = be32_to_cpu(status); |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 288 | ), |
| 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 Myklebust | a9ceb060 | 2020-01-14 12:00:21 -0500 | [diff] [blame] | 291 | __entry->xid, __entry->hash, __entry->inode, |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 292 | 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 Myklebust | a9ceb060 | 2020-01-14 12:00:21 -0500 | [diff] [blame] | 295 | __entry->status) |
Jeff Layton | 65294c1 | 2019-08-18 14:18:48 -0400 | [diff] [blame] | 296 | ); |
| 297 | |
| 298 | DECLARE_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) \ |
| 316 | DEFINE_EVENT(nfsd_file_search_class, name, \ |
| 317 | TP_PROTO(struct inode *inode, unsigned int hash, int found), \ |
| 318 | TP_ARGS(inode, hash, found)) |
| 319 | |
| 320 | DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode_sync); |
| 321 | DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_close_inode); |
| 322 | DEFINE_NFSD_FILE_SEARCH_EVENT(nfsd_file_is_cached); |
| 323 | |
| 324 | TRACE_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 Hellwig | 31ef83d | 2014-08-16 19:02:22 -0500 | [diff] [blame] | 343 | #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> |