1 #undef TRACE_SYSTEM 2 #define TRACE_SYSTEM btrfs 3 4 #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ) 5 #define _TRACE_BTRFS_H 6 7 #include <linux/writeback.h> 8 #include <linux/tracepoint.h> 9 #include <trace/events/gfpflags.h> 10 11 struct btrfs_root; 12 struct btrfs_fs_info; 13 struct btrfs_inode; 14 struct extent_map; 15 struct btrfs_ordered_extent; 16 struct btrfs_delayed_ref_node; 17 struct btrfs_delayed_tree_ref; 18 struct btrfs_delayed_data_ref; 19 struct btrfs_delayed_ref_head; 20 struct btrfs_block_group_cache; 21 struct btrfs_free_cluster; 22 struct map_lookup; 23 struct extent_buffer; 24 struct btrfs_work; 25 struct __btrfs_workqueue; 26 27 #define show_ref_type(type) \ 28 __print_symbolic(type, \ 29 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ 30 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ 31 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \ 32 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ 33 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) 34 35 #define __show_root_type(obj) \ 36 __print_symbolic_u64(obj, \ 37 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ 38 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ 39 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ 40 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ 41 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ 42 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ 43 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ 44 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ 45 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \ 46 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ 47 { BTRFS_UUID_TREE_OBJECTID, "UUID_RELOC" }, \ 48 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) 49 50 #define show_root_type(obj) \ 51 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ 52 (obj >= BTRFS_ROOT_TREE_OBJECTID && \ 53 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-" 54 55 #define BTRFS_GROUP_FLAGS \ 56 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \ 57 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 58 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 59 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \ 60 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ 61 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ 62 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 63 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ 64 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} 65 66 #define BTRFS_UUID_SIZE 16 67 68 TRACE_EVENT(btrfs_transaction_commit, 69 70 TP_PROTO(struct btrfs_root *root), 71 72 TP_ARGS(root), 73 74 TP_STRUCT__entry( 75 __field( u64, generation ) 76 __field( u64, root_objectid ) 77 ), 78 79 TP_fast_assign( 80 __entry->generation = root->fs_info->generation; 81 __entry->root_objectid = root->root_key.objectid; 82 ), 83 84 TP_printk("root = %llu(%s), gen = %llu", 85 show_root_type(__entry->root_objectid), 86 (unsigned long long)__entry->generation) 87 ); 88 89 DECLARE_EVENT_CLASS(btrfs__inode, 90 91 TP_PROTO(struct inode *inode), 92 93 TP_ARGS(inode), 94 95 TP_STRUCT__entry( 96 __field( ino_t, ino ) 97 __field( blkcnt_t, blocks ) 98 __field( u64, disk_i_size ) 99 __field( u64, generation ) 100 __field( u64, last_trans ) 101 __field( u64, logged_trans ) 102 __field( u64, root_objectid ) 103 ), 104 105 TP_fast_assign( 106 __entry->ino = inode->i_ino; 107 __entry->blocks = inode->i_blocks; 108 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; 109 __entry->generation = BTRFS_I(inode)->generation; 110 __entry->last_trans = BTRFS_I(inode)->last_trans; 111 __entry->logged_trans = BTRFS_I(inode)->logged_trans; 112 __entry->root_objectid = 113 BTRFS_I(inode)->root->root_key.objectid; 114 ), 115 116 TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, " 117 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu", 118 show_root_type(__entry->root_objectid), 119 (unsigned long long)__entry->generation, 120 (unsigned long)__entry->ino, 121 (unsigned long long)__entry->blocks, 122 (unsigned long long)__entry->disk_i_size, 123 (unsigned long long)__entry->last_trans, 124 (unsigned long long)__entry->logged_trans) 125 ); 126 127 DEFINE_EVENT(btrfs__inode, btrfs_inode_new, 128 129 TP_PROTO(struct inode *inode), 130 131 TP_ARGS(inode) 132 ); 133 134 DEFINE_EVENT(btrfs__inode, btrfs_inode_request, 135 136 TP_PROTO(struct inode *inode), 137 138 TP_ARGS(inode) 139 ); 140 141 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, 142 143 TP_PROTO(struct inode *inode), 144 145 TP_ARGS(inode) 146 ); 147 148 #define __show_map_type(type) \ 149 __print_symbolic_u64(type, \ 150 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ 151 { EXTENT_MAP_HOLE, "HOLE" }, \ 152 { EXTENT_MAP_INLINE, "INLINE" }, \ 153 { EXTENT_MAP_DELALLOC, "DELALLOC" }) 154 155 #define show_map_type(type) \ 156 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) 157 158 #define show_map_flags(flag) \ 159 __print_flags(flag, "|", \ 160 { EXTENT_FLAG_PINNED, "PINNED" }, \ 161 { EXTENT_FLAG_COMPRESSED, "COMPRESSED" }, \ 162 { EXTENT_FLAG_VACANCY, "VACANCY" }, \ 163 { EXTENT_FLAG_PREALLOC, "PREALLOC" }, \ 164 { EXTENT_FLAG_LOGGING, "LOGGING" }, \ 165 { EXTENT_FLAG_FILLING, "FILLING" }) 166 167 TRACE_EVENT_CONDITION(btrfs_get_extent, 168 169 TP_PROTO(struct btrfs_root *root, struct extent_map *map), 170 171 TP_ARGS(root, map), 172 173 TP_CONDITION(map), 174 175 TP_STRUCT__entry( 176 __field( u64, root_objectid ) 177 __field( u64, start ) 178 __field( u64, len ) 179 __field( u64, orig_start ) 180 __field( u64, block_start ) 181 __field( u64, block_len ) 182 __field( unsigned long, flags ) 183 __field( int, refs ) 184 __field( unsigned int, compress_type ) 185 ), 186 187 TP_fast_assign( 188 __entry->root_objectid = root->root_key.objectid; 189 __entry->start = map->start; 190 __entry->len = map->len; 191 __entry->orig_start = map->orig_start; 192 __entry->block_start = map->block_start; 193 __entry->block_len = map->block_len; 194 __entry->flags = map->flags; 195 __entry->refs = atomic_read(&map->refs); 196 __entry->compress_type = map->compress_type; 197 ), 198 199 TP_printk("root = %llu(%s), start = %llu, len = %llu, " 200 "orig_start = %llu, block_start = %llu(%s), " 201 "block_len = %llu, flags = %s, refs = %u, " 202 "compress_type = %u", 203 show_root_type(__entry->root_objectid), 204 (unsigned long long)__entry->start, 205 (unsigned long long)__entry->len, 206 (unsigned long long)__entry->orig_start, 207 show_map_type(__entry->block_start), 208 (unsigned long long)__entry->block_len, 209 show_map_flags(__entry->flags), 210 __entry->refs, __entry->compress_type) 211 ); 212 213 #define show_ordered_flags(flags) \ 214 __print_flags(flags, "|", \ 215 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \ 216 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \ 217 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \ 218 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \ 219 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \ 220 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \ 221 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \ 222 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \ 223 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \ 224 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" }) 225 226 227 DECLARE_EVENT_CLASS(btrfs__ordered_extent, 228 229 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 230 231 TP_ARGS(inode, ordered), 232 233 TP_STRUCT__entry( 234 __field( ino_t, ino ) 235 __field( u64, file_offset ) 236 __field( u64, start ) 237 __field( u64, len ) 238 __field( u64, disk_len ) 239 __field( u64, bytes_left ) 240 __field( unsigned long, flags ) 241 __field( int, compress_type ) 242 __field( int, refs ) 243 __field( u64, root_objectid ) 244 ), 245 246 TP_fast_assign( 247 __entry->ino = inode->i_ino; 248 __entry->file_offset = ordered->file_offset; 249 __entry->start = ordered->start; 250 __entry->len = ordered->len; 251 __entry->disk_len = ordered->disk_len; 252 __entry->bytes_left = ordered->bytes_left; 253 __entry->flags = ordered->flags; 254 __entry->compress_type = ordered->compress_type; 255 __entry->refs = atomic_read(&ordered->refs); 256 __entry->root_objectid = 257 BTRFS_I(inode)->root->root_key.objectid; 258 ), 259 260 TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, " 261 "start = %llu, len = %llu, disk_len = %llu, " 262 "bytes_left = %llu, flags = %s, compress_type = %d, " 263 "refs = %d", 264 show_root_type(__entry->root_objectid), 265 (unsigned long long)__entry->ino, 266 (unsigned long long)__entry->file_offset, 267 (unsigned long long)__entry->start, 268 (unsigned long long)__entry->len, 269 (unsigned long long)__entry->disk_len, 270 (unsigned long long)__entry->bytes_left, 271 show_ordered_flags(__entry->flags), 272 __entry->compress_type, __entry->refs) 273 ); 274 275 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, 276 277 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 278 279 TP_ARGS(inode, ordered) 280 ); 281 282 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, 283 284 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 285 286 TP_ARGS(inode, ordered) 287 ); 288 289 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, 290 291 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 292 293 TP_ARGS(inode, ordered) 294 ); 295 296 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, 297 298 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 299 300 TP_ARGS(inode, ordered) 301 ); 302 303 DECLARE_EVENT_CLASS(btrfs__writepage, 304 305 TP_PROTO(struct page *page, struct inode *inode, 306 struct writeback_control *wbc), 307 308 TP_ARGS(page, inode, wbc), 309 310 TP_STRUCT__entry( 311 __field( ino_t, ino ) 312 __field( pgoff_t, index ) 313 __field( long, nr_to_write ) 314 __field( long, pages_skipped ) 315 __field( loff_t, range_start ) 316 __field( loff_t, range_end ) 317 __field( char, for_kupdate ) 318 __field( char, for_reclaim ) 319 __field( char, range_cyclic ) 320 __field( pgoff_t, writeback_index ) 321 __field( u64, root_objectid ) 322 ), 323 324 TP_fast_assign( 325 __entry->ino = inode->i_ino; 326 __entry->index = page->index; 327 __entry->nr_to_write = wbc->nr_to_write; 328 __entry->pages_skipped = wbc->pages_skipped; 329 __entry->range_start = wbc->range_start; 330 __entry->range_end = wbc->range_end; 331 __entry->for_kupdate = wbc->for_kupdate; 332 __entry->for_reclaim = wbc->for_reclaim; 333 __entry->range_cyclic = wbc->range_cyclic; 334 __entry->writeback_index = inode->i_mapping->writeback_index; 335 __entry->root_objectid = 336 BTRFS_I(inode)->root->root_key.objectid; 337 ), 338 339 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, " 340 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, " 341 "range_end = %llu, for_kupdate = %d, " 342 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu", 343 show_root_type(__entry->root_objectid), 344 (unsigned long)__entry->ino, __entry->index, 345 __entry->nr_to_write, __entry->pages_skipped, 346 __entry->range_start, __entry->range_end, 347 __entry->for_kupdate, 348 __entry->for_reclaim, __entry->range_cyclic, 349 (unsigned long)__entry->writeback_index) 350 ); 351 352 DEFINE_EVENT(btrfs__writepage, __extent_writepage, 353 354 TP_PROTO(struct page *page, struct inode *inode, 355 struct writeback_control *wbc), 356 357 TP_ARGS(page, inode, wbc) 358 ); 359 360 TRACE_EVENT(btrfs_writepage_end_io_hook, 361 362 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate), 363 364 TP_ARGS(page, start, end, uptodate), 365 366 TP_STRUCT__entry( 367 __field( ino_t, ino ) 368 __field( pgoff_t, index ) 369 __field( u64, start ) 370 __field( u64, end ) 371 __field( int, uptodate ) 372 __field( u64, root_objectid ) 373 ), 374 375 TP_fast_assign( 376 __entry->ino = page->mapping->host->i_ino; 377 __entry->index = page->index; 378 __entry->start = start; 379 __entry->end = end; 380 __entry->uptodate = uptodate; 381 __entry->root_objectid = 382 BTRFS_I(page->mapping->host)->root->root_key.objectid; 383 ), 384 385 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, " 386 "end = %llu, uptodate = %d", 387 show_root_type(__entry->root_objectid), 388 (unsigned long)__entry->ino, (unsigned long)__entry->index, 389 (unsigned long long)__entry->start, 390 (unsigned long long)__entry->end, __entry->uptodate) 391 ); 392 393 TRACE_EVENT(btrfs_sync_file, 394 395 TP_PROTO(struct file *file, int datasync), 396 397 TP_ARGS(file, datasync), 398 399 TP_STRUCT__entry( 400 __field( ino_t, ino ) 401 __field( ino_t, parent ) 402 __field( int, datasync ) 403 __field( u64, root_objectid ) 404 ), 405 406 TP_fast_assign( 407 struct dentry *dentry = file->f_path.dentry; 408 struct inode *inode = dentry->d_inode; 409 410 __entry->ino = inode->i_ino; 411 __entry->parent = dentry->d_parent->d_inode->i_ino; 412 __entry->datasync = datasync; 413 __entry->root_objectid = 414 BTRFS_I(inode)->root->root_key.objectid; 415 ), 416 417 TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d", 418 show_root_type(__entry->root_objectid), 419 (unsigned long)__entry->ino, (unsigned long)__entry->parent, 420 __entry->datasync) 421 ); 422 423 TRACE_EVENT(btrfs_sync_fs, 424 425 TP_PROTO(int wait), 426 427 TP_ARGS(wait), 428 429 TP_STRUCT__entry( 430 __field( int, wait ) 431 ), 432 433 TP_fast_assign( 434 __entry->wait = wait; 435 ), 436 437 TP_printk("wait = %d", __entry->wait) 438 ); 439 440 #define show_ref_action(action) \ 441 __print_symbolic(action, \ 442 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 443 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 444 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 445 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 446 447 448 DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 449 450 TP_PROTO(struct btrfs_delayed_ref_node *ref, 451 struct btrfs_delayed_tree_ref *full_ref, 452 int action), 453 454 TP_ARGS(ref, full_ref, action), 455 456 TP_STRUCT__entry( 457 __field( u64, bytenr ) 458 __field( u64, num_bytes ) 459 __field( int, action ) 460 __field( u64, parent ) 461 __field( u64, ref_root ) 462 __field( int, level ) 463 __field( int, type ) 464 __field( u64, seq ) 465 ), 466 467 TP_fast_assign( 468 __entry->bytenr = ref->bytenr; 469 __entry->num_bytes = ref->num_bytes; 470 __entry->action = action; 471 __entry->parent = full_ref->parent; 472 __entry->ref_root = full_ref->root; 473 __entry->level = full_ref->level; 474 __entry->type = ref->type; 475 __entry->seq = ref->seq; 476 ), 477 478 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, " 479 "parent = %llu(%s), ref_root = %llu(%s), level = %d, " 480 "type = %s, seq = %llu", 481 (unsigned long long)__entry->bytenr, 482 (unsigned long long)__entry->num_bytes, 483 show_ref_action(__entry->action), 484 show_root_type(__entry->parent), 485 show_root_type(__entry->ref_root), 486 __entry->level, show_ref_type(__entry->type), 487 (unsigned long long)__entry->seq) 488 ); 489 490 DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 491 492 TP_PROTO(struct btrfs_delayed_ref_node *ref, 493 struct btrfs_delayed_tree_ref *full_ref, 494 int action), 495 496 TP_ARGS(ref, full_ref, action) 497 ); 498 499 DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 500 501 TP_PROTO(struct btrfs_delayed_ref_node *ref, 502 struct btrfs_delayed_tree_ref *full_ref, 503 int action), 504 505 TP_ARGS(ref, full_ref, action) 506 ); 507 508 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 509 510 TP_PROTO(struct btrfs_delayed_ref_node *ref, 511 struct btrfs_delayed_data_ref *full_ref, 512 int action), 513 514 TP_ARGS(ref, full_ref, action), 515 516 TP_STRUCT__entry( 517 __field( u64, bytenr ) 518 __field( u64, num_bytes ) 519 __field( int, action ) 520 __field( u64, parent ) 521 __field( u64, ref_root ) 522 __field( u64, owner ) 523 __field( u64, offset ) 524 __field( int, type ) 525 __field( u64, seq ) 526 ), 527 528 TP_fast_assign( 529 __entry->bytenr = ref->bytenr; 530 __entry->num_bytes = ref->num_bytes; 531 __entry->action = action; 532 __entry->parent = full_ref->parent; 533 __entry->ref_root = full_ref->root; 534 __entry->owner = full_ref->objectid; 535 __entry->offset = full_ref->offset; 536 __entry->type = ref->type; 537 __entry->seq = ref->seq; 538 ), 539 540 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, " 541 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, " 542 "offset = %llu, type = %s, seq = %llu", 543 (unsigned long long)__entry->bytenr, 544 (unsigned long long)__entry->num_bytes, 545 show_ref_action(__entry->action), 546 show_root_type(__entry->parent), 547 show_root_type(__entry->ref_root), 548 (unsigned long long)__entry->owner, 549 (unsigned long long)__entry->offset, 550 show_ref_type(__entry->type), 551 (unsigned long long)__entry->seq) 552 ); 553 554 DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 555 556 TP_PROTO(struct btrfs_delayed_ref_node *ref, 557 struct btrfs_delayed_data_ref *full_ref, 558 int action), 559 560 TP_ARGS(ref, full_ref, action) 561 ); 562 563 DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 564 565 TP_PROTO(struct btrfs_delayed_ref_node *ref, 566 struct btrfs_delayed_data_ref *full_ref, 567 int action), 568 569 TP_ARGS(ref, full_ref, action) 570 ); 571 572 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 573 574 TP_PROTO(struct btrfs_delayed_ref_node *ref, 575 struct btrfs_delayed_ref_head *head_ref, 576 int action), 577 578 TP_ARGS(ref, head_ref, action), 579 580 TP_STRUCT__entry( 581 __field( u64, bytenr ) 582 __field( u64, num_bytes ) 583 __field( int, action ) 584 __field( int, is_data ) 585 ), 586 587 TP_fast_assign( 588 __entry->bytenr = ref->bytenr; 589 __entry->num_bytes = ref->num_bytes; 590 __entry->action = action; 591 __entry->is_data = head_ref->is_data; 592 ), 593 594 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d", 595 (unsigned long long)__entry->bytenr, 596 (unsigned long long)__entry->num_bytes, 597 show_ref_action(__entry->action), 598 __entry->is_data) 599 ); 600 601 DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 602 603 TP_PROTO(struct btrfs_delayed_ref_node *ref, 604 struct btrfs_delayed_ref_head *head_ref, 605 int action), 606 607 TP_ARGS(ref, head_ref, action) 608 ); 609 610 DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 611 612 TP_PROTO(struct btrfs_delayed_ref_node *ref, 613 struct btrfs_delayed_ref_head *head_ref, 614 int action), 615 616 TP_ARGS(ref, head_ref, action) 617 ); 618 619 #define show_chunk_type(type) \ 620 __print_flags(type, "|", \ 621 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 622 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 623 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 624 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 625 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 626 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 627 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 628 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 629 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 630 631 DECLARE_EVENT_CLASS(btrfs__chunk, 632 633 TP_PROTO(struct btrfs_root *root, struct map_lookup *map, 634 u64 offset, u64 size), 635 636 TP_ARGS(root, map, offset, size), 637 638 TP_STRUCT__entry( 639 __field( int, num_stripes ) 640 __field( u64, type ) 641 __field( int, sub_stripes ) 642 __field( u64, offset ) 643 __field( u64, size ) 644 __field( u64, root_objectid ) 645 ), 646 647 TP_fast_assign( 648 __entry->num_stripes = map->num_stripes; 649 __entry->type = map->type; 650 __entry->sub_stripes = map->sub_stripes; 651 __entry->offset = offset; 652 __entry->size = size; 653 __entry->root_objectid = root->root_key.objectid; 654 ), 655 656 TP_printk("root = %llu(%s), offset = %llu, size = %llu, " 657 "num_stripes = %d, sub_stripes = %d, type = %s", 658 show_root_type(__entry->root_objectid), 659 (unsigned long long)__entry->offset, 660 (unsigned long long)__entry->size, 661 __entry->num_stripes, __entry->sub_stripes, 662 show_chunk_type(__entry->type)) 663 ); 664 665 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 666 667 TP_PROTO(struct btrfs_root *root, struct map_lookup *map, 668 u64 offset, u64 size), 669 670 TP_ARGS(root, map, offset, size) 671 ); 672 673 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 674 675 TP_PROTO(struct btrfs_root *root, struct map_lookup *map, 676 u64 offset, u64 size), 677 678 TP_ARGS(root, map, offset, size) 679 ); 680 681 TRACE_EVENT(btrfs_cow_block, 682 683 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf, 684 struct extent_buffer *cow), 685 686 TP_ARGS(root, buf, cow), 687 688 TP_STRUCT__entry( 689 __field( u64, root_objectid ) 690 __field( u64, buf_start ) 691 __field( int, refs ) 692 __field( u64, cow_start ) 693 __field( int, buf_level ) 694 __field( int, cow_level ) 695 ), 696 697 TP_fast_assign( 698 __entry->root_objectid = root->root_key.objectid; 699 __entry->buf_start = buf->start; 700 __entry->refs = atomic_read(&buf->refs); 701 __entry->cow_start = cow->start; 702 __entry->buf_level = btrfs_header_level(buf); 703 __entry->cow_level = btrfs_header_level(cow); 704 ), 705 706 TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu " 707 "(orig_level = %d), cow_buf = %llu (cow_level = %d)", 708 show_root_type(__entry->root_objectid), 709 __entry->refs, 710 (unsigned long long)__entry->buf_start, 711 __entry->buf_level, 712 (unsigned long long)__entry->cow_start, 713 __entry->cow_level) 714 ); 715 716 TRACE_EVENT(btrfs_space_reservation, 717 718 TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val, 719 u64 bytes, int reserve), 720 721 TP_ARGS(fs_info, type, val, bytes, reserve), 722 723 TP_STRUCT__entry( 724 __array( u8, fsid, BTRFS_UUID_SIZE ) 725 __string( type, type ) 726 __field( u64, val ) 727 __field( u64, bytes ) 728 __field( int, reserve ) 729 ), 730 731 TP_fast_assign( 732 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); 733 __assign_str(type, type); 734 __entry->val = val; 735 __entry->bytes = bytes; 736 __entry->reserve = reserve; 737 ), 738 739 TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type), 740 __entry->val, __entry->reserve ? "reserve" : "release", 741 __entry->bytes) 742 ); 743 744 DECLARE_EVENT_CLASS(btrfs__reserved_extent, 745 746 TP_PROTO(struct btrfs_root *root, u64 start, u64 len), 747 748 TP_ARGS(root, start, len), 749 750 TP_STRUCT__entry( 751 __field( u64, root_objectid ) 752 __field( u64, start ) 753 __field( u64, len ) 754 ), 755 756 TP_fast_assign( 757 __entry->root_objectid = root->root_key.objectid; 758 __entry->start = start; 759 __entry->len = len; 760 ), 761 762 TP_printk("root = %llu(%s), start = %llu, len = %llu", 763 show_root_type(__entry->root_objectid), 764 (unsigned long long)__entry->start, 765 (unsigned long long)__entry->len) 766 ); 767 768 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 769 770 TP_PROTO(struct btrfs_root *root, u64 start, u64 len), 771 772 TP_ARGS(root, start, len) 773 ); 774 775 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 776 777 TP_PROTO(struct btrfs_root *root, u64 start, u64 len), 778 779 TP_ARGS(root, start, len) 780 ); 781 782 TRACE_EVENT(find_free_extent, 783 784 TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size, 785 u64 data), 786 787 TP_ARGS(root, num_bytes, empty_size, data), 788 789 TP_STRUCT__entry( 790 __field( u64, root_objectid ) 791 __field( u64, num_bytes ) 792 __field( u64, empty_size ) 793 __field( u64, data ) 794 ), 795 796 TP_fast_assign( 797 __entry->root_objectid = root->root_key.objectid; 798 __entry->num_bytes = num_bytes; 799 __entry->empty_size = empty_size; 800 __entry->data = data; 801 ), 802 803 TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, " 804 "flags = %Lu(%s)", show_root_type(__entry->root_objectid), 805 __entry->num_bytes, __entry->empty_size, __entry->data, 806 __print_flags((unsigned long)__entry->data, "|", 807 BTRFS_GROUP_FLAGS)) 808 ); 809 810 DECLARE_EVENT_CLASS(btrfs__reserve_extent, 811 812 TP_PROTO(struct btrfs_root *root, 813 struct btrfs_block_group_cache *block_group, u64 start, 814 u64 len), 815 816 TP_ARGS(root, block_group, start, len), 817 818 TP_STRUCT__entry( 819 __field( u64, root_objectid ) 820 __field( u64, bg_objectid ) 821 __field( u64, flags ) 822 __field( u64, start ) 823 __field( u64, len ) 824 ), 825 826 TP_fast_assign( 827 __entry->root_objectid = root->root_key.objectid; 828 __entry->bg_objectid = block_group->key.objectid; 829 __entry->flags = block_group->flags; 830 __entry->start = start; 831 __entry->len = len; 832 ), 833 834 TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), " 835 "start = %Lu, len = %Lu", 836 show_root_type(__entry->root_objectid), __entry->bg_objectid, 837 __entry->flags, __print_flags((unsigned long)__entry->flags, 838 "|", BTRFS_GROUP_FLAGS), 839 __entry->start, __entry->len) 840 ); 841 842 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 843 844 TP_PROTO(struct btrfs_root *root, 845 struct btrfs_block_group_cache *block_group, u64 start, 846 u64 len), 847 848 TP_ARGS(root, block_group, start, len) 849 ); 850 851 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 852 853 TP_PROTO(struct btrfs_root *root, 854 struct btrfs_block_group_cache *block_group, u64 start, 855 u64 len), 856 857 TP_ARGS(root, block_group, start, len) 858 ); 859 860 TRACE_EVENT(btrfs_find_cluster, 861 862 TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start, 863 u64 bytes, u64 empty_size, u64 min_bytes), 864 865 TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 866 867 TP_STRUCT__entry( 868 __field( u64, bg_objectid ) 869 __field( u64, flags ) 870 __field( u64, start ) 871 __field( u64, bytes ) 872 __field( u64, empty_size ) 873 __field( u64, min_bytes ) 874 ), 875 876 TP_fast_assign( 877 __entry->bg_objectid = block_group->key.objectid; 878 __entry->flags = block_group->flags; 879 __entry->start = start; 880 __entry->bytes = bytes; 881 __entry->empty_size = empty_size; 882 __entry->min_bytes = min_bytes; 883 ), 884 885 TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu," 886 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid, 887 __entry->flags, 888 __print_flags((unsigned long)__entry->flags, "|", 889 BTRFS_GROUP_FLAGS), __entry->start, 890 __entry->bytes, __entry->empty_size, __entry->min_bytes) 891 ); 892 893 TRACE_EVENT(btrfs_failed_cluster_setup, 894 895 TP_PROTO(struct btrfs_block_group_cache *block_group), 896 897 TP_ARGS(block_group), 898 899 TP_STRUCT__entry( 900 __field( u64, bg_objectid ) 901 ), 902 903 TP_fast_assign( 904 __entry->bg_objectid = block_group->key.objectid; 905 ), 906 907 TP_printk("block_group = %Lu", __entry->bg_objectid) 908 ); 909 910 TRACE_EVENT(btrfs_setup_cluster, 911 912 TP_PROTO(struct btrfs_block_group_cache *block_group, 913 struct btrfs_free_cluster *cluster, u64 size, int bitmap), 914 915 TP_ARGS(block_group, cluster, size, bitmap), 916 917 TP_STRUCT__entry( 918 __field( u64, bg_objectid ) 919 __field( u64, flags ) 920 __field( u64, start ) 921 __field( u64, max_size ) 922 __field( u64, size ) 923 __field( int, bitmap ) 924 ), 925 926 TP_fast_assign( 927 __entry->bg_objectid = block_group->key.objectid; 928 __entry->flags = block_group->flags; 929 __entry->start = cluster->window_start; 930 __entry->max_size = cluster->max_size; 931 __entry->size = size; 932 __entry->bitmap = bitmap; 933 ), 934 935 TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, " 936 "size = %Lu, max_size = %Lu, bitmap = %d", 937 __entry->bg_objectid, 938 __entry->flags, 939 __print_flags((unsigned long)__entry->flags, "|", 940 BTRFS_GROUP_FLAGS), __entry->start, 941 __entry->size, __entry->max_size, __entry->bitmap) 942 ); 943 944 struct extent_state; 945 TRACE_EVENT(alloc_extent_state, 946 947 TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP), 948 949 TP_ARGS(state, mask, IP), 950 951 TP_STRUCT__entry( 952 __field(struct extent_state *, state) 953 __field(gfp_t, mask) 954 __field(unsigned long, ip) 955 ), 956 957 TP_fast_assign( 958 __entry->state = state, 959 __entry->mask = mask, 960 __entry->ip = IP 961 ), 962 963 TP_printk("state=%p; mask = %s; caller = %pF", __entry->state, 964 show_gfp_flags(__entry->mask), (void *)__entry->ip) 965 ); 966 967 TRACE_EVENT(free_extent_state, 968 969 TP_PROTO(struct extent_state *state, unsigned long IP), 970 971 TP_ARGS(state, IP), 972 973 TP_STRUCT__entry( 974 __field(struct extent_state *, state) 975 __field(unsigned long, ip) 976 ), 977 978 TP_fast_assign( 979 __entry->state = state, 980 __entry->ip = IP 981 ), 982 983 TP_printk(" state=%p; caller = %pF", __entry->state, 984 (void *)__entry->ip) 985 ); 986 987 DECLARE_EVENT_CLASS(btrfs__work, 988 989 TP_PROTO(struct btrfs_work *work), 990 991 TP_ARGS(work), 992 993 TP_STRUCT__entry( 994 __field( void *, work ) 995 __field( void *, wq ) 996 __field( void *, func ) 997 __field( void *, ordered_func ) 998 __field( void *, ordered_free ) 999 ), 1000 1001 TP_fast_assign( 1002 __entry->work = work; 1003 __entry->wq = work->wq; 1004 __entry->func = work->func; 1005 __entry->ordered_func = work->ordered_func; 1006 __entry->ordered_free = work->ordered_free; 1007 ), 1008 1009 TP_printk("work=%p, wq=%p, func=%p, ordered_func=%p, ordered_free=%p", 1010 __entry->work, __entry->wq, __entry->func, 1011 __entry->ordered_func, __entry->ordered_free) 1012 ); 1013 1014 /* For situiations that the work is freed */ 1015 DECLARE_EVENT_CLASS(btrfs__work__done, 1016 1017 TP_PROTO(struct btrfs_work *work), 1018 1019 TP_ARGS(work), 1020 1021 TP_STRUCT__entry( 1022 __field( void *, work ) 1023 ), 1024 1025 TP_fast_assign( 1026 __entry->work = work; 1027 ), 1028 1029 TP_printk("work->%p", __entry->work) 1030 ); 1031 1032 DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1033 1034 TP_PROTO(struct btrfs_work *work), 1035 1036 TP_ARGS(work) 1037 ); 1038 1039 DEFINE_EVENT(btrfs__work, btrfs_work_sched, 1040 1041 TP_PROTO(struct btrfs_work *work), 1042 1043 TP_ARGS(work) 1044 ); 1045 1046 DEFINE_EVENT(btrfs__work, btrfs_normal_work_done, 1047 1048 TP_PROTO(struct btrfs_work *work), 1049 1050 TP_ARGS(work) 1051 ); 1052 1053 DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1054 1055 TP_PROTO(struct btrfs_work *work), 1056 1057 TP_ARGS(work) 1058 ); 1059 1060 DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1061 1062 TP_PROTO(struct btrfs_work *work), 1063 1064 TP_ARGS(work) 1065 ); 1066 1067 DECLARE_EVENT_CLASS(btrfs__workqueue, 1068 1069 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high), 1070 1071 TP_ARGS(wq, name, high), 1072 1073 TP_STRUCT__entry( 1074 __field( void *, wq ) 1075 __string( name, name ) 1076 __field( int , high ) 1077 ), 1078 1079 TP_fast_assign( 1080 __entry->wq = wq; 1081 __assign_str(name, name); 1082 __entry->high = high; 1083 ), 1084 1085 TP_printk("name=%s%s, wq=%p", __get_str(name), 1086 __print_flags(__entry->high, "", 1087 {(WQ_HIGHPRI), "-high"}), 1088 __entry->wq) 1089 ); 1090 1091 DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc, 1092 1093 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high), 1094 1095 TP_ARGS(wq, name, high) 1096 ); 1097 1098 DECLARE_EVENT_CLASS(btrfs__workqueue_done, 1099 1100 TP_PROTO(struct __btrfs_workqueue *wq), 1101 1102 TP_ARGS(wq), 1103 1104 TP_STRUCT__entry( 1105 __field( void *, wq ) 1106 ), 1107 1108 TP_fast_assign( 1109 __entry->wq = wq; 1110 ), 1111 1112 TP_printk("wq=%p", __entry->wq) 1113 ); 1114 1115 DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy, 1116 1117 TP_PROTO(struct __btrfs_workqueue *wq), 1118 1119 TP_ARGS(wq) 1120 ); 1121 1122 #endif /* _TRACE_BTRFS_H */ 1123 1124 /* This part must be outside protection */ 1125 #include <trace/define_trace.h> 1126