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