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 TRACE_EVENT(nfsd_compound, 16 TP_PROTO(const struct svc_rqst *rqst, 17 u32 args_opcnt), 18 TP_ARGS(rqst, args_opcnt), 19 TP_STRUCT__entry( 20 __field(u32, xid) 21 __field(u32, args_opcnt) 22 ), 23 TP_fast_assign( 24 __entry->xid = be32_to_cpu(rqst->rq_xid); 25 __entry->args_opcnt = args_opcnt; 26 ), 27 TP_printk("xid=0x%08x opcnt=%u", 28 __entry->xid, __entry->args_opcnt) 29 ) 30 31 TRACE_EVENT(nfsd_compound_status, 32 TP_PROTO(u32 args_opcnt, 33 u32 resp_opcnt, 34 __be32 status, 35 const char *name), 36 TP_ARGS(args_opcnt, resp_opcnt, status, name), 37 TP_STRUCT__entry( 38 __field(u32, args_opcnt) 39 __field(u32, resp_opcnt) 40 __field(int, status) 41 __string(name, name) 42 ), 43 TP_fast_assign( 44 __entry->args_opcnt = args_opcnt; 45 __entry->resp_opcnt = resp_opcnt; 46 __entry->status = be32_to_cpu(status); 47 __assign_str(name, name); 48 ), 49 TP_printk("op=%u/%u %s status=%d", 50 __entry->resp_opcnt, __entry->args_opcnt, 51 __get_str(name), __entry->status) 52 ) 53 54 DECLARE_EVENT_CLASS(nfsd_fh_err_class, 55 TP_PROTO(struct svc_rqst *rqstp, 56 struct svc_fh *fhp, 57 int status), 58 TP_ARGS(rqstp, fhp, status), 59 TP_STRUCT__entry( 60 __field(u32, xid) 61 __field(u32, fh_hash) 62 __field(int, status) 63 ), 64 TP_fast_assign( 65 __entry->xid = be32_to_cpu(rqstp->rq_xid); 66 __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle); 67 __entry->status = status; 68 ), 69 TP_printk("xid=0x%08x fh_hash=0x%08x status=%d", 70 __entry->xid, __entry->fh_hash, 71 __entry->status) 72 ) 73 74 #define DEFINE_NFSD_FH_ERR_EVENT(name) \ 75 DEFINE_EVENT(nfsd_fh_err_class, nfsd_##name, \ 76 TP_PROTO(struct svc_rqst *rqstp, \ 77 struct svc_fh *fhp, \ 78 int status), \ 79 TP_ARGS(rqstp, fhp, status)) 80 81 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport); 82 DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle); 83 84 TRACE_EVENT(nfsd_exp_find_key, 85 TP_PROTO(const struct svc_expkey *key, 86 int status), 87 TP_ARGS(key, status), 88 TP_STRUCT__entry( 89 __field(int, fsidtype) 90 __array(u32, fsid, 6) 91 __string(auth_domain, key->ek_client->name) 92 __field(int, status) 93 ), 94 TP_fast_assign( 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; 99 ), 100 TP_printk("fsid=%x::%s domain=%s status=%d", 101 __entry->fsidtype, 102 __print_array(__entry->fsid, 6, 4), 103 __get_str(auth_domain), 104 __entry->status 105 ) 106 ); 107 108 TRACE_EVENT(nfsd_expkey_update, 109 TP_PROTO(const struct svc_expkey *key, const char *exp_path), 110 TP_ARGS(key, exp_path), 111 TP_STRUCT__entry( 112 __field(int, fsidtype) 113 __array(u32, fsid, 6) 114 __string(auth_domain, key->ek_client->name) 115 __string(path, exp_path) 116 __field(bool, cache) 117 ), 118 TP_fast_assign( 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); 124 ), 125 TP_printk("fsid=%x::%s domain=%s path=%s cache=%s", 126 __entry->fsidtype, 127 __print_array(__entry->fsid, 6, 4), 128 __get_str(auth_domain), 129 __get_str(path), 130 __entry->cache ? "pos" : "neg" 131 ) 132 ); 133 134 TRACE_EVENT(nfsd_exp_get_by_name, 135 TP_PROTO(const struct svc_export *key, 136 int status), 137 TP_ARGS(key, status), 138 TP_STRUCT__entry( 139 __string(path, key->ex_path.dentry->d_name.name) 140 __string(auth_domain, key->ex_client->name) 141 __field(int, status) 142 ), 143 TP_fast_assign( 144 __assign_str(path, key->ex_path.dentry->d_name.name); 145 __assign_str(auth_domain, key->ex_client->name); 146 __entry->status = status; 147 ), 148 TP_printk("path=%s domain=%s status=%d", 149 __get_str(path), 150 __get_str(auth_domain), 151 __entry->status 152 ) 153 ); 154 155 TRACE_EVENT(nfsd_export_update, 156 TP_PROTO(const struct svc_export *key), 157 TP_ARGS(key), 158 TP_STRUCT__entry( 159 __string(path, key->ex_path.dentry->d_name.name) 160 __string(auth_domain, key->ex_client->name) 161 __field(bool, cache) 162 ), 163 TP_fast_assign( 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); 167 ), 168 TP_printk("path=%s domain=%s cache=%s", 169 __get_str(path), 170 __get_str(auth_domain), 171 __entry->cache ? "pos" : "neg" 172 ) 173 ); 174 175 DECLARE_EVENT_CLASS(nfsd_io_class, 176 TP_PROTO(struct svc_rqst *rqstp, 177 struct svc_fh *fhp, 178 loff_t offset, 179 unsigned long len), 180 TP_ARGS(rqstp, fhp, offset, len), 181 TP_STRUCT__entry( 182 __field(u32, xid) 183 __field(u32, fh_hash) 184 __field(loff_t, offset) 185 __field(unsigned long, len) 186 ), 187 TP_fast_assign( 188 __entry->xid = be32_to_cpu(rqstp->rq_xid); 189 __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle); 190 __entry->offset = offset; 191 __entry->len = len; 192 ), 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) 196 ) 197 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, \ 202 loff_t offset, \ 203 unsigned long len), \ 204 TP_ARGS(rqstp, fhp, offset, len)) 205 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); 215 216 DECLARE_EVENT_CLASS(nfsd_err_class, 217 TP_PROTO(struct svc_rqst *rqstp, 218 struct svc_fh *fhp, 219 loff_t offset, 220 int status), 221 TP_ARGS(rqstp, fhp, offset, status), 222 TP_STRUCT__entry( 223 __field(u32, xid) 224 __field(u32, fh_hash) 225 __field(loff_t, offset) 226 __field(int, status) 227 ), 228 TP_fast_assign( 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; 233 ), 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) 237 ) 238 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, \ 243 loff_t offset, \ 244 int len), \ 245 TP_ARGS(rqstp, fhp, offset, len)) 246 247 DEFINE_NFSD_ERR_EVENT(read_err); 248 DEFINE_NFSD_ERR_EVENT(write_err); 249 250 #include "state.h" 251 #include "filecache.h" 252 #include "vfs.h" 253 254 DECLARE_EVENT_CLASS(nfsd_stateid_class, 255 TP_PROTO(stateid_t *stp), 256 TP_ARGS(stp), 257 TP_STRUCT__entry( 258 __field(u32, cl_boot) 259 __field(u32, cl_id) 260 __field(u32, si_id) 261 __field(u32, si_generation) 262 ), 263 TP_fast_assign( 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; 268 ), 269 TP_printk("client %08x:%08x stateid %08x:%08x", 270 __entry->cl_boot, 271 __entry->cl_id, 272 __entry->si_id, 273 __entry->si_generation) 274 ) 275 276 #define DEFINE_STATEID_EVENT(name) \ 277 DEFINE_EVENT(nfsd_stateid_class, nfsd_##name, \ 278 TP_PROTO(stateid_t *stp), \ 279 TP_ARGS(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); 290 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); 296 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"}) 304 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" }) 311 312 DECLARE_EVENT_CLASS(nfsd_file_class, 313 TP_PROTO(struct nfsd_file *nf), 314 TP_ARGS(nf), 315 TP_STRUCT__entry( 316 __field(unsigned int, nf_hashval) 317 __field(void *, nf_inode) 318 __field(int, nf_ref) 319 __field(unsigned long, nf_flags) 320 __field(unsigned char, nf_may) 321 __field(struct file *, nf_file) 322 ), 323 TP_fast_assign( 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; 330 ), 331 TP_printk("hash=0x%x inode=0x%p ref=%d flags=%s may=%s file=%p", 332 __entry->nf_hashval, 333 __entry->nf_inode, 334 __entry->nf_ref, 335 show_nf_flags(__entry->nf_flags), 336 show_nf_may(__entry->nf_may), 337 __entry->nf_file) 338 ) 339 340 #define DEFINE_NFSD_FILE_EVENT(name) \ 341 DEFINE_EVENT(nfsd_file_class, name, \ 342 TP_PROTO(struct nfsd_file *nf), \ 343 TP_ARGS(nf)) 344 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); 350 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), 355 356 TP_ARGS(rqstp, hash, inode, may_flags, nf, status), 357 358 TP_STRUCT__entry( 359 __field(u32, xid) 360 __field(unsigned int, hash) 361 __field(void *, inode) 362 __field(unsigned int, may_flags) 363 __field(int, nf_ref) 364 __field(unsigned long, nf_flags) 365 __field(unsigned char, nf_may) 366 __field(struct file *, nf_file) 367 __field(u32, status) 368 ), 369 370 TP_fast_assign( 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); 380 ), 381 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, 387 __entry->status) 388 ); 389 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), 393 TP_STRUCT__entry( 394 __field(struct inode *, inode) 395 __field(unsigned int, hash) 396 __field(int, found) 397 ), 398 TP_fast_assign( 399 __entry->inode = inode; 400 __entry->hash = hash; 401 __entry->found = found; 402 ), 403 TP_printk("hash=0x%x inode=0x%p found=%d", __entry->hash, 404 __entry->inode, __entry->found) 405 ); 406 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)) 411 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); 415 416 TRACE_EVENT(nfsd_file_fsnotify_handle_event, 417 TP_PROTO(struct inode *inode, u32 mask), 418 TP_ARGS(inode, mask), 419 TP_STRUCT__entry( 420 __field(struct inode *, inode) 421 __field(unsigned int, nlink) 422 __field(umode_t, mode) 423 __field(u32, mask) 424 ), 425 TP_fast_assign( 426 __entry->inode = inode; 427 __entry->nlink = inode->i_nlink; 428 __entry->mode = inode->i_mode; 429 __entry->mask = mask; 430 ), 431 TP_printk("inode=0x%p nlink=%u mode=0%ho mask=0x%x", __entry->inode, 432 __entry->nlink, __entry->mode, __entry->mask) 433 ); 434 435 #endif /* _NFSD_TRACE_H */ 436 437 #undef TRACE_INCLUDE_PATH 438 #define TRACE_INCLUDE_PATH . 439 #define TRACE_INCLUDE_FILE trace 440 #include <trace/define_trace.h> 441