1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM btrfs 4 5 #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_BTRFS_H 7 8 #include <linux/writeback.h> 9 #include <linux/tracepoint.h> 10 #include <trace/events/mmflags.h> 11 12 struct btrfs_root; 13 struct btrfs_fs_info; 14 struct btrfs_inode; 15 struct extent_map; 16 struct btrfs_file_extent_item; 17 struct btrfs_ordered_extent; 18 struct btrfs_delayed_ref_node; 19 struct btrfs_delayed_tree_ref; 20 struct btrfs_delayed_data_ref; 21 struct btrfs_delayed_ref_head; 22 struct btrfs_block_group_cache; 23 struct btrfs_free_cluster; 24 struct map_lookup; 25 struct extent_buffer; 26 struct btrfs_work; 27 struct __btrfs_workqueue; 28 struct btrfs_qgroup_extent_record; 29 struct btrfs_qgroup; 30 struct extent_io_tree; 31 struct prelim_ref; 32 33 TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR); 34 TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS); 35 TRACE_DEFINE_ENUM(FLUSH_DELALLOC); 36 TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT); 37 TRACE_DEFINE_ENUM(ALLOC_CHUNK); 38 TRACE_DEFINE_ENUM(COMMIT_TRANS); 39 40 #define show_ref_type(type) \ 41 __print_symbolic(type, \ 42 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ 43 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ 44 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \ 45 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ 46 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) 47 48 #define __show_root_type(obj) \ 49 __print_symbolic_u64(obj, \ 50 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ 51 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ 52 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ 53 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ 54 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ 55 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ 56 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ 57 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ 58 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \ 59 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ 60 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \ 61 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \ 62 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) 63 64 #define show_root_type(obj) \ 65 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ 66 (obj >= BTRFS_ROOT_TREE_OBJECTID && \ 67 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-" 68 69 #define show_fi_type(type) \ 70 __print_symbolic(type, \ 71 { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \ 72 { BTRFS_FILE_EXTENT_REG, "REG" }, \ 73 { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"}) 74 75 #define show_qgroup_rsv_type(type) \ 76 __print_symbolic(type, \ 77 { BTRFS_QGROUP_RSV_DATA, "DATA" }, \ 78 { BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS" }, \ 79 { BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC" }) 80 81 #define show_extent_io_tree_owner(owner) \ 82 __print_symbolic(owner, \ 83 { IO_TREE_FS_INFO_FREED_EXTENTS0, "FREED_EXTENTS0" }, \ 84 { IO_TREE_FS_INFO_FREED_EXTENTS1, "FREED_EXTENTS1" }, \ 85 { IO_TREE_INODE_IO, "INODE_IO" }, \ 86 { IO_TREE_INODE_IO_FAILURE, "INODE_IO_FAILURE" }, \ 87 { IO_TREE_RELOC_BLOCKS, "RELOC_BLOCKS" }, \ 88 { IO_TREE_TRANS_DIRTY_PAGES, "TRANS_DIRTY_PAGES" }, \ 89 { IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES" }, \ 90 { IO_TREE_SELFTEST, "SELFTEST" }) 91 92 #define BTRFS_GROUP_FLAGS \ 93 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \ 94 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 95 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 96 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \ 97 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ 98 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ 99 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 100 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ 101 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} 102 103 #define EXTENT_FLAGS \ 104 { EXTENT_DIRTY, "DIRTY"}, \ 105 { EXTENT_UPTODATE, "UPTODATE"}, \ 106 { EXTENT_LOCKED, "LOCKED"}, \ 107 { EXTENT_NEW, "NEW"}, \ 108 { EXTENT_DELALLOC, "DELALLOC"}, \ 109 { EXTENT_DEFRAG, "DEFRAG"}, \ 110 { EXTENT_BOUNDARY, "BOUNDARY"}, \ 111 { EXTENT_NODATASUM, "NODATASUM"}, \ 112 { EXTENT_CLEAR_META_RESV, "CLEAR_META_RESV"}, \ 113 { EXTENT_NEED_WAIT, "NEED_WAIT"}, \ 114 { EXTENT_DAMAGED, "DAMAGED"}, \ 115 { EXTENT_NORESERVE, "NORESERVE"}, \ 116 { EXTENT_QGROUP_RESERVED, "QGROUP_RESERVED"}, \ 117 { EXTENT_CLEAR_DATA_RESV, "CLEAR_DATA_RESV"}, \ 118 { EXTENT_DELALLOC_NEW, "DELALLOC_NEW"} 119 120 #define BTRFS_FSID_SIZE 16 121 #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE) 122 123 #define TP_fast_assign_fsid(fs_info) \ 124 ({ \ 125 if (fs_info) \ 126 memcpy(__entry->fsid, fs_info->fs_devices->fsid, \ 127 BTRFS_FSID_SIZE); \ 128 else \ 129 memset(__entry->fsid, 0, BTRFS_FSID_SIZE); \ 130 }) 131 132 #define TP_STRUCT__entry_btrfs(args...) \ 133 TP_STRUCT__entry( \ 134 TP_STRUCT__entry_fsid \ 135 args) 136 #define TP_fast_assign_btrfs(fs_info, args...) \ 137 TP_fast_assign( \ 138 TP_fast_assign_fsid(fs_info); \ 139 args) 140 #define TP_printk_btrfs(fmt, args...) \ 141 TP_printk("%pU: " fmt, __entry->fsid, args) 142 143 TRACE_EVENT(btrfs_transaction_commit, 144 145 TP_PROTO(const struct btrfs_root *root), 146 147 TP_ARGS(root), 148 149 TP_STRUCT__entry_btrfs( 150 __field( u64, generation ) 151 __field( u64, root_objectid ) 152 ), 153 154 TP_fast_assign_btrfs(root->fs_info, 155 __entry->generation = root->fs_info->generation; 156 __entry->root_objectid = root->root_key.objectid; 157 ), 158 159 TP_printk_btrfs("root=%llu(%s) gen=%llu", 160 show_root_type(__entry->root_objectid), 161 __entry->generation) 162 ); 163 164 DECLARE_EVENT_CLASS(btrfs__inode, 165 166 TP_PROTO(const struct inode *inode), 167 168 TP_ARGS(inode), 169 170 TP_STRUCT__entry_btrfs( 171 __field( u64, ino ) 172 __field( blkcnt_t, blocks ) 173 __field( u64, disk_i_size ) 174 __field( u64, generation ) 175 __field( u64, last_trans ) 176 __field( u64, logged_trans ) 177 __field( u64, root_objectid ) 178 ), 179 180 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 181 __entry->ino = btrfs_ino(BTRFS_I(inode)); 182 __entry->blocks = inode->i_blocks; 183 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; 184 __entry->generation = BTRFS_I(inode)->generation; 185 __entry->last_trans = BTRFS_I(inode)->last_trans; 186 __entry->logged_trans = BTRFS_I(inode)->logged_trans; 187 __entry->root_objectid = 188 BTRFS_I(inode)->root->root_key.objectid; 189 ), 190 191 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu " 192 "disk_i_size=%llu last_trans=%llu logged_trans=%llu", 193 show_root_type(__entry->root_objectid), 194 __entry->generation, 195 __entry->ino, 196 (unsigned long long)__entry->blocks, 197 __entry->disk_i_size, 198 __entry->last_trans, 199 __entry->logged_trans) 200 ); 201 202 DEFINE_EVENT(btrfs__inode, btrfs_inode_new, 203 204 TP_PROTO(const struct inode *inode), 205 206 TP_ARGS(inode) 207 ); 208 209 DEFINE_EVENT(btrfs__inode, btrfs_inode_request, 210 211 TP_PROTO(const struct inode *inode), 212 213 TP_ARGS(inode) 214 ); 215 216 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, 217 218 TP_PROTO(const struct inode *inode), 219 220 TP_ARGS(inode) 221 ); 222 223 #define __show_map_type(type) \ 224 __print_symbolic_u64(type, \ 225 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ 226 { EXTENT_MAP_HOLE, "HOLE" }, \ 227 { EXTENT_MAP_INLINE, "INLINE" }, \ 228 { EXTENT_MAP_DELALLOC, "DELALLOC" }) 229 230 #define show_map_type(type) \ 231 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) 232 233 #define show_map_flags(flag) \ 234 __print_flags(flag, "|", \ 235 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\ 236 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\ 237 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\ 238 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\ 239 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\ 240 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" }) 241 242 TRACE_EVENT_CONDITION(btrfs_get_extent, 243 244 TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode, 245 const struct extent_map *map), 246 247 TP_ARGS(root, inode, map), 248 249 TP_CONDITION(map), 250 251 TP_STRUCT__entry_btrfs( 252 __field( u64, root_objectid ) 253 __field( u64, ino ) 254 __field( u64, start ) 255 __field( u64, len ) 256 __field( u64, orig_start ) 257 __field( u64, block_start ) 258 __field( u64, block_len ) 259 __field( unsigned long, flags ) 260 __field( int, refs ) 261 __field( unsigned int, compress_type ) 262 ), 263 264 TP_fast_assign_btrfs(root->fs_info, 265 __entry->root_objectid = root->root_key.objectid; 266 __entry->ino = btrfs_ino(inode); 267 __entry->start = map->start; 268 __entry->len = map->len; 269 __entry->orig_start = map->orig_start; 270 __entry->block_start = map->block_start; 271 __entry->block_len = map->block_len; 272 __entry->flags = map->flags; 273 __entry->refs = refcount_read(&map->refs); 274 __entry->compress_type = map->compress_type; 275 ), 276 277 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu " 278 "orig_start=%llu block_start=%llu(%s) " 279 "block_len=%llu flags=%s refs=%u " 280 "compress_type=%u", 281 show_root_type(__entry->root_objectid), 282 __entry->ino, 283 __entry->start, 284 __entry->len, 285 __entry->orig_start, 286 show_map_type(__entry->block_start), 287 __entry->block_len, 288 show_map_flags(__entry->flags), 289 __entry->refs, __entry->compress_type) 290 ); 291 292 TRACE_EVENT(btrfs_handle_em_exist, 293 294 TP_PROTO(struct btrfs_fs_info *fs_info, 295 const struct extent_map *existing, const struct extent_map *map, 296 u64 start, u64 len), 297 298 TP_ARGS(fs_info, existing, map, start, len), 299 300 TP_STRUCT__entry_btrfs( 301 __field( u64, e_start ) 302 __field( u64, e_len ) 303 __field( u64, map_start ) 304 __field( u64, map_len ) 305 __field( u64, start ) 306 __field( u64, len ) 307 ), 308 309 TP_fast_assign_btrfs(fs_info, 310 __entry->e_start = existing->start; 311 __entry->e_len = existing->len; 312 __entry->map_start = map->start; 313 __entry->map_len = map->len; 314 __entry->start = start; 315 __entry->len = len; 316 ), 317 318 TP_printk_btrfs("start=%llu len=%llu " 319 "existing(start=%llu len=%llu) " 320 "em(start=%llu len=%llu)", 321 __entry->start, 322 __entry->len, 323 __entry->e_start, 324 __entry->e_len, 325 __entry->map_start, 326 __entry->map_len) 327 ); 328 329 /* file extent item */ 330 DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular, 331 332 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 333 struct btrfs_file_extent_item *fi, u64 start), 334 335 TP_ARGS(bi, l, fi, start), 336 337 TP_STRUCT__entry_btrfs( 338 __field( u64, root_obj ) 339 __field( u64, ino ) 340 __field( loff_t, isize ) 341 __field( u64, disk_isize ) 342 __field( u64, num_bytes ) 343 __field( u64, ram_bytes ) 344 __field( u64, disk_bytenr ) 345 __field( u64, disk_num_bytes ) 346 __field( u64, extent_offset ) 347 __field( u8, extent_type ) 348 __field( u8, compression ) 349 __field( u64, extent_start ) 350 __field( u64, extent_end ) 351 ), 352 353 TP_fast_assign_btrfs(bi->root->fs_info, 354 __entry->root_obj = bi->root->root_key.objectid; 355 __entry->ino = btrfs_ino(bi); 356 __entry->isize = bi->vfs_inode.i_size; 357 __entry->disk_isize = bi->disk_i_size; 358 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi); 359 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi); 360 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi); 361 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi); 362 __entry->extent_offset = btrfs_file_extent_offset(l, fi); 363 __entry->extent_type = btrfs_file_extent_type(l, fi); 364 __entry->compression = btrfs_file_extent_compression(l, fi); 365 __entry->extent_start = start; 366 __entry->extent_end = (start + __entry->num_bytes); 367 ), 368 369 TP_printk_btrfs( 370 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 371 "file extent range=[%llu %llu] " 372 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu " 373 "disk_num_bytes=%llu extent_offset=%llu type=%s " 374 "compression=%u", 375 show_root_type(__entry->root_obj), __entry->ino, 376 __entry->isize, 377 __entry->disk_isize, __entry->extent_start, 378 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes, 379 __entry->disk_bytenr, __entry->disk_num_bytes, 380 __entry->extent_offset, show_fi_type(__entry->extent_type), 381 __entry->compression) 382 ); 383 384 DECLARE_EVENT_CLASS( 385 btrfs__file_extent_item_inline, 386 387 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 388 struct btrfs_file_extent_item *fi, int slot, u64 start), 389 390 TP_ARGS(bi, l, fi, slot, start), 391 392 TP_STRUCT__entry_btrfs( 393 __field( u64, root_obj ) 394 __field( u64, ino ) 395 __field( loff_t, isize ) 396 __field( u64, disk_isize ) 397 __field( u8, extent_type ) 398 __field( u8, compression ) 399 __field( u64, extent_start ) 400 __field( u64, extent_end ) 401 ), 402 403 TP_fast_assign_btrfs( 404 bi->root->fs_info, 405 __entry->root_obj = bi->root->root_key.objectid; 406 __entry->ino = btrfs_ino(bi); 407 __entry->isize = bi->vfs_inode.i_size; 408 __entry->disk_isize = bi->disk_i_size; 409 __entry->extent_type = btrfs_file_extent_type(l, fi); 410 __entry->compression = btrfs_file_extent_compression(l, fi); 411 __entry->extent_start = start; 412 __entry->extent_end = (start + btrfs_file_extent_ram_bytes(l, fi)); 413 ), 414 415 TP_printk_btrfs( 416 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 417 "file extent range=[%llu %llu] " 418 "extent_type=%s compression=%u", 419 show_root_type(__entry->root_obj), __entry->ino, __entry->isize, 420 __entry->disk_isize, __entry->extent_start, 421 __entry->extent_end, show_fi_type(__entry->extent_type), 422 __entry->compression) 423 ); 424 425 DEFINE_EVENT( 426 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular, 427 428 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 429 struct btrfs_file_extent_item *fi, u64 start), 430 431 TP_ARGS(bi, l, fi, start) 432 ); 433 434 DEFINE_EVENT( 435 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular, 436 437 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 438 struct btrfs_file_extent_item *fi, u64 start), 439 440 TP_ARGS(bi, l, fi, start) 441 ); 442 443 DEFINE_EVENT( 444 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline, 445 446 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 447 struct btrfs_file_extent_item *fi, int slot, u64 start), 448 449 TP_ARGS(bi, l, fi, slot, start) 450 ); 451 452 DEFINE_EVENT( 453 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline, 454 455 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 456 struct btrfs_file_extent_item *fi, int slot, u64 start), 457 458 TP_ARGS(bi, l, fi, slot, start) 459 ); 460 461 #define show_ordered_flags(flags) \ 462 __print_flags(flags, "|", \ 463 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \ 464 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \ 465 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \ 466 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \ 467 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \ 468 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \ 469 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \ 470 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \ 471 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" }) 472 473 474 DECLARE_EVENT_CLASS(btrfs__ordered_extent, 475 476 TP_PROTO(const struct inode *inode, 477 const struct btrfs_ordered_extent *ordered), 478 479 TP_ARGS(inode, ordered), 480 481 TP_STRUCT__entry_btrfs( 482 __field( u64, ino ) 483 __field( u64, file_offset ) 484 __field( u64, start ) 485 __field( u64, len ) 486 __field( u64, disk_len ) 487 __field( u64, bytes_left ) 488 __field( unsigned long, flags ) 489 __field( int, compress_type ) 490 __field( int, refs ) 491 __field( u64, root_objectid ) 492 __field( u64, truncated_len ) 493 ), 494 495 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 496 __entry->ino = btrfs_ino(BTRFS_I(inode)); 497 __entry->file_offset = ordered->file_offset; 498 __entry->start = ordered->start; 499 __entry->len = ordered->len; 500 __entry->disk_len = ordered->disk_len; 501 __entry->bytes_left = ordered->bytes_left; 502 __entry->flags = ordered->flags; 503 __entry->compress_type = ordered->compress_type; 504 __entry->refs = refcount_read(&ordered->refs); 505 __entry->root_objectid = 506 BTRFS_I(inode)->root->root_key.objectid; 507 __entry->truncated_len = ordered->truncated_len; 508 ), 509 510 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu " 511 "start=%llu len=%llu disk_len=%llu " 512 "truncated_len=%llu " 513 "bytes_left=%llu flags=%s compress_type=%d " 514 "refs=%d", 515 show_root_type(__entry->root_objectid), 516 __entry->ino, 517 __entry->file_offset, 518 __entry->start, 519 __entry->len, 520 __entry->disk_len, 521 __entry->truncated_len, 522 __entry->bytes_left, 523 show_ordered_flags(__entry->flags), 524 __entry->compress_type, __entry->refs) 525 ); 526 527 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, 528 529 TP_PROTO(const struct inode *inode, 530 const struct btrfs_ordered_extent *ordered), 531 532 TP_ARGS(inode, ordered) 533 ); 534 535 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, 536 537 TP_PROTO(const struct inode *inode, 538 const struct btrfs_ordered_extent *ordered), 539 540 TP_ARGS(inode, ordered) 541 ); 542 543 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, 544 545 TP_PROTO(const struct inode *inode, 546 const struct btrfs_ordered_extent *ordered), 547 548 TP_ARGS(inode, ordered) 549 ); 550 551 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, 552 553 TP_PROTO(const struct inode *inode, 554 const struct btrfs_ordered_extent *ordered), 555 556 TP_ARGS(inode, ordered) 557 ); 558 559 DECLARE_EVENT_CLASS(btrfs__writepage, 560 561 TP_PROTO(const struct page *page, const struct inode *inode, 562 const struct writeback_control *wbc), 563 564 TP_ARGS(page, inode, wbc), 565 566 TP_STRUCT__entry_btrfs( 567 __field( u64, ino ) 568 __field( pgoff_t, index ) 569 __field( long, nr_to_write ) 570 __field( long, pages_skipped ) 571 __field( loff_t, range_start ) 572 __field( loff_t, range_end ) 573 __field( char, for_kupdate ) 574 __field( char, for_reclaim ) 575 __field( char, range_cyclic ) 576 __field( pgoff_t, writeback_index ) 577 __field( u64, root_objectid ) 578 ), 579 580 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 581 __entry->ino = btrfs_ino(BTRFS_I(inode)); 582 __entry->index = page->index; 583 __entry->nr_to_write = wbc->nr_to_write; 584 __entry->pages_skipped = wbc->pages_skipped; 585 __entry->range_start = wbc->range_start; 586 __entry->range_end = wbc->range_end; 587 __entry->for_kupdate = wbc->for_kupdate; 588 __entry->for_reclaim = wbc->for_reclaim; 589 __entry->range_cyclic = wbc->range_cyclic; 590 __entry->writeback_index = inode->i_mapping->writeback_index; 591 __entry->root_objectid = 592 BTRFS_I(inode)->root->root_key.objectid; 593 ), 594 595 TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu " 596 "nr_to_write=%ld pages_skipped=%ld range_start=%llu " 597 "range_end=%llu for_kupdate=%d " 598 "for_reclaim=%d range_cyclic=%d writeback_index=%lu", 599 show_root_type(__entry->root_objectid), 600 __entry->ino, __entry->index, 601 __entry->nr_to_write, __entry->pages_skipped, 602 __entry->range_start, __entry->range_end, 603 __entry->for_kupdate, 604 __entry->for_reclaim, __entry->range_cyclic, 605 (unsigned long)__entry->writeback_index) 606 ); 607 608 DEFINE_EVENT(btrfs__writepage, __extent_writepage, 609 610 TP_PROTO(const struct page *page, const struct inode *inode, 611 const struct writeback_control *wbc), 612 613 TP_ARGS(page, inode, wbc) 614 ); 615 616 TRACE_EVENT(btrfs_writepage_end_io_hook, 617 618 TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate), 619 620 TP_ARGS(page, start, end, uptodate), 621 622 TP_STRUCT__entry_btrfs( 623 __field( u64, ino ) 624 __field( pgoff_t, index ) 625 __field( u64, start ) 626 __field( u64, end ) 627 __field( int, uptodate ) 628 __field( u64, root_objectid ) 629 ), 630 631 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb), 632 __entry->ino = btrfs_ino(BTRFS_I(page->mapping->host)); 633 __entry->index = page->index; 634 __entry->start = start; 635 __entry->end = end; 636 __entry->uptodate = uptodate; 637 __entry->root_objectid = 638 BTRFS_I(page->mapping->host)->root->root_key.objectid; 639 ), 640 641 TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu start=%llu " 642 "end=%llu uptodate=%d", 643 show_root_type(__entry->root_objectid), 644 __entry->ino, (unsigned long)__entry->index, 645 __entry->start, 646 __entry->end, __entry->uptodate) 647 ); 648 649 TRACE_EVENT(btrfs_sync_file, 650 651 TP_PROTO(const struct file *file, int datasync), 652 653 TP_ARGS(file, datasync), 654 655 TP_STRUCT__entry_btrfs( 656 __field( u64, ino ) 657 __field( u64, parent ) 658 __field( int, datasync ) 659 __field( u64, root_objectid ) 660 ), 661 662 TP_fast_assign( 663 const struct dentry *dentry = file->f_path.dentry; 664 const struct inode *inode = d_inode(dentry); 665 666 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb)); 667 __entry->ino = btrfs_ino(BTRFS_I(inode)); 668 __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent))); 669 __entry->datasync = datasync; 670 __entry->root_objectid = 671 BTRFS_I(inode)->root->root_key.objectid; 672 ), 673 674 TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d", 675 show_root_type(__entry->root_objectid), 676 __entry->ino, 677 __entry->parent, 678 __entry->datasync) 679 ); 680 681 TRACE_EVENT(btrfs_sync_fs, 682 683 TP_PROTO(const struct btrfs_fs_info *fs_info, int wait), 684 685 TP_ARGS(fs_info, wait), 686 687 TP_STRUCT__entry_btrfs( 688 __field( int, wait ) 689 ), 690 691 TP_fast_assign_btrfs(fs_info, 692 __entry->wait = wait; 693 ), 694 695 TP_printk_btrfs("wait=%d", __entry->wait) 696 ); 697 698 TRACE_EVENT(btrfs_add_block_group, 699 700 TP_PROTO(const struct btrfs_fs_info *fs_info, 701 const struct btrfs_block_group_cache *block_group, int create), 702 703 TP_ARGS(fs_info, block_group, create), 704 705 TP_STRUCT__entry_btrfs( 706 __field( u64, offset ) 707 __field( u64, size ) 708 __field( u64, flags ) 709 __field( u64, bytes_used ) 710 __field( u64, bytes_super ) 711 __field( int, create ) 712 ), 713 714 TP_fast_assign_btrfs(fs_info, 715 __entry->offset = block_group->key.objectid; 716 __entry->size = block_group->key.offset; 717 __entry->flags = block_group->flags; 718 __entry->bytes_used = 719 btrfs_block_group_used(&block_group->item); 720 __entry->bytes_super = block_group->bytes_super; 721 __entry->create = create; 722 ), 723 724 TP_printk_btrfs("block_group offset=%llu size=%llu " 725 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu " 726 "create=%d", 727 __entry->offset, 728 __entry->size, 729 __entry->flags, 730 __print_flags((unsigned long)__entry->flags, "|", 731 BTRFS_GROUP_FLAGS), 732 __entry->bytes_used, 733 __entry->bytes_super, __entry->create) 734 ); 735 736 #define show_ref_action(action) \ 737 __print_symbolic(action, \ 738 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 739 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 740 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 741 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 742 743 744 DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 745 746 TP_PROTO(const struct btrfs_fs_info *fs_info, 747 const struct btrfs_delayed_ref_node *ref, 748 const struct btrfs_delayed_tree_ref *full_ref, 749 int action), 750 751 TP_ARGS(fs_info, ref, full_ref, action), 752 753 TP_STRUCT__entry_btrfs( 754 __field( u64, bytenr ) 755 __field( u64, num_bytes ) 756 __field( int, action ) 757 __field( u64, parent ) 758 __field( u64, ref_root ) 759 __field( int, level ) 760 __field( int, type ) 761 __field( u64, seq ) 762 ), 763 764 TP_fast_assign_btrfs(fs_info, 765 __entry->bytenr = ref->bytenr; 766 __entry->num_bytes = ref->num_bytes; 767 __entry->action = action; 768 __entry->parent = full_ref->parent; 769 __entry->ref_root = full_ref->root; 770 __entry->level = full_ref->level; 771 __entry->type = ref->type; 772 __entry->seq = ref->seq; 773 ), 774 775 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 776 "parent=%llu(%s) ref_root=%llu(%s) level=%d " 777 "type=%s seq=%llu", 778 __entry->bytenr, 779 __entry->num_bytes, 780 show_ref_action(__entry->action), 781 show_root_type(__entry->parent), 782 show_root_type(__entry->ref_root), 783 __entry->level, show_ref_type(__entry->type), 784 __entry->seq) 785 ); 786 787 DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 788 789 TP_PROTO(const struct btrfs_fs_info *fs_info, 790 const struct btrfs_delayed_ref_node *ref, 791 const struct btrfs_delayed_tree_ref *full_ref, 792 int action), 793 794 TP_ARGS(fs_info, ref, full_ref, action) 795 ); 796 797 DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 798 799 TP_PROTO(const struct btrfs_fs_info *fs_info, 800 const struct btrfs_delayed_ref_node *ref, 801 const struct btrfs_delayed_tree_ref *full_ref, 802 int action), 803 804 TP_ARGS(fs_info, ref, full_ref, action) 805 ); 806 807 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 808 809 TP_PROTO(const struct btrfs_fs_info *fs_info, 810 const struct btrfs_delayed_ref_node *ref, 811 const struct btrfs_delayed_data_ref *full_ref, 812 int action), 813 814 TP_ARGS(fs_info, ref, full_ref, action), 815 816 TP_STRUCT__entry_btrfs( 817 __field( u64, bytenr ) 818 __field( u64, num_bytes ) 819 __field( int, action ) 820 __field( u64, parent ) 821 __field( u64, ref_root ) 822 __field( u64, owner ) 823 __field( u64, offset ) 824 __field( int, type ) 825 __field( u64, seq ) 826 ), 827 828 TP_fast_assign_btrfs(fs_info, 829 __entry->bytenr = ref->bytenr; 830 __entry->num_bytes = ref->num_bytes; 831 __entry->action = action; 832 __entry->parent = full_ref->parent; 833 __entry->ref_root = full_ref->root; 834 __entry->owner = full_ref->objectid; 835 __entry->offset = full_ref->offset; 836 __entry->type = ref->type; 837 __entry->seq = ref->seq; 838 ), 839 840 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 841 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu " 842 "offset=%llu type=%s seq=%llu", 843 __entry->bytenr, 844 __entry->num_bytes, 845 show_ref_action(__entry->action), 846 show_root_type(__entry->parent), 847 show_root_type(__entry->ref_root), 848 __entry->owner, 849 __entry->offset, 850 show_ref_type(__entry->type), 851 __entry->seq) 852 ); 853 854 DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 855 856 TP_PROTO(const struct btrfs_fs_info *fs_info, 857 const struct btrfs_delayed_ref_node *ref, 858 const struct btrfs_delayed_data_ref *full_ref, 859 int action), 860 861 TP_ARGS(fs_info, ref, full_ref, action) 862 ); 863 864 DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 865 866 TP_PROTO(const struct btrfs_fs_info *fs_info, 867 const struct btrfs_delayed_ref_node *ref, 868 const struct btrfs_delayed_data_ref *full_ref, 869 int action), 870 871 TP_ARGS(fs_info, ref, full_ref, action) 872 ); 873 874 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 875 876 TP_PROTO(const struct btrfs_fs_info *fs_info, 877 const struct btrfs_delayed_ref_head *head_ref, 878 int action), 879 880 TP_ARGS(fs_info, head_ref, action), 881 882 TP_STRUCT__entry_btrfs( 883 __field( u64, bytenr ) 884 __field( u64, num_bytes ) 885 __field( int, action ) 886 __field( int, is_data ) 887 ), 888 889 TP_fast_assign_btrfs(fs_info, 890 __entry->bytenr = head_ref->bytenr; 891 __entry->num_bytes = head_ref->num_bytes; 892 __entry->action = action; 893 __entry->is_data = head_ref->is_data; 894 ), 895 896 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d", 897 __entry->bytenr, 898 __entry->num_bytes, 899 show_ref_action(__entry->action), 900 __entry->is_data) 901 ); 902 903 DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 904 905 TP_PROTO(const struct btrfs_fs_info *fs_info, 906 const struct btrfs_delayed_ref_head *head_ref, 907 int action), 908 909 TP_ARGS(fs_info, head_ref, action) 910 ); 911 912 DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 913 914 TP_PROTO(const struct btrfs_fs_info *fs_info, 915 const struct btrfs_delayed_ref_head *head_ref, 916 int action), 917 918 TP_ARGS(fs_info, head_ref, action) 919 ); 920 921 #define show_chunk_type(type) \ 922 __print_flags(type, "|", \ 923 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 924 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 925 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 926 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 927 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 928 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 929 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 930 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 931 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 932 933 DECLARE_EVENT_CLASS(btrfs__chunk, 934 935 TP_PROTO(const struct btrfs_fs_info *fs_info, 936 const struct map_lookup *map, u64 offset, u64 size), 937 938 TP_ARGS(fs_info, map, offset, size), 939 940 TP_STRUCT__entry_btrfs( 941 __field( int, num_stripes ) 942 __field( u64, type ) 943 __field( int, sub_stripes ) 944 __field( u64, offset ) 945 __field( u64, size ) 946 __field( u64, root_objectid ) 947 ), 948 949 TP_fast_assign_btrfs(fs_info, 950 __entry->num_stripes = map->num_stripes; 951 __entry->type = map->type; 952 __entry->sub_stripes = map->sub_stripes; 953 __entry->offset = offset; 954 __entry->size = size; 955 __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 956 ), 957 958 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu " 959 "num_stripes=%d sub_stripes=%d type=%s", 960 show_root_type(__entry->root_objectid), 961 __entry->offset, 962 __entry->size, 963 __entry->num_stripes, __entry->sub_stripes, 964 show_chunk_type(__entry->type)) 965 ); 966 967 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 968 969 TP_PROTO(const struct btrfs_fs_info *fs_info, 970 const struct map_lookup *map, u64 offset, u64 size), 971 972 TP_ARGS(fs_info, map, offset, size) 973 ); 974 975 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 976 977 TP_PROTO(const struct btrfs_fs_info *fs_info, 978 const struct map_lookup *map, u64 offset, u64 size), 979 980 TP_ARGS(fs_info, map, offset, size) 981 ); 982 983 TRACE_EVENT(btrfs_cow_block, 984 985 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf, 986 const struct extent_buffer *cow), 987 988 TP_ARGS(root, buf, cow), 989 990 TP_STRUCT__entry_btrfs( 991 __field( u64, root_objectid ) 992 __field( u64, buf_start ) 993 __field( int, refs ) 994 __field( u64, cow_start ) 995 __field( int, buf_level ) 996 __field( int, cow_level ) 997 ), 998 999 TP_fast_assign_btrfs(root->fs_info, 1000 __entry->root_objectid = root->root_key.objectid; 1001 __entry->buf_start = buf->start; 1002 __entry->refs = atomic_read(&buf->refs); 1003 __entry->cow_start = cow->start; 1004 __entry->buf_level = btrfs_header_level(buf); 1005 __entry->cow_level = btrfs_header_level(cow); 1006 ), 1007 1008 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu " 1009 "(orig_level=%d) cow_buf=%llu (cow_level=%d)", 1010 show_root_type(__entry->root_objectid), 1011 __entry->refs, 1012 __entry->buf_start, 1013 __entry->buf_level, 1014 __entry->cow_start, 1015 __entry->cow_level) 1016 ); 1017 1018 TRACE_EVENT(btrfs_space_reservation, 1019 1020 TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val, 1021 u64 bytes, int reserve), 1022 1023 TP_ARGS(fs_info, type, val, bytes, reserve), 1024 1025 TP_STRUCT__entry_btrfs( 1026 __string( type, type ) 1027 __field( u64, val ) 1028 __field( u64, bytes ) 1029 __field( int, reserve ) 1030 ), 1031 1032 TP_fast_assign_btrfs(fs_info, 1033 __assign_str(type, type); 1034 __entry->val = val; 1035 __entry->bytes = bytes; 1036 __entry->reserve = reserve; 1037 ), 1038 1039 TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val, 1040 __entry->reserve ? "reserve" : "release", 1041 __entry->bytes) 1042 ); 1043 1044 #define show_flush_action(action) \ 1045 __print_symbolic(action, \ 1046 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ 1047 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ 1048 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) 1049 1050 TRACE_EVENT(btrfs_trigger_flush, 1051 1052 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 1053 int flush, char *reason), 1054 1055 TP_ARGS(fs_info, flags, bytes, flush, reason), 1056 1057 TP_STRUCT__entry_btrfs( 1058 __field( u64, flags ) 1059 __field( u64, bytes ) 1060 __field( int, flush ) 1061 __string( reason, reason ) 1062 ), 1063 1064 TP_fast_assign_btrfs(fs_info, 1065 __entry->flags = flags; 1066 __entry->bytes = bytes; 1067 __entry->flush = flush; 1068 __assign_str(reason, reason) 1069 ), 1070 1071 TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu", 1072 __get_str(reason), __entry->flush, 1073 show_flush_action(__entry->flush), 1074 __entry->flags, 1075 __print_flags((unsigned long)__entry->flags, "|", 1076 BTRFS_GROUP_FLAGS), 1077 __entry->bytes) 1078 ); 1079 1080 #define show_flush_state(state) \ 1081 __print_symbolic(state, \ 1082 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ 1083 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ 1084 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ 1085 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ 1086 { FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR"}, \ 1087 { FLUSH_DELAYED_REFS, "FLUSH_ELAYED_REFS"}, \ 1088 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ 1089 { ALLOC_CHUNK_FORCE, "ALLOC_CHUNK_FORCE"}, \ 1090 { COMMIT_TRANS, "COMMIT_TRANS"}) 1091 1092 TRACE_EVENT(btrfs_flush_space, 1093 1094 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, 1095 int state, int ret), 1096 1097 TP_ARGS(fs_info, flags, num_bytes, state, ret), 1098 1099 TP_STRUCT__entry_btrfs( 1100 __field( u64, flags ) 1101 __field( u64, num_bytes ) 1102 __field( int, state ) 1103 __field( int, ret ) 1104 ), 1105 1106 TP_fast_assign_btrfs(fs_info, 1107 __entry->flags = flags; 1108 __entry->num_bytes = num_bytes; 1109 __entry->state = state; 1110 __entry->ret = ret; 1111 ), 1112 1113 TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d", 1114 __entry->state, 1115 show_flush_state(__entry->state), 1116 __entry->flags, 1117 __print_flags((unsigned long)__entry->flags, "|", 1118 BTRFS_GROUP_FLAGS), 1119 __entry->num_bytes, __entry->ret) 1120 ); 1121 1122 DECLARE_EVENT_CLASS(btrfs__reserved_extent, 1123 1124 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 1125 1126 TP_ARGS(fs_info, start, len), 1127 1128 TP_STRUCT__entry_btrfs( 1129 __field( u64, start ) 1130 __field( u64, len ) 1131 ), 1132 1133 TP_fast_assign_btrfs(fs_info, 1134 __entry->start = start; 1135 __entry->len = len; 1136 ), 1137 1138 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu", 1139 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1140 __entry->start, 1141 __entry->len) 1142 ); 1143 1144 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 1145 1146 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 1147 1148 TP_ARGS(fs_info, start, len) 1149 ); 1150 1151 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 1152 1153 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 1154 1155 TP_ARGS(fs_info, start, len) 1156 ); 1157 1158 TRACE_EVENT(find_free_extent, 1159 1160 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, 1161 u64 empty_size, u64 data), 1162 1163 TP_ARGS(fs_info, num_bytes, empty_size, data), 1164 1165 TP_STRUCT__entry_btrfs( 1166 __field( u64, num_bytes ) 1167 __field( u64, empty_size ) 1168 __field( u64, data ) 1169 ), 1170 1171 TP_fast_assign_btrfs(fs_info, 1172 __entry->num_bytes = num_bytes; 1173 __entry->empty_size = empty_size; 1174 __entry->data = data; 1175 ), 1176 1177 TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)", 1178 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1179 __entry->num_bytes, __entry->empty_size, __entry->data, 1180 __print_flags((unsigned long)__entry->data, "|", 1181 BTRFS_GROUP_FLAGS)) 1182 ); 1183 1184 DECLARE_EVENT_CLASS(btrfs__reserve_extent, 1185 1186 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 1187 u64 len), 1188 1189 TP_ARGS(block_group, start, len), 1190 1191 TP_STRUCT__entry_btrfs( 1192 __field( u64, bg_objectid ) 1193 __field( u64, flags ) 1194 __field( u64, start ) 1195 __field( u64, len ) 1196 ), 1197 1198 TP_fast_assign_btrfs(block_group->fs_info, 1199 __entry->bg_objectid = block_group->key.objectid; 1200 __entry->flags = block_group->flags; 1201 __entry->start = start; 1202 __entry->len = len; 1203 ), 1204 1205 TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) " 1206 "start=%llu len=%llu", 1207 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1208 __entry->bg_objectid, 1209 __entry->flags, __print_flags((unsigned long)__entry->flags, 1210 "|", BTRFS_GROUP_FLAGS), 1211 __entry->start, __entry->len) 1212 ); 1213 1214 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 1215 1216 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 1217 u64 len), 1218 1219 TP_ARGS(block_group, start, len) 1220 ); 1221 1222 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 1223 1224 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 1225 u64 len), 1226 1227 TP_ARGS(block_group, start, len) 1228 ); 1229 1230 TRACE_EVENT(btrfs_find_cluster, 1231 1232 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 1233 u64 bytes, u64 empty_size, u64 min_bytes), 1234 1235 TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 1236 1237 TP_STRUCT__entry_btrfs( 1238 __field( u64, bg_objectid ) 1239 __field( u64, flags ) 1240 __field( u64, start ) 1241 __field( u64, bytes ) 1242 __field( u64, empty_size ) 1243 __field( u64, min_bytes ) 1244 ), 1245 1246 TP_fast_assign_btrfs(block_group->fs_info, 1247 __entry->bg_objectid = block_group->key.objectid; 1248 __entry->flags = block_group->flags; 1249 __entry->start = start; 1250 __entry->bytes = bytes; 1251 __entry->empty_size = empty_size; 1252 __entry->min_bytes = min_bytes; 1253 ), 1254 1255 TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu " 1256 "empty_size=%llu min_bytes=%llu", __entry->bg_objectid, 1257 __entry->flags, 1258 __print_flags((unsigned long)__entry->flags, "|", 1259 BTRFS_GROUP_FLAGS), __entry->start, 1260 __entry->bytes, __entry->empty_size, __entry->min_bytes) 1261 ); 1262 1263 TRACE_EVENT(btrfs_failed_cluster_setup, 1264 1265 TP_PROTO(const struct btrfs_block_group_cache *block_group), 1266 1267 TP_ARGS(block_group), 1268 1269 TP_STRUCT__entry_btrfs( 1270 __field( u64, bg_objectid ) 1271 ), 1272 1273 TP_fast_assign_btrfs(block_group->fs_info, 1274 __entry->bg_objectid = block_group->key.objectid; 1275 ), 1276 1277 TP_printk_btrfs("block_group=%llu", __entry->bg_objectid) 1278 ); 1279 1280 TRACE_EVENT(btrfs_setup_cluster, 1281 1282 TP_PROTO(const struct btrfs_block_group_cache *block_group, 1283 const struct btrfs_free_cluster *cluster, 1284 u64 size, int bitmap), 1285 1286 TP_ARGS(block_group, cluster, size, bitmap), 1287 1288 TP_STRUCT__entry_btrfs( 1289 __field( u64, bg_objectid ) 1290 __field( u64, flags ) 1291 __field( u64, start ) 1292 __field( u64, max_size ) 1293 __field( u64, size ) 1294 __field( int, bitmap ) 1295 ), 1296 1297 TP_fast_assign_btrfs(block_group->fs_info, 1298 __entry->bg_objectid = block_group->key.objectid; 1299 __entry->flags = block_group->flags; 1300 __entry->start = cluster->window_start; 1301 __entry->max_size = cluster->max_size; 1302 __entry->size = size; 1303 __entry->bitmap = bitmap; 1304 ), 1305 1306 TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu " 1307 "size=%llu max_size=%llu bitmap=%d", 1308 __entry->bg_objectid, 1309 __entry->flags, 1310 __print_flags((unsigned long)__entry->flags, "|", 1311 BTRFS_GROUP_FLAGS), __entry->start, 1312 __entry->size, __entry->max_size, __entry->bitmap) 1313 ); 1314 1315 struct extent_state; 1316 TRACE_EVENT(alloc_extent_state, 1317 1318 TP_PROTO(const struct extent_state *state, 1319 gfp_t mask, unsigned long IP), 1320 1321 TP_ARGS(state, mask, IP), 1322 1323 TP_STRUCT__entry( 1324 __field(const struct extent_state *, state) 1325 __field(gfp_t, mask) 1326 __field(unsigned long, ip) 1327 ), 1328 1329 TP_fast_assign( 1330 __entry->state = state, 1331 __entry->mask = mask, 1332 __entry->ip = IP 1333 ), 1334 1335 TP_printk("state=%p mask=%s caller=%pS", __entry->state, 1336 show_gfp_flags(__entry->mask), (const void *)__entry->ip) 1337 ); 1338 1339 TRACE_EVENT(free_extent_state, 1340 1341 TP_PROTO(const struct extent_state *state, unsigned long IP), 1342 1343 TP_ARGS(state, IP), 1344 1345 TP_STRUCT__entry( 1346 __field(const struct extent_state *, state) 1347 __field(unsigned long, ip) 1348 ), 1349 1350 TP_fast_assign( 1351 __entry->state = state, 1352 __entry->ip = IP 1353 ), 1354 1355 TP_printk("state=%p caller=%pS", __entry->state, 1356 (const void *)__entry->ip) 1357 ); 1358 1359 DECLARE_EVENT_CLASS(btrfs__work, 1360 1361 TP_PROTO(const struct btrfs_work *work), 1362 1363 TP_ARGS(work), 1364 1365 TP_STRUCT__entry_btrfs( 1366 __field( const void *, work ) 1367 __field( const void *, wq ) 1368 __field( const void *, func ) 1369 __field( const void *, ordered_func ) 1370 __field( const void *, ordered_free ) 1371 __field( const void *, normal_work ) 1372 ), 1373 1374 TP_fast_assign_btrfs(btrfs_work_owner(work), 1375 __entry->work = work; 1376 __entry->wq = work->wq; 1377 __entry->func = work->func; 1378 __entry->ordered_func = work->ordered_func; 1379 __entry->ordered_free = work->ordered_free; 1380 __entry->normal_work = &work->normal_work; 1381 ), 1382 1383 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p " 1384 "ordered_free=%p", 1385 __entry->work, __entry->normal_work, __entry->wq, 1386 __entry->func, __entry->ordered_func, __entry->ordered_free) 1387 ); 1388 1389 /* 1390 * For situiations when the work is freed, we pass fs_info and a tag that that 1391 * matches address of the work structure so it can be paired with the 1392 * scheduling event. 1393 */ 1394 DECLARE_EVENT_CLASS(btrfs__work__done, 1395 1396 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 1397 1398 TP_ARGS(fs_info, wtag), 1399 1400 TP_STRUCT__entry_btrfs( 1401 __field( const void *, wtag ) 1402 ), 1403 1404 TP_fast_assign_btrfs(fs_info, 1405 __entry->wtag = wtag; 1406 ), 1407 1408 TP_printk_btrfs("work->%p", __entry->wtag) 1409 ); 1410 1411 DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1412 1413 TP_PROTO(const struct btrfs_work *work), 1414 1415 TP_ARGS(work) 1416 ); 1417 1418 DEFINE_EVENT(btrfs__work, btrfs_work_sched, 1419 1420 TP_PROTO(const struct btrfs_work *work), 1421 1422 TP_ARGS(work) 1423 ); 1424 1425 DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1426 1427 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 1428 1429 TP_ARGS(fs_info, wtag) 1430 ); 1431 1432 DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1433 1434 TP_PROTO(const struct btrfs_work *work), 1435 1436 TP_ARGS(work) 1437 ); 1438 1439 DECLARE_EVENT_CLASS(btrfs__workqueue, 1440 1441 TP_PROTO(const struct __btrfs_workqueue *wq, 1442 const char *name, int high), 1443 1444 TP_ARGS(wq, name, high), 1445 1446 TP_STRUCT__entry_btrfs( 1447 __field( const void *, wq ) 1448 __string( name, name ) 1449 __field( int , high ) 1450 ), 1451 1452 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1453 __entry->wq = wq; 1454 __assign_str(name, name); 1455 __entry->high = high; 1456 ), 1457 1458 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name), 1459 __print_flags(__entry->high, "", 1460 {(WQ_HIGHPRI), "-high"}), 1461 __entry->wq) 1462 ); 1463 1464 DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc, 1465 1466 TP_PROTO(const struct __btrfs_workqueue *wq, 1467 const char *name, int high), 1468 1469 TP_ARGS(wq, name, high) 1470 ); 1471 1472 DECLARE_EVENT_CLASS(btrfs__workqueue_done, 1473 1474 TP_PROTO(const struct __btrfs_workqueue *wq), 1475 1476 TP_ARGS(wq), 1477 1478 TP_STRUCT__entry_btrfs( 1479 __field( const void *, wq ) 1480 ), 1481 1482 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1483 __entry->wq = wq; 1484 ), 1485 1486 TP_printk_btrfs("wq=%p", __entry->wq) 1487 ); 1488 1489 DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy, 1490 1491 TP_PROTO(const struct __btrfs_workqueue *wq), 1492 1493 TP_ARGS(wq) 1494 ); 1495 1496 #define BTRFS_QGROUP_OPERATIONS \ 1497 { QGROUP_RESERVE, "reserve" }, \ 1498 { QGROUP_RELEASE, "release" }, \ 1499 { QGROUP_FREE, "free" } 1500 1501 DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data, 1502 1503 TP_PROTO(const struct inode *inode, u64 start, u64 len, 1504 u64 reserved, int op), 1505 1506 TP_ARGS(inode, start, len, reserved, op), 1507 1508 TP_STRUCT__entry_btrfs( 1509 __field( u64, rootid ) 1510 __field( u64, ino ) 1511 __field( u64, start ) 1512 __field( u64, len ) 1513 __field( u64, reserved ) 1514 __field( int, op ) 1515 ), 1516 1517 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 1518 __entry->rootid = 1519 BTRFS_I(inode)->root->root_key.objectid; 1520 __entry->ino = btrfs_ino(BTRFS_I(inode)); 1521 __entry->start = start; 1522 __entry->len = len; 1523 __entry->reserved = reserved; 1524 __entry->op = op; 1525 ), 1526 1527 TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s", 1528 __entry->rootid, __entry->ino, __entry->start, __entry->len, 1529 __entry->reserved, 1530 __print_flags((unsigned long)__entry->op, "", 1531 BTRFS_QGROUP_OPERATIONS) 1532 ) 1533 ); 1534 1535 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data, 1536 1537 TP_PROTO(const struct inode *inode, u64 start, u64 len, 1538 u64 reserved, int op), 1539 1540 TP_ARGS(inode, start, len, reserved, op) 1541 ); 1542 1543 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data, 1544 1545 TP_PROTO(const struct inode *inode, u64 start, u64 len, 1546 u64 reserved, int op), 1547 1548 TP_ARGS(inode, start, len, reserved, op) 1549 ); 1550 1551 DECLARE_EVENT_CLASS(btrfs_qgroup_extent, 1552 TP_PROTO(const struct btrfs_fs_info *fs_info, 1553 const struct btrfs_qgroup_extent_record *rec), 1554 1555 TP_ARGS(fs_info, rec), 1556 1557 TP_STRUCT__entry_btrfs( 1558 __field( u64, bytenr ) 1559 __field( u64, num_bytes ) 1560 ), 1561 1562 TP_fast_assign_btrfs(fs_info, 1563 __entry->bytenr = rec->bytenr, 1564 __entry->num_bytes = rec->num_bytes; 1565 ), 1566 1567 TP_printk_btrfs("bytenr=%llu num_bytes=%llu", 1568 (unsigned long long)__entry->bytenr, 1569 (unsigned long long)__entry->num_bytes) 1570 ); 1571 1572 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents, 1573 1574 TP_PROTO(const struct btrfs_fs_info *fs_info, 1575 const struct btrfs_qgroup_extent_record *rec), 1576 1577 TP_ARGS(fs_info, rec) 1578 ); 1579 1580 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent, 1581 1582 TP_PROTO(const struct btrfs_fs_info *fs_info, 1583 const struct btrfs_qgroup_extent_record *rec), 1584 1585 TP_ARGS(fs_info, rec) 1586 ); 1587 1588 TRACE_EVENT(qgroup_num_dirty_extents, 1589 1590 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, 1591 u64 num_dirty_extents), 1592 1593 TP_ARGS(fs_info, transid, num_dirty_extents), 1594 1595 TP_STRUCT__entry_btrfs( 1596 __field( u64, transid ) 1597 __field( u64, num_dirty_extents ) 1598 ), 1599 1600 TP_fast_assign_btrfs(fs_info, 1601 __entry->transid = transid; 1602 __entry->num_dirty_extents = num_dirty_extents; 1603 ), 1604 1605 TP_printk_btrfs("transid=%llu num_dirty_extents=%llu", 1606 __entry->transid, __entry->num_dirty_extents) 1607 ); 1608 1609 TRACE_EVENT(btrfs_qgroup_account_extent, 1610 1611 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr, 1612 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots), 1613 1614 TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots, 1615 nr_new_roots), 1616 1617 TP_STRUCT__entry_btrfs( 1618 __field( u64, transid ) 1619 __field( u64, bytenr ) 1620 __field( u64, num_bytes ) 1621 __field( u64, nr_old_roots ) 1622 __field( u64, nr_new_roots ) 1623 ), 1624 1625 TP_fast_assign_btrfs(fs_info, 1626 __entry->transid = transid; 1627 __entry->bytenr = bytenr; 1628 __entry->num_bytes = num_bytes; 1629 __entry->nr_old_roots = nr_old_roots; 1630 __entry->nr_new_roots = nr_new_roots; 1631 ), 1632 1633 TP_printk_btrfs( 1634 "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu", 1635 __entry->transid, 1636 __entry->bytenr, 1637 __entry->num_bytes, 1638 __entry->nr_old_roots, 1639 __entry->nr_new_roots) 1640 ); 1641 1642 TRACE_EVENT(qgroup_update_counters, 1643 1644 TP_PROTO(const struct btrfs_fs_info *fs_info, 1645 struct btrfs_qgroup *qgroup, 1646 u64 cur_old_count, u64 cur_new_count), 1647 1648 TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count), 1649 1650 TP_STRUCT__entry_btrfs( 1651 __field( u64, qgid ) 1652 __field( u64, old_rfer ) 1653 __field( u64, old_excl ) 1654 __field( u64, cur_old_count ) 1655 __field( u64, cur_new_count ) 1656 ), 1657 1658 TP_fast_assign_btrfs(fs_info, 1659 __entry->qgid = qgroup->qgroupid; 1660 __entry->old_rfer = qgroup->rfer; 1661 __entry->old_excl = qgroup->excl; 1662 __entry->cur_old_count = cur_old_count; 1663 __entry->cur_new_count = cur_new_count; 1664 ), 1665 1666 TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu", 1667 __entry->qgid, __entry->old_rfer, __entry->old_excl, 1668 __entry->cur_old_count, __entry->cur_new_count) 1669 ); 1670 1671 TRACE_EVENT(qgroup_update_reserve, 1672 1673 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup, 1674 s64 diff, int type), 1675 1676 TP_ARGS(fs_info, qgroup, diff, type), 1677 1678 TP_STRUCT__entry_btrfs( 1679 __field( u64, qgid ) 1680 __field( u64, cur_reserved ) 1681 __field( s64, diff ) 1682 __field( int, type ) 1683 ), 1684 1685 TP_fast_assign_btrfs(fs_info, 1686 __entry->qgid = qgroup->qgroupid; 1687 __entry->cur_reserved = qgroup->rsv.values[type]; 1688 __entry->diff = diff; 1689 ), 1690 1691 TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld", 1692 __entry->qgid, show_qgroup_rsv_type(__entry->type), 1693 __entry->cur_reserved, __entry->diff) 1694 ); 1695 1696 TRACE_EVENT(qgroup_meta_reserve, 1697 1698 TP_PROTO(struct btrfs_root *root, s64 diff, int type), 1699 1700 TP_ARGS(root, diff, type), 1701 1702 TP_STRUCT__entry_btrfs( 1703 __field( u64, refroot ) 1704 __field( s64, diff ) 1705 __field( int, type ) 1706 ), 1707 1708 TP_fast_assign_btrfs(root->fs_info, 1709 __entry->refroot = root->root_key.objectid; 1710 __entry->diff = diff; 1711 ), 1712 1713 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 1714 show_root_type(__entry->refroot), 1715 show_qgroup_rsv_type(__entry->type), __entry->diff) 1716 ); 1717 1718 TRACE_EVENT(qgroup_meta_convert, 1719 1720 TP_PROTO(struct btrfs_root *root, s64 diff), 1721 1722 TP_ARGS(root, diff), 1723 1724 TP_STRUCT__entry_btrfs( 1725 __field( u64, refroot ) 1726 __field( s64, diff ) 1727 __field( int, type ) 1728 ), 1729 1730 TP_fast_assign_btrfs(root->fs_info, 1731 __entry->refroot = root->root_key.objectid; 1732 __entry->diff = diff; 1733 ), 1734 1735 TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld", 1736 show_root_type(__entry->refroot), 1737 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC), 1738 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS), 1739 __entry->diff) 1740 ); 1741 1742 TRACE_EVENT(qgroup_meta_free_all_pertrans, 1743 1744 TP_PROTO(struct btrfs_root *root), 1745 1746 TP_ARGS(root), 1747 1748 TP_STRUCT__entry_btrfs( 1749 __field( u64, refroot ) 1750 __field( s64, diff ) 1751 __field( int, type ) 1752 ), 1753 1754 TP_fast_assign_btrfs(root->fs_info, 1755 __entry->refroot = root->root_key.objectid; 1756 spin_lock(&root->qgroup_meta_rsv_lock); 1757 __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans; 1758 spin_unlock(&root->qgroup_meta_rsv_lock); 1759 __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS; 1760 ), 1761 1762 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 1763 show_root_type(__entry->refroot), 1764 show_qgroup_rsv_type(__entry->type), __entry->diff) 1765 ); 1766 1767 DECLARE_EVENT_CLASS(btrfs__prelim_ref, 1768 TP_PROTO(const struct btrfs_fs_info *fs_info, 1769 const struct prelim_ref *oldref, 1770 const struct prelim_ref *newref, u64 tree_size), 1771 TP_ARGS(fs_info, newref, oldref, tree_size), 1772 1773 TP_STRUCT__entry_btrfs( 1774 __field( u64, root_id ) 1775 __field( u64, objectid ) 1776 __field( u8, type ) 1777 __field( u64, offset ) 1778 __field( int, level ) 1779 __field( int, old_count ) 1780 __field( u64, parent ) 1781 __field( u64, bytenr ) 1782 __field( int, mod_count ) 1783 __field( u64, tree_size ) 1784 ), 1785 1786 TP_fast_assign_btrfs(fs_info, 1787 __entry->root_id = oldref->root_id; 1788 __entry->objectid = oldref->key_for_search.objectid; 1789 __entry->type = oldref->key_for_search.type; 1790 __entry->offset = oldref->key_for_search.offset; 1791 __entry->level = oldref->level; 1792 __entry->old_count = oldref->count; 1793 __entry->parent = oldref->parent; 1794 __entry->bytenr = oldref->wanted_disk_byte; 1795 __entry->mod_count = newref ? newref->count : 0; 1796 __entry->tree_size = tree_size; 1797 ), 1798 1799 TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu", 1800 __entry->root_id, 1801 __entry->objectid, __entry->type, 1802 __entry->offset, __entry->level, 1803 __entry->old_count, __entry->mod_count, 1804 __entry->old_count + __entry->mod_count, 1805 __entry->parent, 1806 __entry->bytenr, 1807 __entry->tree_size) 1808 ); 1809 1810 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge, 1811 TP_PROTO(const struct btrfs_fs_info *fs_info, 1812 const struct prelim_ref *oldref, 1813 const struct prelim_ref *newref, u64 tree_size), 1814 TP_ARGS(fs_info, oldref, newref, tree_size) 1815 ); 1816 1817 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert, 1818 TP_PROTO(const struct btrfs_fs_info *fs_info, 1819 const struct prelim_ref *oldref, 1820 const struct prelim_ref *newref, u64 tree_size), 1821 TP_ARGS(fs_info, oldref, newref, tree_size) 1822 ); 1823 1824 TRACE_EVENT(btrfs_inode_mod_outstanding_extents, 1825 TP_PROTO(struct btrfs_root *root, u64 ino, int mod), 1826 1827 TP_ARGS(root, ino, mod), 1828 1829 TP_STRUCT__entry_btrfs( 1830 __field( u64, root_objectid ) 1831 __field( u64, ino ) 1832 __field( int, mod ) 1833 ), 1834 1835 TP_fast_assign_btrfs(root->fs_info, 1836 __entry->root_objectid = root->root_key.objectid; 1837 __entry->ino = ino; 1838 __entry->mod = mod; 1839 ), 1840 1841 TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d", 1842 show_root_type(__entry->root_objectid), 1843 __entry->ino, __entry->mod) 1844 ); 1845 1846 DECLARE_EVENT_CLASS(btrfs__block_group, 1847 TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 1848 1849 TP_ARGS(bg_cache), 1850 1851 TP_STRUCT__entry_btrfs( 1852 __field( u64, bytenr ) 1853 __field( u64, len ) 1854 __field( u64, used ) 1855 __field( u64, flags ) 1856 ), 1857 1858 TP_fast_assign_btrfs(bg_cache->fs_info, 1859 __entry->bytenr = bg_cache->key.objectid, 1860 __entry->len = bg_cache->key.offset, 1861 __entry->used = btrfs_block_group_used(&bg_cache->item); 1862 __entry->flags = bg_cache->flags; 1863 ), 1864 1865 TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)", 1866 __entry->bytenr, __entry->len, __entry->used, __entry->flags, 1867 __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS)) 1868 ); 1869 1870 DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group, 1871 TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 1872 1873 TP_ARGS(bg_cache) 1874 ); 1875 1876 DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group, 1877 TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 1878 1879 TP_ARGS(bg_cache) 1880 ); 1881 1882 DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group, 1883 TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 1884 1885 TP_ARGS(bg_cache) 1886 ); 1887 1888 TRACE_EVENT(btrfs_set_extent_bit, 1889 TP_PROTO(const struct extent_io_tree *tree, 1890 u64 start, u64 len, unsigned set_bits), 1891 1892 TP_ARGS(tree, start, len, set_bits), 1893 1894 TP_STRUCT__entry_btrfs( 1895 __field( unsigned, owner ) 1896 __field( u64, ino ) 1897 __field( u64, rootid ) 1898 __field( u64, start ) 1899 __field( u64, len ) 1900 __field( unsigned, set_bits) 1901 ), 1902 1903 TP_fast_assign_btrfs(tree->fs_info, 1904 __entry->owner = tree->owner; 1905 if (tree->private_data) { 1906 struct inode *inode = tree->private_data; 1907 1908 __entry->ino = btrfs_ino(BTRFS_I(inode)); 1909 __entry->rootid = 1910 BTRFS_I(inode)->root->root_key.objectid; 1911 } else { 1912 __entry->ino = 0; 1913 __entry->rootid = 0; 1914 } 1915 __entry->start = start; 1916 __entry->len = len; 1917 __entry->set_bits = set_bits; 1918 ), 1919 1920 TP_printk_btrfs( 1921 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s", 1922 show_extent_io_tree_owner(__entry->owner), __entry->ino, 1923 __entry->rootid, __entry->start, __entry->len, 1924 __print_flags(__entry->set_bits, "|", EXTENT_FLAGS)) 1925 ); 1926 1927 TRACE_EVENT(btrfs_clear_extent_bit, 1928 TP_PROTO(const struct extent_io_tree *tree, 1929 u64 start, u64 len, unsigned clear_bits), 1930 1931 TP_ARGS(tree, start, len, clear_bits), 1932 1933 TP_STRUCT__entry_btrfs( 1934 __field( unsigned, owner ) 1935 __field( u64, ino ) 1936 __field( u64, rootid ) 1937 __field( u64, start ) 1938 __field( u64, len ) 1939 __field( unsigned, clear_bits) 1940 ), 1941 1942 TP_fast_assign_btrfs(tree->fs_info, 1943 __entry->owner = tree->owner; 1944 if (tree->private_data) { 1945 struct inode *inode = tree->private_data; 1946 1947 __entry->ino = btrfs_ino(BTRFS_I(inode)); 1948 __entry->rootid = 1949 BTRFS_I(inode)->root->root_key.objectid; 1950 } else { 1951 __entry->ino = 0; 1952 __entry->rootid = 0; 1953 } 1954 __entry->start = start; 1955 __entry->len = len; 1956 __entry->clear_bits = clear_bits; 1957 ), 1958 1959 TP_printk_btrfs( 1960 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s", 1961 show_extent_io_tree_owner(__entry->owner), __entry->ino, 1962 __entry->rootid, __entry->start, __entry->len, 1963 __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 1964 ); 1965 1966 TRACE_EVENT(btrfs_convert_extent_bit, 1967 TP_PROTO(const struct extent_io_tree *tree, 1968 u64 start, u64 len, unsigned set_bits, unsigned clear_bits), 1969 1970 TP_ARGS(tree, start, len, set_bits, clear_bits), 1971 1972 TP_STRUCT__entry_btrfs( 1973 __field( unsigned, owner ) 1974 __field( u64, ino ) 1975 __field( u64, rootid ) 1976 __field( u64, start ) 1977 __field( u64, len ) 1978 __field( unsigned, set_bits) 1979 __field( unsigned, clear_bits) 1980 ), 1981 1982 TP_fast_assign_btrfs(tree->fs_info, 1983 __entry->owner = tree->owner; 1984 if (tree->private_data) { 1985 struct inode *inode = tree->private_data; 1986 1987 __entry->ino = btrfs_ino(BTRFS_I(inode)); 1988 __entry->rootid = 1989 BTRFS_I(inode)->root->root_key.objectid; 1990 } else { 1991 __entry->ino = 0; 1992 __entry->rootid = 0; 1993 } 1994 __entry->start = start; 1995 __entry->len = len; 1996 __entry->set_bits = set_bits; 1997 __entry->clear_bits = clear_bits; 1998 ), 1999 2000 TP_printk_btrfs( 2001 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s", 2002 show_extent_io_tree_owner(__entry->owner), __entry->ino, 2003 __entry->rootid, __entry->start, __entry->len, 2004 __print_flags(__entry->set_bits , "|", EXTENT_FLAGS), 2005 __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 2006 ); 2007 2008 DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock, 2009 TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 2010 2011 TP_ARGS(eb, start_ns), 2012 2013 TP_STRUCT__entry_btrfs( 2014 __field( u64, block ) 2015 __field( u64, generation ) 2016 __field( u64, start_ns ) 2017 __field( u64, end_ns ) 2018 __field( u64, diff_ns ) 2019 __field( u64, owner ) 2020 __field( int, is_log_tree ) 2021 ), 2022 2023 TP_fast_assign_btrfs(eb->fs_info, 2024 __entry->block = eb->start; 2025 __entry->generation = btrfs_header_generation(eb); 2026 __entry->start_ns = start_ns; 2027 __entry->end_ns = ktime_get_ns(); 2028 __entry->diff_ns = __entry->end_ns - start_ns; 2029 __entry->owner = btrfs_header_owner(eb); 2030 __entry->is_log_tree = (eb->log_index >= 0); 2031 ), 2032 2033 TP_printk_btrfs( 2034 "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d", 2035 __entry->block, __entry->generation, 2036 __entry->start_ns, __entry->end_ns, __entry->diff_ns, 2037 __entry->owner, __entry->is_log_tree) 2038 ); 2039 2040 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock, 2041 TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 2042 2043 TP_ARGS(eb, start_ns) 2044 ); 2045 2046 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock, 2047 TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 2048 2049 TP_ARGS(eb, start_ns) 2050 ); 2051 2052 DECLARE_EVENT_CLASS(btrfs_locking_events, 2053 TP_PROTO(const struct extent_buffer *eb), 2054 2055 TP_ARGS(eb), 2056 2057 TP_STRUCT__entry_btrfs( 2058 __field( u64, block ) 2059 __field( u64, generation ) 2060 __field( u64, owner ) 2061 __field( int, is_log_tree ) 2062 ), 2063 2064 TP_fast_assign_btrfs(eb->fs_info, 2065 __entry->block = eb->start; 2066 __entry->generation = btrfs_header_generation(eb); 2067 __entry->owner = btrfs_header_owner(eb); 2068 __entry->is_log_tree = (eb->log_index >= 0); 2069 ), 2070 2071 TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d", 2072 __entry->block, __entry->generation, 2073 __entry->owner, __entry->is_log_tree) 2074 ); 2075 2076 #define DEFINE_BTRFS_LOCK_EVENT(name) \ 2077 DEFINE_EVENT(btrfs_locking_events, name, \ 2078 TP_PROTO(const struct extent_buffer *eb), \ 2079 \ 2080 TP_ARGS(eb) \ 2081 ) 2082 2083 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock); 2084 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock); 2085 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking); 2086 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read); 2087 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write); 2088 DEFINE_BTRFS_LOCK_EVENT(btrfs_clear_lock_blocking_read); 2089 DEFINE_BTRFS_LOCK_EVENT(btrfs_clear_lock_blocking_write); 2090 DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock); 2091 DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock); 2092 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic); 2093 2094 #endif /* _TRACE_BTRFS_H */ 2095 2096 /* This part must be outside protection */ 2097 #include <trace/define_trace.h> 2098