1 /* AFS tracepoints 2 * 3 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public Licence 8 * as published by the Free Software Foundation; either version 9 * 2 of the Licence, or (at your option) any later version. 10 */ 11 #undef TRACE_SYSTEM 12 #define TRACE_SYSTEM afs 13 14 #if !defined(_TRACE_AFS_H) || defined(TRACE_HEADER_MULTI_READ) 15 #define _TRACE_AFS_H 16 17 #include <linux/tracepoint.h> 18 19 /* 20 * Define enums for tracing information. 21 */ 22 #ifndef __AFS_DECLARE_TRACE_ENUMS_ONCE_ONLY 23 #define __AFS_DECLARE_TRACE_ENUMS_ONCE_ONLY 24 25 enum afs_call_trace { 26 afs_call_trace_alloc, 27 afs_call_trace_free, 28 afs_call_trace_put, 29 afs_call_trace_wake, 30 afs_call_trace_work, 31 }; 32 33 enum afs_fs_operation { 34 afs_FS_FetchData = 130, /* AFS Fetch file data */ 35 afs_FS_FetchStatus = 132, /* AFS Fetch file status */ 36 afs_FS_StoreData = 133, /* AFS Store file data */ 37 afs_FS_StoreStatus = 135, /* AFS Store file status */ 38 afs_FS_RemoveFile = 136, /* AFS Remove a file */ 39 afs_FS_CreateFile = 137, /* AFS Create a file */ 40 afs_FS_Rename = 138, /* AFS Rename or move a file or directory */ 41 afs_FS_Symlink = 139, /* AFS Create a symbolic link */ 42 afs_FS_Link = 140, /* AFS Create a hard link */ 43 afs_FS_MakeDir = 141, /* AFS Create a directory */ 44 afs_FS_RemoveDir = 142, /* AFS Remove a directory */ 45 afs_FS_GetVolumeInfo = 148, /* AFS Get information about a volume */ 46 afs_FS_GetVolumeStatus = 149, /* AFS Get volume status information */ 47 afs_FS_GetRootVolume = 151, /* AFS Get root volume name */ 48 afs_FS_SetLock = 156, /* AFS Request a file lock */ 49 afs_FS_ExtendLock = 157, /* AFS Extend a file lock */ 50 afs_FS_ReleaseLock = 158, /* AFS Release a file lock */ 51 afs_FS_Lookup = 161, /* AFS lookup file in directory */ 52 afs_FS_InlineBulkStatus = 65536, /* AFS Fetch multiple file statuses with errors */ 53 afs_FS_FetchData64 = 65537, /* AFS Fetch file data */ 54 afs_FS_StoreData64 = 65538, /* AFS Store file data */ 55 afs_FS_GiveUpAllCallBacks = 65539, /* AFS Give up all our callbacks on a server */ 56 afs_FS_GetCapabilities = 65540, /* AFS Get FS server capabilities */ 57 }; 58 59 enum afs_vl_operation { 60 afs_VL_GetEntryByNameU = 527, /* AFS Get Vol Entry By Name operation ID */ 61 afs_VL_GetAddrsU = 533, /* AFS Get FS server addresses */ 62 afs_YFSVL_GetEndpoints = 64002, /* YFS Get FS & Vol server addresses */ 63 afs_VL_GetCapabilities = 65537, /* AFS Get VL server capabilities */ 64 }; 65 66 enum afs_edit_dir_op { 67 afs_edit_dir_create, 68 afs_edit_dir_create_error, 69 afs_edit_dir_create_inval, 70 afs_edit_dir_create_nospc, 71 afs_edit_dir_delete, 72 afs_edit_dir_delete_error, 73 afs_edit_dir_delete_inval, 74 afs_edit_dir_delete_noent, 75 }; 76 77 enum afs_edit_dir_reason { 78 afs_edit_dir_for_create, 79 afs_edit_dir_for_link, 80 afs_edit_dir_for_mkdir, 81 afs_edit_dir_for_rename, 82 afs_edit_dir_for_rmdir, 83 afs_edit_dir_for_symlink, 84 afs_edit_dir_for_unlink, 85 }; 86 87 #endif /* end __AFS_DECLARE_TRACE_ENUMS_ONCE_ONLY */ 88 89 /* 90 * Declare tracing information enums and their string mappings for display. 91 */ 92 #define afs_call_traces \ 93 EM(afs_call_trace_alloc, "ALLOC") \ 94 EM(afs_call_trace_free, "FREE ") \ 95 EM(afs_call_trace_put, "PUT ") \ 96 EM(afs_call_trace_wake, "WAKE ") \ 97 E_(afs_call_trace_work, "QUEUE") 98 99 #define afs_fs_operations \ 100 EM(afs_FS_FetchData, "FS.FetchData") \ 101 EM(afs_FS_FetchStatus, "FS.FetchStatus") \ 102 EM(afs_FS_StoreData, "FS.StoreData") \ 103 EM(afs_FS_StoreStatus, "FS.StoreStatus") \ 104 EM(afs_FS_RemoveFile, "FS.RemoveFile") \ 105 EM(afs_FS_CreateFile, "FS.CreateFile") \ 106 EM(afs_FS_Rename, "FS.Rename") \ 107 EM(afs_FS_Symlink, "FS.Symlink") \ 108 EM(afs_FS_Link, "FS.Link") \ 109 EM(afs_FS_MakeDir, "FS.MakeDir") \ 110 EM(afs_FS_RemoveDir, "FS.RemoveDir") \ 111 EM(afs_FS_GetVolumeInfo, "FS.GetVolumeInfo") \ 112 EM(afs_FS_GetVolumeStatus, "FS.GetVolumeStatus") \ 113 EM(afs_FS_GetRootVolume, "FS.GetRootVolume") \ 114 EM(afs_FS_SetLock, "FS.SetLock") \ 115 EM(afs_FS_ExtendLock, "FS.ExtendLock") \ 116 EM(afs_FS_ReleaseLock, "FS.ReleaseLock") \ 117 EM(afs_FS_Lookup, "FS.Lookup") \ 118 EM(afs_FS_InlineBulkStatus, "FS.InlineBulkStatus") \ 119 EM(afs_FS_FetchData64, "FS.FetchData64") \ 120 EM(afs_FS_StoreData64, "FS.StoreData64") \ 121 EM(afs_FS_GiveUpAllCallBacks, "FS.GiveUpAllCallBacks") \ 122 E_(afs_FS_GetCapabilities, "FS.GetCapabilities") 123 124 #define afs_vl_operations \ 125 EM(afs_VL_GetEntryByNameU, "VL.GetEntryByNameU") \ 126 EM(afs_VL_GetAddrsU, "VL.GetAddrsU") \ 127 EM(afs_YFSVL_GetEndpoints, "YFSVL.GetEndpoints") \ 128 E_(afs_VL_GetCapabilities, "VL.GetCapabilities") 129 130 #define afs_edit_dir_ops \ 131 EM(afs_edit_dir_create, "create") \ 132 EM(afs_edit_dir_create_error, "c_fail") \ 133 EM(afs_edit_dir_create_inval, "c_invl") \ 134 EM(afs_edit_dir_create_nospc, "c_nspc") \ 135 EM(afs_edit_dir_delete, "delete") \ 136 EM(afs_edit_dir_delete_error, "d_err ") \ 137 EM(afs_edit_dir_delete_inval, "d_invl") \ 138 E_(afs_edit_dir_delete_noent, "d_nent") 139 140 #define afs_edit_dir_reasons \ 141 EM(afs_edit_dir_for_create, "Create") \ 142 EM(afs_edit_dir_for_link, "Link ") \ 143 EM(afs_edit_dir_for_mkdir, "MkDir ") \ 144 EM(afs_edit_dir_for_rename, "Rename") \ 145 EM(afs_edit_dir_for_rmdir, "RmDir ") \ 146 EM(afs_edit_dir_for_symlink, "Symlnk") \ 147 E_(afs_edit_dir_for_unlink, "Unlink") 148 149 150 /* 151 * Export enum symbols via userspace. 152 */ 153 #undef EM 154 #undef E_ 155 #define EM(a, b) TRACE_DEFINE_ENUM(a); 156 #define E_(a, b) TRACE_DEFINE_ENUM(a); 157 158 afs_call_traces; 159 afs_fs_operations; 160 afs_vl_operations; 161 afs_edit_dir_ops; 162 afs_edit_dir_reasons; 163 164 /* 165 * Now redefine the EM() and E_() macros to map the enums to the strings that 166 * will be printed in the output. 167 */ 168 #undef EM 169 #undef E_ 170 #define EM(a, b) { a, b }, 171 #define E_(a, b) { a, b } 172 173 TRACE_EVENT(afs_recv_data, 174 TP_PROTO(struct afs_call *call, unsigned count, unsigned offset, 175 bool want_more, int ret), 176 177 TP_ARGS(call, count, offset, want_more, ret), 178 179 TP_STRUCT__entry( 180 __field(unsigned int, call ) 181 __field(enum afs_call_state, state ) 182 __field(unsigned int, count ) 183 __field(unsigned int, offset ) 184 __field(unsigned short, unmarshall ) 185 __field(bool, want_more ) 186 __field(int, ret ) 187 ), 188 189 TP_fast_assign( 190 __entry->call = call->debug_id; 191 __entry->state = call->state; 192 __entry->unmarshall = call->unmarshall; 193 __entry->count = count; 194 __entry->offset = offset; 195 __entry->want_more = want_more; 196 __entry->ret = ret; 197 ), 198 199 TP_printk("c=%08x s=%u u=%u %u/%u wm=%u ret=%d", 200 __entry->call, 201 __entry->state, __entry->unmarshall, 202 __entry->offset, __entry->count, 203 __entry->want_more, __entry->ret) 204 ); 205 206 TRACE_EVENT(afs_notify_call, 207 TP_PROTO(struct rxrpc_call *rxcall, struct afs_call *call), 208 209 TP_ARGS(rxcall, call), 210 211 TP_STRUCT__entry( 212 __field(unsigned int, call ) 213 __field(enum afs_call_state, state ) 214 __field(unsigned short, unmarshall ) 215 ), 216 217 TP_fast_assign( 218 __entry->call = call->debug_id; 219 __entry->state = call->state; 220 __entry->unmarshall = call->unmarshall; 221 ), 222 223 TP_printk("c=%08x s=%u u=%u", 224 __entry->call, 225 __entry->state, __entry->unmarshall) 226 ); 227 228 TRACE_EVENT(afs_cb_call, 229 TP_PROTO(struct afs_call *call), 230 231 TP_ARGS(call), 232 233 TP_STRUCT__entry( 234 __field(unsigned int, call ) 235 __field(const char *, name ) 236 __field(u32, op ) 237 ), 238 239 TP_fast_assign( 240 __entry->call = call->debug_id; 241 __entry->name = call->type->name; 242 __entry->op = call->operation_ID; 243 ), 244 245 TP_printk("c=%08x %s o=%u", 246 __entry->call, 247 __entry->name, 248 __entry->op) 249 ); 250 251 TRACE_EVENT(afs_call, 252 TP_PROTO(struct afs_call *call, enum afs_call_trace op, 253 int usage, int outstanding, const void *where), 254 255 TP_ARGS(call, op, usage, outstanding, where), 256 257 TP_STRUCT__entry( 258 __field(unsigned int, call ) 259 __field(int, op ) 260 __field(int, usage ) 261 __field(int, outstanding ) 262 __field(const void *, where ) 263 ), 264 265 TP_fast_assign( 266 __entry->call = call->debug_id; 267 __entry->op = op; 268 __entry->usage = usage; 269 __entry->outstanding = outstanding; 270 __entry->where = where; 271 ), 272 273 TP_printk("c=%08x %s u=%d o=%d sp=%pSR", 274 __entry->call, 275 __print_symbolic(__entry->op, afs_call_traces), 276 __entry->usage, 277 __entry->outstanding, 278 __entry->where) 279 ); 280 281 TRACE_EVENT(afs_make_fs_call, 282 TP_PROTO(struct afs_call *call, const struct afs_fid *fid), 283 284 TP_ARGS(call, fid), 285 286 TP_STRUCT__entry( 287 __field(unsigned int, call ) 288 __field(enum afs_fs_operation, op ) 289 __field_struct(struct afs_fid, fid ) 290 ), 291 292 TP_fast_assign( 293 __entry->call = call->debug_id; 294 __entry->op = call->operation_ID; 295 if (fid) { 296 __entry->fid = *fid; 297 } else { 298 __entry->fid.vid = 0; 299 __entry->fid.vnode = 0; 300 __entry->fid.unique = 0; 301 } 302 ), 303 304 TP_printk("c=%08x %06x:%06x:%06x %s", 305 __entry->call, 306 __entry->fid.vid, 307 __entry->fid.vnode, 308 __entry->fid.unique, 309 __print_symbolic(__entry->op, afs_fs_operations)) 310 ); 311 312 TRACE_EVENT(afs_make_vl_call, 313 TP_PROTO(struct afs_call *call), 314 315 TP_ARGS(call), 316 317 TP_STRUCT__entry( 318 __field(unsigned int, call ) 319 __field(enum afs_vl_operation, op ) 320 ), 321 322 TP_fast_assign( 323 __entry->call = call->debug_id; 324 __entry->op = call->operation_ID; 325 ), 326 327 TP_printk("c=%08x %s", 328 __entry->call, 329 __print_symbolic(__entry->op, afs_vl_operations)) 330 ); 331 332 TRACE_EVENT(afs_call_done, 333 TP_PROTO(struct afs_call *call), 334 335 TP_ARGS(call), 336 337 TP_STRUCT__entry( 338 __field(unsigned int, call ) 339 __field(struct rxrpc_call *, rx_call ) 340 __field(int, ret ) 341 __field(u32, abort_code ) 342 ), 343 344 TP_fast_assign( 345 __entry->call = call->debug_id; 346 __entry->rx_call = call->rxcall; 347 __entry->ret = call->error; 348 __entry->abort_code = call->abort_code; 349 ), 350 351 TP_printk(" c=%08x ret=%d ab=%d [%p]", 352 __entry->call, 353 __entry->ret, 354 __entry->abort_code, 355 __entry->rx_call) 356 ); 357 358 TRACE_EVENT(afs_send_pages, 359 TP_PROTO(struct afs_call *call, struct msghdr *msg, 360 pgoff_t first, pgoff_t last, unsigned int offset), 361 362 TP_ARGS(call, msg, first, last, offset), 363 364 TP_STRUCT__entry( 365 __field(unsigned int, call ) 366 __field(pgoff_t, first ) 367 __field(pgoff_t, last ) 368 __field(unsigned int, nr ) 369 __field(unsigned int, bytes ) 370 __field(unsigned int, offset ) 371 __field(unsigned int, flags ) 372 ), 373 374 TP_fast_assign( 375 __entry->call = call->debug_id; 376 __entry->first = first; 377 __entry->last = last; 378 __entry->nr = msg->msg_iter.nr_segs; 379 __entry->bytes = msg->msg_iter.count; 380 __entry->offset = offset; 381 __entry->flags = msg->msg_flags; 382 ), 383 384 TP_printk(" c=%08x %lx-%lx-%lx b=%x o=%x f=%x", 385 __entry->call, 386 __entry->first, __entry->first + __entry->nr - 1, __entry->last, 387 __entry->bytes, __entry->offset, 388 __entry->flags) 389 ); 390 391 TRACE_EVENT(afs_sent_pages, 392 TP_PROTO(struct afs_call *call, pgoff_t first, pgoff_t last, 393 pgoff_t cursor, int ret), 394 395 TP_ARGS(call, first, last, cursor, ret), 396 397 TP_STRUCT__entry( 398 __field(unsigned int, call ) 399 __field(pgoff_t, first ) 400 __field(pgoff_t, last ) 401 __field(pgoff_t, cursor ) 402 __field(int, ret ) 403 ), 404 405 TP_fast_assign( 406 __entry->call = call->debug_id; 407 __entry->first = first; 408 __entry->last = last; 409 __entry->cursor = cursor; 410 __entry->ret = ret; 411 ), 412 413 TP_printk(" c=%08x %lx-%lx c=%lx r=%d", 414 __entry->call, 415 __entry->first, __entry->last, 416 __entry->cursor, __entry->ret) 417 ); 418 419 TRACE_EVENT(afs_dir_check_failed, 420 TP_PROTO(struct afs_vnode *vnode, loff_t off, loff_t i_size), 421 422 TP_ARGS(vnode, off, i_size), 423 424 TP_STRUCT__entry( 425 __field(struct afs_vnode *, vnode ) 426 __field(loff_t, off ) 427 __field(loff_t, i_size ) 428 ), 429 430 TP_fast_assign( 431 __entry->vnode = vnode; 432 __entry->off = off; 433 __entry->i_size = i_size; 434 ), 435 436 TP_printk("vn=%p %llx/%llx", 437 __entry->vnode, __entry->off, __entry->i_size) 438 ); 439 440 /* 441 * We use page->private to hold the amount of the page that we've written to, 442 * splitting the field into two parts. However, we need to represent a range 443 * 0...PAGE_SIZE inclusive, so we can't support 64K pages on a 32-bit system. 444 */ 445 #if PAGE_SIZE > 32768 446 #define AFS_PRIV_MAX 0xffffffff 447 #define AFS_PRIV_SHIFT 32 448 #else 449 #define AFS_PRIV_MAX 0xffff 450 #define AFS_PRIV_SHIFT 16 451 #endif 452 453 TRACE_EVENT(afs_page_dirty, 454 TP_PROTO(struct afs_vnode *vnode, const char *where, 455 pgoff_t page, unsigned long priv), 456 457 TP_ARGS(vnode, where, page, priv), 458 459 TP_STRUCT__entry( 460 __field(struct afs_vnode *, vnode ) 461 __field(const char *, where ) 462 __field(pgoff_t, page ) 463 __field(unsigned long, priv ) 464 ), 465 466 TP_fast_assign( 467 __entry->vnode = vnode; 468 __entry->where = where; 469 __entry->page = page; 470 __entry->priv = priv; 471 ), 472 473 TP_printk("vn=%p %lx %s %lu-%lu", 474 __entry->vnode, __entry->page, __entry->where, 475 __entry->priv & AFS_PRIV_MAX, 476 __entry->priv >> AFS_PRIV_SHIFT) 477 ); 478 479 TRACE_EVENT(afs_call_state, 480 TP_PROTO(struct afs_call *call, 481 enum afs_call_state from, 482 enum afs_call_state to, 483 int ret, u32 remote_abort), 484 485 TP_ARGS(call, from, to, ret, remote_abort), 486 487 TP_STRUCT__entry( 488 __field(unsigned int, call ) 489 __field(enum afs_call_state, from ) 490 __field(enum afs_call_state, to ) 491 __field(int, ret ) 492 __field(u32, abort ) 493 ), 494 495 TP_fast_assign( 496 __entry->call = call->debug_id; 497 __entry->from = from; 498 __entry->to = to; 499 __entry->ret = ret; 500 __entry->abort = remote_abort; 501 ), 502 503 TP_printk("c=%08x %u->%u r=%d ab=%d", 504 __entry->call, 505 __entry->from, __entry->to, 506 __entry->ret, __entry->abort) 507 ); 508 509 TRACE_EVENT(afs_edit_dir, 510 TP_PROTO(struct afs_vnode *dvnode, 511 enum afs_edit_dir_reason why, 512 enum afs_edit_dir_op op, 513 unsigned int block, 514 unsigned int slot, 515 unsigned int f_vnode, 516 unsigned int f_unique, 517 const char *name), 518 519 TP_ARGS(dvnode, why, op, block, slot, f_vnode, f_unique, name), 520 521 TP_STRUCT__entry( 522 __field(unsigned int, vnode ) 523 __field(unsigned int, unique ) 524 __field(enum afs_edit_dir_reason, why ) 525 __field(enum afs_edit_dir_op, op ) 526 __field(unsigned int, block ) 527 __field(unsigned short, slot ) 528 __field(unsigned int, f_vnode ) 529 __field(unsigned int, f_unique ) 530 __array(char, name, 18 ) 531 ), 532 533 TP_fast_assign( 534 int __len = strlen(name); 535 __len = min(__len, 17); 536 __entry->vnode = dvnode->fid.vnode; 537 __entry->unique = dvnode->fid.unique; 538 __entry->why = why; 539 __entry->op = op; 540 __entry->block = block; 541 __entry->slot = slot; 542 __entry->f_vnode = f_vnode; 543 __entry->f_unique = f_unique; 544 memcpy(__entry->name, name, __len); 545 __entry->name[__len] = 0; 546 ), 547 548 TP_printk("d=%x:%x %s %s %u[%u] f=%x:%x %s", 549 __entry->vnode, __entry->unique, 550 __print_symbolic(__entry->why, afs_edit_dir_reasons), 551 __print_symbolic(__entry->op, afs_edit_dir_ops), 552 __entry->block, __entry->slot, 553 __entry->f_vnode, __entry->f_unique, 554 __entry->name) 555 ); 556 557 TRACE_EVENT(afs_protocol_error, 558 TP_PROTO(struct afs_call *call, int error, const void *where), 559 560 TP_ARGS(call, error, where), 561 562 TP_STRUCT__entry( 563 __field(unsigned int, call ) 564 __field(int, error ) 565 __field(const void *, where ) 566 ), 567 568 TP_fast_assign( 569 __entry->call = call ? call->debug_id : 0; 570 __entry->error = error; 571 __entry->where = where; 572 ), 573 574 TP_printk("c=%08x r=%d sp=%pSR", 575 __entry->call, __entry->error, __entry->where) 576 ); 577 578 TRACE_EVENT(afs_cm_no_server, 579 TP_PROTO(struct afs_call *call, struct sockaddr_rxrpc *srx), 580 581 TP_ARGS(call, srx), 582 583 TP_STRUCT__entry( 584 __field(unsigned int, call ) 585 __field(unsigned int, op_id ) 586 __field_struct(struct sockaddr_rxrpc, srx ) 587 ), 588 589 TP_fast_assign( 590 __entry->call = call->debug_id; 591 __entry->op_id = call->operation_ID; 592 memcpy(&__entry->srx, srx, sizeof(__entry->srx)); 593 ), 594 595 TP_printk("c=%08x op=%u %pISpc", 596 __entry->call, __entry->op_id, &__entry->srx.transport) 597 ); 598 599 TRACE_EVENT(afs_cm_no_server_u, 600 TP_PROTO(struct afs_call *call, const uuid_t *uuid), 601 602 TP_ARGS(call, uuid), 603 604 TP_STRUCT__entry( 605 __field(unsigned int, call ) 606 __field(unsigned int, op_id ) 607 __field_struct(uuid_t, uuid ) 608 ), 609 610 TP_fast_assign( 611 __entry->call = call->debug_id; 612 __entry->op_id = call->operation_ID; 613 memcpy(&__entry->uuid, uuid, sizeof(__entry->uuid)); 614 ), 615 616 TP_printk("c=%08x op=%u %pU", 617 __entry->call, __entry->op_id, &__entry->uuid) 618 ); 619 620 #endif /* _TRACE_AFS_H */ 621 622 /* This part must be outside protection */ 623 #include <trace/define_trace.h> 624