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