1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21abe9b8aSliubo #undef TRACE_SYSTEM 31abe9b8aSliubo #define TRACE_SYSTEM btrfs 41abe9b8aSliubo 51abe9b8aSliubo #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ) 61abe9b8aSliubo #define _TRACE_BTRFS_H 71abe9b8aSliubo 81abe9b8aSliubo #include <linux/writeback.h> 91abe9b8aSliubo #include <linux/tracepoint.h> 10420adbe9SVlastimil Babka #include <trace/events/mmflags.h> 111abe9b8aSliubo 121abe9b8aSliubo struct btrfs_root; 131abe9b8aSliubo struct btrfs_fs_info; 141abe9b8aSliubo struct btrfs_inode; 151abe9b8aSliubo struct extent_map; 1609ed2f16SLiu Bo struct btrfs_file_extent_item; 171abe9b8aSliubo struct btrfs_ordered_extent; 181abe9b8aSliubo struct btrfs_delayed_ref_node; 191abe9b8aSliubo struct btrfs_delayed_tree_ref; 201abe9b8aSliubo struct btrfs_delayed_data_ref; 211abe9b8aSliubo struct btrfs_delayed_ref_head; 223f7de037SJosef Bacik struct btrfs_block_group_cache; 233f7de037SJosef Bacik struct btrfs_free_cluster; 241abe9b8aSliubo struct map_lookup; 251abe9b8aSliubo struct extent_buffer; 2652483bc2SQu Wenruo struct btrfs_work; 27c3a46891SQu Wenruo struct __btrfs_workqueue; 280f5dcf8dSMark Fasheh struct btrfs_qgroup_extent_record; 293159fe7bSQu Wenruo struct btrfs_qgroup; 3000142756SJeff Mahoney struct prelim_ref; 311abe9b8aSliubo 32012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR); 33012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS); 34012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELALLOC); 35012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT); 36012e513eSAnand Jain TRACE_DEFINE_ENUM(ALLOC_CHUNK); 37012e513eSAnand Jain TRACE_DEFINE_ENUM(COMMIT_TRANS); 38012e513eSAnand Jain 391abe9b8aSliubo #define show_ref_type(type) \ 401abe9b8aSliubo __print_symbolic(type, \ 411abe9b8aSliubo { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ 421abe9b8aSliubo { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ 431abe9b8aSliubo { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \ 441abe9b8aSliubo { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ 451abe9b8aSliubo { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) 461abe9b8aSliubo 471abe9b8aSliubo #define __show_root_type(obj) \ 487f34b746Sliubo __print_symbolic_u64(obj, \ 491abe9b8aSliubo { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ 501abe9b8aSliubo { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ 511abe9b8aSliubo { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ 521abe9b8aSliubo { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ 531abe9b8aSliubo { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ 541abe9b8aSliubo { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ 551abe9b8aSliubo { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ 561abe9b8aSliubo { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ 57e112e2b4SLiu Bo { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \ 581abe9b8aSliubo { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ 59208acb8cSOmar Sandoval { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \ 60208acb8cSOmar Sandoval { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \ 611abe9b8aSliubo { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) 621abe9b8aSliubo 631abe9b8aSliubo #define show_root_type(obj) \ 641abe9b8aSliubo obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ 65fb57dc81SLiu Bo (obj >= BTRFS_ROOT_TREE_OBJECTID && \ 66e112e2b4SLiu Bo obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-" 671abe9b8aSliubo 6809ed2f16SLiu Bo #define show_fi_type(type) \ 6909ed2f16SLiu Bo __print_symbolic(type, \ 7009ed2f16SLiu Bo { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \ 7109ed2f16SLiu Bo { BTRFS_FILE_EXTENT_REG, "REG" }, \ 7209ed2f16SLiu Bo { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"}) 7309ed2f16SLiu Bo 7464ee4e75SQu Wenruo #define show_qgroup_rsv_type(type) \ 7564ee4e75SQu Wenruo __print_symbolic(type, \ 7664ee4e75SQu Wenruo { BTRFS_QGROUP_RSV_DATA, "DATA" }, \ 7764ee4e75SQu Wenruo { BTRFS_QGROUP_RSV_META, "META" }) 7864ee4e75SQu Wenruo 793f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS \ 803f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \ 813f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 823f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 833f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \ 843f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ 853f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ 86e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 87e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ 88e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} 893f7de037SJosef Bacik 90b94417eaSAnand Jain #define BTRFS_FSID_SIZE 16 91b94417eaSAnand Jain #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE) 92bc074524SJeff Mahoney 93bc074524SJeff Mahoney #define TP_fast_assign_fsid(fs_info) \ 94b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE) 95bc074524SJeff Mahoney 96bc074524SJeff Mahoney #define TP_STRUCT__entry_btrfs(args...) \ 97bc074524SJeff Mahoney TP_STRUCT__entry( \ 98bc074524SJeff Mahoney TP_STRUCT__entry_fsid \ 99bc074524SJeff Mahoney args) 100bc074524SJeff Mahoney #define TP_fast_assign_btrfs(fs_info, args...) \ 101bc074524SJeff Mahoney TP_fast_assign( \ 102bc074524SJeff Mahoney TP_fast_assign_fsid(fs_info); \ 103bc074524SJeff Mahoney args) 104bc074524SJeff Mahoney #define TP_printk_btrfs(fmt, args...) \ 105bc074524SJeff Mahoney TP_printk("%pU: " fmt, __entry->fsid, args) 1068c2a3ca2SJosef Bacik 1071abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit, 1081abe9b8aSliubo 1099a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root), 1101abe9b8aSliubo 1111abe9b8aSliubo TP_ARGS(root), 1121abe9b8aSliubo 113bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 1141abe9b8aSliubo __field( u64, generation ) 1151abe9b8aSliubo __field( u64, root_objectid ) 1161abe9b8aSliubo ), 1171abe9b8aSliubo 118bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 1191abe9b8aSliubo __entry->generation = root->fs_info->generation; 1201abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 1211abe9b8aSliubo ), 1221abe9b8aSliubo 123bc074524SJeff Mahoney TP_printk_btrfs("root = %llu(%s), gen = %llu", 1241abe9b8aSliubo show_root_type(__entry->root_objectid), 1251abe9b8aSliubo (unsigned long long)__entry->generation) 1261abe9b8aSliubo ); 1271abe9b8aSliubo 1281abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode, 1291abe9b8aSliubo 1309a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1311abe9b8aSliubo 1321abe9b8aSliubo TP_ARGS(inode), 1331abe9b8aSliubo 134bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 1351abe9b8aSliubo __field( ino_t, ino ) 1361abe9b8aSliubo __field( blkcnt_t, blocks ) 1371abe9b8aSliubo __field( u64, disk_i_size ) 1381abe9b8aSliubo __field( u64, generation ) 1391abe9b8aSliubo __field( u64, last_trans ) 1401abe9b8aSliubo __field( u64, logged_trans ) 1411abe9b8aSliubo __field( u64, root_objectid ) 1421abe9b8aSliubo ), 1431abe9b8aSliubo 144bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 1451abe9b8aSliubo __entry->ino = inode->i_ino; 1461abe9b8aSliubo __entry->blocks = inode->i_blocks; 1471abe9b8aSliubo __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; 1481abe9b8aSliubo __entry->generation = BTRFS_I(inode)->generation; 1491abe9b8aSliubo __entry->last_trans = BTRFS_I(inode)->last_trans; 1501abe9b8aSliubo __entry->logged_trans = BTRFS_I(inode)->logged_trans; 1511abe9b8aSliubo __entry->root_objectid = 1521abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 1531abe9b8aSliubo ), 1541abe9b8aSliubo 155562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu " 156562a7a07SDavid Sterba "disk_i_size=%llu last_trans=%llu logged_trans=%llu", 1571abe9b8aSliubo show_root_type(__entry->root_objectid), 1581abe9b8aSliubo (unsigned long long)__entry->generation, 1591abe9b8aSliubo (unsigned long)__entry->ino, 1601abe9b8aSliubo (unsigned long long)__entry->blocks, 1611abe9b8aSliubo (unsigned long long)__entry->disk_i_size, 1621abe9b8aSliubo (unsigned long long)__entry->last_trans, 1631abe9b8aSliubo (unsigned long long)__entry->logged_trans) 1641abe9b8aSliubo ); 1651abe9b8aSliubo 1661abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new, 1671abe9b8aSliubo 1689a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1691abe9b8aSliubo 1701abe9b8aSliubo TP_ARGS(inode) 1711abe9b8aSliubo ); 1721abe9b8aSliubo 1731abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request, 1741abe9b8aSliubo 1759a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1761abe9b8aSliubo 1771abe9b8aSliubo TP_ARGS(inode) 1781abe9b8aSliubo ); 1791abe9b8aSliubo 1801abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, 1811abe9b8aSliubo 1829a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1831abe9b8aSliubo 1841abe9b8aSliubo TP_ARGS(inode) 1851abe9b8aSliubo ); 1861abe9b8aSliubo 1871abe9b8aSliubo #define __show_map_type(type) \ 1887f34b746Sliubo __print_symbolic_u64(type, \ 1891abe9b8aSliubo { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ 1901abe9b8aSliubo { EXTENT_MAP_HOLE, "HOLE" }, \ 1911abe9b8aSliubo { EXTENT_MAP_INLINE, "INLINE" }, \ 1921abe9b8aSliubo { EXTENT_MAP_DELALLOC, "DELALLOC" }) 1931abe9b8aSliubo 1941abe9b8aSliubo #define show_map_type(type) \ 1951abe9b8aSliubo type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) 1961abe9b8aSliubo 1971abe9b8aSliubo #define show_map_flags(flag) \ 1981abe9b8aSliubo __print_flags(flag, "|", \ 199254a2d14SLiu Bo { (1 << EXTENT_FLAG_PINNED), "PINNED" },\ 200254a2d14SLiu Bo { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\ 201254a2d14SLiu Bo { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\ 202254a2d14SLiu Bo { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\ 203254a2d14SLiu Bo { (1 << EXTENT_FLAG_FILLING), "FILLING" },\ 204254a2d14SLiu Bo { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" }) 2051abe9b8aSliubo 2064cd8587cSSteven Rostedt TRACE_EVENT_CONDITION(btrfs_get_extent, 2071abe9b8aSliubo 2089a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode, 2099a35b637SJeff Mahoney const struct extent_map *map), 2101abe9b8aSliubo 21192a1bf76SLiu Bo TP_ARGS(root, inode, map), 2121abe9b8aSliubo 2134cd8587cSSteven Rostedt TP_CONDITION(map), 2144cd8587cSSteven Rostedt 215bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 2161abe9b8aSliubo __field( u64, root_objectid ) 21792a1bf76SLiu Bo __field( u64, ino ) 2181abe9b8aSliubo __field( u64, start ) 2191abe9b8aSliubo __field( u64, len ) 2201abe9b8aSliubo __field( u64, orig_start ) 2211abe9b8aSliubo __field( u64, block_start ) 2221abe9b8aSliubo __field( u64, block_len ) 2231abe9b8aSliubo __field( unsigned long, flags ) 2241abe9b8aSliubo __field( int, refs ) 2251abe9b8aSliubo __field( unsigned int, compress_type ) 2261abe9b8aSliubo ), 2271abe9b8aSliubo 228bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 2291abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 23092a1bf76SLiu Bo __entry->ino = btrfs_ino(inode); 2311abe9b8aSliubo __entry->start = map->start; 2321abe9b8aSliubo __entry->len = map->len; 2331abe9b8aSliubo __entry->orig_start = map->orig_start; 2341abe9b8aSliubo __entry->block_start = map->block_start; 2351abe9b8aSliubo __entry->block_len = map->block_len; 2361abe9b8aSliubo __entry->flags = map->flags; 237490b54d6SElena Reshetova __entry->refs = refcount_read(&map->refs); 2381abe9b8aSliubo __entry->compress_type = map->compress_type; 2391abe9b8aSliubo ), 2401abe9b8aSliubo 241562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu " 242562a7a07SDavid Sterba "orig_start=%llu block_start=%llu(%s) " 243562a7a07SDavid Sterba "block_len=%llu flags=%s refs=%u " 2441abe9b8aSliubo "compress_type=%u", 2451abe9b8aSliubo show_root_type(__entry->root_objectid), 24692a1bf76SLiu Bo (unsigned long long)__entry->ino, 2471abe9b8aSliubo (unsigned long long)__entry->start, 2481abe9b8aSliubo (unsigned long long)__entry->len, 2491abe9b8aSliubo (unsigned long long)__entry->orig_start, 2501abe9b8aSliubo show_map_type(__entry->block_start), 2511abe9b8aSliubo (unsigned long long)__entry->block_len, 2521abe9b8aSliubo show_map_flags(__entry->flags), 2531abe9b8aSliubo __entry->refs, __entry->compress_type) 2541abe9b8aSliubo ); 2551abe9b8aSliubo 256393da918SLiu Bo TRACE_EVENT(btrfs_handle_em_exist, 257393da918SLiu Bo 258393da918SLiu Bo TP_PROTO(const struct extent_map *existing, const struct extent_map *map, u64 start, u64 len), 259393da918SLiu Bo 260393da918SLiu Bo TP_ARGS(existing, map, start, len), 261393da918SLiu Bo 262393da918SLiu Bo TP_STRUCT__entry( 263393da918SLiu Bo __field( u64, e_start ) 264393da918SLiu Bo __field( u64, e_len ) 265393da918SLiu Bo __field( u64, map_start ) 266393da918SLiu Bo __field( u64, map_len ) 267393da918SLiu Bo __field( u64, start ) 268393da918SLiu Bo __field( u64, len ) 269393da918SLiu Bo ), 270393da918SLiu Bo 271393da918SLiu Bo TP_fast_assign( 272393da918SLiu Bo __entry->e_start = existing->start; 273393da918SLiu Bo __entry->e_len = existing->len; 274393da918SLiu Bo __entry->map_start = map->start; 275393da918SLiu Bo __entry->map_len = map->len; 276393da918SLiu Bo __entry->start = start; 277393da918SLiu Bo __entry->len = len; 278393da918SLiu Bo ), 279393da918SLiu Bo 280393da918SLiu Bo TP_printk("start=%llu len=%llu " 281393da918SLiu Bo "existing(start=%llu len=%llu) " 282393da918SLiu Bo "em(start=%llu len=%llu)", 283393da918SLiu Bo (unsigned long long)__entry->start, 284393da918SLiu Bo (unsigned long long)__entry->len, 285393da918SLiu Bo (unsigned long long)__entry->e_start, 286393da918SLiu Bo (unsigned long long)__entry->e_len, 287393da918SLiu Bo (unsigned long long)__entry->map_start, 288393da918SLiu Bo (unsigned long long)__entry->map_len) 289393da918SLiu Bo ); 290393da918SLiu Bo 29109ed2f16SLiu Bo /* file extent item */ 29209ed2f16SLiu Bo DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular, 29309ed2f16SLiu Bo 29409ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 29509ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 29609ed2f16SLiu Bo 29709ed2f16SLiu Bo TP_ARGS(bi, l, fi, start), 29809ed2f16SLiu Bo 29909ed2f16SLiu Bo TP_STRUCT__entry_btrfs( 30009ed2f16SLiu Bo __field( u64, root_obj ) 30109ed2f16SLiu Bo __field( u64, ino ) 30209ed2f16SLiu Bo __field( loff_t, isize ) 30309ed2f16SLiu Bo __field( u64, disk_isize ) 30409ed2f16SLiu Bo __field( u64, num_bytes ) 30509ed2f16SLiu Bo __field( u64, ram_bytes ) 30609ed2f16SLiu Bo __field( u64, disk_bytenr ) 30709ed2f16SLiu Bo __field( u64, disk_num_bytes ) 30809ed2f16SLiu Bo __field( u64, extent_offset ) 30909ed2f16SLiu Bo __field( u8, extent_type ) 31009ed2f16SLiu Bo __field( u8, compression ) 31109ed2f16SLiu Bo __field( u64, extent_start ) 31209ed2f16SLiu Bo __field( u64, extent_end ) 31309ed2f16SLiu Bo ), 31409ed2f16SLiu Bo 31509ed2f16SLiu Bo TP_fast_assign_btrfs(bi->root->fs_info, 31609ed2f16SLiu Bo __entry->root_obj = bi->root->objectid; 31709ed2f16SLiu Bo __entry->ino = btrfs_ino(bi); 31809ed2f16SLiu Bo __entry->isize = bi->vfs_inode.i_size; 31909ed2f16SLiu Bo __entry->disk_isize = bi->disk_i_size; 32009ed2f16SLiu Bo __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi); 32109ed2f16SLiu Bo __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi); 32209ed2f16SLiu Bo __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi); 32309ed2f16SLiu Bo __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi); 32409ed2f16SLiu Bo __entry->extent_offset = btrfs_file_extent_offset(l, fi); 32509ed2f16SLiu Bo __entry->extent_type = btrfs_file_extent_type(l, fi); 32609ed2f16SLiu Bo __entry->compression = btrfs_file_extent_compression(l, fi); 32709ed2f16SLiu Bo __entry->extent_start = start; 32809ed2f16SLiu Bo __entry->extent_end = (start + __entry->num_bytes); 32909ed2f16SLiu Bo ), 33009ed2f16SLiu Bo 33109ed2f16SLiu Bo TP_printk_btrfs( 33209ed2f16SLiu Bo "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 33309ed2f16SLiu Bo "file extent range=[%llu %llu] " 33409ed2f16SLiu Bo "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu " 33509ed2f16SLiu Bo "disk_num_bytes=%llu extent_offset=%llu type=%s " 33609ed2f16SLiu Bo "compression=%u", 33709ed2f16SLiu Bo show_root_type(__entry->root_obj), __entry->ino, 33809ed2f16SLiu Bo __entry->isize, 33909ed2f16SLiu Bo __entry->disk_isize, __entry->extent_start, 34009ed2f16SLiu Bo __entry->extent_end, __entry->num_bytes, __entry->ram_bytes, 34109ed2f16SLiu Bo __entry->disk_bytenr, __entry->disk_num_bytes, 34209ed2f16SLiu Bo __entry->extent_offset, show_fi_type(__entry->extent_type), 34309ed2f16SLiu Bo __entry->compression) 34409ed2f16SLiu Bo ); 34509ed2f16SLiu Bo 34609ed2f16SLiu Bo DECLARE_EVENT_CLASS( 34709ed2f16SLiu Bo btrfs__file_extent_item_inline, 34809ed2f16SLiu Bo 34909ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 35009ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 35109ed2f16SLiu Bo 35209ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start), 35309ed2f16SLiu Bo 35409ed2f16SLiu Bo TP_STRUCT__entry_btrfs( 35509ed2f16SLiu Bo __field( u64, root_obj ) 35609ed2f16SLiu Bo __field( u64, ino ) 35709ed2f16SLiu Bo __field( loff_t, isize ) 35809ed2f16SLiu Bo __field( u64, disk_isize ) 35909ed2f16SLiu Bo __field( u8, extent_type ) 36009ed2f16SLiu Bo __field( u8, compression ) 36109ed2f16SLiu Bo __field( u64, extent_start ) 36209ed2f16SLiu Bo __field( u64, extent_end ) 36309ed2f16SLiu Bo ), 36409ed2f16SLiu Bo 36509ed2f16SLiu Bo TP_fast_assign_btrfs( 36609ed2f16SLiu Bo bi->root->fs_info, 36709ed2f16SLiu Bo __entry->root_obj = bi->root->objectid; 36809ed2f16SLiu Bo __entry->ino = btrfs_ino(bi); 36909ed2f16SLiu Bo __entry->isize = bi->vfs_inode.i_size; 37009ed2f16SLiu Bo __entry->disk_isize = bi->disk_i_size; 37109ed2f16SLiu Bo __entry->extent_type = btrfs_file_extent_type(l, fi); 37209ed2f16SLiu Bo __entry->compression = btrfs_file_extent_compression(l, fi); 37309ed2f16SLiu Bo __entry->extent_start = start; 37409ed2f16SLiu Bo __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi)); 37509ed2f16SLiu Bo ), 37609ed2f16SLiu Bo 37709ed2f16SLiu Bo TP_printk_btrfs( 37809ed2f16SLiu Bo "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 37909ed2f16SLiu Bo "file extent range=[%llu %llu] " 38009ed2f16SLiu Bo "extent_type=%s compression=%u", 38109ed2f16SLiu Bo show_root_type(__entry->root_obj), __entry->ino, __entry->isize, 38209ed2f16SLiu Bo __entry->disk_isize, __entry->extent_start, 38309ed2f16SLiu Bo __entry->extent_end, show_fi_type(__entry->extent_type), 38409ed2f16SLiu Bo __entry->compression) 38509ed2f16SLiu Bo ); 38609ed2f16SLiu Bo 38709ed2f16SLiu Bo DEFINE_EVENT( 38809ed2f16SLiu Bo btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular, 38909ed2f16SLiu Bo 39009ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 39109ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 39209ed2f16SLiu Bo 39309ed2f16SLiu Bo TP_ARGS(bi, l, fi, start) 39409ed2f16SLiu Bo ); 39509ed2f16SLiu Bo 39609ed2f16SLiu Bo DEFINE_EVENT( 39709ed2f16SLiu Bo btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular, 39809ed2f16SLiu Bo 39909ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 40009ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 40109ed2f16SLiu Bo 40209ed2f16SLiu Bo TP_ARGS(bi, l, fi, start) 40309ed2f16SLiu Bo ); 40409ed2f16SLiu Bo 40509ed2f16SLiu Bo DEFINE_EVENT( 40609ed2f16SLiu Bo btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline, 40709ed2f16SLiu Bo 40809ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 40909ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 41009ed2f16SLiu Bo 41109ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start) 41209ed2f16SLiu Bo ); 41309ed2f16SLiu Bo 41409ed2f16SLiu Bo DEFINE_EVENT( 41509ed2f16SLiu Bo btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline, 41609ed2f16SLiu Bo 41709ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 41809ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 41909ed2f16SLiu Bo 42009ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start) 42109ed2f16SLiu Bo ); 42209ed2f16SLiu Bo 4231abe9b8aSliubo #define show_ordered_flags(flags) \ 4249d04a8ceSLiu Bo __print_flags(flags, "|", \ 4259d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \ 4269d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \ 4279d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \ 4289d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \ 4299d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \ 4309d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \ 4319d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \ 4329d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \ 433792ddef0SLiu Bo { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \ 434792ddef0SLiu Bo { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" }) 435e112e2b4SLiu Bo 4361abe9b8aSliubo 4371abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent, 4381abe9b8aSliubo 4399a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 4409a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 4411abe9b8aSliubo 4421abe9b8aSliubo TP_ARGS(inode, ordered), 4431abe9b8aSliubo 444bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 4451abe9b8aSliubo __field( ino_t, ino ) 4461abe9b8aSliubo __field( u64, file_offset ) 4471abe9b8aSliubo __field( u64, start ) 4481abe9b8aSliubo __field( u64, len ) 4491abe9b8aSliubo __field( u64, disk_len ) 4501abe9b8aSliubo __field( u64, bytes_left ) 4511abe9b8aSliubo __field( unsigned long, flags ) 4521abe9b8aSliubo __field( int, compress_type ) 4531abe9b8aSliubo __field( int, refs ) 4541abe9b8aSliubo __field( u64, root_objectid ) 45578566548SLiu Bo __field( u64, truncated_len ) 4561abe9b8aSliubo ), 4571abe9b8aSliubo 458bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 4591abe9b8aSliubo __entry->ino = inode->i_ino; 4601abe9b8aSliubo __entry->file_offset = ordered->file_offset; 4611abe9b8aSliubo __entry->start = ordered->start; 4621abe9b8aSliubo __entry->len = ordered->len; 4631abe9b8aSliubo __entry->disk_len = ordered->disk_len; 4641abe9b8aSliubo __entry->bytes_left = ordered->bytes_left; 4651abe9b8aSliubo __entry->flags = ordered->flags; 4661abe9b8aSliubo __entry->compress_type = ordered->compress_type; 467e76edab7SElena Reshetova __entry->refs = refcount_read(&ordered->refs); 4681abe9b8aSliubo __entry->root_objectid = 4691abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 47078566548SLiu Bo __entry->truncated_len = ordered->truncated_len; 4711abe9b8aSliubo ), 4721abe9b8aSliubo 473562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu " 474562a7a07SDavid Sterba "start=%llu len=%llu disk_len=%llu " 475562a7a07SDavid Sterba "truncated_len=%llu " 476562a7a07SDavid Sterba "bytes_left=%llu flags=%s compress_type=%d " 4771abe9b8aSliubo "refs=%d", 4781abe9b8aSliubo show_root_type(__entry->root_objectid), 4791abe9b8aSliubo (unsigned long long)__entry->ino, 4801abe9b8aSliubo (unsigned long long)__entry->file_offset, 4811abe9b8aSliubo (unsigned long long)__entry->start, 4821abe9b8aSliubo (unsigned long long)__entry->len, 4831abe9b8aSliubo (unsigned long long)__entry->disk_len, 48478566548SLiu Bo (unsigned long long)__entry->truncated_len, 4851abe9b8aSliubo (unsigned long long)__entry->bytes_left, 4861abe9b8aSliubo show_ordered_flags(__entry->flags), 4871abe9b8aSliubo __entry->compress_type, __entry->refs) 4881abe9b8aSliubo ); 4891abe9b8aSliubo 4901abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, 4911abe9b8aSliubo 4929a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 4939a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 4941abe9b8aSliubo 4951abe9b8aSliubo TP_ARGS(inode, ordered) 4961abe9b8aSliubo ); 4971abe9b8aSliubo 4981abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, 4991abe9b8aSliubo 5009a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 5019a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 5021abe9b8aSliubo 5031abe9b8aSliubo TP_ARGS(inode, ordered) 5041abe9b8aSliubo ); 5051abe9b8aSliubo 5061abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, 5071abe9b8aSliubo 5089a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 5099a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 5101abe9b8aSliubo 5111abe9b8aSliubo TP_ARGS(inode, ordered) 5121abe9b8aSliubo ); 5131abe9b8aSliubo 5141abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, 5151abe9b8aSliubo 5169a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 5179a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 5181abe9b8aSliubo 5191abe9b8aSliubo TP_ARGS(inode, ordered) 5201abe9b8aSliubo ); 5211abe9b8aSliubo 5221abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage, 5231abe9b8aSliubo 5249a35b637SJeff Mahoney TP_PROTO(const struct page *page, const struct inode *inode, 5259a35b637SJeff Mahoney const struct writeback_control *wbc), 5261abe9b8aSliubo 5271abe9b8aSliubo TP_ARGS(page, inode, wbc), 5281abe9b8aSliubo 529bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 5301abe9b8aSliubo __field( ino_t, ino ) 5311abe9b8aSliubo __field( pgoff_t, index ) 5321abe9b8aSliubo __field( long, nr_to_write ) 5331abe9b8aSliubo __field( long, pages_skipped ) 5341abe9b8aSliubo __field( loff_t, range_start ) 5351abe9b8aSliubo __field( loff_t, range_end ) 5361abe9b8aSliubo __field( char, for_kupdate ) 5371abe9b8aSliubo __field( char, for_reclaim ) 5381abe9b8aSliubo __field( char, range_cyclic ) 5391abe9b8aSliubo __field( pgoff_t, writeback_index ) 5401abe9b8aSliubo __field( u64, root_objectid ) 5411abe9b8aSliubo ), 5421abe9b8aSliubo 543bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 5441abe9b8aSliubo __entry->ino = inode->i_ino; 5451abe9b8aSliubo __entry->index = page->index; 5461abe9b8aSliubo __entry->nr_to_write = wbc->nr_to_write; 5471abe9b8aSliubo __entry->pages_skipped = wbc->pages_skipped; 5481abe9b8aSliubo __entry->range_start = wbc->range_start; 5491abe9b8aSliubo __entry->range_end = wbc->range_end; 5501abe9b8aSliubo __entry->for_kupdate = wbc->for_kupdate; 5511abe9b8aSliubo __entry->for_reclaim = wbc->for_reclaim; 5521abe9b8aSliubo __entry->range_cyclic = wbc->range_cyclic; 5531abe9b8aSliubo __entry->writeback_index = inode->i_mapping->writeback_index; 5541abe9b8aSliubo __entry->root_objectid = 5551abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 5561abe9b8aSliubo ), 5571abe9b8aSliubo 558562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu " 559562a7a07SDavid Sterba "nr_to_write=%ld pages_skipped=%ld range_start=%llu " 560562a7a07SDavid Sterba "range_end=%llu for_kupdate=%d " 561562a7a07SDavid Sterba "for_reclaim=%d range_cyclic=%d writeback_index=%lu", 5621abe9b8aSliubo show_root_type(__entry->root_objectid), 5631abe9b8aSliubo (unsigned long)__entry->ino, __entry->index, 5641abe9b8aSliubo __entry->nr_to_write, __entry->pages_skipped, 5651abe9b8aSliubo __entry->range_start, __entry->range_end, 566846d5a09SWu Fengguang __entry->for_kupdate, 5671abe9b8aSliubo __entry->for_reclaim, __entry->range_cyclic, 5681abe9b8aSliubo (unsigned long)__entry->writeback_index) 5691abe9b8aSliubo ); 5701abe9b8aSliubo 5711abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage, 5721abe9b8aSliubo 5739a35b637SJeff Mahoney TP_PROTO(const struct page *page, const struct inode *inode, 5749a35b637SJeff Mahoney const struct writeback_control *wbc), 5751abe9b8aSliubo 5761abe9b8aSliubo TP_ARGS(page, inode, wbc) 5771abe9b8aSliubo ); 5781abe9b8aSliubo 5791abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook, 5801abe9b8aSliubo 5819a35b637SJeff Mahoney TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate), 5821abe9b8aSliubo 5831abe9b8aSliubo TP_ARGS(page, start, end, uptodate), 5841abe9b8aSliubo 585bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 5861abe9b8aSliubo __field( ino_t, ino ) 5871abe9b8aSliubo __field( pgoff_t, index ) 5881abe9b8aSliubo __field( u64, start ) 5891abe9b8aSliubo __field( u64, end ) 5901abe9b8aSliubo __field( int, uptodate ) 5911abe9b8aSliubo __field( u64, root_objectid ) 5921abe9b8aSliubo ), 5931abe9b8aSliubo 594bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb), 5951abe9b8aSliubo __entry->ino = page->mapping->host->i_ino; 5961abe9b8aSliubo __entry->index = page->index; 5971abe9b8aSliubo __entry->start = start; 5981abe9b8aSliubo __entry->end = end; 5991abe9b8aSliubo __entry->uptodate = uptodate; 6001abe9b8aSliubo __entry->root_objectid = 6011abe9b8aSliubo BTRFS_I(page->mapping->host)->root->root_key.objectid; 6021abe9b8aSliubo ), 6031abe9b8aSliubo 604562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu " 605562a7a07SDavid Sterba "end=%llu uptodate=%d", 6061abe9b8aSliubo show_root_type(__entry->root_objectid), 6071abe9b8aSliubo (unsigned long)__entry->ino, (unsigned long)__entry->index, 6081abe9b8aSliubo (unsigned long long)__entry->start, 6091abe9b8aSliubo (unsigned long long)__entry->end, __entry->uptodate) 6101abe9b8aSliubo ); 6111abe9b8aSliubo 6121abe9b8aSliubo TRACE_EVENT(btrfs_sync_file, 6131abe9b8aSliubo 6149a35b637SJeff Mahoney TP_PROTO(const struct file *file, int datasync), 6151abe9b8aSliubo 6161abe9b8aSliubo TP_ARGS(file, datasync), 6171abe9b8aSliubo 618bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 6191abe9b8aSliubo __field( ino_t, ino ) 6201abe9b8aSliubo __field( ino_t, parent ) 6211abe9b8aSliubo __field( int, datasync ) 6221abe9b8aSliubo __field( u64, root_objectid ) 6231abe9b8aSliubo ), 6241abe9b8aSliubo 6251abe9b8aSliubo TP_fast_assign( 6269a35b637SJeff Mahoney const struct dentry *dentry = file->f_path.dentry; 6279a35b637SJeff Mahoney const struct inode *inode = d_inode(dentry); 6281abe9b8aSliubo 629bc074524SJeff Mahoney TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb)); 6301abe9b8aSliubo __entry->ino = inode->i_ino; 6312b0143b5SDavid Howells __entry->parent = d_inode(dentry->d_parent)->i_ino; 6321abe9b8aSliubo __entry->datasync = datasync; 6331abe9b8aSliubo __entry->root_objectid = 6341abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 6351abe9b8aSliubo ), 6361abe9b8aSliubo 637562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d", 6381abe9b8aSliubo show_root_type(__entry->root_objectid), 6391abe9b8aSliubo (unsigned long)__entry->ino, (unsigned long)__entry->parent, 6401abe9b8aSliubo __entry->datasync) 6411abe9b8aSliubo ); 6421abe9b8aSliubo 6431abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs, 6441abe9b8aSliubo 6459a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, int wait), 6461abe9b8aSliubo 647bc074524SJeff Mahoney TP_ARGS(fs_info, wait), 6481abe9b8aSliubo 649bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 6501abe9b8aSliubo __field( int, wait ) 6511abe9b8aSliubo ), 6521abe9b8aSliubo 653bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 6541abe9b8aSliubo __entry->wait = wait; 6551abe9b8aSliubo ), 6561abe9b8aSliubo 657bc074524SJeff Mahoney TP_printk_btrfs("wait = %d", __entry->wait) 6581abe9b8aSliubo ); 6591abe9b8aSliubo 660c83f8effSJosef Bacik TRACE_EVENT(btrfs_add_block_group, 661c83f8effSJosef Bacik 6629a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 6639a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, int create), 664c83f8effSJosef Bacik 665c83f8effSJosef Bacik TP_ARGS(fs_info, block_group, create), 666c83f8effSJosef Bacik 667c83f8effSJosef Bacik TP_STRUCT__entry( 668b94417eaSAnand Jain __array( u8, fsid, BTRFS_FSID_SIZE ) 669c83f8effSJosef Bacik __field( u64, offset ) 670c83f8effSJosef Bacik __field( u64, size ) 671c83f8effSJosef Bacik __field( u64, flags ) 672c83f8effSJosef Bacik __field( u64, bytes_used ) 673c83f8effSJosef Bacik __field( u64, bytes_super ) 674c83f8effSJosef Bacik __field( int, create ) 675c83f8effSJosef Bacik ), 676c83f8effSJosef Bacik 677c83f8effSJosef Bacik TP_fast_assign( 678b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE); 679c83f8effSJosef Bacik __entry->offset = block_group->key.objectid; 680c83f8effSJosef Bacik __entry->size = block_group->key.offset; 681c83f8effSJosef Bacik __entry->flags = block_group->flags; 682c83f8effSJosef Bacik __entry->bytes_used = 683c83f8effSJosef Bacik btrfs_block_group_used(&block_group->item); 684c83f8effSJosef Bacik __entry->bytes_super = block_group->bytes_super; 685c83f8effSJosef Bacik __entry->create = create; 686c83f8effSJosef Bacik ), 687c83f8effSJosef Bacik 688562a7a07SDavid Sterba TP_printk("%pU: block_group offset=%llu size=%llu " 689562a7a07SDavid Sterba "flags=%llu(%s) bytes_used=%llu bytes_super=%llu " 690c83f8effSJosef Bacik "create=%d", __entry->fsid, 691c83f8effSJosef Bacik (unsigned long long)__entry->offset, 692c83f8effSJosef Bacik (unsigned long long)__entry->size, 693c83f8effSJosef Bacik (unsigned long long)__entry->flags, 694c83f8effSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 695c83f8effSJosef Bacik BTRFS_GROUP_FLAGS), 696c83f8effSJosef Bacik (unsigned long long)__entry->bytes_used, 697c83f8effSJosef Bacik (unsigned long long)__entry->bytes_super, __entry->create) 698c83f8effSJosef Bacik ); 699c83f8effSJosef Bacik 7001abe9b8aSliubo #define show_ref_action(action) \ 7011abe9b8aSliubo __print_symbolic(action, \ 7021abe9b8aSliubo { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 7031abe9b8aSliubo { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 7041abe9b8aSliubo { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 7051abe9b8aSliubo { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 7061abe9b8aSliubo 7071abe9b8aSliubo 708599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 7091abe9b8aSliubo 7109a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7119a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7129a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 7131abe9b8aSliubo int action), 7141abe9b8aSliubo 715bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 7161abe9b8aSliubo 717bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 7181abe9b8aSliubo __field( u64, bytenr ) 7191abe9b8aSliubo __field( u64, num_bytes ) 7201abe9b8aSliubo __field( int, action ) 7211abe9b8aSliubo __field( u64, parent ) 7221abe9b8aSliubo __field( u64, ref_root ) 7231abe9b8aSliubo __field( int, level ) 7241abe9b8aSliubo __field( int, type ) 725dea7d76eSLiu Bo __field( u64, seq ) 7261abe9b8aSliubo ), 7271abe9b8aSliubo 728bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 7291abe9b8aSliubo __entry->bytenr = ref->bytenr; 7301abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 7311abe9b8aSliubo __entry->action = action; 7321abe9b8aSliubo __entry->parent = full_ref->parent; 7331abe9b8aSliubo __entry->ref_root = full_ref->root; 7341abe9b8aSliubo __entry->level = full_ref->level; 7351abe9b8aSliubo __entry->type = ref->type; 736dea7d76eSLiu Bo __entry->seq = ref->seq; 7371abe9b8aSliubo ), 7381abe9b8aSliubo 739562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 740562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) level=%d " 741562a7a07SDavid Sterba "type=%s seq=%llu", 7421abe9b8aSliubo (unsigned long long)__entry->bytenr, 7431abe9b8aSliubo (unsigned long long)__entry->num_bytes, 7441abe9b8aSliubo show_ref_action(__entry->action), 7451abe9b8aSliubo show_root_type(__entry->parent), 7461abe9b8aSliubo show_root_type(__entry->ref_root), 747dea7d76eSLiu Bo __entry->level, show_ref_type(__entry->type), 748dea7d76eSLiu Bo (unsigned long long)__entry->seq) 7491abe9b8aSliubo ); 7501abe9b8aSliubo 751599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 752599c75ecSLiu Bo 7539a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7549a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7559a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 756599c75ecSLiu Bo int action), 757599c75ecSLiu Bo 758bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 759599c75ecSLiu Bo ); 760599c75ecSLiu Bo 761599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 762599c75ecSLiu Bo 7639a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7649a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7659a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 766599c75ecSLiu Bo int action), 767599c75ecSLiu Bo 768bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 769599c75ecSLiu Bo ); 770599c75ecSLiu Bo 771599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 7721abe9b8aSliubo 7739a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7749a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7759a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 7761abe9b8aSliubo int action), 7771abe9b8aSliubo 778bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 7791abe9b8aSliubo 780bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 7811abe9b8aSliubo __field( u64, bytenr ) 7821abe9b8aSliubo __field( u64, num_bytes ) 7831abe9b8aSliubo __field( int, action ) 7841abe9b8aSliubo __field( u64, parent ) 7851abe9b8aSliubo __field( u64, ref_root ) 7861abe9b8aSliubo __field( u64, owner ) 7871abe9b8aSliubo __field( u64, offset ) 7881abe9b8aSliubo __field( int, type ) 789dea7d76eSLiu Bo __field( u64, seq ) 7901abe9b8aSliubo ), 7911abe9b8aSliubo 792bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 7931abe9b8aSliubo __entry->bytenr = ref->bytenr; 7941abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 7951abe9b8aSliubo __entry->action = action; 7961abe9b8aSliubo __entry->parent = full_ref->parent; 7971abe9b8aSliubo __entry->ref_root = full_ref->root; 7981abe9b8aSliubo __entry->owner = full_ref->objectid; 7991abe9b8aSliubo __entry->offset = full_ref->offset; 8001abe9b8aSliubo __entry->type = ref->type; 801dea7d76eSLiu Bo __entry->seq = ref->seq; 8021abe9b8aSliubo ), 8031abe9b8aSliubo 804562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 805562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) owner=%llu " 806562a7a07SDavid Sterba "offset=%llu type=%s seq=%llu", 8071abe9b8aSliubo (unsigned long long)__entry->bytenr, 8081abe9b8aSliubo (unsigned long long)__entry->num_bytes, 8091abe9b8aSliubo show_ref_action(__entry->action), 8101abe9b8aSliubo show_root_type(__entry->parent), 8111abe9b8aSliubo show_root_type(__entry->ref_root), 8121abe9b8aSliubo (unsigned long long)__entry->owner, 8131abe9b8aSliubo (unsigned long long)__entry->offset, 814dea7d76eSLiu Bo show_ref_type(__entry->type), 815dea7d76eSLiu Bo (unsigned long long)__entry->seq) 8161abe9b8aSliubo ); 8171abe9b8aSliubo 818599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 819599c75ecSLiu Bo 8209a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8219a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8229a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 823599c75ecSLiu Bo int action), 824599c75ecSLiu Bo 825bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 826599c75ecSLiu Bo ); 827599c75ecSLiu Bo 828599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 829599c75ecSLiu Bo 8309a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8319a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8329a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 833599c75ecSLiu Bo int action), 834599c75ecSLiu Bo 835bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 836599c75ecSLiu Bo ); 837599c75ecSLiu Bo 838599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 8391abe9b8aSliubo 8409a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8419a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 8421abe9b8aSliubo int action), 8431abe9b8aSliubo 844d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action), 8451abe9b8aSliubo 846bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 8471abe9b8aSliubo __field( u64, bytenr ) 8481abe9b8aSliubo __field( u64, num_bytes ) 8491abe9b8aSliubo __field( int, action ) 8501abe9b8aSliubo __field( int, is_data ) 8511abe9b8aSliubo ), 8521abe9b8aSliubo 853bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 854d278850eSJosef Bacik __entry->bytenr = head_ref->bytenr; 855d278850eSJosef Bacik __entry->num_bytes = head_ref->num_bytes; 8561abe9b8aSliubo __entry->action = action; 8571abe9b8aSliubo __entry->is_data = head_ref->is_data; 8581abe9b8aSliubo ), 8591abe9b8aSliubo 860562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d", 8611abe9b8aSliubo (unsigned long long)__entry->bytenr, 8621abe9b8aSliubo (unsigned long long)__entry->num_bytes, 8631abe9b8aSliubo show_ref_action(__entry->action), 8641abe9b8aSliubo __entry->is_data) 8651abe9b8aSliubo ); 8661abe9b8aSliubo 867599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 868599c75ecSLiu Bo 8699a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8709a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 871599c75ecSLiu Bo int action), 872599c75ecSLiu Bo 873d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action) 874599c75ecSLiu Bo ); 875599c75ecSLiu Bo 876599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 877599c75ecSLiu Bo 8789a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8799a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 880599c75ecSLiu Bo int action), 881599c75ecSLiu Bo 882d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action) 883599c75ecSLiu Bo ); 884599c75ecSLiu Bo 8851abe9b8aSliubo #define show_chunk_type(type) \ 8861abe9b8aSliubo __print_flags(type, "|", \ 8871abe9b8aSliubo { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 8881abe9b8aSliubo { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 8891abe9b8aSliubo { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 8901abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 8911abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 8921abe9b8aSliubo { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 893e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 894e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 895e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 8961abe9b8aSliubo 8971abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk, 8981abe9b8aSliubo 8999a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9009a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9011abe9b8aSliubo 9026bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size), 9031abe9b8aSliubo 904bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9051abe9b8aSliubo __field( int, num_stripes ) 9061abe9b8aSliubo __field( u64, type ) 9071abe9b8aSliubo __field( int, sub_stripes ) 9081abe9b8aSliubo __field( u64, offset ) 9091abe9b8aSliubo __field( u64, size ) 9101abe9b8aSliubo __field( u64, root_objectid ) 9111abe9b8aSliubo ), 9121abe9b8aSliubo 9136bccf3abSJeff Mahoney TP_fast_assign_btrfs(fs_info, 9141abe9b8aSliubo __entry->num_stripes = map->num_stripes; 9151abe9b8aSliubo __entry->type = map->type; 9161abe9b8aSliubo __entry->sub_stripes = map->sub_stripes; 9171abe9b8aSliubo __entry->offset = offset; 9181abe9b8aSliubo __entry->size = size; 9196bccf3abSJeff Mahoney __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 9201abe9b8aSliubo ), 9211abe9b8aSliubo 922562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu " 923562a7a07SDavid Sterba "num_stripes=%d sub_stripes=%d type=%s", 9241abe9b8aSliubo show_root_type(__entry->root_objectid), 9251abe9b8aSliubo (unsigned long long)__entry->offset, 9261abe9b8aSliubo (unsigned long long)__entry->size, 9271abe9b8aSliubo __entry->num_stripes, __entry->sub_stripes, 9281abe9b8aSliubo show_chunk_type(__entry->type)) 9291abe9b8aSliubo ); 9301abe9b8aSliubo 9311abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 9321abe9b8aSliubo 9339a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9349a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9351abe9b8aSliubo 9366bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 9371abe9b8aSliubo ); 9381abe9b8aSliubo 9391abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 9401abe9b8aSliubo 9419a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9429a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9431abe9b8aSliubo 9446bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 9451abe9b8aSliubo ); 9461abe9b8aSliubo 9471abe9b8aSliubo TRACE_EVENT(btrfs_cow_block, 9481abe9b8aSliubo 9499a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf, 9509a35b637SJeff Mahoney const struct extent_buffer *cow), 9511abe9b8aSliubo 9521abe9b8aSliubo TP_ARGS(root, buf, cow), 9531abe9b8aSliubo 954bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9551abe9b8aSliubo __field( u64, root_objectid ) 9561abe9b8aSliubo __field( u64, buf_start ) 9571abe9b8aSliubo __field( int, refs ) 9581abe9b8aSliubo __field( u64, cow_start ) 9591abe9b8aSliubo __field( int, buf_level ) 9601abe9b8aSliubo __field( int, cow_level ) 9611abe9b8aSliubo ), 9621abe9b8aSliubo 963bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 9641abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 9651abe9b8aSliubo __entry->buf_start = buf->start; 9661abe9b8aSliubo __entry->refs = atomic_read(&buf->refs); 9671abe9b8aSliubo __entry->cow_start = cow->start; 9681abe9b8aSliubo __entry->buf_level = btrfs_header_level(buf); 9691abe9b8aSliubo __entry->cow_level = btrfs_header_level(cow); 9701abe9b8aSliubo ), 9711abe9b8aSliubo 972562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu " 973562a7a07SDavid Sterba "(orig_level=%d) cow_buf=%llu (cow_level=%d)", 9741abe9b8aSliubo show_root_type(__entry->root_objectid), 9751abe9b8aSliubo __entry->refs, 9761abe9b8aSliubo (unsigned long long)__entry->buf_start, 9771abe9b8aSliubo __entry->buf_level, 9781abe9b8aSliubo (unsigned long long)__entry->cow_start, 9791abe9b8aSliubo __entry->cow_level) 9801abe9b8aSliubo ); 9811abe9b8aSliubo 9828c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation, 9838c2a3ca2SJosef Bacik 9849a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val, 9858c2a3ca2SJosef Bacik u64 bytes, int reserve), 9868c2a3ca2SJosef Bacik 9878c2a3ca2SJosef Bacik TP_ARGS(fs_info, type, val, bytes, reserve), 9888c2a3ca2SJosef Bacik 989bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9908c2a3ca2SJosef Bacik __string( type, type ) 9918c2a3ca2SJosef Bacik __field( u64, val ) 9928c2a3ca2SJosef Bacik __field( u64, bytes ) 9938c2a3ca2SJosef Bacik __field( int, reserve ) 9948c2a3ca2SJosef Bacik ), 9958c2a3ca2SJosef Bacik 996bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 9978c2a3ca2SJosef Bacik __assign_str(type, type); 9988c2a3ca2SJosef Bacik __entry->val = val; 9998c2a3ca2SJosef Bacik __entry->bytes = bytes; 10008c2a3ca2SJosef Bacik __entry->reserve = reserve; 10018c2a3ca2SJosef Bacik ), 10028c2a3ca2SJosef Bacik 1003bc074524SJeff Mahoney TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val, 1004bc074524SJeff Mahoney __entry->reserve ? "reserve" : "release", 10058c2a3ca2SJosef Bacik __entry->bytes) 10068c2a3ca2SJosef Bacik ); 10078c2a3ca2SJosef Bacik 1008f376df2bSJosef Bacik #define show_flush_action(action) \ 1009f376df2bSJosef Bacik __print_symbolic(action, \ 1010f376df2bSJosef Bacik { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ 1011f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ 1012f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) 1013f376df2bSJosef Bacik 1014f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush, 1015f376df2bSJosef Bacik 10169a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 1017f376df2bSJosef Bacik int flush, char *reason), 1018f376df2bSJosef Bacik 1019f376df2bSJosef Bacik TP_ARGS(fs_info, flags, bytes, flush, reason), 1020f376df2bSJosef Bacik 1021f376df2bSJosef Bacik TP_STRUCT__entry( 1022b94417eaSAnand Jain __array( u8, fsid, BTRFS_FSID_SIZE ) 1023f376df2bSJosef Bacik __field( u64, flags ) 1024f376df2bSJosef Bacik __field( u64, bytes ) 1025f376df2bSJosef Bacik __field( int, flush ) 1026f376df2bSJosef Bacik __string( reason, reason ) 1027f376df2bSJosef Bacik ), 1028f376df2bSJosef Bacik 1029f376df2bSJosef Bacik TP_fast_assign( 1030b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE); 1031f376df2bSJosef Bacik __entry->flags = flags; 1032f376df2bSJosef Bacik __entry->bytes = bytes; 1033f376df2bSJosef Bacik __entry->flush = flush; 1034f376df2bSJosef Bacik __assign_str(reason, reason) 1035f376df2bSJosef Bacik ), 1036f376df2bSJosef Bacik 1037562a7a07SDavid Sterba TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu", 1038f376df2bSJosef Bacik __entry->fsid, __get_str(reason), __entry->flush, 1039f376df2bSJosef Bacik show_flush_action(__entry->flush), 1040f376df2bSJosef Bacik (unsigned long long)__entry->flags, 1041f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 1042f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 1043f376df2bSJosef Bacik (unsigned long long)__entry->bytes) 1044f376df2bSJosef Bacik ); 1045f376df2bSJosef Bacik 1046f376df2bSJosef Bacik #define show_flush_state(state) \ 1047f376df2bSJosef Bacik __print_symbolic(state, \ 1048f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ 1049f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ 1050f376df2bSJosef Bacik { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ 1051f376df2bSJosef Bacik { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ 1052f376df2bSJosef Bacik { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ 1053f376df2bSJosef Bacik { COMMIT_TRANS, "COMMIT_TRANS"}) 1054f376df2bSJosef Bacik 1055f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space, 1056f376df2bSJosef Bacik 10579a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, 10587bdd6277SNikolay Borisov int state, int ret), 1059f376df2bSJosef Bacik 10607bdd6277SNikolay Borisov TP_ARGS(fs_info, flags, num_bytes, state, ret), 1061f376df2bSJosef Bacik 1062f376df2bSJosef Bacik TP_STRUCT__entry( 1063b94417eaSAnand Jain __array( u8, fsid, BTRFS_FSID_SIZE ) 1064f376df2bSJosef Bacik __field( u64, flags ) 1065f376df2bSJosef Bacik __field( u64, num_bytes ) 1066f376df2bSJosef Bacik __field( int, state ) 1067f376df2bSJosef Bacik __field( int, ret ) 1068f376df2bSJosef Bacik ), 1069f376df2bSJosef Bacik 1070f376df2bSJosef Bacik TP_fast_assign( 1071b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE); 1072f376df2bSJosef Bacik __entry->flags = flags; 1073f376df2bSJosef Bacik __entry->num_bytes = num_bytes; 1074f376df2bSJosef Bacik __entry->state = state; 1075f376df2bSJosef Bacik __entry->ret = ret; 1076f376df2bSJosef Bacik ), 1077f376df2bSJosef Bacik 10787bdd6277SNikolay Borisov TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d", 10797bdd6277SNikolay Borisov __entry->fsid, __entry->state, 1080f376df2bSJosef Bacik show_flush_state(__entry->state), 1081f376df2bSJosef Bacik (unsigned long long)__entry->flags, 1082f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 1083f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 10847bdd6277SNikolay Borisov (unsigned long long)__entry->num_bytes, __entry->ret) 1085f376df2bSJosef Bacik ); 1086f376df2bSJosef Bacik 10871abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent, 10881abe9b8aSliubo 10899a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 10901abe9b8aSliubo 109171ff6437SJeff Mahoney TP_ARGS(fs_info, start, len), 10921abe9b8aSliubo 1093bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 10941abe9b8aSliubo __field( u64, start ) 10951abe9b8aSliubo __field( u64, len ) 10961abe9b8aSliubo ), 10971abe9b8aSliubo 109871ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 10991abe9b8aSliubo __entry->start = start; 11001abe9b8aSliubo __entry->len = len; 11011abe9b8aSliubo ), 11021abe9b8aSliubo 1103562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu", 110471ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 11051abe9b8aSliubo (unsigned long long)__entry->start, 11061abe9b8aSliubo (unsigned long long)__entry->len) 11071abe9b8aSliubo ); 11081abe9b8aSliubo 11091abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 11101abe9b8aSliubo 11119a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11121abe9b8aSliubo 111371ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 11141abe9b8aSliubo ); 11151abe9b8aSliubo 11161abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 11171abe9b8aSliubo 11189a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11191abe9b8aSliubo 112071ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 11211abe9b8aSliubo ); 11221abe9b8aSliubo 11233f7de037SJosef Bacik TRACE_EVENT(find_free_extent, 11243f7de037SJosef Bacik 11259a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, 11269a35b637SJeff Mahoney u64 empty_size, u64 data), 11273f7de037SJosef Bacik 112871ff6437SJeff Mahoney TP_ARGS(fs_info, num_bytes, empty_size, data), 11293f7de037SJosef Bacik 1130bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11313f7de037SJosef Bacik __field( u64, num_bytes ) 11323f7de037SJosef Bacik __field( u64, empty_size ) 11333f7de037SJosef Bacik __field( u64, data ) 11343f7de037SJosef Bacik ), 11353f7de037SJosef Bacik 113671ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 11373f7de037SJosef Bacik __entry->num_bytes = num_bytes; 11383f7de037SJosef Bacik __entry->empty_size = empty_size; 11393f7de037SJosef Bacik __entry->data = data; 11403f7de037SJosef Bacik ), 11413f7de037SJosef Bacik 1142562a7a07SDavid Sterba TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)", 114371ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 11443f7de037SJosef Bacik __entry->num_bytes, __entry->empty_size, __entry->data, 11453f7de037SJosef Bacik __print_flags((unsigned long)__entry->data, "|", 11463f7de037SJosef Bacik BTRFS_GROUP_FLAGS)) 11473f7de037SJosef Bacik ); 11483f7de037SJosef Bacik 11493f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent, 11503f7de037SJosef Bacik 11519a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 11529a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, u64 start, 11533f7de037SJosef Bacik u64 len), 11543f7de037SJosef Bacik 115571ff6437SJeff Mahoney TP_ARGS(fs_info, block_group, start, len), 11563f7de037SJosef Bacik 1157bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11583f7de037SJosef Bacik __field( u64, bg_objectid ) 11593f7de037SJosef Bacik __field( u64, flags ) 11603f7de037SJosef Bacik __field( u64, start ) 11613f7de037SJosef Bacik __field( u64, len ) 11623f7de037SJosef Bacik ), 11633f7de037SJosef Bacik 116471ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 11653f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 11663f7de037SJosef Bacik __entry->flags = block_group->flags; 11673f7de037SJosef Bacik __entry->start = start; 11683f7de037SJosef Bacik __entry->len = len; 11693f7de037SJosef Bacik ), 11703f7de037SJosef Bacik 1171562a7a07SDavid Sterba TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) " 1172562a7a07SDavid Sterba "start=%Lu len=%Lu", 117371ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 117471ff6437SJeff Mahoney __entry->bg_objectid, 11753f7de037SJosef Bacik __entry->flags, __print_flags((unsigned long)__entry->flags, 11763f7de037SJosef Bacik "|", BTRFS_GROUP_FLAGS), 11773f7de037SJosef Bacik __entry->start, __entry->len) 11783f7de037SJosef Bacik ); 11793f7de037SJosef Bacik 11803f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 11813f7de037SJosef Bacik 11829a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 11839a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, u64 start, 11843f7de037SJosef Bacik u64 len), 11853f7de037SJosef Bacik 118671ff6437SJeff Mahoney TP_ARGS(fs_info, block_group, start, len) 11873f7de037SJosef Bacik ); 11883f7de037SJosef Bacik 11893f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 11903f7de037SJosef Bacik 11919a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 11929a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, u64 start, 11933f7de037SJosef Bacik u64 len), 11943f7de037SJosef Bacik 119571ff6437SJeff Mahoney TP_ARGS(fs_info, block_group, start, len) 11963f7de037SJosef Bacik ); 11973f7de037SJosef Bacik 11983f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster, 11993f7de037SJosef Bacik 12009a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 12013f7de037SJosef Bacik u64 bytes, u64 empty_size, u64 min_bytes), 12023f7de037SJosef Bacik 12033f7de037SJosef Bacik TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 12043f7de037SJosef Bacik 1205bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12063f7de037SJosef Bacik __field( u64, bg_objectid ) 12073f7de037SJosef Bacik __field( u64, flags ) 12083f7de037SJosef Bacik __field( u64, start ) 12093f7de037SJosef Bacik __field( u64, bytes ) 12103f7de037SJosef Bacik __field( u64, empty_size ) 12113f7de037SJosef Bacik __field( u64, min_bytes ) 12123f7de037SJosef Bacik ), 12133f7de037SJosef Bacik 1214bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 12153f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12163f7de037SJosef Bacik __entry->flags = block_group->flags; 12173f7de037SJosef Bacik __entry->start = start; 12183f7de037SJosef Bacik __entry->bytes = bytes; 12193f7de037SJosef Bacik __entry->empty_size = empty_size; 12203f7de037SJosef Bacik __entry->min_bytes = min_bytes; 12213f7de037SJosef Bacik ), 12223f7de037SJosef Bacik 1223562a7a07SDavid Sterba TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu " 1224562a7a07SDavid Sterba "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid, 12253f7de037SJosef Bacik __entry->flags, 12263f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 12273f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 12283f7de037SJosef Bacik __entry->bytes, __entry->empty_size, __entry->min_bytes) 12293f7de037SJosef Bacik ); 12303f7de037SJosef Bacik 12313f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup, 12323f7de037SJosef Bacik 12339a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group), 12343f7de037SJosef Bacik 12353f7de037SJosef Bacik TP_ARGS(block_group), 12363f7de037SJosef Bacik 1237bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12383f7de037SJosef Bacik __field( u64, bg_objectid ) 12393f7de037SJosef Bacik ), 12403f7de037SJosef Bacik 1241bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 12423f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12433f7de037SJosef Bacik ), 12443f7de037SJosef Bacik 1245bc074524SJeff Mahoney TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid) 12463f7de037SJosef Bacik ); 12473f7de037SJosef Bacik 12483f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster, 12493f7de037SJosef Bacik 12509a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group, 12519a35b637SJeff Mahoney const struct btrfs_free_cluster *cluster, 12529a35b637SJeff Mahoney u64 size, int bitmap), 12533f7de037SJosef Bacik 12543f7de037SJosef Bacik TP_ARGS(block_group, cluster, size, bitmap), 12553f7de037SJosef Bacik 1256bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12573f7de037SJosef Bacik __field( u64, bg_objectid ) 12583f7de037SJosef Bacik __field( u64, flags ) 12593f7de037SJosef Bacik __field( u64, start ) 12603f7de037SJosef Bacik __field( u64, max_size ) 12613f7de037SJosef Bacik __field( u64, size ) 12623f7de037SJosef Bacik __field( int, bitmap ) 12633f7de037SJosef Bacik ), 12643f7de037SJosef Bacik 1265bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 12663f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12673f7de037SJosef Bacik __entry->flags = block_group->flags; 12683f7de037SJosef Bacik __entry->start = cluster->window_start; 12693f7de037SJosef Bacik __entry->max_size = cluster->max_size; 12703f7de037SJosef Bacik __entry->size = size; 12713f7de037SJosef Bacik __entry->bitmap = bitmap; 12723f7de037SJosef Bacik ), 12733f7de037SJosef Bacik 1274562a7a07SDavid Sterba TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu " 1275562a7a07SDavid Sterba "size=%Lu max_size=%Lu bitmap=%d", 12763f7de037SJosef Bacik __entry->bg_objectid, 12773f7de037SJosef Bacik __entry->flags, 12783f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 12793f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 12803f7de037SJosef Bacik __entry->size, __entry->max_size, __entry->bitmap) 12813f7de037SJosef Bacik ); 12823f7de037SJosef Bacik 1283143bede5SJeff Mahoney struct extent_state; 1284143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state, 1285143bede5SJeff Mahoney 12869a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, 12879a35b637SJeff Mahoney gfp_t mask, unsigned long IP), 1288143bede5SJeff Mahoney 1289143bede5SJeff Mahoney TP_ARGS(state, mask, IP), 1290143bede5SJeff Mahoney 1291143bede5SJeff Mahoney TP_STRUCT__entry( 12929a35b637SJeff Mahoney __field(const struct extent_state *, state) 1293143bede5SJeff Mahoney __field(gfp_t, mask) 1294143bede5SJeff Mahoney __field(unsigned long, ip) 1295143bede5SJeff Mahoney ), 1296143bede5SJeff Mahoney 1297143bede5SJeff Mahoney TP_fast_assign( 1298143bede5SJeff Mahoney __entry->state = state, 1299143bede5SJeff Mahoney __entry->mask = mask, 1300143bede5SJeff Mahoney __entry->ip = IP 1301143bede5SJeff Mahoney ), 1302143bede5SJeff Mahoney 1303562a7a07SDavid Sterba TP_printk("state=%p mask=%s caller=%pS", __entry->state, 13049a35b637SJeff Mahoney show_gfp_flags(__entry->mask), (const void *)__entry->ip) 1305143bede5SJeff Mahoney ); 1306143bede5SJeff Mahoney 1307143bede5SJeff Mahoney TRACE_EVENT(free_extent_state, 1308143bede5SJeff Mahoney 13099a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, unsigned long IP), 1310143bede5SJeff Mahoney 1311143bede5SJeff Mahoney TP_ARGS(state, IP), 1312143bede5SJeff Mahoney 1313143bede5SJeff Mahoney TP_STRUCT__entry( 13149a35b637SJeff Mahoney __field(const struct extent_state *, state) 1315143bede5SJeff Mahoney __field(unsigned long, ip) 1316143bede5SJeff Mahoney ), 1317143bede5SJeff Mahoney 1318143bede5SJeff Mahoney TP_fast_assign( 1319143bede5SJeff Mahoney __entry->state = state, 1320143bede5SJeff Mahoney __entry->ip = IP 1321143bede5SJeff Mahoney ), 1322143bede5SJeff Mahoney 1323562a7a07SDavid Sterba TP_printk("state=%p caller=%pS", __entry->state, 13249a35b637SJeff Mahoney (const void *)__entry->ip) 1325143bede5SJeff Mahoney ); 1326143bede5SJeff Mahoney 132752483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work, 132852483bc2SQu Wenruo 13299a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 133052483bc2SQu Wenruo 133152483bc2SQu Wenruo TP_ARGS(work), 133252483bc2SQu Wenruo 1333bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 13349a35b637SJeff Mahoney __field( const void *, work ) 13359a35b637SJeff Mahoney __field( const void *, wq ) 13369a35b637SJeff Mahoney __field( const void *, func ) 13379a35b637SJeff Mahoney __field( const void *, ordered_func ) 13389a35b637SJeff Mahoney __field( const void *, ordered_free ) 13399a35b637SJeff Mahoney __field( const void *, normal_work ) 134052483bc2SQu Wenruo ), 134152483bc2SQu Wenruo 1342bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_work_owner(work), 134352483bc2SQu Wenruo __entry->work = work; 134452483bc2SQu Wenruo __entry->wq = work->wq; 134552483bc2SQu Wenruo __entry->func = work->func; 134652483bc2SQu Wenruo __entry->ordered_func = work->ordered_func; 134752483bc2SQu Wenruo __entry->ordered_free = work->ordered_free; 1348b38a6258SLiu Bo __entry->normal_work = &work->normal_work; 134952483bc2SQu Wenruo ), 135052483bc2SQu Wenruo 1351562a7a07SDavid Sterba TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p " 1352b38a6258SLiu Bo "ordered_free=%p", 1353b38a6258SLiu Bo __entry->work, __entry->normal_work, __entry->wq, 1354b38a6258SLiu Bo __entry->func, __entry->ordered_func, __entry->ordered_free) 135552483bc2SQu Wenruo ); 135652483bc2SQu Wenruo 1357ac0c7cf8SDavid Sterba /* 1358ac0c7cf8SDavid Sterba * For situiations when the work is freed, we pass fs_info and a tag that that 1359ac0c7cf8SDavid Sterba * matches address of the work structure so it can be paired with the 1360ac0c7cf8SDavid Sterba * scheduling event. 1361ac0c7cf8SDavid Sterba */ 136252483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done, 136352483bc2SQu Wenruo 13649a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 136552483bc2SQu Wenruo 1366ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag), 136752483bc2SQu Wenruo 1368bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 13699a35b637SJeff Mahoney __field( const void *, wtag ) 137052483bc2SQu Wenruo ), 137152483bc2SQu Wenruo 1372ac0c7cf8SDavid Sterba TP_fast_assign_btrfs(fs_info, 1373ac0c7cf8SDavid Sterba __entry->wtag = wtag; 137452483bc2SQu Wenruo ), 137552483bc2SQu Wenruo 1376ac0c7cf8SDavid Sterba TP_printk_btrfs("work->%p", __entry->wtag) 137752483bc2SQu Wenruo ); 137852483bc2SQu Wenruo 137952483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued, 138052483bc2SQu Wenruo 13819a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 138252483bc2SQu Wenruo 138352483bc2SQu Wenruo TP_ARGS(work) 138452483bc2SQu Wenruo ); 138552483bc2SQu Wenruo 138652483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched, 138752483bc2SQu Wenruo 13889a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 138952483bc2SQu Wenruo 139052483bc2SQu Wenruo TP_ARGS(work) 139152483bc2SQu Wenruo ); 139252483bc2SQu Wenruo 139352483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 139452483bc2SQu Wenruo 13959a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 139652483bc2SQu Wenruo 1397ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag) 139852483bc2SQu Wenruo ); 139952483bc2SQu Wenruo 140052483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 140152483bc2SQu Wenruo 14029a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 140352483bc2SQu Wenruo 140452483bc2SQu Wenruo TP_ARGS(work) 140552483bc2SQu Wenruo ); 140652483bc2SQu Wenruo 1407c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue, 1408c3a46891SQu Wenruo 14099a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 14109a35b637SJeff Mahoney const char *name, int high), 1411c3a46891SQu Wenruo 1412c3a46891SQu Wenruo TP_ARGS(wq, name, high), 1413c3a46891SQu Wenruo 1414bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14159a35b637SJeff Mahoney __field( const void *, wq ) 1416c3a46891SQu Wenruo __string( name, name ) 1417c3a46891SQu Wenruo __field( int , high ) 1418c3a46891SQu Wenruo ), 1419c3a46891SQu Wenruo 1420bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1421c3a46891SQu Wenruo __entry->wq = wq; 1422c3a46891SQu Wenruo __assign_str(name, name); 1423c3a46891SQu Wenruo __entry->high = high; 1424c3a46891SQu Wenruo ), 1425c3a46891SQu Wenruo 1426562a7a07SDavid Sterba TP_printk_btrfs("name=%s%s wq=%p", __get_str(name), 1427c3a46891SQu Wenruo __print_flags(__entry->high, "", 1428c3a46891SQu Wenruo {(WQ_HIGHPRI), "-high"}), 1429c3a46891SQu Wenruo __entry->wq) 1430c3a46891SQu Wenruo ); 1431c3a46891SQu Wenruo 1432c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc, 1433c3a46891SQu Wenruo 14349a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 14359a35b637SJeff Mahoney const char *name, int high), 1436c3a46891SQu Wenruo 1437c3a46891SQu Wenruo TP_ARGS(wq, name, high) 1438c3a46891SQu Wenruo ); 1439c3a46891SQu Wenruo 1440c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue_done, 1441c3a46891SQu Wenruo 14429a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1443c3a46891SQu Wenruo 1444c3a46891SQu Wenruo TP_ARGS(wq), 1445c3a46891SQu Wenruo 1446bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14479a35b637SJeff Mahoney __field( const void *, wq ) 1448c3a46891SQu Wenruo ), 1449c3a46891SQu Wenruo 1450bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1451c3a46891SQu Wenruo __entry->wq = wq; 1452c3a46891SQu Wenruo ), 1453c3a46891SQu Wenruo 1454bc074524SJeff Mahoney TP_printk_btrfs("wq=%p", __entry->wq) 1455c3a46891SQu Wenruo ); 1456c3a46891SQu Wenruo 1457c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy, 1458c3a46891SQu Wenruo 14599a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1460c3a46891SQu Wenruo 1461c3a46891SQu Wenruo TP_ARGS(wq) 1462c3a46891SQu Wenruo ); 146352483bc2SQu Wenruo 146481fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS \ 146581fb6f77SQu Wenruo { QGROUP_RESERVE, "reserve" }, \ 146681fb6f77SQu Wenruo { QGROUP_RELEASE, "release" }, \ 146781fb6f77SQu Wenruo { QGROUP_FREE, "free" } 146881fb6f77SQu Wenruo 146981fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data, 147081fb6f77SQu Wenruo 14719a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 14729a35b637SJeff Mahoney u64 reserved, int op), 147381fb6f77SQu Wenruo 147481fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op), 147581fb6f77SQu Wenruo 1476bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 147781fb6f77SQu Wenruo __field( u64, rootid ) 147881fb6f77SQu Wenruo __field( unsigned long, ino ) 147981fb6f77SQu Wenruo __field( u64, start ) 148081fb6f77SQu Wenruo __field( u64, len ) 148181fb6f77SQu Wenruo __field( u64, reserved ) 148281fb6f77SQu Wenruo __field( int, op ) 148381fb6f77SQu Wenruo ), 148481fb6f77SQu Wenruo 1485bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 148681fb6f77SQu Wenruo __entry->rootid = BTRFS_I(inode)->root->objectid; 148781fb6f77SQu Wenruo __entry->ino = inode->i_ino; 148881fb6f77SQu Wenruo __entry->start = start; 148981fb6f77SQu Wenruo __entry->len = len; 149081fb6f77SQu Wenruo __entry->reserved = reserved; 149181fb6f77SQu Wenruo __entry->op = op; 149281fb6f77SQu Wenruo ), 149381fb6f77SQu Wenruo 1494562a7a07SDavid Sterba TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s", 149581fb6f77SQu Wenruo __entry->rootid, __entry->ino, __entry->start, __entry->len, 149681fb6f77SQu Wenruo __entry->reserved, 149781fb6f77SQu Wenruo __print_flags((unsigned long)__entry->op, "", 149881fb6f77SQu Wenruo BTRFS_QGROUP_OPERATIONS) 149981fb6f77SQu Wenruo ) 150081fb6f77SQu Wenruo ); 150181fb6f77SQu Wenruo 150281fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data, 150381fb6f77SQu Wenruo 15049a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 15059a35b637SJeff Mahoney u64 reserved, int op), 150681fb6f77SQu Wenruo 150781fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 150881fb6f77SQu Wenruo ); 150981fb6f77SQu Wenruo 151081fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data, 151181fb6f77SQu Wenruo 15129a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 15139a35b637SJeff Mahoney u64 reserved, int op), 151481fb6f77SQu Wenruo 151581fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 151681fb6f77SQu Wenruo ); 151781fb6f77SQu Wenruo 151881fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref, 151981fb6f77SQu Wenruo 15209a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15219a35b637SJeff Mahoney u64 ref_root, u64 reserved), 152281fb6f77SQu Wenruo 1523bc074524SJeff Mahoney TP_ARGS(fs_info, ref_root, reserved), 152481fb6f77SQu Wenruo 1525bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 152681fb6f77SQu Wenruo __field( u64, ref_root ) 152781fb6f77SQu Wenruo __field( u64, reserved ) 152881fb6f77SQu Wenruo ), 152981fb6f77SQu Wenruo 1530bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 153181fb6f77SQu Wenruo __entry->ref_root = ref_root; 153281fb6f77SQu Wenruo __entry->reserved = reserved; 153381fb6f77SQu Wenruo ), 153481fb6f77SQu Wenruo 1535562a7a07SDavid Sterba TP_printk_btrfs("root=%llu reserved=%llu op=free", 153681fb6f77SQu Wenruo __entry->ref_root, __entry->reserved) 153781fb6f77SQu Wenruo ); 153881fb6f77SQu Wenruo 153981fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref, 154081fb6f77SQu Wenruo 15419a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15429a35b637SJeff Mahoney u64 ref_root, u64 reserved), 154381fb6f77SQu Wenruo 1544bc074524SJeff Mahoney TP_ARGS(fs_info, ref_root, reserved) 154581fb6f77SQu Wenruo ); 15460f5dcf8dSMark Fasheh 15470f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent, 15489a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15499a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15500f5dcf8dSMark Fasheh 1551bc074524SJeff Mahoney TP_ARGS(fs_info, rec), 15520f5dcf8dSMark Fasheh 1553bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 15540f5dcf8dSMark Fasheh __field( u64, bytenr ) 15550f5dcf8dSMark Fasheh __field( u64, num_bytes ) 15560f5dcf8dSMark Fasheh ), 15570f5dcf8dSMark Fasheh 1558bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 15590f5dcf8dSMark Fasheh __entry->bytenr = rec->bytenr, 15600f5dcf8dSMark Fasheh __entry->num_bytes = rec->num_bytes; 15610f5dcf8dSMark Fasheh ), 15620f5dcf8dSMark Fasheh 1563562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu", 15640f5dcf8dSMark Fasheh (unsigned long long)__entry->bytenr, 15650f5dcf8dSMark Fasheh (unsigned long long)__entry->num_bytes) 15660f5dcf8dSMark Fasheh ); 15670f5dcf8dSMark Fasheh 15680f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents, 15690f5dcf8dSMark Fasheh 15709a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15719a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15720f5dcf8dSMark Fasheh 1573bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15740f5dcf8dSMark Fasheh ); 15750f5dcf8dSMark Fasheh 157650b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent, 15770f5dcf8dSMark Fasheh 15789a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15799a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15800f5dcf8dSMark Fasheh 1581bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15820f5dcf8dSMark Fasheh ); 15830f5dcf8dSMark Fasheh 15840f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent, 15850f5dcf8dSMark Fasheh 15869a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr, 1587bc074524SJeff Mahoney u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots), 15880f5dcf8dSMark Fasheh 1589bc074524SJeff Mahoney TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots), 15900f5dcf8dSMark Fasheh 1591bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 15920f5dcf8dSMark Fasheh __field( u64, bytenr ) 15930f5dcf8dSMark Fasheh __field( u64, num_bytes ) 15940f5dcf8dSMark Fasheh __field( u64, nr_old_roots ) 15950f5dcf8dSMark Fasheh __field( u64, nr_new_roots ) 15960f5dcf8dSMark Fasheh ), 15970f5dcf8dSMark Fasheh 1598bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 15990f5dcf8dSMark Fasheh __entry->bytenr = bytenr; 16000f5dcf8dSMark Fasheh __entry->num_bytes = num_bytes; 16010f5dcf8dSMark Fasheh __entry->nr_old_roots = nr_old_roots; 16020f5dcf8dSMark Fasheh __entry->nr_new_roots = nr_new_roots; 16030f5dcf8dSMark Fasheh ), 16040f5dcf8dSMark Fasheh 1605562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu " 16060f5dcf8dSMark Fasheh "nr_new_roots=%llu", 16070f5dcf8dSMark Fasheh __entry->bytenr, 16080f5dcf8dSMark Fasheh __entry->num_bytes, 16090f5dcf8dSMark Fasheh __entry->nr_old_roots, 16100f5dcf8dSMark Fasheh __entry->nr_new_roots) 16110f5dcf8dSMark Fasheh ); 16120f5dcf8dSMark Fasheh 16130f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters, 16140f5dcf8dSMark Fasheh 16159a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid, 1616bc074524SJeff Mahoney u64 cur_old_count, u64 cur_new_count), 16170f5dcf8dSMark Fasheh 1618bc074524SJeff Mahoney TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count), 16190f5dcf8dSMark Fasheh 1620bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 16210f5dcf8dSMark Fasheh __field( u64, qgid ) 16220f5dcf8dSMark Fasheh __field( u64, cur_old_count ) 16230f5dcf8dSMark Fasheh __field( u64, cur_new_count ) 16240f5dcf8dSMark Fasheh ), 16250f5dcf8dSMark Fasheh 1626bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 16270f5dcf8dSMark Fasheh __entry->qgid = qgid; 16280f5dcf8dSMark Fasheh __entry->cur_old_count = cur_old_count; 16290f5dcf8dSMark Fasheh __entry->cur_new_count = cur_new_count; 16300f5dcf8dSMark Fasheh ), 16310f5dcf8dSMark Fasheh 1632562a7a07SDavid Sterba TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu", 16330f5dcf8dSMark Fasheh __entry->qgid, 16340f5dcf8dSMark Fasheh __entry->cur_old_count, 16350f5dcf8dSMark Fasheh __entry->cur_new_count) 16360f5dcf8dSMark Fasheh ); 16370f5dcf8dSMark Fasheh 16383159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve, 16393159fe7bSQu Wenruo 16403159fe7bSQu Wenruo TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup, 164164ee4e75SQu Wenruo s64 diff, int type), 16423159fe7bSQu Wenruo 164364ee4e75SQu Wenruo TP_ARGS(fs_info, qgroup, diff, type), 16443159fe7bSQu Wenruo 16453159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 16463159fe7bSQu Wenruo __field( u64, qgid ) 16473159fe7bSQu Wenruo __field( u64, cur_reserved ) 16483159fe7bSQu Wenruo __field( s64, diff ) 164964ee4e75SQu Wenruo __field( int, type ) 16503159fe7bSQu Wenruo ), 16513159fe7bSQu Wenruo 16523159fe7bSQu Wenruo TP_fast_assign_btrfs(fs_info, 16533159fe7bSQu Wenruo __entry->qgid = qgroup->qgroupid; 165464ee4e75SQu Wenruo __entry->cur_reserved = qgroup->rsv.values[type]; 16553159fe7bSQu Wenruo __entry->diff = diff; 16563159fe7bSQu Wenruo ), 16573159fe7bSQu Wenruo 165864ee4e75SQu Wenruo TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld", 165964ee4e75SQu Wenruo __entry->qgid, show_qgroup_rsv_type(__entry->type), 166064ee4e75SQu Wenruo __entry->cur_reserved, __entry->diff) 16613159fe7bSQu Wenruo ); 16623159fe7bSQu Wenruo 16633159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve, 16643159fe7bSQu Wenruo 16653159fe7bSQu Wenruo TP_PROTO(struct btrfs_root *root, s64 diff), 16663159fe7bSQu Wenruo 16673159fe7bSQu Wenruo TP_ARGS(root, diff), 16683159fe7bSQu Wenruo 16693159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 16703159fe7bSQu Wenruo __field( u64, refroot ) 16713159fe7bSQu Wenruo __field( s64, diff ) 16723159fe7bSQu Wenruo ), 16733159fe7bSQu Wenruo 16743159fe7bSQu Wenruo TP_fast_assign_btrfs(root->fs_info, 16753159fe7bSQu Wenruo __entry->refroot = root->objectid; 16763159fe7bSQu Wenruo __entry->diff = diff; 16773159fe7bSQu Wenruo ), 16783159fe7bSQu Wenruo 16793159fe7bSQu Wenruo TP_printk_btrfs("refroot=%llu(%s) diff=%lld", 16803159fe7bSQu Wenruo show_root_type(__entry->refroot), __entry->diff) 16813159fe7bSQu Wenruo ); 16823159fe7bSQu Wenruo 168300142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref, 168400142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 168500142756SJeff Mahoney const struct prelim_ref *oldref, 168600142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 168700142756SJeff Mahoney TP_ARGS(fs_info, newref, oldref, tree_size), 168800142756SJeff Mahoney 168900142756SJeff Mahoney TP_STRUCT__entry_btrfs( 169000142756SJeff Mahoney __field( u64, root_id ) 169100142756SJeff Mahoney __field( u64, objectid ) 169200142756SJeff Mahoney __field( u8, type ) 169300142756SJeff Mahoney __field( u64, offset ) 169400142756SJeff Mahoney __field( int, level ) 169500142756SJeff Mahoney __field( int, old_count ) 169600142756SJeff Mahoney __field( u64, parent ) 169700142756SJeff Mahoney __field( u64, bytenr ) 169800142756SJeff Mahoney __field( int, mod_count ) 169900142756SJeff Mahoney __field( u64, tree_size ) 170000142756SJeff Mahoney ), 170100142756SJeff Mahoney 170200142756SJeff Mahoney TP_fast_assign_btrfs(fs_info, 170300142756SJeff Mahoney __entry->root_id = oldref->root_id; 170400142756SJeff Mahoney __entry->objectid = oldref->key_for_search.objectid; 170500142756SJeff Mahoney __entry->type = oldref->key_for_search.type; 170600142756SJeff Mahoney __entry->offset = oldref->key_for_search.offset; 170700142756SJeff Mahoney __entry->level = oldref->level; 170800142756SJeff Mahoney __entry->old_count = oldref->count; 170900142756SJeff Mahoney __entry->parent = oldref->parent; 171000142756SJeff Mahoney __entry->bytenr = oldref->wanted_disk_byte; 171100142756SJeff Mahoney __entry->mod_count = newref ? newref->count : 0; 171200142756SJeff Mahoney __entry->tree_size = tree_size; 171300142756SJeff Mahoney ), 171400142756SJeff Mahoney 171500142756SJeff Mahoney TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu", 171600142756SJeff Mahoney (unsigned long long)__entry->root_id, 171700142756SJeff Mahoney (unsigned long long)__entry->objectid, __entry->type, 171800142756SJeff Mahoney (unsigned long long)__entry->offset, __entry->level, 171900142756SJeff Mahoney __entry->old_count, __entry->mod_count, 172000142756SJeff Mahoney __entry->old_count + __entry->mod_count, 172100142756SJeff Mahoney (unsigned long long)__entry->parent, 172200142756SJeff Mahoney (unsigned long long)__entry->bytenr, 172300142756SJeff Mahoney (unsigned long long)__entry->tree_size) 172400142756SJeff Mahoney ); 172500142756SJeff Mahoney 172600142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge, 172700142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 172800142756SJeff Mahoney const struct prelim_ref *oldref, 172900142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 173000142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 173100142756SJeff Mahoney ); 173200142756SJeff Mahoney 173300142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert, 173400142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 173500142756SJeff Mahoney const struct prelim_ref *oldref, 173600142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 173700142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 173800142756SJeff Mahoney ); 173900142756SJeff Mahoney 1740dd48d407SJosef Bacik TRACE_EVENT(btrfs_inode_mod_outstanding_extents, 1741dd48d407SJosef Bacik TP_PROTO(struct btrfs_root *root, u64 ino, int mod), 1742dd48d407SJosef Bacik 1743dd48d407SJosef Bacik TP_ARGS(root, ino, mod), 1744dd48d407SJosef Bacik 1745dd48d407SJosef Bacik TP_STRUCT__entry_btrfs( 1746dd48d407SJosef Bacik __field( u64, root_objectid ) 1747dd48d407SJosef Bacik __field( u64, ino ) 1748dd48d407SJosef Bacik __field( int, mod ) 1749dd48d407SJosef Bacik ), 1750dd48d407SJosef Bacik 1751dd48d407SJosef Bacik TP_fast_assign_btrfs(root->fs_info, 1752dd48d407SJosef Bacik __entry->root_objectid = root->objectid; 1753dd48d407SJosef Bacik __entry->ino = ino; 1754dd48d407SJosef Bacik __entry->mod = mod; 1755dd48d407SJosef Bacik ), 1756dd48d407SJosef Bacik 1757dd48d407SJosef Bacik TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d", 1758dd48d407SJosef Bacik show_root_type(__entry->root_objectid), 1759dd48d407SJosef Bacik (unsigned long long)__entry->ino, __entry->mod) 1760dd48d407SJosef Bacik ); 17611abe9b8aSliubo #endif /* _TRACE_BTRFS_H */ 17621abe9b8aSliubo 17631abe9b8aSliubo /* This part must be outside protection */ 17641abe9b8aSliubo #include <trace/define_trace.h> 1765