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_ref_head; 20 struct btrfs_block_group; 21 struct btrfs_free_cluster; 22 struct btrfs_chunk_map; 23 struct extent_buffer; 24 struct btrfs_work; 25 struct btrfs_workqueue; 26 struct btrfs_qgroup_extent_record; 27 struct btrfs_qgroup; 28 struct extent_io_tree; 29 struct prelim_ref; 30 struct btrfs_space_info; 31 struct btrfs_raid_bio; 32 struct raid56_bio_trace_info; 33 struct find_free_extent_ctl; 34 35 #define show_ref_type(type) \ 36 __print_symbolic(type, \ 37 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ 38 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ 39 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ 40 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) 41 42 #define __show_root_type(obj) \ 43 __print_symbolic_u64(obj, \ 44 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ 45 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ 46 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ 47 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ 48 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ 49 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ 50 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ 51 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ 52 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \ 53 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ 54 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \ 55 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \ 56 { BTRFS_BLOCK_GROUP_TREE_OBJECTID, "BLOCK_GROUP_TREE" },\ 57 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) 58 59 #define show_root_type(obj) \ 60 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ 61 (obj >= BTRFS_ROOT_TREE_OBJECTID && \ 62 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-" 63 64 #define FLUSH_ACTIONS \ 65 EM( BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH") \ 66 EM( BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT") \ 67 EM( BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL") \ 68 EMe(BTRFS_RESERVE_FLUSH_ALL_STEAL, "BTRFS_RESERVE_FLUSH_ALL_STEAL") 69 70 #define FI_TYPES \ 71 EM( BTRFS_FILE_EXTENT_INLINE, "INLINE") \ 72 EM( BTRFS_FILE_EXTENT_REG, "REG") \ 73 EMe(BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC") 74 75 #define QGROUP_RSV_TYPES \ 76 EM( BTRFS_QGROUP_RSV_DATA, "DATA") \ 77 EM( BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS") \ 78 EMe(BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC") 79 80 #define IO_TREE_OWNER \ 81 EM( IO_TREE_FS_PINNED_EXTENTS, "PINNED_EXTENTS") \ 82 EM( IO_TREE_FS_EXCLUDED_EXTENTS, "EXCLUDED_EXTENTS") \ 83 EM( IO_TREE_BTREE_INODE_IO, "BTREE_INODE_IO") \ 84 EM( IO_TREE_INODE_IO, "INODE_IO") \ 85 EM( IO_TREE_RELOC_BLOCKS, "RELOC_BLOCKS") \ 86 EM( IO_TREE_TRANS_DIRTY_PAGES, "TRANS_DIRTY_PAGES") \ 87 EM( IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES") \ 88 EM( IO_TREE_INODE_FILE_EXTENT, "INODE_FILE_EXTENT") \ 89 EM( IO_TREE_LOG_CSUM_RANGE, "LOG_CSUM_RANGE") \ 90 EMe(IO_TREE_SELFTEST, "SELFTEST") 91 92 #define FLUSH_STATES \ 93 EM( FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR") \ 94 EM( FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS") \ 95 EM( FLUSH_DELALLOC, "FLUSH_DELALLOC") \ 96 EM( FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT") \ 97 EM( FLUSH_DELALLOC_FULL, "FLUSH_DELALLOC_FULL") \ 98 EM( FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR") \ 99 EM( FLUSH_DELAYED_REFS, "FLUSH_DELAYED_REFS") \ 100 EM( ALLOC_CHUNK, "ALLOC_CHUNK") \ 101 EM( ALLOC_CHUNK_FORCE, "ALLOC_CHUNK_FORCE") \ 102 EM( RUN_DELAYED_IPUTS, "RUN_DELAYED_IPUTS") \ 103 EMe(COMMIT_TRANS, "COMMIT_TRANS") 104 105 /* 106 * First define the enums in the above macros to be exported to userspace via 107 * TRACE_DEFINE_ENUM(). 108 */ 109 110 #undef EM 111 #undef EMe 112 #define EM(a, b) TRACE_DEFINE_ENUM(a); 113 #define EMe(a, b) TRACE_DEFINE_ENUM(a); 114 115 FLUSH_ACTIONS 116 FI_TYPES 117 QGROUP_RSV_TYPES 118 IO_TREE_OWNER 119 FLUSH_STATES 120 121 /* 122 * Now redefine the EM and EMe macros to map the enums to the strings that will 123 * be printed in the output 124 */ 125 126 #undef EM 127 #undef EMe 128 #define EM(a, b) {a, b}, 129 #define EMe(a, b) {a, b} 130 131 132 #define BTRFS_GROUP_FLAGS \ 133 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \ 134 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 135 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 136 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \ 137 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ 138 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ 139 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 140 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ 141 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} 142 143 #define EXTENT_FLAGS \ 144 { EXTENT_DIRTY, "DIRTY"}, \ 145 { EXTENT_UPTODATE, "UPTODATE"}, \ 146 { EXTENT_LOCKED, "LOCKED"}, \ 147 { EXTENT_NEW, "NEW"}, \ 148 { EXTENT_DELALLOC, "DELALLOC"}, \ 149 { EXTENT_DEFRAG, "DEFRAG"}, \ 150 { EXTENT_BOUNDARY, "BOUNDARY"}, \ 151 { EXTENT_NODATASUM, "NODATASUM"}, \ 152 { EXTENT_CLEAR_META_RESV, "CLEAR_META_RESV"}, \ 153 { EXTENT_NEED_WAIT, "NEED_WAIT"}, \ 154 { EXTENT_NORESERVE, "NORESERVE"}, \ 155 { EXTENT_QGROUP_RESERVED, "QGROUP_RESERVED"}, \ 156 { EXTENT_CLEAR_DATA_RESV, "CLEAR_DATA_RESV"}, \ 157 { EXTENT_DELALLOC_NEW, "DELALLOC_NEW"} 158 159 #define BTRFS_FSID_SIZE 16 160 #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE) 161 162 #define TP_fast_assign_fsid(fs_info) \ 163 ({ \ 164 if (fs_info) \ 165 memcpy(__entry->fsid, fs_info->fs_devices->fsid, \ 166 BTRFS_FSID_SIZE); \ 167 else \ 168 memset(__entry->fsid, 0, BTRFS_FSID_SIZE); \ 169 }) 170 171 #define TP_STRUCT__entry_btrfs(args...) \ 172 TP_STRUCT__entry( \ 173 TP_STRUCT__entry_fsid \ 174 args) 175 #define TP_fast_assign_btrfs(fs_info, args...) \ 176 TP_fast_assign( \ 177 TP_fast_assign_fsid(fs_info); \ 178 args) 179 #define TP_printk_btrfs(fmt, args...) \ 180 TP_printk("%pU: " fmt, __entry->fsid, args) 181 182 TRACE_EVENT(btrfs_transaction_commit, 183 184 TP_PROTO(const struct btrfs_fs_info *fs_info), 185 186 TP_ARGS(fs_info), 187 188 TP_STRUCT__entry_btrfs( 189 __field( u64, generation ) 190 __field( u64, root_objectid ) 191 ), 192 193 TP_fast_assign_btrfs(fs_info, 194 __entry->generation = fs_info->generation; 195 __entry->root_objectid = BTRFS_ROOT_TREE_OBJECTID; 196 ), 197 198 TP_printk_btrfs("root=%llu(%s) gen=%llu", 199 show_root_type(__entry->root_objectid), 200 __entry->generation) 201 ); 202 203 DECLARE_EVENT_CLASS(btrfs__inode, 204 205 TP_PROTO(const struct inode *inode), 206 207 TP_ARGS(inode), 208 209 TP_STRUCT__entry_btrfs( 210 __field( u64, ino ) 211 __field( u64, blocks ) 212 __field( u64, disk_i_size ) 213 __field( u64, generation ) 214 __field( u64, last_trans ) 215 __field( u64, logged_trans ) 216 __field( u64, root_objectid ) 217 ), 218 219 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 220 __entry->ino = btrfs_ino(BTRFS_I(inode)); 221 __entry->blocks = inode->i_blocks; 222 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; 223 __entry->generation = BTRFS_I(inode)->generation; 224 __entry->last_trans = BTRFS_I(inode)->last_trans; 225 __entry->logged_trans = BTRFS_I(inode)->logged_trans; 226 __entry->root_objectid = 227 BTRFS_I(inode)->root->root_key.objectid; 228 ), 229 230 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu " 231 "disk_i_size=%llu last_trans=%llu logged_trans=%llu", 232 show_root_type(__entry->root_objectid), 233 __entry->generation, 234 __entry->ino, 235 __entry->blocks, 236 __entry->disk_i_size, 237 __entry->last_trans, 238 __entry->logged_trans) 239 ); 240 241 DEFINE_EVENT(btrfs__inode, btrfs_inode_new, 242 243 TP_PROTO(const struct inode *inode), 244 245 TP_ARGS(inode) 246 ); 247 248 DEFINE_EVENT(btrfs__inode, btrfs_inode_request, 249 250 TP_PROTO(const struct inode *inode), 251 252 TP_ARGS(inode) 253 ); 254 255 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, 256 257 TP_PROTO(const struct inode *inode), 258 259 TP_ARGS(inode) 260 ); 261 262 #define __show_map_type(type) \ 263 __print_symbolic_u64(type, \ 264 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ 265 { EXTENT_MAP_HOLE, "HOLE" }, \ 266 { EXTENT_MAP_INLINE, "INLINE" }) 267 268 #define show_map_type(type) \ 269 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) 270 271 #define show_map_flags(flag) \ 272 __print_flags(flag, "|", \ 273 { EXTENT_FLAG_PINNED, "PINNED" },\ 274 { EXTENT_FLAG_COMPRESS_ZLIB, "COMPRESS_ZLIB" },\ 275 { EXTENT_FLAG_COMPRESS_LZO, "COMPRESS_LZO" },\ 276 { EXTENT_FLAG_COMPRESS_ZSTD, "COMPRESS_ZSTD" },\ 277 { EXTENT_FLAG_PREALLOC, "PREALLOC" },\ 278 { EXTENT_FLAG_LOGGING, "LOGGING" }) 279 280 TRACE_EVENT_CONDITION(btrfs_get_extent, 281 282 TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode, 283 const struct extent_map *map), 284 285 TP_ARGS(root, inode, map), 286 287 TP_CONDITION(map), 288 289 TP_STRUCT__entry_btrfs( 290 __field( u64, root_objectid ) 291 __field( u64, ino ) 292 __field( u64, start ) 293 __field( u64, len ) 294 __field( u32, flags ) 295 __field( int, refs ) 296 ), 297 298 TP_fast_assign_btrfs(root->fs_info, 299 __entry->root_objectid = root->root_key.objectid; 300 __entry->ino = btrfs_ino(inode); 301 __entry->start = map->start; 302 __entry->len = map->len; 303 __entry->flags = map->flags; 304 __entry->refs = refcount_read(&map->refs); 305 ), 306 307 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu flags=%s refs=%u", 308 show_root_type(__entry->root_objectid), 309 __entry->ino, 310 __entry->start, 311 __entry->len, 312 show_map_flags(__entry->flags), 313 __entry->refs) 314 ); 315 316 TRACE_EVENT(btrfs_handle_em_exist, 317 318 TP_PROTO(const struct btrfs_fs_info *fs_info, 319 const struct extent_map *existing, const struct extent_map *map, 320 u64 start, u64 len), 321 322 TP_ARGS(fs_info, existing, map, start, len), 323 324 TP_STRUCT__entry_btrfs( 325 __field( u64, e_start ) 326 __field( u64, e_len ) 327 __field( u64, map_start ) 328 __field( u64, map_len ) 329 __field( u64, start ) 330 __field( u64, len ) 331 ), 332 333 TP_fast_assign_btrfs(fs_info, 334 __entry->e_start = existing->start; 335 __entry->e_len = existing->len; 336 __entry->map_start = map->start; 337 __entry->map_len = map->len; 338 __entry->start = start; 339 __entry->len = len; 340 ), 341 342 TP_printk_btrfs("start=%llu len=%llu " 343 "existing(start=%llu len=%llu) " 344 "em(start=%llu len=%llu)", 345 __entry->start, 346 __entry->len, 347 __entry->e_start, 348 __entry->e_len, 349 __entry->map_start, 350 __entry->map_len) 351 ); 352 353 /* file extent item */ 354 DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular, 355 356 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 357 const struct btrfs_file_extent_item *fi, u64 start), 358 359 TP_ARGS(bi, l, fi, start), 360 361 TP_STRUCT__entry_btrfs( 362 __field( u64, root_obj ) 363 __field( u64, ino ) 364 __field( loff_t, isize ) 365 __field( u64, disk_isize ) 366 __field( u64, num_bytes ) 367 __field( u64, ram_bytes ) 368 __field( u64, disk_bytenr ) 369 __field( u64, disk_num_bytes ) 370 __field( u64, extent_offset ) 371 __field( u8, extent_type ) 372 __field( u8, compression ) 373 __field( u64, extent_start ) 374 __field( u64, extent_end ) 375 ), 376 377 TP_fast_assign_btrfs(bi->root->fs_info, 378 __entry->root_obj = bi->root->root_key.objectid; 379 __entry->ino = btrfs_ino(bi); 380 __entry->isize = bi->vfs_inode.i_size; 381 __entry->disk_isize = bi->disk_i_size; 382 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi); 383 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi); 384 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi); 385 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi); 386 __entry->extent_offset = btrfs_file_extent_offset(l, fi); 387 __entry->extent_type = btrfs_file_extent_type(l, fi); 388 __entry->compression = btrfs_file_extent_compression(l, fi); 389 __entry->extent_start = start; 390 __entry->extent_end = (start + __entry->num_bytes); 391 ), 392 393 TP_printk_btrfs( 394 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 395 "file extent range=[%llu %llu] " 396 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu " 397 "disk_num_bytes=%llu extent_offset=%llu type=%s " 398 "compression=%u", 399 show_root_type(__entry->root_obj), __entry->ino, 400 __entry->isize, 401 __entry->disk_isize, __entry->extent_start, 402 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes, 403 __entry->disk_bytenr, __entry->disk_num_bytes, 404 __entry->extent_offset, __print_symbolic(__entry->extent_type, FI_TYPES), 405 __entry->compression) 406 ); 407 408 DECLARE_EVENT_CLASS( 409 btrfs__file_extent_item_inline, 410 411 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 412 const struct btrfs_file_extent_item *fi, int slot, u64 start), 413 414 TP_ARGS(bi, l, fi, slot, start), 415 416 TP_STRUCT__entry_btrfs( 417 __field( u64, root_obj ) 418 __field( u64, ino ) 419 __field( loff_t, isize ) 420 __field( u64, disk_isize ) 421 __field( u8, extent_type ) 422 __field( u8, compression ) 423 __field( u64, extent_start ) 424 __field( u64, extent_end ) 425 ), 426 427 TP_fast_assign_btrfs( 428 bi->root->fs_info, 429 __entry->root_obj = bi->root->root_key.objectid; 430 __entry->ino = btrfs_ino(bi); 431 __entry->isize = bi->vfs_inode.i_size; 432 __entry->disk_isize = bi->disk_i_size; 433 __entry->extent_type = btrfs_file_extent_type(l, fi); 434 __entry->compression = btrfs_file_extent_compression(l, fi); 435 __entry->extent_start = start; 436 __entry->extent_end = (start + btrfs_file_extent_ram_bytes(l, fi)); 437 ), 438 439 TP_printk_btrfs( 440 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 441 "file extent range=[%llu %llu] " 442 "extent_type=%s compression=%u", 443 show_root_type(__entry->root_obj), __entry->ino, __entry->isize, 444 __entry->disk_isize, __entry->extent_start, 445 __entry->extent_end, __print_symbolic(__entry->extent_type, FI_TYPES), 446 __entry->compression) 447 ); 448 449 DEFINE_EVENT( 450 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular, 451 452 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 453 const struct btrfs_file_extent_item *fi, u64 start), 454 455 TP_ARGS(bi, l, fi, start) 456 ); 457 458 DEFINE_EVENT( 459 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular, 460 461 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 462 const struct btrfs_file_extent_item *fi, u64 start), 463 464 TP_ARGS(bi, l, fi, start) 465 ); 466 467 DEFINE_EVENT( 468 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline, 469 470 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 471 const struct btrfs_file_extent_item *fi, int slot, u64 start), 472 473 TP_ARGS(bi, l, fi, slot, start) 474 ); 475 476 DEFINE_EVENT( 477 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline, 478 479 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 480 const struct btrfs_file_extent_item *fi, int slot, u64 start), 481 482 TP_ARGS(bi, l, fi, slot, start) 483 ); 484 485 #define show_ordered_flags(flags) \ 486 __print_flags(flags, "|", \ 487 { (1 << BTRFS_ORDERED_REGULAR), "REGULAR" }, \ 488 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \ 489 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \ 490 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \ 491 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \ 492 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \ 493 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \ 494 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \ 495 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" }) 496 497 498 DECLARE_EVENT_CLASS(btrfs__ordered_extent, 499 500 TP_PROTO(const struct btrfs_inode *inode, 501 const struct btrfs_ordered_extent *ordered), 502 503 TP_ARGS(inode, ordered), 504 505 TP_STRUCT__entry_btrfs( 506 __field( u64, ino ) 507 __field( u64, file_offset ) 508 __field( u64, start ) 509 __field( u64, len ) 510 __field( u64, disk_len ) 511 __field( u64, bytes_left ) 512 __field( unsigned long, flags ) 513 __field( int, compress_type ) 514 __field( int, refs ) 515 __field( u64, root_objectid ) 516 __field( u64, truncated_len ) 517 ), 518 519 TP_fast_assign_btrfs(inode->root->fs_info, 520 __entry->ino = btrfs_ino(inode); 521 __entry->file_offset = ordered->file_offset; 522 __entry->start = ordered->disk_bytenr; 523 __entry->len = ordered->num_bytes; 524 __entry->disk_len = ordered->disk_num_bytes; 525 __entry->bytes_left = ordered->bytes_left; 526 __entry->flags = ordered->flags; 527 __entry->compress_type = ordered->compress_type; 528 __entry->refs = refcount_read(&ordered->refs); 529 __entry->root_objectid = inode->root->root_key.objectid; 530 __entry->truncated_len = ordered->truncated_len; 531 ), 532 533 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu " 534 "start=%llu len=%llu disk_len=%llu " 535 "truncated_len=%llu " 536 "bytes_left=%llu flags=%s compress_type=%d " 537 "refs=%d", 538 show_root_type(__entry->root_objectid), 539 __entry->ino, 540 __entry->file_offset, 541 __entry->start, 542 __entry->len, 543 __entry->disk_len, 544 __entry->truncated_len, 545 __entry->bytes_left, 546 show_ordered_flags(__entry->flags), 547 __entry->compress_type, __entry->refs) 548 ); 549 550 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, 551 552 TP_PROTO(const struct btrfs_inode *inode, 553 const struct btrfs_ordered_extent *ordered), 554 555 TP_ARGS(inode, ordered) 556 ); 557 558 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, 559 560 TP_PROTO(const struct btrfs_inode *inode, 561 const struct btrfs_ordered_extent *ordered), 562 563 TP_ARGS(inode, ordered) 564 ); 565 566 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, 567 568 TP_PROTO(const struct btrfs_inode *inode, 569 const struct btrfs_ordered_extent *ordered), 570 571 TP_ARGS(inode, ordered) 572 ); 573 574 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, 575 576 TP_PROTO(const struct btrfs_inode *inode, 577 const struct btrfs_ordered_extent *ordered), 578 579 TP_ARGS(inode, ordered) 580 ); 581 582 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup, 583 584 TP_PROTO(const struct btrfs_inode *inode, 585 const struct btrfs_ordered_extent *ordered), 586 587 TP_ARGS(inode, ordered) 588 ); 589 590 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_range, 591 592 TP_PROTO(const struct btrfs_inode *inode, 593 const struct btrfs_ordered_extent *ordered), 594 595 TP_ARGS(inode, ordered) 596 ); 597 598 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_first_range, 599 600 TP_PROTO(const struct btrfs_inode *inode, 601 const struct btrfs_ordered_extent *ordered), 602 603 TP_ARGS(inode, ordered) 604 ); 605 606 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_for_logging, 607 608 TP_PROTO(const struct btrfs_inode *inode, 609 const struct btrfs_ordered_extent *ordered), 610 611 TP_ARGS(inode, ordered) 612 ); 613 614 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_first, 615 616 TP_PROTO(const struct btrfs_inode *inode, 617 const struct btrfs_ordered_extent *ordered), 618 619 TP_ARGS(inode, ordered) 620 ); 621 622 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_split, 623 624 TP_PROTO(const struct btrfs_inode *inode, 625 const struct btrfs_ordered_extent *ordered), 626 627 TP_ARGS(inode, ordered) 628 ); 629 630 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_dec_test_pending, 631 632 TP_PROTO(const struct btrfs_inode *inode, 633 const struct btrfs_ordered_extent *ordered), 634 635 TP_ARGS(inode, ordered) 636 ); 637 638 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_mark_finished, 639 640 TP_PROTO(const struct btrfs_inode *inode, 641 const struct btrfs_ordered_extent *ordered), 642 643 TP_ARGS(inode, ordered) 644 ); 645 646 TRACE_EVENT(btrfs_finish_ordered_extent, 647 648 TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 len, 649 bool uptodate), 650 651 TP_ARGS(inode, start, len, uptodate), 652 653 TP_STRUCT__entry_btrfs( 654 __field( u64, ino ) 655 __field( u64, start ) 656 __field( u64, len ) 657 __field( bool, uptodate ) 658 __field( u64, root_objectid ) 659 ), 660 661 TP_fast_assign_btrfs(inode->root->fs_info, 662 __entry->ino = btrfs_ino(inode); 663 __entry->start = start; 664 __entry->len = len; 665 __entry->uptodate = uptodate; 666 __entry->root_objectid = inode->root->root_key.objectid; 667 ), 668 669 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu uptodate=%d", 670 show_root_type(__entry->root_objectid), 671 __entry->ino, __entry->start, 672 __entry->len, !!__entry->uptodate) 673 ); 674 675 DECLARE_EVENT_CLASS(btrfs__writepage, 676 677 TP_PROTO(const struct folio *folio, const struct inode *inode, 678 const struct writeback_control *wbc), 679 680 TP_ARGS(folio, inode, wbc), 681 682 TP_STRUCT__entry_btrfs( 683 __field( u64, ino ) 684 __field( pgoff_t, index ) 685 __field( long, nr_to_write ) 686 __field( long, pages_skipped ) 687 __field( loff_t, range_start ) 688 __field( loff_t, range_end ) 689 __field( char, for_kupdate ) 690 __field( char, for_reclaim ) 691 __field( char, range_cyclic ) 692 __field( unsigned long, writeback_index ) 693 __field( u64, root_objectid ) 694 ), 695 696 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 697 __entry->ino = btrfs_ino(BTRFS_I(inode)); 698 __entry->index = folio->index; 699 __entry->nr_to_write = wbc->nr_to_write; 700 __entry->pages_skipped = wbc->pages_skipped; 701 __entry->range_start = wbc->range_start; 702 __entry->range_end = wbc->range_end; 703 __entry->for_kupdate = wbc->for_kupdate; 704 __entry->for_reclaim = wbc->for_reclaim; 705 __entry->range_cyclic = wbc->range_cyclic; 706 __entry->writeback_index = inode->i_mapping->writeback_index; 707 __entry->root_objectid = 708 BTRFS_I(inode)->root->root_key.objectid; 709 ), 710 711 TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu " 712 "nr_to_write=%ld pages_skipped=%ld range_start=%llu " 713 "range_end=%llu for_kupdate=%d " 714 "for_reclaim=%d range_cyclic=%d writeback_index=%lu", 715 show_root_type(__entry->root_objectid), 716 __entry->ino, __entry->index, 717 __entry->nr_to_write, __entry->pages_skipped, 718 __entry->range_start, __entry->range_end, 719 __entry->for_kupdate, 720 __entry->for_reclaim, __entry->range_cyclic, 721 __entry->writeback_index) 722 ); 723 724 DEFINE_EVENT(btrfs__writepage, extent_writepage, 725 726 TP_PROTO(const struct folio *folio, const struct inode *inode, 727 const struct writeback_control *wbc), 728 729 TP_ARGS(folio, inode, wbc) 730 ); 731 732 TRACE_EVENT(btrfs_writepage_end_io_hook, 733 734 TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 end, 735 int uptodate), 736 737 TP_ARGS(inode, start, end, uptodate), 738 739 TP_STRUCT__entry_btrfs( 740 __field( u64, ino ) 741 __field( u64, start ) 742 __field( u64, end ) 743 __field( int, uptodate ) 744 __field( u64, root_objectid ) 745 ), 746 747 TP_fast_assign_btrfs(inode->root->fs_info, 748 __entry->ino = btrfs_ino(inode); 749 __entry->start = start; 750 __entry->end = end; 751 __entry->uptodate = uptodate; 752 __entry->root_objectid = inode->root->root_key.objectid; 753 ), 754 755 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu end=%llu uptodate=%d", 756 show_root_type(__entry->root_objectid), 757 __entry->ino, __entry->start, 758 __entry->end, __entry->uptodate) 759 ); 760 761 TRACE_EVENT(btrfs_sync_file, 762 763 TP_PROTO(const struct file *file, int datasync), 764 765 TP_ARGS(file, datasync), 766 767 TP_STRUCT__entry_btrfs( 768 __field( u64, ino ) 769 __field( u64, parent ) 770 __field( int, datasync ) 771 __field( u64, root_objectid ) 772 ), 773 774 TP_fast_assign( 775 const struct dentry *dentry = file->f_path.dentry; 776 const struct inode *inode = d_inode(dentry); 777 778 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb)); 779 __entry->ino = btrfs_ino(BTRFS_I(inode)); 780 __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent))); 781 __entry->datasync = datasync; 782 __entry->root_objectid = 783 BTRFS_I(inode)->root->root_key.objectid; 784 ), 785 786 TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d", 787 show_root_type(__entry->root_objectid), 788 __entry->ino, 789 __entry->parent, 790 __entry->datasync) 791 ); 792 793 TRACE_EVENT(btrfs_sync_fs, 794 795 TP_PROTO(const struct btrfs_fs_info *fs_info, int wait), 796 797 TP_ARGS(fs_info, wait), 798 799 TP_STRUCT__entry_btrfs( 800 __field( int, wait ) 801 ), 802 803 TP_fast_assign_btrfs(fs_info, 804 __entry->wait = wait; 805 ), 806 807 TP_printk_btrfs("wait=%d", __entry->wait) 808 ); 809 810 TRACE_EVENT(btrfs_add_block_group, 811 812 TP_PROTO(const struct btrfs_fs_info *fs_info, 813 const struct btrfs_block_group *block_group, int create), 814 815 TP_ARGS(fs_info, block_group, create), 816 817 TP_STRUCT__entry_btrfs( 818 __field( u64, offset ) 819 __field( u64, size ) 820 __field( u64, flags ) 821 __field( u64, bytes_used ) 822 __field( u64, bytes_super ) 823 __field( int, create ) 824 ), 825 826 TP_fast_assign_btrfs(fs_info, 827 __entry->offset = block_group->start; 828 __entry->size = block_group->length; 829 __entry->flags = block_group->flags; 830 __entry->bytes_used = block_group->used; 831 __entry->bytes_super = block_group->bytes_super; 832 __entry->create = create; 833 ), 834 835 TP_printk_btrfs("block_group offset=%llu size=%llu " 836 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu " 837 "create=%d", 838 __entry->offset, 839 __entry->size, 840 __entry->flags, 841 __print_flags((unsigned long)__entry->flags, "|", 842 BTRFS_GROUP_FLAGS), 843 __entry->bytes_used, 844 __entry->bytes_super, __entry->create) 845 ); 846 847 #define show_ref_action(action) \ 848 __print_symbolic(action, \ 849 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 850 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 851 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 852 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 853 854 855 DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 856 857 TP_PROTO(const struct btrfs_fs_info *fs_info, 858 const struct btrfs_delayed_ref_node *ref), 859 860 TP_ARGS(fs_info, ref), 861 862 TP_STRUCT__entry_btrfs( 863 __field( u64, bytenr ) 864 __field( u64, num_bytes ) 865 __field( int, action ) 866 __field( u64, parent ) 867 __field( u64, ref_root ) 868 __field( int, level ) 869 __field( int, type ) 870 __field( u64, seq ) 871 ), 872 873 TP_fast_assign_btrfs(fs_info, 874 __entry->bytenr = ref->bytenr; 875 __entry->num_bytes = ref->num_bytes; 876 __entry->action = ref->action; 877 __entry->parent = ref->parent; 878 __entry->ref_root = ref->ref_root; 879 __entry->level = ref->tree_ref.level; 880 __entry->type = ref->type; 881 __entry->seq = ref->seq; 882 ), 883 884 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 885 "parent=%llu(%s) ref_root=%llu(%s) level=%d " 886 "type=%s seq=%llu", 887 __entry->bytenr, 888 __entry->num_bytes, 889 show_ref_action(__entry->action), 890 show_root_type(__entry->parent), 891 show_root_type(__entry->ref_root), 892 __entry->level, show_ref_type(__entry->type), 893 __entry->seq) 894 ); 895 896 DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 897 898 TP_PROTO(const struct btrfs_fs_info *fs_info, 899 const struct btrfs_delayed_ref_node *ref), 900 901 TP_ARGS(fs_info, ref) 902 ); 903 904 DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 905 906 TP_PROTO(const struct btrfs_fs_info *fs_info, 907 const struct btrfs_delayed_ref_node *ref), 908 909 TP_ARGS(fs_info, ref) 910 ); 911 912 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 913 914 TP_PROTO(const struct btrfs_fs_info *fs_info, 915 const struct btrfs_delayed_ref_node *ref), 916 917 TP_ARGS(fs_info, ref), 918 919 TP_STRUCT__entry_btrfs( 920 __field( u64, bytenr ) 921 __field( u64, num_bytes ) 922 __field( int, action ) 923 __field( u64, parent ) 924 __field( u64, ref_root ) 925 __field( u64, owner ) 926 __field( u64, offset ) 927 __field( int, type ) 928 __field( u64, seq ) 929 ), 930 931 TP_fast_assign_btrfs(fs_info, 932 __entry->bytenr = ref->bytenr; 933 __entry->num_bytes = ref->num_bytes; 934 __entry->action = ref->action; 935 __entry->parent = ref->parent; 936 __entry->ref_root = ref->ref_root; 937 __entry->owner = ref->data_ref.objectid; 938 __entry->offset = ref->data_ref.offset; 939 __entry->type = ref->type; 940 __entry->seq = ref->seq; 941 ), 942 943 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 944 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu " 945 "offset=%llu type=%s seq=%llu", 946 __entry->bytenr, 947 __entry->num_bytes, 948 show_ref_action(__entry->action), 949 show_root_type(__entry->parent), 950 show_root_type(__entry->ref_root), 951 __entry->owner, 952 __entry->offset, 953 show_ref_type(__entry->type), 954 __entry->seq) 955 ); 956 957 DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 958 959 TP_PROTO(const struct btrfs_fs_info *fs_info, 960 const struct btrfs_delayed_ref_node *ref), 961 962 TP_ARGS(fs_info, ref) 963 ); 964 965 DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 966 967 TP_PROTO(const struct btrfs_fs_info *fs_info, 968 const struct btrfs_delayed_ref_node *ref), 969 970 TP_ARGS(fs_info, ref) 971 ); 972 973 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 974 975 TP_PROTO(const struct btrfs_fs_info *fs_info, 976 const struct btrfs_delayed_ref_head *head_ref, 977 int action), 978 979 TP_ARGS(fs_info, head_ref, action), 980 981 TP_STRUCT__entry_btrfs( 982 __field( u64, bytenr ) 983 __field( u64, num_bytes ) 984 __field( int, action ) 985 __field( int, is_data ) 986 ), 987 988 TP_fast_assign_btrfs(fs_info, 989 __entry->bytenr = head_ref->bytenr; 990 __entry->num_bytes = head_ref->num_bytes; 991 __entry->action = action; 992 __entry->is_data = head_ref->is_data; 993 ), 994 995 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d", 996 __entry->bytenr, 997 __entry->num_bytes, 998 show_ref_action(__entry->action), 999 __entry->is_data) 1000 ); 1001 1002 DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 1003 1004 TP_PROTO(const struct btrfs_fs_info *fs_info, 1005 const struct btrfs_delayed_ref_head *head_ref, 1006 int action), 1007 1008 TP_ARGS(fs_info, head_ref, action) 1009 ); 1010 1011 DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 1012 1013 TP_PROTO(const struct btrfs_fs_info *fs_info, 1014 const struct btrfs_delayed_ref_head *head_ref, 1015 int action), 1016 1017 TP_ARGS(fs_info, head_ref, action) 1018 ); 1019 1020 #define show_chunk_type(type) \ 1021 __print_flags(type, "|", \ 1022 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 1023 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 1024 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 1025 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 1026 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 1027 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 1028 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 1029 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 1030 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 1031 1032 DECLARE_EVENT_CLASS(btrfs__chunk, 1033 1034 TP_PROTO(const struct btrfs_fs_info *fs_info, 1035 const struct btrfs_chunk_map *map, u64 offset, u64 size), 1036 1037 TP_ARGS(fs_info, map, offset, size), 1038 1039 TP_STRUCT__entry_btrfs( 1040 __field( int, num_stripes ) 1041 __field( u64, type ) 1042 __field( int, sub_stripes ) 1043 __field( u64, offset ) 1044 __field( u64, size ) 1045 __field( u64, root_objectid ) 1046 ), 1047 1048 TP_fast_assign_btrfs(fs_info, 1049 __entry->num_stripes = map->num_stripes; 1050 __entry->type = map->type; 1051 __entry->sub_stripes = map->sub_stripes; 1052 __entry->offset = offset; 1053 __entry->size = size; 1054 __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 1055 ), 1056 1057 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu " 1058 "num_stripes=%d sub_stripes=%d type=%s", 1059 show_root_type(__entry->root_objectid), 1060 __entry->offset, 1061 __entry->size, 1062 __entry->num_stripes, __entry->sub_stripes, 1063 show_chunk_type(__entry->type)) 1064 ); 1065 1066 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 1067 1068 TP_PROTO(const struct btrfs_fs_info *fs_info, 1069 const struct btrfs_chunk_map *map, u64 offset, u64 size), 1070 1071 TP_ARGS(fs_info, map, offset, size) 1072 ); 1073 1074 DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 1075 1076 TP_PROTO(const struct btrfs_fs_info *fs_info, 1077 const struct btrfs_chunk_map *map, u64 offset, u64 size), 1078 1079 TP_ARGS(fs_info, map, offset, size) 1080 ); 1081 1082 TRACE_EVENT(btrfs_cow_block, 1083 1084 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf, 1085 const struct extent_buffer *cow), 1086 1087 TP_ARGS(root, buf, cow), 1088 1089 TP_STRUCT__entry_btrfs( 1090 __field( u64, root_objectid ) 1091 __field( u64, buf_start ) 1092 __field( int, refs ) 1093 __field( u64, cow_start ) 1094 __field( int, buf_level ) 1095 __field( int, cow_level ) 1096 ), 1097 1098 TP_fast_assign_btrfs(root->fs_info, 1099 __entry->root_objectid = root->root_key.objectid; 1100 __entry->buf_start = buf->start; 1101 __entry->refs = atomic_read(&buf->refs); 1102 __entry->cow_start = cow->start; 1103 __entry->buf_level = btrfs_header_level(buf); 1104 __entry->cow_level = btrfs_header_level(cow); 1105 ), 1106 1107 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu " 1108 "(orig_level=%d) cow_buf=%llu (cow_level=%d)", 1109 show_root_type(__entry->root_objectid), 1110 __entry->refs, 1111 __entry->buf_start, 1112 __entry->buf_level, 1113 __entry->cow_start, 1114 __entry->cow_level) 1115 ); 1116 1117 TRACE_EVENT(btrfs_space_reservation, 1118 1119 TP_PROTO(const struct btrfs_fs_info *fs_info, const char *type, u64 val, 1120 u64 bytes, int reserve), 1121 1122 TP_ARGS(fs_info, type, val, bytes, reserve), 1123 1124 TP_STRUCT__entry_btrfs( 1125 __string( type, type ) 1126 __field( u64, val ) 1127 __field( u64, bytes ) 1128 __field( int, reserve ) 1129 ), 1130 1131 TP_fast_assign_btrfs(fs_info, 1132 __assign_str(type); 1133 __entry->val = val; 1134 __entry->bytes = bytes; 1135 __entry->reserve = reserve; 1136 ), 1137 1138 TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val, 1139 __entry->reserve ? "reserve" : "release", 1140 __entry->bytes) 1141 ); 1142 1143 TRACE_EVENT(btrfs_trigger_flush, 1144 1145 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 1146 int flush, const char *reason), 1147 1148 TP_ARGS(fs_info, flags, bytes, flush, reason), 1149 1150 TP_STRUCT__entry_btrfs( 1151 __field( u64, flags ) 1152 __field( u64, bytes ) 1153 __field( int, flush ) 1154 __string( reason, reason ) 1155 ), 1156 1157 TP_fast_assign_btrfs(fs_info, 1158 __entry->flags = flags; 1159 __entry->bytes = bytes; 1160 __entry->flush = flush; 1161 __assign_str(reason); 1162 ), 1163 1164 TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu", 1165 __get_str(reason), __entry->flush, 1166 __print_symbolic(__entry->flush, FLUSH_ACTIONS), 1167 __entry->flags, 1168 __print_flags((unsigned long)__entry->flags, "|", 1169 BTRFS_GROUP_FLAGS), 1170 __entry->bytes) 1171 ); 1172 1173 1174 TRACE_EVENT(btrfs_flush_space, 1175 1176 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, 1177 int state, int ret, bool for_preempt), 1178 1179 TP_ARGS(fs_info, flags, num_bytes, state, ret, for_preempt), 1180 1181 TP_STRUCT__entry_btrfs( 1182 __field( u64, flags ) 1183 __field( u64, num_bytes ) 1184 __field( int, state ) 1185 __field( int, ret ) 1186 __field( bool, for_preempt ) 1187 ), 1188 1189 TP_fast_assign_btrfs(fs_info, 1190 __entry->flags = flags; 1191 __entry->num_bytes = num_bytes; 1192 __entry->state = state; 1193 __entry->ret = ret; 1194 __entry->for_preempt = for_preempt; 1195 ), 1196 1197 TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d for_preempt=%d", 1198 __entry->state, 1199 __print_symbolic(__entry->state, FLUSH_STATES), 1200 __entry->flags, 1201 __print_flags((unsigned long)__entry->flags, "|", 1202 BTRFS_GROUP_FLAGS), 1203 __entry->num_bytes, __entry->ret, __entry->for_preempt) 1204 ); 1205 1206 DECLARE_EVENT_CLASS(btrfs__reserved_extent, 1207 1208 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 1209 1210 TP_ARGS(fs_info, start, len), 1211 1212 TP_STRUCT__entry_btrfs( 1213 __field( u64, start ) 1214 __field( u64, len ) 1215 ), 1216 1217 TP_fast_assign_btrfs(fs_info, 1218 __entry->start = start; 1219 __entry->len = len; 1220 ), 1221 1222 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu", 1223 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1224 __entry->start, 1225 __entry->len) 1226 ); 1227 1228 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 1229 1230 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 1231 1232 TP_ARGS(fs_info, start, len) 1233 ); 1234 1235 DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 1236 1237 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 1238 1239 TP_ARGS(fs_info, start, len) 1240 ); 1241 1242 TRACE_EVENT(find_free_extent, 1243 1244 TP_PROTO(const struct btrfs_root *root, 1245 const struct find_free_extent_ctl *ffe_ctl), 1246 1247 TP_ARGS(root, ffe_ctl), 1248 1249 TP_STRUCT__entry_btrfs( 1250 __field( u64, root_objectid ) 1251 __field( u64, num_bytes ) 1252 __field( u64, empty_size ) 1253 __field( u64, flags ) 1254 ), 1255 1256 TP_fast_assign_btrfs(root->fs_info, 1257 __entry->root_objectid = root->root_key.objectid; 1258 __entry->num_bytes = ffe_ctl->num_bytes; 1259 __entry->empty_size = ffe_ctl->empty_size; 1260 __entry->flags = ffe_ctl->flags; 1261 ), 1262 1263 TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)", 1264 show_root_type(__entry->root_objectid), 1265 __entry->num_bytes, __entry->empty_size, __entry->flags, 1266 __print_flags((unsigned long)__entry->flags, "|", 1267 BTRFS_GROUP_FLAGS)) 1268 ); 1269 1270 TRACE_EVENT(find_free_extent_search_loop, 1271 1272 TP_PROTO(const struct btrfs_root *root, 1273 const struct find_free_extent_ctl *ffe_ctl), 1274 1275 TP_ARGS(root, ffe_ctl), 1276 1277 TP_STRUCT__entry_btrfs( 1278 __field( u64, root_objectid ) 1279 __field( u64, num_bytes ) 1280 __field( u64, empty_size ) 1281 __field( u64, flags ) 1282 __field( u64, loop ) 1283 ), 1284 1285 TP_fast_assign_btrfs(root->fs_info, 1286 __entry->root_objectid = root->root_key.objectid; 1287 __entry->num_bytes = ffe_ctl->num_bytes; 1288 __entry->empty_size = ffe_ctl->empty_size; 1289 __entry->flags = ffe_ctl->flags; 1290 __entry->loop = ffe_ctl->loop; 1291 ), 1292 1293 TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s) loop=%llu", 1294 show_root_type(__entry->root_objectid), 1295 __entry->num_bytes, __entry->empty_size, __entry->flags, 1296 __print_flags((unsigned long)__entry->flags, "|", BTRFS_GROUP_FLAGS), 1297 __entry->loop) 1298 ); 1299 1300 TRACE_EVENT(find_free_extent_have_block_group, 1301 1302 TP_PROTO(const struct btrfs_root *root, 1303 const struct find_free_extent_ctl *ffe_ctl, 1304 const struct btrfs_block_group *block_group), 1305 1306 TP_ARGS(root, ffe_ctl, block_group), 1307 1308 TP_STRUCT__entry_btrfs( 1309 __field( u64, root_objectid ) 1310 __field( u64, num_bytes ) 1311 __field( u64, empty_size ) 1312 __field( u64, flags ) 1313 __field( u64, loop ) 1314 __field( bool, hinted ) 1315 __field( u64, bg_start ) 1316 __field( u64, bg_flags ) 1317 ), 1318 1319 TP_fast_assign_btrfs(root->fs_info, 1320 __entry->root_objectid = root->root_key.objectid; 1321 __entry->num_bytes = ffe_ctl->num_bytes; 1322 __entry->empty_size = ffe_ctl->empty_size; 1323 __entry->flags = ffe_ctl->flags; 1324 __entry->loop = ffe_ctl->loop; 1325 __entry->hinted = ffe_ctl->hinted; 1326 __entry->bg_start = block_group->start; 1327 __entry->bg_flags = block_group->flags; 1328 ), 1329 1330 TP_printk_btrfs( 1331 "root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s) loop=%llu hinted=%d block_group=%llu bg_flags=%llu(%s)", 1332 show_root_type(__entry->root_objectid), 1333 __entry->num_bytes, __entry->empty_size, __entry->flags, 1334 __print_flags((unsigned long)__entry->flags, "|", BTRFS_GROUP_FLAGS), 1335 __entry->loop, __entry->hinted, 1336 __entry->bg_start, __entry->bg_flags, 1337 __print_flags((unsigned long)__entry->bg_flags, "|", 1338 BTRFS_GROUP_FLAGS)) 1339 ); 1340 1341 DECLARE_EVENT_CLASS(btrfs__reserve_extent, 1342 1343 TP_PROTO(const struct btrfs_block_group *block_group, 1344 const struct find_free_extent_ctl *ffe_ctl), 1345 1346 TP_ARGS(block_group, ffe_ctl), 1347 1348 TP_STRUCT__entry_btrfs( 1349 __field( u64, bg_objectid ) 1350 __field( u64, flags ) 1351 __field( int, bg_size_class ) 1352 __field( u64, start ) 1353 __field( u64, len ) 1354 __field( u64, loop ) 1355 __field( bool, hinted ) 1356 __field( int, size_class ) 1357 ), 1358 1359 TP_fast_assign_btrfs(block_group->fs_info, 1360 __entry->bg_objectid = block_group->start; 1361 __entry->flags = block_group->flags; 1362 __entry->bg_size_class = block_group->size_class; 1363 __entry->start = ffe_ctl->search_start; 1364 __entry->len = ffe_ctl->num_bytes; 1365 __entry->loop = ffe_ctl->loop; 1366 __entry->hinted = ffe_ctl->hinted; 1367 __entry->size_class = ffe_ctl->size_class; 1368 ), 1369 1370 TP_printk_btrfs( 1371 "root=%llu(%s) block_group=%llu flags=%llu(%s) bg_size_class=%d start=%llu len=%llu loop=%llu hinted=%d size_class=%d", 1372 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 1373 __entry->bg_objectid, 1374 __entry->flags, __print_flags((unsigned long)__entry->flags, 1375 "|", BTRFS_GROUP_FLAGS), 1376 __entry->bg_size_class, __entry->start, __entry->len, 1377 __entry->loop, __entry->hinted, __entry->size_class) 1378 ); 1379 1380 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 1381 1382 TP_PROTO(const struct btrfs_block_group *block_group, 1383 const struct find_free_extent_ctl *ffe_ctl), 1384 1385 TP_ARGS(block_group, ffe_ctl) 1386 ); 1387 1388 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 1389 1390 TP_PROTO(const struct btrfs_block_group *block_group, 1391 const struct find_free_extent_ctl *ffe_ctl), 1392 1393 TP_ARGS(block_group, ffe_ctl) 1394 ); 1395 1396 TRACE_EVENT(btrfs_find_cluster, 1397 1398 TP_PROTO(const struct btrfs_block_group *block_group, u64 start, 1399 u64 bytes, u64 empty_size, u64 min_bytes), 1400 1401 TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 1402 1403 TP_STRUCT__entry_btrfs( 1404 __field( u64, bg_objectid ) 1405 __field( u64, flags ) 1406 __field( u64, start ) 1407 __field( u64, bytes ) 1408 __field( u64, empty_size ) 1409 __field( u64, min_bytes ) 1410 ), 1411 1412 TP_fast_assign_btrfs(block_group->fs_info, 1413 __entry->bg_objectid = block_group->start; 1414 __entry->flags = block_group->flags; 1415 __entry->start = start; 1416 __entry->bytes = bytes; 1417 __entry->empty_size = empty_size; 1418 __entry->min_bytes = min_bytes; 1419 ), 1420 1421 TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu " 1422 "empty_size=%llu min_bytes=%llu", __entry->bg_objectid, 1423 __entry->flags, 1424 __print_flags((unsigned long)__entry->flags, "|", 1425 BTRFS_GROUP_FLAGS), __entry->start, 1426 __entry->bytes, __entry->empty_size, __entry->min_bytes) 1427 ); 1428 1429 TRACE_EVENT(btrfs_failed_cluster_setup, 1430 1431 TP_PROTO(const struct btrfs_block_group *block_group), 1432 1433 TP_ARGS(block_group), 1434 1435 TP_STRUCT__entry_btrfs( 1436 __field( u64, bg_objectid ) 1437 ), 1438 1439 TP_fast_assign_btrfs(block_group->fs_info, 1440 __entry->bg_objectid = block_group->start; 1441 ), 1442 1443 TP_printk_btrfs("block_group=%llu", __entry->bg_objectid) 1444 ); 1445 1446 TRACE_EVENT(btrfs_setup_cluster, 1447 1448 TP_PROTO(const struct btrfs_block_group *block_group, 1449 const struct btrfs_free_cluster *cluster, 1450 u64 size, int bitmap), 1451 1452 TP_ARGS(block_group, cluster, size, bitmap), 1453 1454 TP_STRUCT__entry_btrfs( 1455 __field( u64, bg_objectid ) 1456 __field( u64, flags ) 1457 __field( u64, start ) 1458 __field( u64, max_size ) 1459 __field( u64, size ) 1460 __field( int, bitmap ) 1461 ), 1462 1463 TP_fast_assign_btrfs(block_group->fs_info, 1464 __entry->bg_objectid = block_group->start; 1465 __entry->flags = block_group->flags; 1466 __entry->start = cluster->window_start; 1467 __entry->max_size = cluster->max_size; 1468 __entry->size = size; 1469 __entry->bitmap = bitmap; 1470 ), 1471 1472 TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu " 1473 "size=%llu max_size=%llu bitmap=%d", 1474 __entry->bg_objectid, 1475 __entry->flags, 1476 __print_flags((unsigned long)__entry->flags, "|", 1477 BTRFS_GROUP_FLAGS), __entry->start, 1478 __entry->size, __entry->max_size, __entry->bitmap) 1479 ); 1480 1481 struct extent_state; 1482 TRACE_EVENT(alloc_extent_state, 1483 1484 TP_PROTO(const struct extent_state *state, 1485 gfp_t mask, unsigned long IP), 1486 1487 TP_ARGS(state, mask, IP), 1488 1489 TP_STRUCT__entry( 1490 __field(const struct extent_state *, state) 1491 __field(unsigned long, mask) 1492 __field(const void*, ip) 1493 ), 1494 1495 TP_fast_assign( 1496 __entry->state = state, 1497 __entry->mask = (__force unsigned long)mask, 1498 __entry->ip = (const void *)IP 1499 ), 1500 1501 TP_printk("state=%p mask=%s caller=%pS", __entry->state, 1502 show_gfp_flags(__entry->mask), __entry->ip) 1503 ); 1504 1505 TRACE_EVENT(free_extent_state, 1506 1507 TP_PROTO(const struct extent_state *state, unsigned long IP), 1508 1509 TP_ARGS(state, IP), 1510 1511 TP_STRUCT__entry( 1512 __field(const struct extent_state *, state) 1513 __field(const void*, ip) 1514 ), 1515 1516 TP_fast_assign( 1517 __entry->state = state, 1518 __entry->ip = (const void *)IP 1519 ), 1520 1521 TP_printk("state=%p caller=%pS", __entry->state, __entry->ip) 1522 ); 1523 1524 DECLARE_EVENT_CLASS(btrfs__work, 1525 1526 TP_PROTO(const struct btrfs_work *work), 1527 1528 TP_ARGS(work), 1529 1530 TP_STRUCT__entry_btrfs( 1531 __field( const void *, work ) 1532 __field( const void *, wq ) 1533 __field( const void *, func ) 1534 __field( const void *, ordered_func ) 1535 __field( const void *, normal_work ) 1536 ), 1537 1538 TP_fast_assign_btrfs(btrfs_work_owner(work), 1539 __entry->work = work; 1540 __entry->wq = work->wq; 1541 __entry->func = work->func; 1542 __entry->ordered_func = work->ordered_func; 1543 __entry->normal_work = &work->normal_work; 1544 ), 1545 1546 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p", 1547 __entry->work, __entry->normal_work, __entry->wq, 1548 __entry->func, __entry->ordered_func) 1549 ); 1550 1551 /* 1552 * For situations when the work is freed, we pass fs_info and a tag that matches 1553 * the address of the work structure so it can be paired with the scheduling 1554 * event. DO NOT add anything here that dereferences wtag. 1555 */ 1556 DECLARE_EVENT_CLASS(btrfs__work__done, 1557 1558 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 1559 1560 TP_ARGS(fs_info, wtag), 1561 1562 TP_STRUCT__entry_btrfs( 1563 __field( const void *, wtag ) 1564 ), 1565 1566 TP_fast_assign_btrfs(fs_info, 1567 __entry->wtag = wtag; 1568 ), 1569 1570 TP_printk_btrfs("work->%p", __entry->wtag) 1571 ); 1572 1573 DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1574 1575 TP_PROTO(const struct btrfs_work *work), 1576 1577 TP_ARGS(work) 1578 ); 1579 1580 DEFINE_EVENT(btrfs__work, btrfs_work_sched, 1581 1582 TP_PROTO(const struct btrfs_work *work), 1583 1584 TP_ARGS(work) 1585 ); 1586 1587 DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1588 1589 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 1590 1591 TP_ARGS(fs_info, wtag) 1592 ); 1593 1594 DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1595 1596 TP_PROTO(const struct btrfs_work *work), 1597 1598 TP_ARGS(work) 1599 ); 1600 1601 DECLARE_EVENT_CLASS(btrfs_workqueue, 1602 1603 TP_PROTO(const struct btrfs_workqueue *wq, const char *name), 1604 1605 TP_ARGS(wq, name), 1606 1607 TP_STRUCT__entry_btrfs( 1608 __field( const void *, wq ) 1609 __string( name, name ) 1610 ), 1611 1612 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1613 __entry->wq = wq; 1614 __assign_str(name); 1615 ), 1616 1617 TP_printk_btrfs("name=%s wq=%p", __get_str(name), 1618 __entry->wq) 1619 ); 1620 1621 DEFINE_EVENT(btrfs_workqueue, btrfs_workqueue_alloc, 1622 1623 TP_PROTO(const struct btrfs_workqueue *wq, const char *name), 1624 1625 TP_ARGS(wq, name) 1626 ); 1627 1628 DECLARE_EVENT_CLASS(btrfs_workqueue_done, 1629 1630 TP_PROTO(const struct btrfs_workqueue *wq), 1631 1632 TP_ARGS(wq), 1633 1634 TP_STRUCT__entry_btrfs( 1635 __field( const void *, wq ) 1636 ), 1637 1638 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1639 __entry->wq = wq; 1640 ), 1641 1642 TP_printk_btrfs("wq=%p", __entry->wq) 1643 ); 1644 1645 DEFINE_EVENT(btrfs_workqueue_done, btrfs_workqueue_destroy, 1646 1647 TP_PROTO(const struct btrfs_workqueue *wq), 1648 1649 TP_ARGS(wq) 1650 ); 1651 1652 #define BTRFS_QGROUP_OPERATIONS \ 1653 { QGROUP_RESERVE, "reserve" }, \ 1654 { QGROUP_RELEASE, "release" }, \ 1655 { QGROUP_FREE, "free" } 1656 1657 DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data, 1658 1659 TP_PROTO(const struct inode *inode, u64 start, u64 len, 1660 u64 reserved, int op), 1661 1662 TP_ARGS(inode, start, len, reserved, op), 1663 1664 TP_STRUCT__entry_btrfs( 1665 __field( u64, rootid ) 1666 __field( u64, ino ) 1667 __field( u64, start ) 1668 __field( u64, len ) 1669 __field( u64, reserved ) 1670 __field( int, op ) 1671 ), 1672 1673 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 1674 __entry->rootid = 1675 BTRFS_I(inode)->root->root_key.objectid; 1676 __entry->ino = btrfs_ino(BTRFS_I(inode)); 1677 __entry->start = start; 1678 __entry->len = len; 1679 __entry->reserved = reserved; 1680 __entry->op = op; 1681 ), 1682 1683 TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s", 1684 __entry->rootid, __entry->ino, __entry->start, __entry->len, 1685 __entry->reserved, 1686 __print_flags((unsigned long)__entry->op, "", 1687 BTRFS_QGROUP_OPERATIONS) 1688 ) 1689 ); 1690 1691 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data, 1692 1693 TP_PROTO(const struct inode *inode, u64 start, u64 len, 1694 u64 reserved, int op), 1695 1696 TP_ARGS(inode, start, len, reserved, op) 1697 ); 1698 1699 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data, 1700 1701 TP_PROTO(const struct inode *inode, u64 start, u64 len, 1702 u64 reserved, int op), 1703 1704 TP_ARGS(inode, start, len, reserved, op) 1705 ); 1706 1707 DECLARE_EVENT_CLASS(btrfs_qgroup_extent, 1708 TP_PROTO(const struct btrfs_fs_info *fs_info, 1709 const struct btrfs_qgroup_extent_record *rec, 1710 u64 bytenr), 1711 1712 TP_ARGS(fs_info, rec, bytenr), 1713 1714 TP_STRUCT__entry_btrfs( 1715 __field( u64, bytenr ) 1716 __field( u64, num_bytes ) 1717 ), 1718 1719 TP_fast_assign_btrfs(fs_info, 1720 __entry->bytenr = bytenr; 1721 __entry->num_bytes = rec->num_bytes; 1722 ), 1723 1724 TP_printk_btrfs("bytenr=%llu num_bytes=%llu", 1725 __entry->bytenr, __entry->num_bytes) 1726 ); 1727 1728 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents, 1729 1730 TP_PROTO(const struct btrfs_fs_info *fs_info, 1731 const struct btrfs_qgroup_extent_record *rec, 1732 u64 bytenr), 1733 1734 TP_ARGS(fs_info, rec, bytenr) 1735 ); 1736 1737 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent, 1738 1739 TP_PROTO(const struct btrfs_fs_info *fs_info, 1740 const struct btrfs_qgroup_extent_record *rec, 1741 u64 bytenr), 1742 1743 TP_ARGS(fs_info, rec, bytenr) 1744 ); 1745 1746 TRACE_EVENT(qgroup_num_dirty_extents, 1747 1748 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, 1749 u64 num_dirty_extents), 1750 1751 TP_ARGS(fs_info, transid, num_dirty_extents), 1752 1753 TP_STRUCT__entry_btrfs( 1754 __field( u64, transid ) 1755 __field( u64, num_dirty_extents ) 1756 ), 1757 1758 TP_fast_assign_btrfs(fs_info, 1759 __entry->transid = transid; 1760 __entry->num_dirty_extents = num_dirty_extents; 1761 ), 1762 1763 TP_printk_btrfs("transid=%llu num_dirty_extents=%llu", 1764 __entry->transid, __entry->num_dirty_extents) 1765 ); 1766 1767 TRACE_EVENT(btrfs_qgroup_account_extent, 1768 1769 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr, 1770 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots), 1771 1772 TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots, 1773 nr_new_roots), 1774 1775 TP_STRUCT__entry_btrfs( 1776 __field( u64, transid ) 1777 __field( u64, bytenr ) 1778 __field( u64, num_bytes ) 1779 __field( u64, nr_old_roots ) 1780 __field( u64, nr_new_roots ) 1781 ), 1782 1783 TP_fast_assign_btrfs(fs_info, 1784 __entry->transid = transid; 1785 __entry->bytenr = bytenr; 1786 __entry->num_bytes = num_bytes; 1787 __entry->nr_old_roots = nr_old_roots; 1788 __entry->nr_new_roots = nr_new_roots; 1789 ), 1790 1791 TP_printk_btrfs( 1792 "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu", 1793 __entry->transid, 1794 __entry->bytenr, 1795 __entry->num_bytes, 1796 __entry->nr_old_roots, 1797 __entry->nr_new_roots) 1798 ); 1799 1800 TRACE_EVENT(qgroup_update_counters, 1801 1802 TP_PROTO(const struct btrfs_fs_info *fs_info, 1803 const struct btrfs_qgroup *qgroup, 1804 u64 cur_old_count, u64 cur_new_count), 1805 1806 TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count), 1807 1808 TP_STRUCT__entry_btrfs( 1809 __field( u64, qgid ) 1810 __field( u64, old_rfer ) 1811 __field( u64, old_excl ) 1812 __field( u64, cur_old_count ) 1813 __field( u64, cur_new_count ) 1814 ), 1815 1816 TP_fast_assign_btrfs(fs_info, 1817 __entry->qgid = qgroup->qgroupid; 1818 __entry->old_rfer = qgroup->rfer; 1819 __entry->old_excl = qgroup->excl; 1820 __entry->cur_old_count = cur_old_count; 1821 __entry->cur_new_count = cur_new_count; 1822 ), 1823 1824 TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu", 1825 __entry->qgid, __entry->old_rfer, __entry->old_excl, 1826 __entry->cur_old_count, __entry->cur_new_count) 1827 ); 1828 1829 TRACE_EVENT(qgroup_update_reserve, 1830 1831 TP_PROTO(const struct btrfs_fs_info *fs_info, const struct btrfs_qgroup *qgroup, 1832 s64 diff, int type), 1833 1834 TP_ARGS(fs_info, qgroup, diff, type), 1835 1836 TP_STRUCT__entry_btrfs( 1837 __field( u64, qgid ) 1838 __field( u64, cur_reserved ) 1839 __field( s64, diff ) 1840 __field( int, type ) 1841 ), 1842 1843 TP_fast_assign_btrfs(fs_info, 1844 __entry->qgid = qgroup->qgroupid; 1845 __entry->cur_reserved = qgroup->rsv.values[type]; 1846 __entry->diff = diff; 1847 __entry->type = type; 1848 ), 1849 1850 TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld", 1851 __entry->qgid, __print_symbolic(__entry->type, QGROUP_RSV_TYPES), 1852 __entry->cur_reserved, __entry->diff) 1853 ); 1854 1855 TRACE_EVENT(qgroup_meta_reserve, 1856 1857 TP_PROTO(const struct btrfs_root *root, s64 diff, int type), 1858 1859 TP_ARGS(root, diff, type), 1860 1861 TP_STRUCT__entry_btrfs( 1862 __field( u64, refroot ) 1863 __field( s64, diff ) 1864 __field( int, type ) 1865 ), 1866 1867 TP_fast_assign_btrfs(root->fs_info, 1868 __entry->refroot = root->root_key.objectid; 1869 __entry->diff = diff; 1870 __entry->type = type; 1871 ), 1872 1873 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 1874 show_root_type(__entry->refroot), 1875 __print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff) 1876 ); 1877 1878 TRACE_EVENT(qgroup_meta_convert, 1879 1880 TP_PROTO(const struct btrfs_root *root, s64 diff), 1881 1882 TP_ARGS(root, diff), 1883 1884 TP_STRUCT__entry_btrfs( 1885 __field( u64, refroot ) 1886 __field( s64, diff ) 1887 ), 1888 1889 TP_fast_assign_btrfs(root->fs_info, 1890 __entry->refroot = root->root_key.objectid; 1891 __entry->diff = diff; 1892 ), 1893 1894 TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld", 1895 show_root_type(__entry->refroot), 1896 __print_symbolic(BTRFS_QGROUP_RSV_META_PREALLOC, QGROUP_RSV_TYPES), 1897 __print_symbolic(BTRFS_QGROUP_RSV_META_PERTRANS, QGROUP_RSV_TYPES), 1898 __entry->diff) 1899 ); 1900 1901 TRACE_EVENT(qgroup_meta_free_all_pertrans, 1902 1903 TP_PROTO(struct btrfs_root *root), 1904 1905 TP_ARGS(root), 1906 1907 TP_STRUCT__entry_btrfs( 1908 __field( u64, refroot ) 1909 __field( s64, diff ) 1910 __field( int, type ) 1911 ), 1912 1913 TP_fast_assign_btrfs(root->fs_info, 1914 __entry->refroot = root->root_key.objectid; 1915 spin_lock(&root->qgroup_meta_rsv_lock); 1916 __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans; 1917 spin_unlock(&root->qgroup_meta_rsv_lock); 1918 __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS; 1919 ), 1920 1921 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 1922 show_root_type(__entry->refroot), 1923 __print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff) 1924 ); 1925 1926 DECLARE_EVENT_CLASS(btrfs__prelim_ref, 1927 TP_PROTO(const struct btrfs_fs_info *fs_info, 1928 const struct prelim_ref *oldref, 1929 const struct prelim_ref *newref, u64 tree_size), 1930 TP_ARGS(fs_info, newref, oldref, tree_size), 1931 1932 TP_STRUCT__entry_btrfs( 1933 __field( u64, root_id ) 1934 __field( u64, objectid ) 1935 __field( u8, type ) 1936 __field( u64, offset ) 1937 __field( int, level ) 1938 __field( int, old_count ) 1939 __field( u64, parent ) 1940 __field( u64, bytenr ) 1941 __field( int, mod_count ) 1942 __field( u64, tree_size ) 1943 ), 1944 1945 TP_fast_assign_btrfs(fs_info, 1946 __entry->root_id = oldref->root_id; 1947 __entry->objectid = oldref->key_for_search.objectid; 1948 __entry->type = oldref->key_for_search.type; 1949 __entry->offset = oldref->key_for_search.offset; 1950 __entry->level = oldref->level; 1951 __entry->old_count = oldref->count; 1952 __entry->parent = oldref->parent; 1953 __entry->bytenr = oldref->wanted_disk_byte; 1954 __entry->mod_count = newref ? newref->count : 0; 1955 __entry->tree_size = tree_size; 1956 ), 1957 1958 TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu", 1959 __entry->root_id, 1960 __entry->objectid, __entry->type, 1961 __entry->offset, __entry->level, 1962 __entry->old_count, __entry->mod_count, 1963 __entry->old_count + __entry->mod_count, 1964 __entry->parent, 1965 __entry->bytenr, 1966 __entry->tree_size) 1967 ); 1968 1969 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge, 1970 TP_PROTO(const struct btrfs_fs_info *fs_info, 1971 const struct prelim_ref *oldref, 1972 const struct prelim_ref *newref, u64 tree_size), 1973 TP_ARGS(fs_info, oldref, newref, tree_size) 1974 ); 1975 1976 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert, 1977 TP_PROTO(const struct btrfs_fs_info *fs_info, 1978 const struct prelim_ref *oldref, 1979 const struct prelim_ref *newref, u64 tree_size), 1980 TP_ARGS(fs_info, oldref, newref, tree_size) 1981 ); 1982 1983 TRACE_EVENT(btrfs_inode_mod_outstanding_extents, 1984 TP_PROTO(const struct btrfs_root *root, u64 ino, int mod, unsigned outstanding), 1985 1986 TP_ARGS(root, ino, mod, outstanding), 1987 1988 TP_STRUCT__entry_btrfs( 1989 __field( u64, root_objectid ) 1990 __field( u64, ino ) 1991 __field( int, mod ) 1992 __field( unsigned, outstanding ) 1993 ), 1994 1995 TP_fast_assign_btrfs(root->fs_info, 1996 __entry->root_objectid = root->root_key.objectid; 1997 __entry->ino = ino; 1998 __entry->mod = mod; 1999 __entry->outstanding = outstanding; 2000 ), 2001 2002 TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d outstanding=%u", 2003 show_root_type(__entry->root_objectid), 2004 __entry->ino, __entry->mod, __entry->outstanding) 2005 ); 2006 2007 DECLARE_EVENT_CLASS(btrfs__block_group, 2008 TP_PROTO(const struct btrfs_block_group *bg_cache), 2009 2010 TP_ARGS(bg_cache), 2011 2012 TP_STRUCT__entry_btrfs( 2013 __field( u64, bytenr ) 2014 __field( u64, len ) 2015 __field( u64, used ) 2016 __field( u64, flags ) 2017 ), 2018 2019 TP_fast_assign_btrfs(bg_cache->fs_info, 2020 __entry->bytenr = bg_cache->start, 2021 __entry->len = bg_cache->length, 2022 __entry->used = bg_cache->used; 2023 __entry->flags = bg_cache->flags; 2024 ), 2025 2026 TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)", 2027 __entry->bytenr, __entry->len, __entry->used, __entry->flags, 2028 __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS)) 2029 ); 2030 2031 DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group, 2032 TP_PROTO(const struct btrfs_block_group *bg_cache), 2033 2034 TP_ARGS(bg_cache) 2035 ); 2036 2037 DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group, 2038 TP_PROTO(const struct btrfs_block_group *bg_cache), 2039 2040 TP_ARGS(bg_cache) 2041 ); 2042 2043 DEFINE_EVENT(btrfs__block_group, btrfs_add_reclaim_block_group, 2044 TP_PROTO(const struct btrfs_block_group *bg_cache), 2045 2046 TP_ARGS(bg_cache) 2047 ); 2048 2049 DEFINE_EVENT(btrfs__block_group, btrfs_reclaim_block_group, 2050 TP_PROTO(const struct btrfs_block_group *bg_cache), 2051 2052 TP_ARGS(bg_cache) 2053 ); 2054 2055 DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group, 2056 TP_PROTO(const struct btrfs_block_group *bg_cache), 2057 2058 TP_ARGS(bg_cache) 2059 ); 2060 2061 TRACE_EVENT(btrfs_set_extent_bit, 2062 TP_PROTO(const struct extent_io_tree *tree, 2063 u64 start, u64 len, unsigned set_bits), 2064 2065 TP_ARGS(tree, start, len, set_bits), 2066 2067 TP_STRUCT__entry_btrfs( 2068 __field( unsigned, owner ) 2069 __field( u64, ino ) 2070 __field( u64, rootid ) 2071 __field( u64, start ) 2072 __field( u64, len ) 2073 __field( unsigned, set_bits) 2074 ), 2075 2076 TP_fast_assign_btrfs(extent_io_tree_to_fs_info(tree), 2077 const struct btrfs_inode *inode = extent_io_tree_to_inode_const(tree); 2078 2079 __entry->owner = tree->owner; 2080 __entry->ino = inode ? btrfs_ino(inode) : 0; 2081 __entry->rootid = inode ? inode->root->root_key.objectid : 0; 2082 __entry->start = start; 2083 __entry->len = len; 2084 __entry->set_bits = set_bits; 2085 ), 2086 2087 TP_printk_btrfs( 2088 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s", 2089 __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino, 2090 __entry->rootid, __entry->start, __entry->len, 2091 __print_flags(__entry->set_bits, "|", EXTENT_FLAGS)) 2092 ); 2093 2094 TRACE_EVENT(btrfs_clear_extent_bit, 2095 TP_PROTO(const struct extent_io_tree *tree, 2096 u64 start, u64 len, unsigned clear_bits), 2097 2098 TP_ARGS(tree, start, len, clear_bits), 2099 2100 TP_STRUCT__entry_btrfs( 2101 __field( unsigned, owner ) 2102 __field( u64, ino ) 2103 __field( u64, rootid ) 2104 __field( u64, start ) 2105 __field( u64, len ) 2106 __field( unsigned, clear_bits) 2107 ), 2108 2109 TP_fast_assign_btrfs(extent_io_tree_to_fs_info(tree), 2110 const struct btrfs_inode *inode = extent_io_tree_to_inode_const(tree); 2111 2112 __entry->owner = tree->owner; 2113 __entry->ino = inode ? btrfs_ino(inode) : 0; 2114 __entry->rootid = inode ? inode->root->root_key.objectid : 0; 2115 __entry->start = start; 2116 __entry->len = len; 2117 __entry->clear_bits = clear_bits; 2118 ), 2119 2120 TP_printk_btrfs( 2121 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s", 2122 __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino, 2123 __entry->rootid, __entry->start, __entry->len, 2124 __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 2125 ); 2126 2127 TRACE_EVENT(btrfs_convert_extent_bit, 2128 TP_PROTO(const struct extent_io_tree *tree, 2129 u64 start, u64 len, unsigned set_bits, unsigned clear_bits), 2130 2131 TP_ARGS(tree, start, len, set_bits, clear_bits), 2132 2133 TP_STRUCT__entry_btrfs( 2134 __field( unsigned, owner ) 2135 __field( u64, ino ) 2136 __field( u64, rootid ) 2137 __field( u64, start ) 2138 __field( u64, len ) 2139 __field( unsigned, set_bits) 2140 __field( unsigned, clear_bits) 2141 ), 2142 2143 TP_fast_assign_btrfs(extent_io_tree_to_fs_info(tree), 2144 const struct btrfs_inode *inode = extent_io_tree_to_inode_const(tree); 2145 2146 __entry->owner = tree->owner; 2147 __entry->ino = inode ? btrfs_ino(inode) : 0; 2148 __entry->rootid = inode ? inode->root->root_key.objectid : 0; 2149 __entry->start = start; 2150 __entry->len = len; 2151 __entry->set_bits = set_bits; 2152 __entry->clear_bits = clear_bits; 2153 ), 2154 2155 TP_printk_btrfs( 2156 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s", 2157 __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino, 2158 __entry->rootid, __entry->start, __entry->len, 2159 __print_flags(__entry->set_bits , "|", EXTENT_FLAGS), 2160 __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 2161 ); 2162 2163 DECLARE_EVENT_CLASS(btrfs_dump_space_info, 2164 TP_PROTO(struct btrfs_fs_info *fs_info, 2165 const struct btrfs_space_info *sinfo), 2166 2167 TP_ARGS(fs_info, sinfo), 2168 2169 TP_STRUCT__entry_btrfs( 2170 __field( u64, flags ) 2171 __field( u64, total_bytes ) 2172 __field( u64, bytes_used ) 2173 __field( u64, bytes_pinned ) 2174 __field( u64, bytes_reserved ) 2175 __field( u64, bytes_may_use ) 2176 __field( u64, bytes_readonly ) 2177 __field( u64, reclaim_size ) 2178 __field( int, clamp ) 2179 __field( u64, global_reserved ) 2180 __field( u64, trans_reserved ) 2181 __field( u64, delayed_refs_reserved ) 2182 __field( u64, delayed_reserved ) 2183 __field( u64, free_chunk_space ) 2184 __field( u64, delalloc_bytes ) 2185 __field( u64, ordered_bytes ) 2186 ), 2187 2188 TP_fast_assign_btrfs(fs_info, 2189 __entry->flags = sinfo->flags; 2190 __entry->total_bytes = sinfo->total_bytes; 2191 __entry->bytes_used = sinfo->bytes_used; 2192 __entry->bytes_pinned = sinfo->bytes_pinned; 2193 __entry->bytes_reserved = sinfo->bytes_reserved; 2194 __entry->bytes_may_use = sinfo->bytes_may_use; 2195 __entry->bytes_readonly = sinfo->bytes_readonly; 2196 __entry->reclaim_size = sinfo->reclaim_size; 2197 __entry->clamp = sinfo->clamp; 2198 __entry->global_reserved = fs_info->global_block_rsv.reserved; 2199 __entry->trans_reserved = fs_info->trans_block_rsv.reserved; 2200 __entry->delayed_refs_reserved = fs_info->delayed_refs_rsv.reserved; 2201 __entry->delayed_reserved = fs_info->delayed_block_rsv.reserved; 2202 __entry->free_chunk_space = atomic64_read(&fs_info->free_chunk_space); 2203 __entry->delalloc_bytes = percpu_counter_sum_positive(&fs_info->delalloc_bytes); 2204 __entry->ordered_bytes = percpu_counter_sum_positive(&fs_info->ordered_bytes); 2205 ), 2206 2207 TP_printk_btrfs("flags=%s total_bytes=%llu bytes_used=%llu " 2208 "bytes_pinned=%llu bytes_reserved=%llu " 2209 "bytes_may_use=%llu bytes_readonly=%llu " 2210 "reclaim_size=%llu clamp=%d global_reserved=%llu " 2211 "trans_reserved=%llu delayed_refs_reserved=%llu " 2212 "delayed_reserved=%llu chunk_free_space=%llu " 2213 "delalloc_bytes=%llu ordered_bytes=%llu", 2214 __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS), 2215 __entry->total_bytes, __entry->bytes_used, 2216 __entry->bytes_pinned, __entry->bytes_reserved, 2217 __entry->bytes_may_use, __entry->bytes_readonly, 2218 __entry->reclaim_size, __entry->clamp, 2219 __entry->global_reserved, __entry->trans_reserved, 2220 __entry->delayed_refs_reserved, 2221 __entry->delayed_reserved, __entry->free_chunk_space, 2222 __entry->delalloc_bytes, __entry->ordered_bytes) 2223 ); 2224 2225 DEFINE_EVENT(btrfs_dump_space_info, btrfs_done_preemptive_reclaim, 2226 TP_PROTO(struct btrfs_fs_info *fs_info, 2227 const struct btrfs_space_info *sinfo), 2228 TP_ARGS(fs_info, sinfo) 2229 ); 2230 2231 DEFINE_EVENT(btrfs_dump_space_info, btrfs_fail_all_tickets, 2232 TP_PROTO(struct btrfs_fs_info *fs_info, 2233 const struct btrfs_space_info *sinfo), 2234 TP_ARGS(fs_info, sinfo) 2235 ); 2236 2237 TRACE_EVENT(btrfs_reserve_ticket, 2238 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 2239 u64 start_ns, int flush, int error), 2240 2241 TP_ARGS(fs_info, flags, bytes, start_ns, flush, error), 2242 2243 TP_STRUCT__entry_btrfs( 2244 __field( u64, flags ) 2245 __field( u64, bytes ) 2246 __field( u64, start_ns ) 2247 __field( int, flush ) 2248 __field( int, error ) 2249 ), 2250 2251 TP_fast_assign_btrfs(fs_info, 2252 __entry->flags = flags; 2253 __entry->bytes = bytes; 2254 __entry->start_ns = start_ns; 2255 __entry->flush = flush; 2256 __entry->error = error; 2257 ), 2258 2259 TP_printk_btrfs("flags=%s bytes=%llu start_ns=%llu flush=%s error=%d", 2260 __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS), 2261 __entry->bytes, __entry->start_ns, 2262 __print_symbolic(__entry->flush, FLUSH_ACTIONS), 2263 __entry->error) 2264 ); 2265 2266 DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock, 2267 TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 2268 2269 TP_ARGS(eb, start_ns), 2270 2271 TP_STRUCT__entry_btrfs( 2272 __field( u64, block ) 2273 __field( u64, generation ) 2274 __field( u64, start_ns ) 2275 __field( u64, end_ns ) 2276 __field( u64, diff_ns ) 2277 __field( u64, owner ) 2278 __field( int, is_log_tree ) 2279 ), 2280 2281 TP_fast_assign_btrfs(eb->fs_info, 2282 __entry->block = eb->start; 2283 __entry->generation = btrfs_header_generation(eb); 2284 __entry->start_ns = start_ns; 2285 __entry->end_ns = ktime_get_ns(); 2286 __entry->diff_ns = __entry->end_ns - start_ns; 2287 __entry->owner = btrfs_header_owner(eb); 2288 __entry->is_log_tree = (eb->log_index >= 0); 2289 ), 2290 2291 TP_printk_btrfs( 2292 "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d", 2293 __entry->block, __entry->generation, 2294 __entry->start_ns, __entry->end_ns, __entry->diff_ns, 2295 __entry->owner, __entry->is_log_tree) 2296 ); 2297 2298 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock, 2299 TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 2300 2301 TP_ARGS(eb, start_ns) 2302 ); 2303 2304 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock, 2305 TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 2306 2307 TP_ARGS(eb, start_ns) 2308 ); 2309 2310 DECLARE_EVENT_CLASS(btrfs_locking_events, 2311 TP_PROTO(const struct extent_buffer *eb), 2312 2313 TP_ARGS(eb), 2314 2315 TP_STRUCT__entry_btrfs( 2316 __field( u64, block ) 2317 __field( u64, generation ) 2318 __field( u64, owner ) 2319 __field( int, is_log_tree ) 2320 ), 2321 2322 TP_fast_assign_btrfs(eb->fs_info, 2323 __entry->block = eb->start; 2324 __entry->generation = btrfs_header_generation(eb); 2325 __entry->owner = btrfs_header_owner(eb); 2326 __entry->is_log_tree = (eb->log_index >= 0); 2327 ), 2328 2329 TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d", 2330 __entry->block, __entry->generation, 2331 __entry->owner, __entry->is_log_tree) 2332 ); 2333 2334 #define DEFINE_BTRFS_LOCK_EVENT(name) \ 2335 DEFINE_EVENT(btrfs_locking_events, name, \ 2336 TP_PROTO(const struct extent_buffer *eb), \ 2337 \ 2338 TP_ARGS(eb) \ 2339 ) 2340 2341 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock); 2342 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock); 2343 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking); 2344 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read); 2345 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write); 2346 DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock); 2347 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic); 2348 2349 DECLARE_EVENT_CLASS(btrfs__space_info_update, 2350 2351 TP_PROTO(const struct btrfs_fs_info *fs_info, 2352 const struct btrfs_space_info *sinfo, u64 old, s64 diff), 2353 2354 TP_ARGS(fs_info, sinfo, old, diff), 2355 2356 TP_STRUCT__entry_btrfs( 2357 __field( u64, type ) 2358 __field( u64, old ) 2359 __field( s64, diff ) 2360 ), 2361 2362 TP_fast_assign_btrfs(fs_info, 2363 __entry->type = sinfo->flags; 2364 __entry->old = old; 2365 __entry->diff = diff; 2366 ), 2367 TP_printk_btrfs("type=%s old=%llu diff=%lld", 2368 __print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS), 2369 __entry->old, __entry->diff) 2370 ); 2371 2372 DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use, 2373 2374 TP_PROTO(const struct btrfs_fs_info *fs_info, 2375 const struct btrfs_space_info *sinfo, u64 old, s64 diff), 2376 2377 TP_ARGS(fs_info, sinfo, old, diff) 2378 ); 2379 2380 DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned, 2381 2382 TP_PROTO(const struct btrfs_fs_info *fs_info, 2383 const struct btrfs_space_info *sinfo, u64 old, s64 diff), 2384 2385 TP_ARGS(fs_info, sinfo, old, diff) 2386 ); 2387 2388 DEFINE_EVENT(btrfs__space_info_update, update_bytes_zone_unusable, 2389 2390 TP_PROTO(const struct btrfs_fs_info *fs_info, 2391 const struct btrfs_space_info *sinfo, u64 old, s64 diff), 2392 2393 TP_ARGS(fs_info, sinfo, old, diff) 2394 ); 2395 2396 DECLARE_EVENT_CLASS(btrfs_raid56_bio, 2397 2398 TP_PROTO(const struct btrfs_raid_bio *rbio, 2399 const struct bio *bio, 2400 const struct raid56_bio_trace_info *trace_info), 2401 2402 TP_ARGS(rbio, bio, trace_info), 2403 2404 TP_STRUCT__entry_btrfs( 2405 __field( u64, full_stripe ) 2406 __field( u64, physical ) 2407 __field( u64, devid ) 2408 __field( u32, offset ) 2409 __field( u32, len ) 2410 __field( u8, opf ) 2411 __field( u8, total_stripes ) 2412 __field( u8, real_stripes ) 2413 __field( u8, nr_data ) 2414 __field( u8, stripe_nr ) 2415 ), 2416 2417 TP_fast_assign_btrfs(rbio->bioc->fs_info, 2418 __entry->full_stripe = rbio->bioc->full_stripe_logical; 2419 __entry->physical = bio->bi_iter.bi_sector << SECTOR_SHIFT; 2420 __entry->len = bio->bi_iter.bi_size; 2421 __entry->opf = bio_op(bio); 2422 __entry->devid = trace_info->devid; 2423 __entry->offset = trace_info->offset; 2424 __entry->stripe_nr = trace_info->stripe_nr; 2425 __entry->total_stripes = rbio->bioc->num_stripes; 2426 __entry->real_stripes = rbio->real_stripes; 2427 __entry->nr_data = rbio->nr_data; 2428 ), 2429 /* 2430 * For type output, we need to output things like "DATA1" 2431 * (the first data stripe), "DATA2" (the second data stripe), 2432 * "PQ1" (P stripe),"PQ2" (Q stripe), "REPLACE0" (replace target device). 2433 */ 2434 TP_printk_btrfs( 2435 "full_stripe=%llu devid=%lld type=%s%d offset=%d opf=0x%x physical=%llu len=%u", 2436 __entry->full_stripe, __entry->devid, 2437 (__entry->stripe_nr < __entry->nr_data) ? "DATA" : 2438 ((__entry->stripe_nr < __entry->real_stripes) ? "PQ" : 2439 "REPLACE"), 2440 (__entry->stripe_nr < __entry->nr_data) ? 2441 (__entry->stripe_nr + 1) : 2442 ((__entry->stripe_nr < __entry->real_stripes) ? 2443 (__entry->stripe_nr - __entry->nr_data + 1) : 0), 2444 __entry->offset, __entry->opf, __entry->physical, __entry->len) 2445 ); 2446 2447 DEFINE_EVENT(btrfs_raid56_bio, raid56_read, 2448 TP_PROTO(const struct btrfs_raid_bio *rbio, 2449 const struct bio *bio, 2450 const struct raid56_bio_trace_info *trace_info), 2451 2452 TP_ARGS(rbio, bio, trace_info) 2453 ); 2454 2455 DEFINE_EVENT(btrfs_raid56_bio, raid56_write, 2456 TP_PROTO(const struct btrfs_raid_bio *rbio, 2457 const struct bio *bio, 2458 const struct raid56_bio_trace_info *trace_info), 2459 2460 TP_ARGS(rbio, bio, trace_info) 2461 ); 2462 2463 TRACE_EVENT(btrfs_insert_one_raid_extent, 2464 2465 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 logical, u64 length, 2466 int num_stripes), 2467 2468 TP_ARGS(fs_info, logical, length, num_stripes), 2469 2470 TP_STRUCT__entry_btrfs( 2471 __field( u64, logical ) 2472 __field( u64, length ) 2473 __field( int, num_stripes ) 2474 ), 2475 2476 TP_fast_assign_btrfs(fs_info, 2477 __entry->logical = logical; 2478 __entry->length = length; 2479 __entry->num_stripes = num_stripes; 2480 ), 2481 2482 TP_printk_btrfs("logical=%llu length=%llu num_stripes=%d", 2483 __entry->logical, __entry->length, 2484 __entry->num_stripes) 2485 ); 2486 2487 TRACE_EVENT(btrfs_raid_extent_delete, 2488 2489 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 end, 2490 u64 found_start, u64 found_end), 2491 2492 TP_ARGS(fs_info, start, end, found_start, found_end), 2493 2494 TP_STRUCT__entry_btrfs( 2495 __field( u64, start ) 2496 __field( u64, end ) 2497 __field( u64, found_start ) 2498 __field( u64, found_end ) 2499 ), 2500 2501 TP_fast_assign_btrfs(fs_info, 2502 __entry->start = start; 2503 __entry->end = end; 2504 __entry->found_start = found_start; 2505 __entry->found_end = found_end; 2506 ), 2507 2508 TP_printk_btrfs("start=%llu end=%llu found_start=%llu found_end=%llu", 2509 __entry->start, __entry->end, __entry->found_start, 2510 __entry->found_end) 2511 ); 2512 2513 TRACE_EVENT(btrfs_get_raid_extent_offset, 2514 2515 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 logical, u64 length, 2516 u64 physical, u64 devid), 2517 2518 TP_ARGS(fs_info, logical, length, physical, devid), 2519 2520 TP_STRUCT__entry_btrfs( 2521 __field( u64, logical ) 2522 __field( u64, length ) 2523 __field( u64, physical ) 2524 __field( u64, devid ) 2525 ), 2526 2527 TP_fast_assign_btrfs(fs_info, 2528 __entry->logical = logical; 2529 __entry->length = length; 2530 __entry->physical = physical; 2531 __entry->devid = devid; 2532 ), 2533 2534 TP_printk_btrfs("logical=%llu length=%llu physical=%llu devid=%llu", 2535 __entry->logical, __entry->length, __entry->physical, 2536 __entry->devid) 2537 ); 2538 2539 TRACE_EVENT(btrfs_extent_map_shrinker_count, 2540 2541 TP_PROTO(const struct btrfs_fs_info *fs_info, long nr), 2542 2543 TP_ARGS(fs_info, nr), 2544 2545 TP_STRUCT__entry_btrfs( 2546 __field( long, nr ) 2547 ), 2548 2549 TP_fast_assign_btrfs(fs_info, 2550 __entry->nr = nr; 2551 ), 2552 2553 TP_printk_btrfs("nr=%ld", __entry->nr) 2554 ); 2555 2556 TRACE_EVENT(btrfs_extent_map_shrinker_scan_enter, 2557 2558 TP_PROTO(const struct btrfs_fs_info *fs_info, long nr), 2559 2560 TP_ARGS(fs_info, nr), 2561 2562 TP_STRUCT__entry_btrfs( 2563 __field( long, nr_to_scan ) 2564 __field( long, nr ) 2565 __field( u64, last_root_id ) 2566 __field( u64, last_ino ) 2567 ), 2568 2569 TP_fast_assign_btrfs(fs_info, 2570 __entry->nr_to_scan = \ 2571 atomic64_read(&fs_info->em_shrinker_nr_to_scan); 2572 __entry->nr = nr; 2573 __entry->last_root_id = fs_info->em_shrinker_last_root; 2574 __entry->last_ino = fs_info->em_shrinker_last_ino; 2575 ), 2576 2577 TP_printk_btrfs("nr_to_scan=%ld nr=%ld last_root=%llu(%s) last_ino=%llu", 2578 __entry->nr_to_scan, __entry->nr, 2579 show_root_type(__entry->last_root_id), __entry->last_ino) 2580 ); 2581 2582 TRACE_EVENT(btrfs_extent_map_shrinker_scan_exit, 2583 2584 TP_PROTO(const struct btrfs_fs_info *fs_info, long nr_dropped, long nr), 2585 2586 TP_ARGS(fs_info, nr_dropped, nr), 2587 2588 TP_STRUCT__entry_btrfs( 2589 __field( long, nr_dropped ) 2590 __field( long, nr ) 2591 __field( u64, last_root_id ) 2592 __field( u64, last_ino ) 2593 ), 2594 2595 TP_fast_assign_btrfs(fs_info, 2596 __entry->nr_dropped = nr_dropped; 2597 __entry->nr = nr; 2598 __entry->last_root_id = fs_info->em_shrinker_last_root; 2599 __entry->last_ino = fs_info->em_shrinker_last_ino; 2600 ), 2601 2602 TP_printk_btrfs("nr_dropped=%ld nr=%ld last_root=%llu(%s) last_ino=%llu", 2603 __entry->nr_dropped, __entry->nr, 2604 show_root_type(__entry->last_root_id), __entry->last_ino) 2605 ); 2606 2607 TRACE_EVENT(btrfs_extent_map_shrinker_remove_em, 2608 2609 TP_PROTO(const struct btrfs_inode *inode, const struct extent_map *em), 2610 2611 TP_ARGS(inode, em), 2612 2613 TP_STRUCT__entry_btrfs( 2614 __field( u64, ino ) 2615 __field( u64, root_id ) 2616 __field( u64, start ) 2617 __field( u64, len ) 2618 __field( u32, flags ) 2619 ), 2620 2621 TP_fast_assign_btrfs(inode->root->fs_info, 2622 __entry->ino = btrfs_ino(inode); 2623 __entry->root_id = inode->root->root_key.objectid; 2624 __entry->start = em->start; 2625 __entry->len = em->len; 2626 __entry->flags = em->flags; 2627 ), 2628 2629 TP_printk_btrfs("ino=%llu root=%llu(%s) start=%llu len=%llu flags=%s", 2630 __entry->ino, show_root_type(__entry->root_id), 2631 __entry->start, __entry->len, 2632 show_map_flags(__entry->flags)) 2633 ); 2634 2635 #endif /* _TRACE_BTRFS_H */ 2636 2637 /* This part must be outside protection */ 2638 #include <trace/define_trace.h> 2639