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/mmflags.h> 10 11 struct btrfs_root; 12 struct btrfs_fs_info; 13 struct btrfs_inode; 14 struct extent_map; 15 struct btrfs_file_extent_item; 16 struct btrfs_ordered_extent; 17 struct btrfs_delayed_ref_node; 18 struct btrfs_delayed_tree_ref; 19 struct btrfs_delayed_data_ref; 20 struct btrfs_delayed_ref_head; 21 struct btrfs_block_group_cache; 22 struct btrfs_free_cluster; 23 struct map_lookup; 24 struct extent_buffer; 25 struct btrfs_work; 26 struct __btrfs_workqueue; 27 struct btrfs_qgroup_extent_record; 28 struct btrfs_qgroup; 29 30 #define show_ref_type(type) \ 31 __print_symbolic(type, \ 32 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ 33 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ 34 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \ 35 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ 36 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) 37 38 #define __show_root_type(obj) \ 39 __print_symbolic_u64(obj, \ 40 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ 41 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ 42 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ 43 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ 44 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ 45 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ 46 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ 47 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ 48 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \ 49 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ 50 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \ 51 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \ 52 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) 53 54 #define show_root_type(obj) \ 55 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ 56 (obj >= BTRFS_ROOT_TREE_OBJECTID && \ 57 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-" 58 59 #define show_fi_type(type) \ 60 __print_symbolic(type, \ 61 { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \ 62 { BTRFS_FILE_EXTENT_REG, "REG" }, \ 63 { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"}) 64 65 #define BTRFS_GROUP_FLAGS \ 66 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \ 67 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 68 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 69 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \ 70 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ 71 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ 72 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 73 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ 74 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} 75 76 #define BTRFS_UUID_SIZE 16 77 #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_UUID_SIZE) 78 79 #define TP_fast_assign_fsid(fs_info) \ 80 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE) 81 82 #define TP_STRUCT__entry_btrfs(args...) \ 83 TP_STRUCT__entry( \ 84 TP_STRUCT__entry_fsid \ 85 args) 86 #define TP_fast_assign_btrfs(fs_info, args...) \ 87 TP_fast_assign( \ 88 TP_fast_assign_fsid(fs_info); \ 89 args) 90 #define TP_printk_btrfs(fmt, args...) \ 91 TP_printk("%pU: " fmt, __entry->fsid, args) 92 93 TRACE_EVENT(btrfs_transaction_commit, 94 95 TP_PROTO(struct btrfs_root *root), 96 97 TP_ARGS(root), 98 99 TP_STRUCT__entry_btrfs( 100 __field( u64, generation ) 101 __field( u64, root_objectid ) 102 ), 103 104 TP_fast_assign_btrfs(root->fs_info, 105 __entry->generation = root->fs_info->generation; 106 __entry->root_objectid = root->root_key.objectid; 107 ), 108 109 TP_printk_btrfs("root = %llu(%s), gen = %llu", 110 show_root_type(__entry->root_objectid), 111 (unsigned long long)__entry->generation) 112 ); 113 114 DECLARE_EVENT_CLASS(btrfs__inode, 115 116 TP_PROTO(struct inode *inode), 117 118 TP_ARGS(inode), 119 120 TP_STRUCT__entry_btrfs( 121 __field( ino_t, ino ) 122 __field( blkcnt_t, blocks ) 123 __field( u64, disk_i_size ) 124 __field( u64, generation ) 125 __field( u64, last_trans ) 126 __field( u64, logged_trans ) 127 __field( u64, root_objectid ) 128 ), 129 130 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 131 __entry->ino = inode->i_ino; 132 __entry->blocks = inode->i_blocks; 133 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; 134 __entry->generation = BTRFS_I(inode)->generation; 135 __entry->last_trans = BTRFS_I(inode)->last_trans; 136 __entry->logged_trans = BTRFS_I(inode)->logged_trans; 137 __entry->root_objectid = 138 BTRFS_I(inode)->root->root_key.objectid; 139 ), 140 141 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu " 142 "disk_i_size=%llu last_trans=%llu logged_trans=%llu", 143 show_root_type(__entry->root_objectid), 144 (unsigned long long)__entry->generation, 145 (unsigned long)__entry->ino, 146 (unsigned long long)__entry->blocks, 147 (unsigned long long)__entry->disk_i_size, 148 (unsigned long long)__entry->last_trans, 149 (unsigned long long)__entry->logged_trans) 150 ); 151 152 DEFINE_EVENT(btrfs__inode, btrfs_inode_new, 153 154 TP_PROTO(struct inode *inode), 155 156 TP_ARGS(inode) 157 ); 158 159 DEFINE_EVENT(btrfs__inode, btrfs_inode_request, 160 161 TP_PROTO(struct inode *inode), 162 163 TP_ARGS(inode) 164 ); 165 166 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, 167 168 TP_PROTO(struct inode *inode), 169 170 TP_ARGS(inode) 171 ); 172 173 #define __show_map_type(type) \ 174 __print_symbolic_u64(type, \ 175 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ 176 { EXTENT_MAP_HOLE, "HOLE" }, \ 177 { EXTENT_MAP_INLINE, "INLINE" }, \ 178 { EXTENT_MAP_DELALLOC, "DELALLOC" }) 179 180 #define show_map_type(type) \ 181 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) 182 183 #define show_map_flags(flag) \ 184 __print_flags(flag, "|", \ 185 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\ 186 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\ 187 { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\ 188 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\ 189 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\ 190 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\ 191 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" }) 192 193 TRACE_EVENT_CONDITION(btrfs_get_extent, 194 195 TP_PROTO(struct btrfs_root *root, struct btrfs_inode *inode, 196 struct extent_map *map), 197 198 TP_ARGS(root, inode, map), 199 200 TP_CONDITION(map), 201 202 TP_STRUCT__entry_btrfs( 203 __field( u64, root_objectid ) 204 __field( u64, ino ) 205 __field( u64, start ) 206 __field( u64, len ) 207 __field( u64, orig_start ) 208 __field( u64, block_start ) 209 __field( u64, block_len ) 210 __field( unsigned long, flags ) 211 __field( int, refs ) 212 __field( unsigned int, compress_type ) 213 ), 214 215 TP_fast_assign_btrfs(root->fs_info, 216 __entry->root_objectid = root->root_key.objectid; 217 __entry->ino = btrfs_ino(inode); 218 __entry->start = map->start; 219 __entry->len = map->len; 220 __entry->orig_start = map->orig_start; 221 __entry->block_start = map->block_start; 222 __entry->block_len = map->block_len; 223 __entry->flags = map->flags; 224 __entry->refs = refcount_read(&map->refs); 225 __entry->compress_type = map->compress_type; 226 ), 227 228 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu " 229 "orig_start=%llu block_start=%llu(%s) " 230 "block_len=%llu flags=%s refs=%u " 231 "compress_type=%u", 232 show_root_type(__entry->root_objectid), 233 (unsigned long long)__entry->ino, 234 (unsigned long long)__entry->start, 235 (unsigned long long)__entry->len, 236 (unsigned long long)__entry->orig_start, 237 show_map_type(__entry->block_start), 238 (unsigned long long)__entry->block_len, 239 show_map_flags(__entry->flags), 240 __entry->refs, __entry->compress_type) 241 ); 242 243 /* file extent item */ 244 DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular, 245 246 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 247 struct btrfs_file_extent_item *fi, u64 start), 248 249 TP_ARGS(bi, l, fi, start), 250 251 TP_STRUCT__entry_btrfs( 252 __field( u64, root_obj ) 253 __field( u64, ino ) 254 __field( loff_t, isize ) 255 __field( u64, disk_isize ) 256 __field( u64, num_bytes ) 257 __field( u64, ram_bytes ) 258 __field( u64, disk_bytenr ) 259 __field( u64, disk_num_bytes ) 260 __field( u64, extent_offset ) 261 __field( u8, extent_type ) 262 __field( u8, compression ) 263 __field( u64, extent_start ) 264 __field( u64, extent_end ) 265 ), 266 267 TP_fast_assign_btrfs(bi->root->fs_info, 268 __entry->root_obj = bi->root->objectid; 269 __entry->ino = btrfs_ino(bi); 270 __entry->isize = bi->vfs_inode.i_size; 271 __entry->disk_isize = bi->disk_i_size; 272 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi); 273 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi); 274 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi); 275 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi); 276 __entry->extent_offset = btrfs_file_extent_offset(l, fi); 277 __entry->extent_type = btrfs_file_extent_type(l, fi); 278 __entry->compression = btrfs_file_extent_compression(l, fi); 279 __entry->extent_start = start; 280 __entry->extent_end = (start + __entry->num_bytes); 281 ), 282 283 TP_printk_btrfs( 284 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 285 "file extent range=[%llu %llu] " 286 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu " 287 "disk_num_bytes=%llu extent_offset=%llu type=%s " 288 "compression=%u", 289 show_root_type(__entry->root_obj), __entry->ino, 290 __entry->isize, 291 __entry->disk_isize, __entry->extent_start, 292 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes, 293 __entry->disk_bytenr, __entry->disk_num_bytes, 294 __entry->extent_offset, show_fi_type(__entry->extent_type), 295 __entry->compression) 296 ); 297 298 DECLARE_EVENT_CLASS( 299 btrfs__file_extent_item_inline, 300 301 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 302 struct btrfs_file_extent_item *fi, int slot, u64 start), 303 304 TP_ARGS(bi, l, fi, slot, start), 305 306 TP_STRUCT__entry_btrfs( 307 __field( u64, root_obj ) 308 __field( u64, ino ) 309 __field( loff_t, isize ) 310 __field( u64, disk_isize ) 311 __field( u8, extent_type ) 312 __field( u8, compression ) 313 __field( u64, extent_start ) 314 __field( u64, extent_end ) 315 ), 316 317 TP_fast_assign_btrfs( 318 bi->root->fs_info, 319 __entry->root_obj = bi->root->objectid; 320 __entry->ino = btrfs_ino(bi); 321 __entry->isize = bi->vfs_inode.i_size; 322 __entry->disk_isize = bi->disk_i_size; 323 __entry->extent_type = btrfs_file_extent_type(l, fi); 324 __entry->compression = btrfs_file_extent_compression(l, fi); 325 __entry->extent_start = start; 326 __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi)); 327 ), 328 329 TP_printk_btrfs( 330 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 331 "file extent range=[%llu %llu] " 332 "extent_type=%s compression=%u", 333 show_root_type(__entry->root_obj), __entry->ino, __entry->isize, 334 __entry->disk_isize, __entry->extent_start, 335 __entry->extent_end, show_fi_type(__entry->extent_type), 336 __entry->compression) 337 ); 338 339 DEFINE_EVENT( 340 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular, 341 342 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 343 struct btrfs_file_extent_item *fi, u64 start), 344 345 TP_ARGS(bi, l, fi, start) 346 ); 347 348 DEFINE_EVENT( 349 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular, 350 351 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 352 struct btrfs_file_extent_item *fi, u64 start), 353 354 TP_ARGS(bi, l, fi, start) 355 ); 356 357 DEFINE_EVENT( 358 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline, 359 360 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 361 struct btrfs_file_extent_item *fi, int slot, u64 start), 362 363 TP_ARGS(bi, l, fi, slot, start) 364 ); 365 366 DEFINE_EVENT( 367 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline, 368 369 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 370 struct btrfs_file_extent_item *fi, int slot, u64 start), 371 372 TP_ARGS(bi, l, fi, slot, start) 373 ); 374 375 #define show_ordered_flags(flags) \ 376 __print_flags(flags, "|", \ 377 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \ 378 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \ 379 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \ 380 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \ 381 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \ 382 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \ 383 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \ 384 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \ 385 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \ 386 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" }) 387 388 389 DECLARE_EVENT_CLASS(btrfs__ordered_extent, 390 391 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 392 393 TP_ARGS(inode, ordered), 394 395 TP_STRUCT__entry_btrfs( 396 __field( ino_t, ino ) 397 __field( u64, file_offset ) 398 __field( u64, start ) 399 __field( u64, len ) 400 __field( u64, disk_len ) 401 __field( u64, bytes_left ) 402 __field( unsigned long, flags ) 403 __field( int, compress_type ) 404 __field( int, refs ) 405 __field( u64, root_objectid ) 406 __field( u64, truncated_len ) 407 ), 408 409 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 410 __entry->ino = inode->i_ino; 411 __entry->file_offset = ordered->file_offset; 412 __entry->start = ordered->start; 413 __entry->len = ordered->len; 414 __entry->disk_len = ordered->disk_len; 415 __entry->bytes_left = ordered->bytes_left; 416 __entry->flags = ordered->flags; 417 __entry->compress_type = ordered->compress_type; 418 __entry->refs = refcount_read(&ordered->refs); 419 __entry->root_objectid = 420 BTRFS_I(inode)->root->root_key.objectid; 421 __entry->truncated_len = ordered->truncated_len; 422 ), 423 424 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu " 425 "start=%llu len=%llu disk_len=%llu " 426 "truncated_len=%llu " 427 "bytes_left=%llu flags=%s compress_type=%d " 428 "refs=%d", 429 show_root_type(__entry->root_objectid), 430 (unsigned long long)__entry->ino, 431 (unsigned long long)__entry->file_offset, 432 (unsigned long long)__entry->start, 433 (unsigned long long)__entry->len, 434 (unsigned long long)__entry->disk_len, 435 (unsigned long long)__entry->truncated_len, 436 (unsigned long long)__entry->bytes_left, 437 show_ordered_flags(__entry->flags), 438 __entry->compress_type, __entry->refs) 439 ); 440 441 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, 442 443 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 444 445 TP_ARGS(inode, ordered) 446 ); 447 448 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, 449 450 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 451 452 TP_ARGS(inode, ordered) 453 ); 454 455 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, 456 457 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 458 459 TP_ARGS(inode, ordered) 460 ); 461 462 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, 463 464 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), 465 466 TP_ARGS(inode, ordered) 467 ); 468 469 DECLARE_EVENT_CLASS(btrfs__writepage, 470 471 TP_PROTO(struct page *page, struct inode *inode, 472 struct writeback_control *wbc), 473 474 TP_ARGS(page, inode, wbc), 475 476 TP_STRUCT__entry_btrfs( 477 __field( ino_t, ino ) 478 __field( pgoff_t, index ) 479 __field( long, nr_to_write ) 480 __field( long, pages_skipped ) 481 __field( loff_t, range_start ) 482 __field( loff_t, range_end ) 483 __field( char, for_kupdate ) 484 __field( char, for_reclaim ) 485 __field( char, range_cyclic ) 486 __field( pgoff_t, writeback_index ) 487 __field( u64, root_objectid ) 488 ), 489 490 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 491 __entry->ino = inode->i_ino; 492 __entry->index = page->index; 493 __entry->nr_to_write = wbc->nr_to_write; 494 __entry->pages_skipped = wbc->pages_skipped; 495 __entry->range_start = wbc->range_start; 496 __entry->range_end = wbc->range_end; 497 __entry->for_kupdate = wbc->for_kupdate; 498 __entry->for_reclaim = wbc->for_reclaim; 499 __entry->range_cyclic = wbc->range_cyclic; 500 __entry->writeback_index = inode->i_mapping->writeback_index; 501 __entry->root_objectid = 502 BTRFS_I(inode)->root->root_key.objectid; 503 ), 504 505 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu " 506 "nr_to_write=%ld pages_skipped=%ld range_start=%llu " 507 "range_end=%llu for_kupdate=%d " 508 "for_reclaim=%d range_cyclic=%d writeback_index=%lu", 509 show_root_type(__entry->root_objectid), 510 (unsigned long)__entry->ino, __entry->index, 511 __entry->nr_to_write, __entry->pages_skipped, 512 __entry->range_start, __entry->range_end, 513 __entry->for_kupdate, 514 __entry->for_reclaim, __entry->range_cyclic, 515 (unsigned long)__entry->writeback_index) 516 ); 517 518 DEFINE_EVENT(btrfs__writepage, __extent_writepage, 519 520 TP_PROTO(struct page *page, struct inode *inode, 521 struct writeback_control *wbc), 522 523 TP_ARGS(page, inode, wbc) 524 ); 525 526 TRACE_EVENT(btrfs_writepage_end_io_hook, 527 528 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate), 529 530 TP_ARGS(page, start, end, uptodate), 531 532 TP_STRUCT__entry_btrfs( 533 __field( ino_t, ino ) 534 __field( pgoff_t, index ) 535 __field( u64, start ) 536 __field( u64, end ) 537 __field( int, uptodate ) 538 __field( u64, root_objectid ) 539 ), 540 541 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb), 542 __entry->ino = page->mapping->host->i_ino; 543 __entry->index = page->index; 544 __entry->start = start; 545 __entry->end = end; 546 __entry->uptodate = uptodate; 547 __entry->root_objectid = 548 BTRFS_I(page->mapping->host)->root->root_key.objectid; 549 ), 550 551 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu " 552 "end=%llu uptodate=%d", 553 show_root_type(__entry->root_objectid), 554 (unsigned long)__entry->ino, (unsigned long)__entry->index, 555 (unsigned long long)__entry->start, 556 (unsigned long long)__entry->end, __entry->uptodate) 557 ); 558 559 TRACE_EVENT(btrfs_sync_file, 560 561 TP_PROTO(struct file *file, int datasync), 562 563 TP_ARGS(file, datasync), 564 565 TP_STRUCT__entry_btrfs( 566 __field( ino_t, ino ) 567 __field( ino_t, parent ) 568 __field( int, datasync ) 569 __field( u64, root_objectid ) 570 ), 571 572 TP_fast_assign( 573 struct dentry *dentry = file->f_path.dentry; 574 struct inode *inode = d_inode(dentry); 575 576 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb)); 577 __entry->ino = inode->i_ino; 578 __entry->parent = d_inode(dentry->d_parent)->i_ino; 579 __entry->datasync = datasync; 580 __entry->root_objectid = 581 BTRFS_I(inode)->root->root_key.objectid; 582 ), 583 584 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d", 585 show_root_type(__entry->root_objectid), 586 (unsigned long)__entry->ino, (unsigned long)__entry->parent, 587 __entry->datasync) 588 ); 589 590 TRACE_EVENT(btrfs_sync_fs, 591 592 TP_PROTO(struct btrfs_fs_info *fs_info, int wait), 593 594 TP_ARGS(fs_info, wait), 595 596 TP_STRUCT__entry_btrfs( 597 __field( int, wait ) 598 ), 599 600 TP_fast_assign_btrfs(fs_info, 601 __entry->wait = wait; 602 ), 603 604 TP_printk_btrfs("wait = %d", __entry->wait) 605 ); 606 607 TRACE_EVENT(btrfs_add_block_group, 608 609 TP_PROTO(struct btrfs_fs_info *fs_info, 610 struct btrfs_block_group_cache *block_group, int create), 611 612 TP_ARGS(fs_info, block_group, create), 613 614 TP_STRUCT__entry( 615 __array( u8, fsid, BTRFS_UUID_SIZE ) 616 __field( u64, offset ) 617 __field( u64, size ) 618 __field( u64, flags ) 619 __field( u64, bytes_used ) 620 __field( u64, bytes_super ) 621 __field( int, create ) 622 ), 623 624 TP_fast_assign( 625 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); 626 __entry->offset = block_group->key.objectid; 627 __entry->size = block_group->key.offset; 628 __entry->flags = block_group->flags; 629 __entry->bytes_used = 630 btrfs_block_group_used(&block_group->item); 631 __entry->bytes_super = block_group->bytes_super; 632 __entry->create = create; 633 ), 634 635 TP_printk("%pU: block_group offset=%llu size=%llu " 636 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu " 637 "create=%d", __entry->fsid, 638 (unsigned long long)__entry->offset, 639 (unsigned long long)__entry->size, 640 (unsigned long long)__entry->flags, 641 __print_flags((unsigned long)__entry->flags, "|", 642 BTRFS_GROUP_FLAGS), 643 (unsigned long long)__entry->bytes_used, 644 (unsigned long long)__entry->bytes_super, __entry->create) 645 ); 646 647 #define show_ref_action(action) \ 648 __print_symbolic(action, \ 649 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 650 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 651 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 652 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 653 654 655 DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 656 657 TP_PROTO(struct btrfs_fs_info *fs_info, 658 struct btrfs_delayed_ref_node *ref, 659 struct btrfs_delayed_tree_ref *full_ref, 660 int action), 661 662 TP_ARGS(fs_info, ref, full_ref, action), 663 664 TP_STRUCT__entry_btrfs( 665 __field( u64, bytenr ) 666 __field( u64, num_bytes ) 667 __field( int, action ) 668 __field( u64, parent ) 669 __field( u64, ref_root ) 670 __field( int, level ) 671 __field( int, type ) 672 __field( u64, seq ) 673 ), 674 675 TP_fast_assign_btrfs(fs_info, 676 __entry->bytenr = ref->bytenr; 677 __entry->num_bytes = ref->num_bytes; 678 __entry->action = action; 679 __entry->parent = full_ref->parent; 680 __entry->ref_root = full_ref->root; 681 __entry->level = full_ref->level; 682 __entry->type = ref->type; 683 __entry->seq = ref->seq; 684 ), 685 686 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 687 "parent=%llu(%s) ref_root=%llu(%s) level=%d " 688 "type=%s seq=%llu", 689 (unsigned long long)__entry->bytenr, 690 (unsigned long long)__entry->num_bytes, 691 show_ref_action(__entry->action), 692 show_root_type(__entry->parent), 693 show_root_type(__entry->ref_root), 694 __entry->level, show_ref_type(__entry->type), 695 (unsigned long long)__entry->seq) 696 ); 697 698 DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 699 700 TP_PROTO(struct btrfs_fs_info *fs_info, 701 struct btrfs_delayed_ref_node *ref, 702 struct btrfs_delayed_tree_ref *full_ref, 703 int action), 704 705 TP_ARGS(fs_info, ref, full_ref, action) 706 ); 707 708 DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 709 710 TP_PROTO(struct btrfs_fs_info *fs_info, 711 struct btrfs_delayed_ref_node *ref, 712 struct btrfs_delayed_tree_ref *full_ref, 713 int action), 714 715 TP_ARGS(fs_info, ref, full_ref, action) 716 ); 717 718 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 719 720 TP_PROTO(struct btrfs_fs_info *fs_info, 721 struct btrfs_delayed_ref_node *ref, 722 struct btrfs_delayed_data_ref *full_ref, 723 int action), 724 725 TP_ARGS(fs_info, ref, full_ref, action), 726 727 TP_STRUCT__entry_btrfs( 728 __field( u64, bytenr ) 729 __field( u64, num_bytes ) 730 __field( int, action ) 731 __field( u64, parent ) 732 __field( u64, ref_root ) 733 __field( u64, owner ) 734 __field( u64, offset ) 735 __field( int, type ) 736 __field( u64, seq ) 737 ), 738 739 TP_fast_assign_btrfs(fs_info, 740 __entry->bytenr = ref->bytenr; 741 __entry->num_bytes = ref->num_bytes; 742 __entry->action = action; 743 __entry->parent = full_ref->parent; 744 __entry->ref_root = full_ref->root; 745 __entry->owner = full_ref->objectid; 746 __entry->offset = full_ref->offset; 747 __entry->type = ref->type; 748 __entry->seq = ref->seq; 749 ), 750 751 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 752 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu " 753 "offset=%llu type=%s seq=%llu", 754 (unsigned long long)__entry->bytenr, 755 (unsigned long long)__entry->num_bytes, 756 show_ref_action(__entry->action), 757 show_root_type(__entry->parent), 758 show_root_type(__entry->ref_root), 759 (unsigned long long)__entry->owner, 760 (unsigned long long)__entry->offset, 761 show_ref_type(__entry->type), 762 (unsigned long long)__entry->seq) 763 ); 764 765 DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 766 767 TP_PROTO(struct btrfs_fs_info *fs_info, 768 struct btrfs_delayed_ref_node *ref, 769 struct btrfs_delayed_data_ref *full_ref, 770 int action), 771 772 TP_ARGS(fs_info, ref, full_ref, action) 773 ); 774 775 DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 776 777 TP_PROTO(struct btrfs_fs_info *fs_info, 778 struct btrfs_delayed_ref_node *ref, 779 struct btrfs_delayed_data_ref *full_ref, 780 int action), 781 782 TP_ARGS(fs_info, ref, full_ref, action) 783 ); 784 785 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 786 787 TP_PROTO(struct btrfs_fs_info *fs_info, 788 struct btrfs_delayed_ref_node *ref, 789 struct btrfs_delayed_ref_head *head_ref, 790 int action), 791 792 TP_ARGS(fs_info, ref, head_ref, action), 793 794 TP_STRUCT__entry_btrfs( 795 __field( u64, bytenr ) 796 __field( u64, num_bytes ) 797 __field( int, action ) 798 __field( int, is_data ) 799 ), 800 801 TP_fast_assign_btrfs(fs_info, 802 __entry->bytenr = ref->bytenr; 803 __entry->num_bytes = ref->num_bytes; 804 __entry->action = action; 805 __entry->is_data = head_ref->is_data; 806 ), 807 808 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d", 809 (unsigned long long)__entry->bytenr, 810 (unsigned long long)__entry->num_bytes, 811 show_ref_action(__entry->action), 812 __entry->is_data) 813 ); 814 815 DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 816 817 TP_PROTO(struct btrfs_fs_info *fs_info, 818 struct btrfs_delayed_ref_node *ref, 819 struct btrfs_delayed_ref_head *head_ref, 820 int action), 821 822 TP_ARGS(fs_info, ref, head_ref, action) 823 ); 824 825 DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 826 827 TP_PROTO(struct btrfs_fs_info *fs_info, 828 struct btrfs_delayed_ref_node *ref, 829 struct btrfs_delayed_ref_head *head_ref, 830 int action), 831 832 TP_ARGS(fs_info, ref, head_ref, action) 833 ); 834 835 #define show_chunk_type(type) \ 836 __print_flags(type, "|", \ 837 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 838 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 839 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 840 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 841 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 842 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 843 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 844 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 845 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 846 847 DECLARE_EVENT_CLASS(btrfs__chunk, 848 849 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, 850 u64 offset, u64 size), 851 852 TP_ARGS(fs_info, map, offset, size), 853 854 TP_STRUCT__entry_btrfs( 855 __field( int, num_stripes ) 856 __field( u64, type ) 857 __field( int, sub_stripes ) 858 __field( u64, offset ) 859 __field( u64, size ) 860 __field( u64, root_objectid ) 861 ), 862 863 TP_fast_assign_btrfs(fs_info, 864 __entry->num_stripes = map->num_stripes; 865 __entry->type = map->type; 866 __entry->sub_stripes = map->sub_stripes; 867 __entry->offset = offset; 868 __entry->size = size; 869 __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 870 ), 871 872 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu " 873 "num_stripes=%d sub_stripes=%d type=%s", 874 show_root_type(__entry->root_objectid), 875 (unsigned long long)__entry->offset, 876 (unsigned long long)__entry->size, 877 __entry->num_stripes, __entry->sub_stripes, 878 show_chunk_type(__entry->type)) 879 ); 880 881 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 882 883 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, 884 u64 offset, u64 size), 885 886 TP_ARGS(fs_info, map, offset, size) 887 ); 888 889 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 890 891 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, 892 u64 offset, u64 size), 893 894 TP_ARGS(fs_info, map, offset, size) 895 ); 896 897 TRACE_EVENT(btrfs_cow_block, 898 899 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf, 900 struct extent_buffer *cow), 901 902 TP_ARGS(root, buf, cow), 903 904 TP_STRUCT__entry_btrfs( 905 __field( u64, root_objectid ) 906 __field( u64, buf_start ) 907 __field( int, refs ) 908 __field( u64, cow_start ) 909 __field( int, buf_level ) 910 __field( int, cow_level ) 911 ), 912 913 TP_fast_assign_btrfs(root->fs_info, 914 __entry->root_objectid = root->root_key.objectid; 915 __entry->buf_start = buf->start; 916 __entry->refs = atomic_read(&buf->refs); 917 __entry->cow_start = cow->start; 918 __entry->buf_level = btrfs_header_level(buf); 919 __entry->cow_level = btrfs_header_level(cow); 920 ), 921 922 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu " 923 "(orig_level=%d) cow_buf=%llu (cow_level=%d)", 924 show_root_type(__entry->root_objectid), 925 __entry->refs, 926 (unsigned long long)__entry->buf_start, 927 __entry->buf_level, 928 (unsigned long long)__entry->cow_start, 929 __entry->cow_level) 930 ); 931 932 TRACE_EVENT(btrfs_space_reservation, 933 934 TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val, 935 u64 bytes, int reserve), 936 937 TP_ARGS(fs_info, type, val, bytes, reserve), 938 939 TP_STRUCT__entry_btrfs( 940 __string( type, type ) 941 __field( u64, val ) 942 __field( u64, bytes ) 943 __field( int, reserve ) 944 ), 945 946 TP_fast_assign_btrfs(fs_info, 947 __assign_str(type, type); 948 __entry->val = val; 949 __entry->bytes = bytes; 950 __entry->reserve = reserve; 951 ), 952 953 TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val, 954 __entry->reserve ? "reserve" : "release", 955 __entry->bytes) 956 ); 957 958 #define show_flush_action(action) \ 959 __print_symbolic(action, \ 960 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ 961 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ 962 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) 963 964 TRACE_EVENT(btrfs_trigger_flush, 965 966 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 967 int flush, char *reason), 968 969 TP_ARGS(fs_info, flags, bytes, flush, reason), 970 971 TP_STRUCT__entry( 972 __array( u8, fsid, BTRFS_UUID_SIZE ) 973 __field( u64, flags ) 974 __field( u64, bytes ) 975 __field( int, flush ) 976 __string( reason, reason ) 977 ), 978 979 TP_fast_assign( 980 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); 981 __entry->flags = flags; 982 __entry->bytes = bytes; 983 __entry->flush = flush; 984 __assign_str(reason, reason) 985 ), 986 987 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu", 988 __entry->fsid, __get_str(reason), __entry->flush, 989 show_flush_action(__entry->flush), 990 (unsigned long long)__entry->flags, 991 __print_flags((unsigned long)__entry->flags, "|", 992 BTRFS_GROUP_FLAGS), 993 (unsigned long long)__entry->bytes) 994 ); 995 996 #define show_flush_state(state) \ 997 __print_symbolic(state, \ 998 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ 999 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ 1000 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ 1001 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ 1002 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ 1003 { COMMIT_TRANS, "COMMIT_TRANS"}) 1004 1005 TRACE_EVENT(btrfs_flush_space, 1006 1007 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, 1008 u64 orig_bytes, int state, int ret), 1009 1010 TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret), 1011 1012 TP_STRUCT__entry( 1013 __array( u8, fsid, BTRFS_UUID_SIZE ) 1014 __field( u64, flags ) 1015 __field( u64, num_bytes ) 1016 __field( u64, orig_bytes ) 1017 __field( int, state ) 1018 __field( int, ret ) 1019 ), 1020 1021 TP_fast_assign( 1022 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); 1023 __entry->flags = flags; 1024 __entry->num_bytes = num_bytes; 1025 __entry->orig_bytes = orig_bytes; 1026 __entry->state = state; 1027 __entry->ret = ret; 1028 ), 1029 1030 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu " 1031 "orig_bytes=%llu ret=%d", __entry->fsid, __entry->state, 1032 show_flush_state(__entry->state), 1033 (unsigned long long)__entry->flags, 1034 __print_flags((unsigned long)__entry->flags, "|", 1035 BTRFS_GROUP_FLAGS), 1036 (unsigned long long)__entry->num_bytes, 1037 (unsigned long long)__entry->orig_bytes, __entry->ret) 1038 ); 1039 1040 DECLARE_EVENT_CLASS(btrfs__reserved_extent, 1041 1042 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len), 1043 1044 TP_ARGS(fs_info, start, len), 1045 1046 TP_STRUCT__entry_btrfs( 1047 __field( u64, start ) 1048 __field( u64, len ) 1049 ), 1050 1051 TP_fast_assign_btrfs(fs_info, 1052 __entry->start = start; 1053 __entry->len = len; 1054 ), 1055 1056 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu", 1057 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1058 (unsigned long long)__entry->start, 1059 (unsigned long long)__entry->len) 1060 ); 1061 1062 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 1063 1064 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len), 1065 1066 TP_ARGS(fs_info, start, len) 1067 ); 1068 1069 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 1070 1071 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len), 1072 1073 TP_ARGS(fs_info, start, len) 1074 ); 1075 1076 TRACE_EVENT(find_free_extent, 1077 1078 TP_PROTO(struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size, 1079 u64 data), 1080 1081 TP_ARGS(fs_info, num_bytes, empty_size, data), 1082 1083 TP_STRUCT__entry_btrfs( 1084 __field( u64, num_bytes ) 1085 __field( u64, empty_size ) 1086 __field( u64, data ) 1087 ), 1088 1089 TP_fast_assign_btrfs(fs_info, 1090 __entry->num_bytes = num_bytes; 1091 __entry->empty_size = empty_size; 1092 __entry->data = data; 1093 ), 1094 1095 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)", 1096 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1097 __entry->num_bytes, __entry->empty_size, __entry->data, 1098 __print_flags((unsigned long)__entry->data, "|", 1099 BTRFS_GROUP_FLAGS)) 1100 ); 1101 1102 DECLARE_EVENT_CLASS(btrfs__reserve_extent, 1103 1104 TP_PROTO(struct btrfs_fs_info *fs_info, 1105 struct btrfs_block_group_cache *block_group, u64 start, 1106 u64 len), 1107 1108 TP_ARGS(fs_info, block_group, start, len), 1109 1110 TP_STRUCT__entry_btrfs( 1111 __field( u64, bg_objectid ) 1112 __field( u64, flags ) 1113 __field( u64, start ) 1114 __field( u64, len ) 1115 ), 1116 1117 TP_fast_assign_btrfs(fs_info, 1118 __entry->bg_objectid = block_group->key.objectid; 1119 __entry->flags = block_group->flags; 1120 __entry->start = start; 1121 __entry->len = len; 1122 ), 1123 1124 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) " 1125 "start=%Lu len=%Lu", 1126 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1127 __entry->bg_objectid, 1128 __entry->flags, __print_flags((unsigned long)__entry->flags, 1129 "|", BTRFS_GROUP_FLAGS), 1130 __entry->start, __entry->len) 1131 ); 1132 1133 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 1134 1135 TP_PROTO(struct btrfs_fs_info *fs_info, 1136 struct btrfs_block_group_cache *block_group, u64 start, 1137 u64 len), 1138 1139 TP_ARGS(fs_info, block_group, start, len) 1140 ); 1141 1142 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 1143 1144 TP_PROTO(struct btrfs_fs_info *fs_info, 1145 struct btrfs_block_group_cache *block_group, u64 start, 1146 u64 len), 1147 1148 TP_ARGS(fs_info, block_group, start, len) 1149 ); 1150 1151 TRACE_EVENT(btrfs_find_cluster, 1152 1153 TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start, 1154 u64 bytes, u64 empty_size, u64 min_bytes), 1155 1156 TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 1157 1158 TP_STRUCT__entry_btrfs( 1159 __field( u64, bg_objectid ) 1160 __field( u64, flags ) 1161 __field( u64, start ) 1162 __field( u64, bytes ) 1163 __field( u64, empty_size ) 1164 __field( u64, min_bytes ) 1165 ), 1166 1167 TP_fast_assign_btrfs(block_group->fs_info, 1168 __entry->bg_objectid = block_group->key.objectid; 1169 __entry->flags = block_group->flags; 1170 __entry->start = start; 1171 __entry->bytes = bytes; 1172 __entry->empty_size = empty_size; 1173 __entry->min_bytes = min_bytes; 1174 ), 1175 1176 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu " 1177 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid, 1178 __entry->flags, 1179 __print_flags((unsigned long)__entry->flags, "|", 1180 BTRFS_GROUP_FLAGS), __entry->start, 1181 __entry->bytes, __entry->empty_size, __entry->min_bytes) 1182 ); 1183 1184 TRACE_EVENT(btrfs_failed_cluster_setup, 1185 1186 TP_PROTO(struct btrfs_block_group_cache *block_group), 1187 1188 TP_ARGS(block_group), 1189 1190 TP_STRUCT__entry_btrfs( 1191 __field( u64, bg_objectid ) 1192 ), 1193 1194 TP_fast_assign_btrfs(block_group->fs_info, 1195 __entry->bg_objectid = block_group->key.objectid; 1196 ), 1197 1198 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid) 1199 ); 1200 1201 TRACE_EVENT(btrfs_setup_cluster, 1202 1203 TP_PROTO(struct btrfs_block_group_cache *block_group, 1204 struct btrfs_free_cluster *cluster, u64 size, int bitmap), 1205 1206 TP_ARGS(block_group, cluster, size, bitmap), 1207 1208 TP_STRUCT__entry_btrfs( 1209 __field( u64, bg_objectid ) 1210 __field( u64, flags ) 1211 __field( u64, start ) 1212 __field( u64, max_size ) 1213 __field( u64, size ) 1214 __field( int, bitmap ) 1215 ), 1216 1217 TP_fast_assign_btrfs(block_group->fs_info, 1218 __entry->bg_objectid = block_group->key.objectid; 1219 __entry->flags = block_group->flags; 1220 __entry->start = cluster->window_start; 1221 __entry->max_size = cluster->max_size; 1222 __entry->size = size; 1223 __entry->bitmap = bitmap; 1224 ), 1225 1226 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu " 1227 "size=%Lu max_size=%Lu bitmap=%d", 1228 __entry->bg_objectid, 1229 __entry->flags, 1230 __print_flags((unsigned long)__entry->flags, "|", 1231 BTRFS_GROUP_FLAGS), __entry->start, 1232 __entry->size, __entry->max_size, __entry->bitmap) 1233 ); 1234 1235 struct extent_state; 1236 TRACE_EVENT(alloc_extent_state, 1237 1238 TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP), 1239 1240 TP_ARGS(state, mask, IP), 1241 1242 TP_STRUCT__entry( 1243 __field(struct extent_state *, state) 1244 __field(gfp_t, mask) 1245 __field(unsigned long, ip) 1246 ), 1247 1248 TP_fast_assign( 1249 __entry->state = state, 1250 __entry->mask = mask, 1251 __entry->ip = IP 1252 ), 1253 1254 TP_printk("state=%p mask=%s caller=%pS", __entry->state, 1255 show_gfp_flags(__entry->mask), (void *)__entry->ip) 1256 ); 1257 1258 TRACE_EVENT(free_extent_state, 1259 1260 TP_PROTO(struct extent_state *state, unsigned long IP), 1261 1262 TP_ARGS(state, IP), 1263 1264 TP_STRUCT__entry( 1265 __field(struct extent_state *, state) 1266 __field(unsigned long, ip) 1267 ), 1268 1269 TP_fast_assign( 1270 __entry->state = state, 1271 __entry->ip = IP 1272 ), 1273 1274 TP_printk("state=%p caller=%pS", __entry->state, 1275 (void *)__entry->ip) 1276 ); 1277 1278 DECLARE_EVENT_CLASS(btrfs__work, 1279 1280 TP_PROTO(struct btrfs_work *work), 1281 1282 TP_ARGS(work), 1283 1284 TP_STRUCT__entry_btrfs( 1285 __field( void *, work ) 1286 __field( void *, wq ) 1287 __field( void *, func ) 1288 __field( void *, ordered_func ) 1289 __field( void *, ordered_free ) 1290 __field( void *, normal_work ) 1291 ), 1292 1293 TP_fast_assign_btrfs(btrfs_work_owner(work), 1294 __entry->work = work; 1295 __entry->wq = work->wq; 1296 __entry->func = work->func; 1297 __entry->ordered_func = work->ordered_func; 1298 __entry->ordered_free = work->ordered_free; 1299 __entry->normal_work = &work->normal_work; 1300 ), 1301 1302 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p " 1303 "ordered_free=%p", 1304 __entry->work, __entry->normal_work, __entry->wq, 1305 __entry->func, __entry->ordered_func, __entry->ordered_free) 1306 ); 1307 1308 /* 1309 * For situiations when the work is freed, we pass fs_info and a tag that that 1310 * matches address of the work structure so it can be paired with the 1311 * scheduling event. 1312 */ 1313 DECLARE_EVENT_CLASS(btrfs__work__done, 1314 1315 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag), 1316 1317 TP_ARGS(fs_info, wtag), 1318 1319 TP_STRUCT__entry_btrfs( 1320 __field( void *, wtag ) 1321 ), 1322 1323 TP_fast_assign_btrfs(fs_info, 1324 __entry->wtag = wtag; 1325 ), 1326 1327 TP_printk_btrfs("work->%p", __entry->wtag) 1328 ); 1329 1330 DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1331 1332 TP_PROTO(struct btrfs_work *work), 1333 1334 TP_ARGS(work) 1335 ); 1336 1337 DEFINE_EVENT(btrfs__work, btrfs_work_sched, 1338 1339 TP_PROTO(struct btrfs_work *work), 1340 1341 TP_ARGS(work) 1342 ); 1343 1344 DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1345 1346 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag), 1347 1348 TP_ARGS(fs_info, wtag) 1349 ); 1350 1351 DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1352 1353 TP_PROTO(struct btrfs_work *work), 1354 1355 TP_ARGS(work) 1356 ); 1357 1358 DECLARE_EVENT_CLASS(btrfs__workqueue, 1359 1360 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high), 1361 1362 TP_ARGS(wq, name, high), 1363 1364 TP_STRUCT__entry_btrfs( 1365 __field( void *, wq ) 1366 __string( name, name ) 1367 __field( int , high ) 1368 ), 1369 1370 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1371 __entry->wq = wq; 1372 __assign_str(name, name); 1373 __entry->high = high; 1374 ), 1375 1376 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name), 1377 __print_flags(__entry->high, "", 1378 {(WQ_HIGHPRI), "-high"}), 1379 __entry->wq) 1380 ); 1381 1382 DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc, 1383 1384 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high), 1385 1386 TP_ARGS(wq, name, high) 1387 ); 1388 1389 DECLARE_EVENT_CLASS(btrfs__workqueue_done, 1390 1391 TP_PROTO(struct __btrfs_workqueue *wq), 1392 1393 TP_ARGS(wq), 1394 1395 TP_STRUCT__entry_btrfs( 1396 __field( void *, wq ) 1397 ), 1398 1399 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1400 __entry->wq = wq; 1401 ), 1402 1403 TP_printk_btrfs("wq=%p", __entry->wq) 1404 ); 1405 1406 DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy, 1407 1408 TP_PROTO(struct __btrfs_workqueue *wq), 1409 1410 TP_ARGS(wq) 1411 ); 1412 1413 #define BTRFS_QGROUP_OPERATIONS \ 1414 { QGROUP_RESERVE, "reserve" }, \ 1415 { QGROUP_RELEASE, "release" }, \ 1416 { QGROUP_FREE, "free" } 1417 1418 DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data, 1419 1420 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op), 1421 1422 TP_ARGS(inode, start, len, reserved, op), 1423 1424 TP_STRUCT__entry_btrfs( 1425 __field( u64, rootid ) 1426 __field( unsigned long, ino ) 1427 __field( u64, start ) 1428 __field( u64, len ) 1429 __field( u64, reserved ) 1430 __field( int, op ) 1431 ), 1432 1433 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 1434 __entry->rootid = BTRFS_I(inode)->root->objectid; 1435 __entry->ino = inode->i_ino; 1436 __entry->start = start; 1437 __entry->len = len; 1438 __entry->reserved = reserved; 1439 __entry->op = op; 1440 ), 1441 1442 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s", 1443 __entry->rootid, __entry->ino, __entry->start, __entry->len, 1444 __entry->reserved, 1445 __print_flags((unsigned long)__entry->op, "", 1446 BTRFS_QGROUP_OPERATIONS) 1447 ) 1448 ); 1449 1450 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data, 1451 1452 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op), 1453 1454 TP_ARGS(inode, start, len, reserved, op) 1455 ); 1456 1457 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data, 1458 1459 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op), 1460 1461 TP_ARGS(inode, start, len, reserved, op) 1462 ); 1463 1464 DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref, 1465 1466 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved), 1467 1468 TP_ARGS(fs_info, ref_root, reserved), 1469 1470 TP_STRUCT__entry_btrfs( 1471 __field( u64, ref_root ) 1472 __field( u64, reserved ) 1473 ), 1474 1475 TP_fast_assign_btrfs(fs_info, 1476 __entry->ref_root = ref_root; 1477 __entry->reserved = reserved; 1478 ), 1479 1480 TP_printk_btrfs("root=%llu reserved=%llu op=free", 1481 __entry->ref_root, __entry->reserved) 1482 ); 1483 1484 DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref, 1485 1486 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved), 1487 1488 TP_ARGS(fs_info, ref_root, reserved) 1489 ); 1490 1491 DECLARE_EVENT_CLASS(btrfs_qgroup_extent, 1492 TP_PROTO(struct btrfs_fs_info *fs_info, 1493 struct btrfs_qgroup_extent_record *rec), 1494 1495 TP_ARGS(fs_info, rec), 1496 1497 TP_STRUCT__entry_btrfs( 1498 __field( u64, bytenr ) 1499 __field( u64, num_bytes ) 1500 ), 1501 1502 TP_fast_assign_btrfs(fs_info, 1503 __entry->bytenr = rec->bytenr, 1504 __entry->num_bytes = rec->num_bytes; 1505 ), 1506 1507 TP_printk_btrfs("bytenr=%llu num_bytes=%llu", 1508 (unsigned long long)__entry->bytenr, 1509 (unsigned long long)__entry->num_bytes) 1510 ); 1511 1512 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents, 1513 1514 TP_PROTO(struct btrfs_fs_info *fs_info, 1515 struct btrfs_qgroup_extent_record *rec), 1516 1517 TP_ARGS(fs_info, rec) 1518 ); 1519 1520 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent, 1521 1522 TP_PROTO(struct btrfs_fs_info *fs_info, 1523 struct btrfs_qgroup_extent_record *rec), 1524 1525 TP_ARGS(fs_info, rec) 1526 ); 1527 1528 TRACE_EVENT(btrfs_qgroup_account_extent, 1529 1530 TP_PROTO(struct btrfs_fs_info *fs_info, u64 bytenr, 1531 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots), 1532 1533 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots), 1534 1535 TP_STRUCT__entry_btrfs( 1536 __field( u64, bytenr ) 1537 __field( u64, num_bytes ) 1538 __field( u64, nr_old_roots ) 1539 __field( u64, nr_new_roots ) 1540 ), 1541 1542 TP_fast_assign_btrfs(fs_info, 1543 __entry->bytenr = bytenr; 1544 __entry->num_bytes = num_bytes; 1545 __entry->nr_old_roots = nr_old_roots; 1546 __entry->nr_new_roots = nr_new_roots; 1547 ), 1548 1549 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu " 1550 "nr_new_roots=%llu", 1551 __entry->bytenr, 1552 __entry->num_bytes, 1553 __entry->nr_old_roots, 1554 __entry->nr_new_roots) 1555 ); 1556 1557 TRACE_EVENT(qgroup_update_counters, 1558 1559 TP_PROTO(struct btrfs_fs_info *fs_info, u64 qgid, 1560 u64 cur_old_count, u64 cur_new_count), 1561 1562 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count), 1563 1564 TP_STRUCT__entry_btrfs( 1565 __field( u64, qgid ) 1566 __field( u64, cur_old_count ) 1567 __field( u64, cur_new_count ) 1568 ), 1569 1570 TP_fast_assign_btrfs(fs_info, 1571 __entry->qgid = qgid; 1572 __entry->cur_old_count = cur_old_count; 1573 __entry->cur_new_count = cur_new_count; 1574 ), 1575 1576 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu", 1577 __entry->qgid, 1578 __entry->cur_old_count, 1579 __entry->cur_new_count) 1580 ); 1581 1582 TRACE_EVENT(qgroup_update_reserve, 1583 1584 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup, 1585 s64 diff), 1586 1587 TP_ARGS(fs_info, qgroup, diff), 1588 1589 TP_STRUCT__entry_btrfs( 1590 __field( u64, qgid ) 1591 __field( u64, cur_reserved ) 1592 __field( s64, diff ) 1593 ), 1594 1595 TP_fast_assign_btrfs(fs_info, 1596 __entry->qgid = qgroup->qgroupid; 1597 __entry->cur_reserved = qgroup->reserved; 1598 __entry->diff = diff; 1599 ), 1600 1601 TP_printk_btrfs("qgid=%llu cur_reserved=%llu diff=%lld", 1602 __entry->qgid, __entry->cur_reserved, __entry->diff) 1603 ); 1604 1605 TRACE_EVENT(qgroup_meta_reserve, 1606 1607 TP_PROTO(struct btrfs_root *root, s64 diff), 1608 1609 TP_ARGS(root, diff), 1610 1611 TP_STRUCT__entry_btrfs( 1612 __field( u64, refroot ) 1613 __field( s64, diff ) 1614 ), 1615 1616 TP_fast_assign_btrfs(root->fs_info, 1617 __entry->refroot = root->objectid; 1618 __entry->diff = diff; 1619 ), 1620 1621 TP_printk_btrfs("refroot=%llu(%s) diff=%lld", 1622 show_root_type(__entry->refroot), __entry->diff) 1623 ); 1624 1625 #endif /* _TRACE_BTRFS_H */ 1626 1627 /* This part must be outside protection */ 1628 #include <trace/define_trace.h> 1629