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; 30a1d19847SQu Wenruo struct extent_io_tree; 3100142756SJeff Mahoney struct prelim_ref; 32480b9b4dSQu Wenruo struct btrfs_space_info; 331abe9b8aSliubo 34012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR); 35012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS); 36012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELALLOC); 37012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT); 38012e513eSAnand Jain TRACE_DEFINE_ENUM(ALLOC_CHUNK); 39012e513eSAnand Jain TRACE_DEFINE_ENUM(COMMIT_TRANS); 40012e513eSAnand Jain 411abe9b8aSliubo #define show_ref_type(type) \ 421abe9b8aSliubo __print_symbolic(type, \ 431abe9b8aSliubo { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ 441abe9b8aSliubo { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ 451abe9b8aSliubo { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \ 461abe9b8aSliubo { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ 471abe9b8aSliubo { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) 481abe9b8aSliubo 491abe9b8aSliubo #define __show_root_type(obj) \ 507f34b746Sliubo __print_symbolic_u64(obj, \ 511abe9b8aSliubo { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ 521abe9b8aSliubo { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ 531abe9b8aSliubo { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ 541abe9b8aSliubo { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ 551abe9b8aSliubo { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ 561abe9b8aSliubo { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ 571abe9b8aSliubo { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ 581abe9b8aSliubo { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ 59e112e2b4SLiu Bo { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \ 601abe9b8aSliubo { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ 61208acb8cSOmar Sandoval { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \ 62208acb8cSOmar Sandoval { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \ 631abe9b8aSliubo { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) 641abe9b8aSliubo 651abe9b8aSliubo #define show_root_type(obj) \ 661abe9b8aSliubo obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ 67fb57dc81SLiu Bo (obj >= BTRFS_ROOT_TREE_OBJECTID && \ 68e112e2b4SLiu Bo obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-" 691abe9b8aSliubo 7009ed2f16SLiu Bo #define show_fi_type(type) \ 7109ed2f16SLiu Bo __print_symbolic(type, \ 7209ed2f16SLiu Bo { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \ 7309ed2f16SLiu Bo { BTRFS_FILE_EXTENT_REG, "REG" }, \ 7409ed2f16SLiu Bo { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"}) 7509ed2f16SLiu Bo 7664ee4e75SQu Wenruo #define show_qgroup_rsv_type(type) \ 7764ee4e75SQu Wenruo __print_symbolic(type, \ 7864ee4e75SQu Wenruo { BTRFS_QGROUP_RSV_DATA, "DATA" }, \ 79733e03a0SQu Wenruo { BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS" }, \ 80733e03a0SQu Wenruo { BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC" }) 8164ee4e75SQu Wenruo 82a1d19847SQu Wenruo #define show_extent_io_tree_owner(owner) \ 83a1d19847SQu Wenruo __print_symbolic(owner, \ 84a1d19847SQu Wenruo { IO_TREE_FS_INFO_FREED_EXTENTS0, "FREED_EXTENTS0" }, \ 85a1d19847SQu Wenruo { IO_TREE_FS_INFO_FREED_EXTENTS1, "FREED_EXTENTS1" }, \ 86a1d19847SQu Wenruo { IO_TREE_INODE_IO, "INODE_IO" }, \ 87a1d19847SQu Wenruo { IO_TREE_INODE_IO_FAILURE, "INODE_IO_FAILURE" }, \ 88a1d19847SQu Wenruo { IO_TREE_RELOC_BLOCKS, "RELOC_BLOCKS" }, \ 89a1d19847SQu Wenruo { IO_TREE_TRANS_DIRTY_PAGES, "TRANS_DIRTY_PAGES" }, \ 90a1d19847SQu Wenruo { IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES" }, \ 91a1d19847SQu Wenruo { IO_TREE_SELFTEST, "SELFTEST" }) 92a1d19847SQu Wenruo 933f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS \ 943f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \ 953f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 963f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 973f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \ 983f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ 993f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ 100e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 101e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ 102e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} 1033f7de037SJosef Bacik 104a1d19847SQu Wenruo #define EXTENT_FLAGS \ 105a1d19847SQu Wenruo { EXTENT_DIRTY, "DIRTY"}, \ 106a1d19847SQu Wenruo { EXTENT_UPTODATE, "UPTODATE"}, \ 107a1d19847SQu Wenruo { EXTENT_LOCKED, "LOCKED"}, \ 108a1d19847SQu Wenruo { EXTENT_NEW, "NEW"}, \ 109a1d19847SQu Wenruo { EXTENT_DELALLOC, "DELALLOC"}, \ 110a1d19847SQu Wenruo { EXTENT_DEFRAG, "DEFRAG"}, \ 111a1d19847SQu Wenruo { EXTENT_BOUNDARY, "BOUNDARY"}, \ 112a1d19847SQu Wenruo { EXTENT_NODATASUM, "NODATASUM"}, \ 113a1d19847SQu Wenruo { EXTENT_CLEAR_META_RESV, "CLEAR_META_RESV"}, \ 114a1d19847SQu Wenruo { EXTENT_NEED_WAIT, "NEED_WAIT"}, \ 115a1d19847SQu Wenruo { EXTENT_DAMAGED, "DAMAGED"}, \ 116a1d19847SQu Wenruo { EXTENT_NORESERVE, "NORESERVE"}, \ 117a1d19847SQu Wenruo { EXTENT_QGROUP_RESERVED, "QGROUP_RESERVED"}, \ 118a1d19847SQu Wenruo { EXTENT_CLEAR_DATA_RESV, "CLEAR_DATA_RESV"}, \ 119a1d19847SQu Wenruo { EXTENT_DELALLOC_NEW, "DELALLOC_NEW"} 120a1d19847SQu Wenruo 121b94417eaSAnand Jain #define BTRFS_FSID_SIZE 16 122b94417eaSAnand Jain #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE) 123bc074524SJeff Mahoney 124bc074524SJeff Mahoney #define TP_fast_assign_fsid(fs_info) \ 125a1d19847SQu Wenruo ({ \ 126a1d19847SQu Wenruo if (fs_info) \ 127a1d19847SQu Wenruo memcpy(__entry->fsid, fs_info->fs_devices->fsid, \ 128a1d19847SQu Wenruo BTRFS_FSID_SIZE); \ 129a1d19847SQu Wenruo else \ 130a1d19847SQu Wenruo memset(__entry->fsid, 0, BTRFS_FSID_SIZE); \ 131a1d19847SQu Wenruo }) 132bc074524SJeff Mahoney 133bc074524SJeff Mahoney #define TP_STRUCT__entry_btrfs(args...) \ 134bc074524SJeff Mahoney TP_STRUCT__entry( \ 135bc074524SJeff Mahoney TP_STRUCT__entry_fsid \ 136bc074524SJeff Mahoney args) 137bc074524SJeff Mahoney #define TP_fast_assign_btrfs(fs_info, args...) \ 138bc074524SJeff Mahoney TP_fast_assign( \ 139bc074524SJeff Mahoney TP_fast_assign_fsid(fs_info); \ 140bc074524SJeff Mahoney args) 141bc074524SJeff Mahoney #define TP_printk_btrfs(fmt, args...) \ 142bc074524SJeff Mahoney TP_printk("%pU: " fmt, __entry->fsid, args) 1438c2a3ca2SJosef Bacik 1441abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit, 1451abe9b8aSliubo 1469a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root), 1471abe9b8aSliubo 1481abe9b8aSliubo TP_ARGS(root), 1491abe9b8aSliubo 150bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 1511abe9b8aSliubo __field( u64, generation ) 1521abe9b8aSliubo __field( u64, root_objectid ) 1531abe9b8aSliubo ), 1541abe9b8aSliubo 155bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 1561abe9b8aSliubo __entry->generation = root->fs_info->generation; 1571abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 1581abe9b8aSliubo ), 1591abe9b8aSliubo 16079bcb71aSDavid Sterba TP_printk_btrfs("root=%llu(%s) gen=%llu", 1611abe9b8aSliubo show_root_type(__entry->root_objectid), 1628eec8463SDavid Sterba __entry->generation) 1631abe9b8aSliubo ); 1641abe9b8aSliubo 1651abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode, 1661abe9b8aSliubo 1679a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1681abe9b8aSliubo 1691abe9b8aSliubo TP_ARGS(inode), 1701abe9b8aSliubo 171bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 172f8f8e189SDavid Sterba __field( u64, ino ) 173*94c3f6c6SDavid Sterba __field( u64, blocks ) 1741abe9b8aSliubo __field( u64, disk_i_size ) 1751abe9b8aSliubo __field( u64, generation ) 1761abe9b8aSliubo __field( u64, last_trans ) 1771abe9b8aSliubo __field( u64, logged_trans ) 1781abe9b8aSliubo __field( u64, root_objectid ) 1791abe9b8aSliubo ), 1801abe9b8aSliubo 181bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 182f8f8e189SDavid Sterba __entry->ino = btrfs_ino(BTRFS_I(inode)); 1831abe9b8aSliubo __entry->blocks = inode->i_blocks; 1841abe9b8aSliubo __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; 1851abe9b8aSliubo __entry->generation = BTRFS_I(inode)->generation; 1861abe9b8aSliubo __entry->last_trans = BTRFS_I(inode)->last_trans; 1871abe9b8aSliubo __entry->logged_trans = BTRFS_I(inode)->logged_trans; 1881abe9b8aSliubo __entry->root_objectid = 1891abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 1901abe9b8aSliubo ), 1911abe9b8aSliubo 192f8f8e189SDavid Sterba TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu " 193562a7a07SDavid Sterba "disk_i_size=%llu last_trans=%llu logged_trans=%llu", 1941abe9b8aSliubo show_root_type(__entry->root_objectid), 1958eec8463SDavid Sterba __entry->generation, 1968eec8463SDavid Sterba __entry->ino, 197*94c3f6c6SDavid Sterba __entry->blocks, 1988eec8463SDavid Sterba __entry->disk_i_size, 1998eec8463SDavid Sterba __entry->last_trans, 2008eec8463SDavid Sterba __entry->logged_trans) 2011abe9b8aSliubo ); 2021abe9b8aSliubo 2031abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new, 2041abe9b8aSliubo 2059a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 2061abe9b8aSliubo 2071abe9b8aSliubo TP_ARGS(inode) 2081abe9b8aSliubo ); 2091abe9b8aSliubo 2101abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request, 2111abe9b8aSliubo 2129a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 2131abe9b8aSliubo 2141abe9b8aSliubo TP_ARGS(inode) 2151abe9b8aSliubo ); 2161abe9b8aSliubo 2171abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, 2181abe9b8aSliubo 2199a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 2201abe9b8aSliubo 2211abe9b8aSliubo TP_ARGS(inode) 2221abe9b8aSliubo ); 2231abe9b8aSliubo 2241abe9b8aSliubo #define __show_map_type(type) \ 2257f34b746Sliubo __print_symbolic_u64(type, \ 2261abe9b8aSliubo { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ 2271abe9b8aSliubo { EXTENT_MAP_HOLE, "HOLE" }, \ 2281abe9b8aSliubo { EXTENT_MAP_INLINE, "INLINE" }, \ 2291abe9b8aSliubo { EXTENT_MAP_DELALLOC, "DELALLOC" }) 2301abe9b8aSliubo 2311abe9b8aSliubo #define show_map_type(type) \ 2321abe9b8aSliubo type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) 2331abe9b8aSliubo 2341abe9b8aSliubo #define show_map_flags(flag) \ 2351abe9b8aSliubo __print_flags(flag, "|", \ 236254a2d14SLiu Bo { (1 << EXTENT_FLAG_PINNED), "PINNED" },\ 237254a2d14SLiu Bo { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\ 238254a2d14SLiu Bo { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\ 239254a2d14SLiu Bo { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\ 240254a2d14SLiu Bo { (1 << EXTENT_FLAG_FILLING), "FILLING" },\ 241254a2d14SLiu Bo { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" }) 2421abe9b8aSliubo 2434cd8587cSSteven Rostedt TRACE_EVENT_CONDITION(btrfs_get_extent, 2441abe9b8aSliubo 2459a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode, 2469a35b637SJeff Mahoney const struct extent_map *map), 2471abe9b8aSliubo 24892a1bf76SLiu Bo TP_ARGS(root, inode, map), 2491abe9b8aSliubo 2504cd8587cSSteven Rostedt TP_CONDITION(map), 2514cd8587cSSteven Rostedt 252bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 2531abe9b8aSliubo __field( u64, root_objectid ) 25492a1bf76SLiu Bo __field( u64, ino ) 2551abe9b8aSliubo __field( u64, start ) 2561abe9b8aSliubo __field( u64, len ) 2571abe9b8aSliubo __field( u64, orig_start ) 2581abe9b8aSliubo __field( u64, block_start ) 2591abe9b8aSliubo __field( u64, block_len ) 2601abe9b8aSliubo __field( unsigned long, flags ) 2611abe9b8aSliubo __field( int, refs ) 2621abe9b8aSliubo __field( unsigned int, compress_type ) 2631abe9b8aSliubo ), 2641abe9b8aSliubo 265bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 2661abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 26792a1bf76SLiu Bo __entry->ino = btrfs_ino(inode); 2681abe9b8aSliubo __entry->start = map->start; 2691abe9b8aSliubo __entry->len = map->len; 2701abe9b8aSliubo __entry->orig_start = map->orig_start; 2711abe9b8aSliubo __entry->block_start = map->block_start; 2721abe9b8aSliubo __entry->block_len = map->block_len; 2731abe9b8aSliubo __entry->flags = map->flags; 274490b54d6SElena Reshetova __entry->refs = refcount_read(&map->refs); 2751abe9b8aSliubo __entry->compress_type = map->compress_type; 2761abe9b8aSliubo ), 2771abe9b8aSliubo 278562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu " 279562a7a07SDavid Sterba "orig_start=%llu block_start=%llu(%s) " 280562a7a07SDavid Sterba "block_len=%llu flags=%s refs=%u " 2811abe9b8aSliubo "compress_type=%u", 2821abe9b8aSliubo show_root_type(__entry->root_objectid), 2838eec8463SDavid Sterba __entry->ino, 2848eec8463SDavid Sterba __entry->start, 2858eec8463SDavid Sterba __entry->len, 2868eec8463SDavid Sterba __entry->orig_start, 2871abe9b8aSliubo show_map_type(__entry->block_start), 2888eec8463SDavid Sterba __entry->block_len, 2891abe9b8aSliubo show_map_flags(__entry->flags), 2901abe9b8aSliubo __entry->refs, __entry->compress_type) 2911abe9b8aSliubo ); 2921abe9b8aSliubo 293393da918SLiu Bo TRACE_EVENT(btrfs_handle_em_exist, 294393da918SLiu Bo 295f46b24c9SDavid Sterba TP_PROTO(struct btrfs_fs_info *fs_info, 296f46b24c9SDavid Sterba const struct extent_map *existing, const struct extent_map *map, 297f46b24c9SDavid Sterba u64 start, u64 len), 298393da918SLiu Bo 299f46b24c9SDavid Sterba TP_ARGS(fs_info, existing, map, start, len), 300393da918SLiu Bo 301f46b24c9SDavid Sterba TP_STRUCT__entry_btrfs( 302393da918SLiu Bo __field( u64, e_start ) 303393da918SLiu Bo __field( u64, e_len ) 304393da918SLiu Bo __field( u64, map_start ) 305393da918SLiu Bo __field( u64, map_len ) 306393da918SLiu Bo __field( u64, start ) 307393da918SLiu Bo __field( u64, len ) 308393da918SLiu Bo ), 309393da918SLiu Bo 310f46b24c9SDavid Sterba TP_fast_assign_btrfs(fs_info, 311393da918SLiu Bo __entry->e_start = existing->start; 312393da918SLiu Bo __entry->e_len = existing->len; 313393da918SLiu Bo __entry->map_start = map->start; 314393da918SLiu Bo __entry->map_len = map->len; 315393da918SLiu Bo __entry->start = start; 316393da918SLiu Bo __entry->len = len; 317393da918SLiu Bo ), 318393da918SLiu Bo 319f46b24c9SDavid Sterba TP_printk_btrfs("start=%llu len=%llu " 320393da918SLiu Bo "existing(start=%llu len=%llu) " 321393da918SLiu Bo "em(start=%llu len=%llu)", 3228eec8463SDavid Sterba __entry->start, 3238eec8463SDavid Sterba __entry->len, 3248eec8463SDavid Sterba __entry->e_start, 3258eec8463SDavid Sterba __entry->e_len, 3268eec8463SDavid Sterba __entry->map_start, 3278eec8463SDavid Sterba __entry->map_len) 328393da918SLiu Bo ); 329393da918SLiu Bo 33009ed2f16SLiu Bo /* file extent item */ 33109ed2f16SLiu Bo DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular, 33209ed2f16SLiu Bo 33309ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 33409ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 33509ed2f16SLiu Bo 33609ed2f16SLiu Bo TP_ARGS(bi, l, fi, start), 33709ed2f16SLiu Bo 33809ed2f16SLiu Bo TP_STRUCT__entry_btrfs( 33909ed2f16SLiu Bo __field( u64, root_obj ) 34009ed2f16SLiu Bo __field( u64, ino ) 34109ed2f16SLiu Bo __field( loff_t, isize ) 34209ed2f16SLiu Bo __field( u64, disk_isize ) 34309ed2f16SLiu Bo __field( u64, num_bytes ) 34409ed2f16SLiu Bo __field( u64, ram_bytes ) 34509ed2f16SLiu Bo __field( u64, disk_bytenr ) 34609ed2f16SLiu Bo __field( u64, disk_num_bytes ) 34709ed2f16SLiu Bo __field( u64, extent_offset ) 34809ed2f16SLiu Bo __field( u8, extent_type ) 34909ed2f16SLiu Bo __field( u8, compression ) 35009ed2f16SLiu Bo __field( u64, extent_start ) 35109ed2f16SLiu Bo __field( u64, extent_end ) 35209ed2f16SLiu Bo ), 35309ed2f16SLiu Bo 35409ed2f16SLiu Bo TP_fast_assign_btrfs(bi->root->fs_info, 3554fd786e6SMisono Tomohiro __entry->root_obj = bi->root->root_key.objectid; 35609ed2f16SLiu Bo __entry->ino = btrfs_ino(bi); 35709ed2f16SLiu Bo __entry->isize = bi->vfs_inode.i_size; 35809ed2f16SLiu Bo __entry->disk_isize = bi->disk_i_size; 35909ed2f16SLiu Bo __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi); 36009ed2f16SLiu Bo __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi); 36109ed2f16SLiu Bo __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi); 36209ed2f16SLiu Bo __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi); 36309ed2f16SLiu Bo __entry->extent_offset = btrfs_file_extent_offset(l, fi); 36409ed2f16SLiu Bo __entry->extent_type = btrfs_file_extent_type(l, fi); 36509ed2f16SLiu Bo __entry->compression = btrfs_file_extent_compression(l, fi); 36609ed2f16SLiu Bo __entry->extent_start = start; 36709ed2f16SLiu Bo __entry->extent_end = (start + __entry->num_bytes); 36809ed2f16SLiu Bo ), 36909ed2f16SLiu Bo 37009ed2f16SLiu Bo TP_printk_btrfs( 37109ed2f16SLiu Bo "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 37209ed2f16SLiu Bo "file extent range=[%llu %llu] " 37309ed2f16SLiu Bo "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu " 37409ed2f16SLiu Bo "disk_num_bytes=%llu extent_offset=%llu type=%s " 37509ed2f16SLiu Bo "compression=%u", 37609ed2f16SLiu Bo show_root_type(__entry->root_obj), __entry->ino, 37709ed2f16SLiu Bo __entry->isize, 37809ed2f16SLiu Bo __entry->disk_isize, __entry->extent_start, 37909ed2f16SLiu Bo __entry->extent_end, __entry->num_bytes, __entry->ram_bytes, 38009ed2f16SLiu Bo __entry->disk_bytenr, __entry->disk_num_bytes, 38109ed2f16SLiu Bo __entry->extent_offset, show_fi_type(__entry->extent_type), 38209ed2f16SLiu Bo __entry->compression) 38309ed2f16SLiu Bo ); 38409ed2f16SLiu Bo 38509ed2f16SLiu Bo DECLARE_EVENT_CLASS( 38609ed2f16SLiu Bo btrfs__file_extent_item_inline, 38709ed2f16SLiu Bo 38809ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 38909ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 39009ed2f16SLiu Bo 39109ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start), 39209ed2f16SLiu Bo 39309ed2f16SLiu Bo TP_STRUCT__entry_btrfs( 39409ed2f16SLiu Bo __field( u64, root_obj ) 39509ed2f16SLiu Bo __field( u64, ino ) 39609ed2f16SLiu Bo __field( loff_t, isize ) 39709ed2f16SLiu Bo __field( u64, disk_isize ) 39809ed2f16SLiu Bo __field( u8, extent_type ) 39909ed2f16SLiu Bo __field( u8, compression ) 40009ed2f16SLiu Bo __field( u64, extent_start ) 40109ed2f16SLiu Bo __field( u64, extent_end ) 40209ed2f16SLiu Bo ), 40309ed2f16SLiu Bo 40409ed2f16SLiu Bo TP_fast_assign_btrfs( 40509ed2f16SLiu Bo bi->root->fs_info, 4064fd786e6SMisono Tomohiro __entry->root_obj = bi->root->root_key.objectid; 40709ed2f16SLiu Bo __entry->ino = btrfs_ino(bi); 40809ed2f16SLiu Bo __entry->isize = bi->vfs_inode.i_size; 40909ed2f16SLiu Bo __entry->disk_isize = bi->disk_i_size; 41009ed2f16SLiu Bo __entry->extent_type = btrfs_file_extent_type(l, fi); 41109ed2f16SLiu Bo __entry->compression = btrfs_file_extent_compression(l, fi); 41209ed2f16SLiu Bo __entry->extent_start = start; 413e41ca589SQu Wenruo __entry->extent_end = (start + btrfs_file_extent_ram_bytes(l, fi)); 41409ed2f16SLiu Bo ), 41509ed2f16SLiu Bo 41609ed2f16SLiu Bo TP_printk_btrfs( 41709ed2f16SLiu Bo "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 41809ed2f16SLiu Bo "file extent range=[%llu %llu] " 41909ed2f16SLiu Bo "extent_type=%s compression=%u", 42009ed2f16SLiu Bo show_root_type(__entry->root_obj), __entry->ino, __entry->isize, 42109ed2f16SLiu Bo __entry->disk_isize, __entry->extent_start, 42209ed2f16SLiu Bo __entry->extent_end, show_fi_type(__entry->extent_type), 42309ed2f16SLiu Bo __entry->compression) 42409ed2f16SLiu Bo ); 42509ed2f16SLiu Bo 42609ed2f16SLiu Bo DEFINE_EVENT( 42709ed2f16SLiu Bo btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular, 42809ed2f16SLiu Bo 42909ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 43009ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 43109ed2f16SLiu Bo 43209ed2f16SLiu Bo TP_ARGS(bi, l, fi, start) 43309ed2f16SLiu Bo ); 43409ed2f16SLiu Bo 43509ed2f16SLiu Bo DEFINE_EVENT( 43609ed2f16SLiu Bo btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular, 43709ed2f16SLiu Bo 43809ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 43909ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 44009ed2f16SLiu Bo 44109ed2f16SLiu Bo TP_ARGS(bi, l, fi, start) 44209ed2f16SLiu Bo ); 44309ed2f16SLiu Bo 44409ed2f16SLiu Bo DEFINE_EVENT( 44509ed2f16SLiu Bo btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline, 44609ed2f16SLiu Bo 44709ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 44809ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 44909ed2f16SLiu Bo 45009ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start) 45109ed2f16SLiu Bo ); 45209ed2f16SLiu Bo 45309ed2f16SLiu Bo DEFINE_EVENT( 45409ed2f16SLiu Bo btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline, 45509ed2f16SLiu Bo 45609ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 45709ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 45809ed2f16SLiu Bo 45909ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start) 46009ed2f16SLiu Bo ); 46109ed2f16SLiu Bo 4621abe9b8aSliubo #define show_ordered_flags(flags) \ 4639d04a8ceSLiu Bo __print_flags(flags, "|", \ 4649d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \ 4659d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \ 4669d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \ 4679d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \ 4689d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \ 4699d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \ 4709d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \ 4719d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \ 472792ddef0SLiu Bo { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" }) 473e112e2b4SLiu Bo 4741abe9b8aSliubo 4751abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent, 4761abe9b8aSliubo 4779a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 4789a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 4791abe9b8aSliubo 4801abe9b8aSliubo TP_ARGS(inode, ordered), 4811abe9b8aSliubo 482bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 483f8f8e189SDavid Sterba __field( u64, ino ) 4841abe9b8aSliubo __field( u64, file_offset ) 4851abe9b8aSliubo __field( u64, start ) 4861abe9b8aSliubo __field( u64, len ) 4871abe9b8aSliubo __field( u64, disk_len ) 4881abe9b8aSliubo __field( u64, bytes_left ) 4891abe9b8aSliubo __field( unsigned long, flags ) 4901abe9b8aSliubo __field( int, compress_type ) 4911abe9b8aSliubo __field( int, refs ) 4921abe9b8aSliubo __field( u64, root_objectid ) 49378566548SLiu Bo __field( u64, truncated_len ) 4941abe9b8aSliubo ), 4951abe9b8aSliubo 496bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 497f8f8e189SDavid Sterba __entry->ino = btrfs_ino(BTRFS_I(inode)); 4981abe9b8aSliubo __entry->file_offset = ordered->file_offset; 4991abe9b8aSliubo __entry->start = ordered->start; 5001abe9b8aSliubo __entry->len = ordered->len; 5011abe9b8aSliubo __entry->disk_len = ordered->disk_len; 5021abe9b8aSliubo __entry->bytes_left = ordered->bytes_left; 5031abe9b8aSliubo __entry->flags = ordered->flags; 5041abe9b8aSliubo __entry->compress_type = ordered->compress_type; 505e76edab7SElena Reshetova __entry->refs = refcount_read(&ordered->refs); 5061abe9b8aSliubo __entry->root_objectid = 5071abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 50878566548SLiu Bo __entry->truncated_len = ordered->truncated_len; 5091abe9b8aSliubo ), 5101abe9b8aSliubo 511562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu " 512562a7a07SDavid Sterba "start=%llu len=%llu disk_len=%llu " 513562a7a07SDavid Sterba "truncated_len=%llu " 514562a7a07SDavid Sterba "bytes_left=%llu flags=%s compress_type=%d " 5151abe9b8aSliubo "refs=%d", 5161abe9b8aSliubo show_root_type(__entry->root_objectid), 5178eec8463SDavid Sterba __entry->ino, 5188eec8463SDavid Sterba __entry->file_offset, 5198eec8463SDavid Sterba __entry->start, 5208eec8463SDavid Sterba __entry->len, 5218eec8463SDavid Sterba __entry->disk_len, 5228eec8463SDavid Sterba __entry->truncated_len, 5238eec8463SDavid Sterba __entry->bytes_left, 5241abe9b8aSliubo show_ordered_flags(__entry->flags), 5251abe9b8aSliubo __entry->compress_type, __entry->refs) 5261abe9b8aSliubo ); 5271abe9b8aSliubo 5281abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, 5291abe9b8aSliubo 5309a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 5319a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 5321abe9b8aSliubo 5331abe9b8aSliubo TP_ARGS(inode, ordered) 5341abe9b8aSliubo ); 5351abe9b8aSliubo 5361abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, 5371abe9b8aSliubo 5389a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 5399a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 5401abe9b8aSliubo 5411abe9b8aSliubo TP_ARGS(inode, ordered) 5421abe9b8aSliubo ); 5431abe9b8aSliubo 5441abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, 5451abe9b8aSliubo 5469a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 5479a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 5481abe9b8aSliubo 5491abe9b8aSliubo TP_ARGS(inode, ordered) 5501abe9b8aSliubo ); 5511abe9b8aSliubo 5521abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, 5531abe9b8aSliubo 5549a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 5559a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 5561abe9b8aSliubo 5571abe9b8aSliubo TP_ARGS(inode, ordered) 5581abe9b8aSliubo ); 5591abe9b8aSliubo 5601abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage, 5611abe9b8aSliubo 5629a35b637SJeff Mahoney TP_PROTO(const struct page *page, const struct inode *inode, 5639a35b637SJeff Mahoney const struct writeback_control *wbc), 5641abe9b8aSliubo 5651abe9b8aSliubo TP_ARGS(page, inode, wbc), 5661abe9b8aSliubo 567bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 568f8f8e189SDavid Sterba __field( u64, ino ) 5691abe9b8aSliubo __field( pgoff_t, index ) 5701abe9b8aSliubo __field( long, nr_to_write ) 5711abe9b8aSliubo __field( long, pages_skipped ) 5721abe9b8aSliubo __field( loff_t, range_start ) 5731abe9b8aSliubo __field( loff_t, range_end ) 5741abe9b8aSliubo __field( char, for_kupdate ) 5751abe9b8aSliubo __field( char, for_reclaim ) 5761abe9b8aSliubo __field( char, range_cyclic ) 577*94c3f6c6SDavid Sterba __field( unsigned long, writeback_index ) 5781abe9b8aSliubo __field( u64, root_objectid ) 5791abe9b8aSliubo ), 5801abe9b8aSliubo 581bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 582f8f8e189SDavid Sterba __entry->ino = btrfs_ino(BTRFS_I(inode)); 5831abe9b8aSliubo __entry->index = page->index; 5841abe9b8aSliubo __entry->nr_to_write = wbc->nr_to_write; 5851abe9b8aSliubo __entry->pages_skipped = wbc->pages_skipped; 5861abe9b8aSliubo __entry->range_start = wbc->range_start; 5871abe9b8aSliubo __entry->range_end = wbc->range_end; 5881abe9b8aSliubo __entry->for_kupdate = wbc->for_kupdate; 5891abe9b8aSliubo __entry->for_reclaim = wbc->for_reclaim; 5901abe9b8aSliubo __entry->range_cyclic = wbc->range_cyclic; 5911abe9b8aSliubo __entry->writeback_index = inode->i_mapping->writeback_index; 5921abe9b8aSliubo __entry->root_objectid = 5931abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 5941abe9b8aSliubo ), 5951abe9b8aSliubo 596f8f8e189SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu " 597562a7a07SDavid Sterba "nr_to_write=%ld pages_skipped=%ld range_start=%llu " 598562a7a07SDavid Sterba "range_end=%llu for_kupdate=%d " 599562a7a07SDavid Sterba "for_reclaim=%d range_cyclic=%d writeback_index=%lu", 6001abe9b8aSliubo show_root_type(__entry->root_objectid), 6018eec8463SDavid Sterba __entry->ino, __entry->index, 6021abe9b8aSliubo __entry->nr_to_write, __entry->pages_skipped, 6031abe9b8aSliubo __entry->range_start, __entry->range_end, 604846d5a09SWu Fengguang __entry->for_kupdate, 6051abe9b8aSliubo __entry->for_reclaim, __entry->range_cyclic, 606*94c3f6c6SDavid Sterba __entry->writeback_index) 6071abe9b8aSliubo ); 6081abe9b8aSliubo 6091abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage, 6101abe9b8aSliubo 6119a35b637SJeff Mahoney TP_PROTO(const struct page *page, const struct inode *inode, 6129a35b637SJeff Mahoney const struct writeback_control *wbc), 6131abe9b8aSliubo 6141abe9b8aSliubo TP_ARGS(page, inode, wbc) 6151abe9b8aSliubo ); 6161abe9b8aSliubo 6171abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook, 6181abe9b8aSliubo 6199a35b637SJeff Mahoney TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate), 6201abe9b8aSliubo 6211abe9b8aSliubo TP_ARGS(page, start, end, uptodate), 6221abe9b8aSliubo 623bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 624f8f8e189SDavid Sterba __field( u64, ino ) 625*94c3f6c6SDavid Sterba __field( unsigned long, index ) 6261abe9b8aSliubo __field( u64, start ) 6271abe9b8aSliubo __field( u64, end ) 6281abe9b8aSliubo __field( int, uptodate ) 6291abe9b8aSliubo __field( u64, root_objectid ) 6301abe9b8aSliubo ), 6311abe9b8aSliubo 632bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb), 633f8f8e189SDavid Sterba __entry->ino = btrfs_ino(BTRFS_I(page->mapping->host)); 6341abe9b8aSliubo __entry->index = page->index; 6351abe9b8aSliubo __entry->start = start; 6361abe9b8aSliubo __entry->end = end; 6371abe9b8aSliubo __entry->uptodate = uptodate; 6381abe9b8aSliubo __entry->root_objectid = 6391abe9b8aSliubo BTRFS_I(page->mapping->host)->root->root_key.objectid; 6401abe9b8aSliubo ), 6411abe9b8aSliubo 642f8f8e189SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu start=%llu " 643562a7a07SDavid Sterba "end=%llu uptodate=%d", 6441abe9b8aSliubo show_root_type(__entry->root_objectid), 645*94c3f6c6SDavid Sterba __entry->ino, __entry->index, 6468eec8463SDavid Sterba __entry->start, 6478eec8463SDavid Sterba __entry->end, __entry->uptodate) 6481abe9b8aSliubo ); 6491abe9b8aSliubo 6501abe9b8aSliubo TRACE_EVENT(btrfs_sync_file, 6511abe9b8aSliubo 6529a35b637SJeff Mahoney TP_PROTO(const struct file *file, int datasync), 6531abe9b8aSliubo 6541abe9b8aSliubo TP_ARGS(file, datasync), 6551abe9b8aSliubo 656bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 657f8f8e189SDavid Sterba __field( u64, ino ) 658f8f8e189SDavid Sterba __field( u64, parent ) 6591abe9b8aSliubo __field( int, datasync ) 6601abe9b8aSliubo __field( u64, root_objectid ) 6611abe9b8aSliubo ), 6621abe9b8aSliubo 6631abe9b8aSliubo TP_fast_assign( 6649a35b637SJeff Mahoney const struct dentry *dentry = file->f_path.dentry; 6659a35b637SJeff Mahoney const struct inode *inode = d_inode(dentry); 6661abe9b8aSliubo 667bc074524SJeff Mahoney TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb)); 668f8f8e189SDavid Sterba __entry->ino = btrfs_ino(BTRFS_I(inode)); 669f8f8e189SDavid Sterba __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent))); 6701abe9b8aSliubo __entry->datasync = datasync; 6711abe9b8aSliubo __entry->root_objectid = 6721abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 6731abe9b8aSliubo ), 6741abe9b8aSliubo 675f8f8e189SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d", 6761abe9b8aSliubo show_root_type(__entry->root_objectid), 6778eec8463SDavid Sterba __entry->ino, 6788eec8463SDavid Sterba __entry->parent, 6791abe9b8aSliubo __entry->datasync) 6801abe9b8aSliubo ); 6811abe9b8aSliubo 6821abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs, 6831abe9b8aSliubo 6849a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, int wait), 6851abe9b8aSliubo 686bc074524SJeff Mahoney TP_ARGS(fs_info, wait), 6871abe9b8aSliubo 688bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 6891abe9b8aSliubo __field( int, wait ) 6901abe9b8aSliubo ), 6911abe9b8aSliubo 692bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 6931abe9b8aSliubo __entry->wait = wait; 6941abe9b8aSliubo ), 6951abe9b8aSliubo 696bc074524SJeff Mahoney TP_printk_btrfs("wait=%d", __entry->wait) 6971abe9b8aSliubo ); 6981abe9b8aSliubo 699c83f8effSJosef Bacik TRACE_EVENT(btrfs_add_block_group, 700c83f8effSJosef Bacik 7019a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7029a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, int create), 703c83f8effSJosef Bacik 704c83f8effSJosef Bacik TP_ARGS(fs_info, block_group, create), 705c83f8effSJosef Bacik 7062e63e62dSDavid Sterba TP_STRUCT__entry_btrfs( 707c83f8effSJosef Bacik __field( u64, offset ) 708c83f8effSJosef Bacik __field( u64, size ) 709c83f8effSJosef Bacik __field( u64, flags ) 710c83f8effSJosef Bacik __field( u64, bytes_used ) 711c83f8effSJosef Bacik __field( u64, bytes_super ) 712c83f8effSJosef Bacik __field( int, create ) 713c83f8effSJosef Bacik ), 714c83f8effSJosef Bacik 7152e63e62dSDavid Sterba TP_fast_assign_btrfs(fs_info, 716c83f8effSJosef Bacik __entry->offset = block_group->key.objectid; 717c83f8effSJosef Bacik __entry->size = block_group->key.offset; 718c83f8effSJosef Bacik __entry->flags = block_group->flags; 719c83f8effSJosef Bacik __entry->bytes_used = 720c83f8effSJosef Bacik btrfs_block_group_used(&block_group->item); 721c83f8effSJosef Bacik __entry->bytes_super = block_group->bytes_super; 722c83f8effSJosef Bacik __entry->create = create; 723c83f8effSJosef Bacik ), 724c83f8effSJosef Bacik 7252e63e62dSDavid Sterba TP_printk_btrfs("block_group offset=%llu size=%llu " 726562a7a07SDavid Sterba "flags=%llu(%s) bytes_used=%llu bytes_super=%llu " 7272e63e62dSDavid Sterba "create=%d", 7288eec8463SDavid Sterba __entry->offset, 7298eec8463SDavid Sterba __entry->size, 7308eec8463SDavid Sterba __entry->flags, 731c83f8effSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 732c83f8effSJosef Bacik BTRFS_GROUP_FLAGS), 7338eec8463SDavid Sterba __entry->bytes_used, 7348eec8463SDavid Sterba __entry->bytes_super, __entry->create) 735c83f8effSJosef Bacik ); 736c83f8effSJosef Bacik 7371abe9b8aSliubo #define show_ref_action(action) \ 7381abe9b8aSliubo __print_symbolic(action, \ 7391abe9b8aSliubo { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 7401abe9b8aSliubo { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 7411abe9b8aSliubo { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 7421abe9b8aSliubo { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 7431abe9b8aSliubo 7441abe9b8aSliubo 745599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 7461abe9b8aSliubo 7479a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7489a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7499a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 7501abe9b8aSliubo int action), 7511abe9b8aSliubo 752bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 7531abe9b8aSliubo 754bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 7551abe9b8aSliubo __field( u64, bytenr ) 7561abe9b8aSliubo __field( u64, num_bytes ) 7571abe9b8aSliubo __field( int, action ) 7581abe9b8aSliubo __field( u64, parent ) 7591abe9b8aSliubo __field( u64, ref_root ) 7601abe9b8aSliubo __field( int, level ) 7611abe9b8aSliubo __field( int, type ) 762dea7d76eSLiu Bo __field( u64, seq ) 7631abe9b8aSliubo ), 7641abe9b8aSliubo 765bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 7661abe9b8aSliubo __entry->bytenr = ref->bytenr; 7671abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 7681abe9b8aSliubo __entry->action = action; 7691abe9b8aSliubo __entry->parent = full_ref->parent; 7701abe9b8aSliubo __entry->ref_root = full_ref->root; 7711abe9b8aSliubo __entry->level = full_ref->level; 7721abe9b8aSliubo __entry->type = ref->type; 773dea7d76eSLiu Bo __entry->seq = ref->seq; 7741abe9b8aSliubo ), 7751abe9b8aSliubo 776562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 777562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) level=%d " 778562a7a07SDavid Sterba "type=%s seq=%llu", 7798eec8463SDavid Sterba __entry->bytenr, 7808eec8463SDavid Sterba __entry->num_bytes, 7811abe9b8aSliubo show_ref_action(__entry->action), 7821abe9b8aSliubo show_root_type(__entry->parent), 7831abe9b8aSliubo show_root_type(__entry->ref_root), 784dea7d76eSLiu Bo __entry->level, show_ref_type(__entry->type), 7858eec8463SDavid Sterba __entry->seq) 7861abe9b8aSliubo ); 7871abe9b8aSliubo 788599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 789599c75ecSLiu Bo 7909a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7919a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7929a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 793599c75ecSLiu Bo int action), 794599c75ecSLiu Bo 795bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 796599c75ecSLiu Bo ); 797599c75ecSLiu Bo 798599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 799599c75ecSLiu Bo 8009a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8019a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8029a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 803599c75ecSLiu Bo int action), 804599c75ecSLiu Bo 805bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 806599c75ecSLiu Bo ); 807599c75ecSLiu Bo 808599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 8091abe9b8aSliubo 8109a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8119a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8129a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 8131abe9b8aSliubo int action), 8141abe9b8aSliubo 815bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 8161abe9b8aSliubo 817bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 8181abe9b8aSliubo __field( u64, bytenr ) 8191abe9b8aSliubo __field( u64, num_bytes ) 8201abe9b8aSliubo __field( int, action ) 8211abe9b8aSliubo __field( u64, parent ) 8221abe9b8aSliubo __field( u64, ref_root ) 8231abe9b8aSliubo __field( u64, owner ) 8241abe9b8aSliubo __field( u64, offset ) 8251abe9b8aSliubo __field( int, type ) 826dea7d76eSLiu Bo __field( u64, seq ) 8271abe9b8aSliubo ), 8281abe9b8aSliubo 829bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 8301abe9b8aSliubo __entry->bytenr = ref->bytenr; 8311abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 8321abe9b8aSliubo __entry->action = action; 8331abe9b8aSliubo __entry->parent = full_ref->parent; 8341abe9b8aSliubo __entry->ref_root = full_ref->root; 8351abe9b8aSliubo __entry->owner = full_ref->objectid; 8361abe9b8aSliubo __entry->offset = full_ref->offset; 8371abe9b8aSliubo __entry->type = ref->type; 838dea7d76eSLiu Bo __entry->seq = ref->seq; 8391abe9b8aSliubo ), 8401abe9b8aSliubo 841562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 842562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) owner=%llu " 843562a7a07SDavid Sterba "offset=%llu type=%s seq=%llu", 8448eec8463SDavid Sterba __entry->bytenr, 8458eec8463SDavid Sterba __entry->num_bytes, 8461abe9b8aSliubo show_ref_action(__entry->action), 8471abe9b8aSliubo show_root_type(__entry->parent), 8481abe9b8aSliubo show_root_type(__entry->ref_root), 8498eec8463SDavid Sterba __entry->owner, 8508eec8463SDavid Sterba __entry->offset, 851dea7d76eSLiu Bo show_ref_type(__entry->type), 8528eec8463SDavid Sterba __entry->seq) 8531abe9b8aSliubo ); 8541abe9b8aSliubo 855599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 856599c75ecSLiu Bo 8579a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8589a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8599a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 860599c75ecSLiu Bo int action), 861599c75ecSLiu Bo 862bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 863599c75ecSLiu Bo ); 864599c75ecSLiu Bo 865599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 866599c75ecSLiu Bo 8679a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8689a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8699a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 870599c75ecSLiu Bo int action), 871599c75ecSLiu Bo 872bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 873599c75ecSLiu Bo ); 874599c75ecSLiu Bo 875599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 8761abe9b8aSliubo 8779a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8789a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 8791abe9b8aSliubo int action), 8801abe9b8aSliubo 881d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action), 8821abe9b8aSliubo 883bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 8841abe9b8aSliubo __field( u64, bytenr ) 8851abe9b8aSliubo __field( u64, num_bytes ) 8861abe9b8aSliubo __field( int, action ) 8871abe9b8aSliubo __field( int, is_data ) 8881abe9b8aSliubo ), 8891abe9b8aSliubo 890bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 891d278850eSJosef Bacik __entry->bytenr = head_ref->bytenr; 892d278850eSJosef Bacik __entry->num_bytes = head_ref->num_bytes; 8931abe9b8aSliubo __entry->action = action; 8941abe9b8aSliubo __entry->is_data = head_ref->is_data; 8951abe9b8aSliubo ), 8961abe9b8aSliubo 897562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d", 8988eec8463SDavid Sterba __entry->bytenr, 8998eec8463SDavid Sterba __entry->num_bytes, 9001abe9b8aSliubo show_ref_action(__entry->action), 9011abe9b8aSliubo __entry->is_data) 9021abe9b8aSliubo ); 9031abe9b8aSliubo 904599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 905599c75ecSLiu Bo 9069a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9079a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 908599c75ecSLiu Bo int action), 909599c75ecSLiu Bo 910d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action) 911599c75ecSLiu Bo ); 912599c75ecSLiu Bo 913599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 914599c75ecSLiu Bo 9159a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9169a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 917599c75ecSLiu Bo int action), 918599c75ecSLiu Bo 919d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action) 920599c75ecSLiu Bo ); 921599c75ecSLiu Bo 9221abe9b8aSliubo #define show_chunk_type(type) \ 9231abe9b8aSliubo __print_flags(type, "|", \ 9241abe9b8aSliubo { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 9251abe9b8aSliubo { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 9261abe9b8aSliubo { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 9271abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 9281abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 9291abe9b8aSliubo { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 930e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 931e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 932e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 9331abe9b8aSliubo 9341abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk, 9351abe9b8aSliubo 9369a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9379a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9381abe9b8aSliubo 9396bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size), 9401abe9b8aSliubo 941bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9421abe9b8aSliubo __field( int, num_stripes ) 9431abe9b8aSliubo __field( u64, type ) 9441abe9b8aSliubo __field( int, sub_stripes ) 9451abe9b8aSliubo __field( u64, offset ) 9461abe9b8aSliubo __field( u64, size ) 9471abe9b8aSliubo __field( u64, root_objectid ) 9481abe9b8aSliubo ), 9491abe9b8aSliubo 9506bccf3abSJeff Mahoney TP_fast_assign_btrfs(fs_info, 9511abe9b8aSliubo __entry->num_stripes = map->num_stripes; 9521abe9b8aSliubo __entry->type = map->type; 9531abe9b8aSliubo __entry->sub_stripes = map->sub_stripes; 9541abe9b8aSliubo __entry->offset = offset; 9551abe9b8aSliubo __entry->size = size; 9566bccf3abSJeff Mahoney __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 9571abe9b8aSliubo ), 9581abe9b8aSliubo 959562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu " 960562a7a07SDavid Sterba "num_stripes=%d sub_stripes=%d type=%s", 9611abe9b8aSliubo show_root_type(__entry->root_objectid), 9628eec8463SDavid Sterba __entry->offset, 9638eec8463SDavid Sterba __entry->size, 9641abe9b8aSliubo __entry->num_stripes, __entry->sub_stripes, 9651abe9b8aSliubo show_chunk_type(__entry->type)) 9661abe9b8aSliubo ); 9671abe9b8aSliubo 9681abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 9691abe9b8aSliubo 9709a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9719a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9721abe9b8aSliubo 9736bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 9741abe9b8aSliubo ); 9751abe9b8aSliubo 9761abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 9771abe9b8aSliubo 9789a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9799a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9801abe9b8aSliubo 9816bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 9821abe9b8aSliubo ); 9831abe9b8aSliubo 9841abe9b8aSliubo TRACE_EVENT(btrfs_cow_block, 9851abe9b8aSliubo 9869a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf, 9879a35b637SJeff Mahoney const struct extent_buffer *cow), 9881abe9b8aSliubo 9891abe9b8aSliubo TP_ARGS(root, buf, cow), 9901abe9b8aSliubo 991bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9921abe9b8aSliubo __field( u64, root_objectid ) 9931abe9b8aSliubo __field( u64, buf_start ) 9941abe9b8aSliubo __field( int, refs ) 9951abe9b8aSliubo __field( u64, cow_start ) 9961abe9b8aSliubo __field( int, buf_level ) 9971abe9b8aSliubo __field( int, cow_level ) 9981abe9b8aSliubo ), 9991abe9b8aSliubo 1000bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 10011abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 10021abe9b8aSliubo __entry->buf_start = buf->start; 10031abe9b8aSliubo __entry->refs = atomic_read(&buf->refs); 10041abe9b8aSliubo __entry->cow_start = cow->start; 10051abe9b8aSliubo __entry->buf_level = btrfs_header_level(buf); 10061abe9b8aSliubo __entry->cow_level = btrfs_header_level(cow); 10071abe9b8aSliubo ), 10081abe9b8aSliubo 1009562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu " 1010562a7a07SDavid Sterba "(orig_level=%d) cow_buf=%llu (cow_level=%d)", 10111abe9b8aSliubo show_root_type(__entry->root_objectid), 10121abe9b8aSliubo __entry->refs, 10138eec8463SDavid Sterba __entry->buf_start, 10141abe9b8aSliubo __entry->buf_level, 10158eec8463SDavid Sterba __entry->cow_start, 10161abe9b8aSliubo __entry->cow_level) 10171abe9b8aSliubo ); 10181abe9b8aSliubo 10198c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation, 10208c2a3ca2SJosef Bacik 10219a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val, 10228c2a3ca2SJosef Bacik u64 bytes, int reserve), 10238c2a3ca2SJosef Bacik 10248c2a3ca2SJosef Bacik TP_ARGS(fs_info, type, val, bytes, reserve), 10258c2a3ca2SJosef Bacik 1026bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 10278c2a3ca2SJosef Bacik __string( type, type ) 10288c2a3ca2SJosef Bacik __field( u64, val ) 10298c2a3ca2SJosef Bacik __field( u64, bytes ) 10308c2a3ca2SJosef Bacik __field( int, reserve ) 10318c2a3ca2SJosef Bacik ), 10328c2a3ca2SJosef Bacik 1033bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 10348c2a3ca2SJosef Bacik __assign_str(type, type); 10358c2a3ca2SJosef Bacik __entry->val = val; 10368c2a3ca2SJosef Bacik __entry->bytes = bytes; 10378c2a3ca2SJosef Bacik __entry->reserve = reserve; 10388c2a3ca2SJosef Bacik ), 10398c2a3ca2SJosef Bacik 10405439c7f5SDavid Sterba TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val, 1041bc074524SJeff Mahoney __entry->reserve ? "reserve" : "release", 10428c2a3ca2SJosef Bacik __entry->bytes) 10438c2a3ca2SJosef Bacik ); 10448c2a3ca2SJosef Bacik 1045f376df2bSJosef Bacik #define show_flush_action(action) \ 1046f376df2bSJosef Bacik __print_symbolic(action, \ 1047f376df2bSJosef Bacik { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ 1048f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ 1049f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) 1050f376df2bSJosef Bacik 1051f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush, 1052f376df2bSJosef Bacik 10539a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 1054f376df2bSJosef Bacik int flush, char *reason), 1055f376df2bSJosef Bacik 1056f376df2bSJosef Bacik TP_ARGS(fs_info, flags, bytes, flush, reason), 1057f376df2bSJosef Bacik 10582e63e62dSDavid Sterba TP_STRUCT__entry_btrfs( 1059f376df2bSJosef Bacik __field( u64, flags ) 1060f376df2bSJosef Bacik __field( u64, bytes ) 1061f376df2bSJosef Bacik __field( int, flush ) 1062f376df2bSJosef Bacik __string( reason, reason ) 1063f376df2bSJosef Bacik ), 1064f376df2bSJosef Bacik 10652e63e62dSDavid Sterba TP_fast_assign_btrfs(fs_info, 1066f376df2bSJosef Bacik __entry->flags = flags; 1067f376df2bSJosef Bacik __entry->bytes = bytes; 1068f376df2bSJosef Bacik __entry->flush = flush; 1069f376df2bSJosef Bacik __assign_str(reason, reason) 1070f376df2bSJosef Bacik ), 1071f376df2bSJosef Bacik 10722e63e62dSDavid Sterba TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu", 10732e63e62dSDavid Sterba __get_str(reason), __entry->flush, 1074f376df2bSJosef Bacik show_flush_action(__entry->flush), 10758eec8463SDavid Sterba __entry->flags, 1076f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 1077f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 10788eec8463SDavid Sterba __entry->bytes) 1079f376df2bSJosef Bacik ); 1080f376df2bSJosef Bacik 1081f376df2bSJosef Bacik #define show_flush_state(state) \ 1082f376df2bSJosef Bacik __print_symbolic(state, \ 1083f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ 1084f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ 1085f376df2bSJosef Bacik { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ 1086f376df2bSJosef Bacik { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ 1087413df725SJosef Bacik { FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR"}, \ 1088413df725SJosef Bacik { FLUSH_DELAYED_REFS, "FLUSH_ELAYED_REFS"}, \ 1089f376df2bSJosef Bacik { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ 1090450114fcSJosef Bacik { ALLOC_CHUNK_FORCE, "ALLOC_CHUNK_FORCE"}, \ 1091844245b4SJosef Bacik { RUN_DELAYED_IPUTS, "RUN_DELAYED_IPUTS"}, \ 1092f376df2bSJosef Bacik { COMMIT_TRANS, "COMMIT_TRANS"}) 1093f376df2bSJosef Bacik 1094f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space, 1095f376df2bSJosef Bacik 10969a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, 10977bdd6277SNikolay Borisov int state, int ret), 1098f376df2bSJosef Bacik 10997bdd6277SNikolay Borisov TP_ARGS(fs_info, flags, num_bytes, state, ret), 1100f376df2bSJosef Bacik 11012e63e62dSDavid Sterba TP_STRUCT__entry_btrfs( 1102f376df2bSJosef Bacik __field( u64, flags ) 1103f376df2bSJosef Bacik __field( u64, num_bytes ) 1104f376df2bSJosef Bacik __field( int, state ) 1105f376df2bSJosef Bacik __field( int, ret ) 1106f376df2bSJosef Bacik ), 1107f376df2bSJosef Bacik 11082e63e62dSDavid Sterba TP_fast_assign_btrfs(fs_info, 1109f376df2bSJosef Bacik __entry->flags = flags; 1110f376df2bSJosef Bacik __entry->num_bytes = num_bytes; 1111f376df2bSJosef Bacik __entry->state = state; 1112f376df2bSJosef Bacik __entry->ret = ret; 1113f376df2bSJosef Bacik ), 1114f376df2bSJosef Bacik 11152e63e62dSDavid Sterba TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d", 11162e63e62dSDavid Sterba __entry->state, 1117f376df2bSJosef Bacik show_flush_state(__entry->state), 11188eec8463SDavid Sterba __entry->flags, 1119f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 1120f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 11218eec8463SDavid Sterba __entry->num_bytes, __entry->ret) 1122f376df2bSJosef Bacik ); 1123f376df2bSJosef Bacik 11241abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent, 11251abe9b8aSliubo 11269a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11271abe9b8aSliubo 112871ff6437SJeff Mahoney TP_ARGS(fs_info, start, len), 11291abe9b8aSliubo 1130bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11311abe9b8aSliubo __field( u64, start ) 11321abe9b8aSliubo __field( u64, len ) 11331abe9b8aSliubo ), 11341abe9b8aSliubo 113571ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 11361abe9b8aSliubo __entry->start = start; 11371abe9b8aSliubo __entry->len = len; 11381abe9b8aSliubo ), 11391abe9b8aSliubo 1140562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu", 114171ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 11428eec8463SDavid Sterba __entry->start, 11438eec8463SDavid Sterba __entry->len) 11441abe9b8aSliubo ); 11451abe9b8aSliubo 11461abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 11471abe9b8aSliubo 11489a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11491abe9b8aSliubo 115071ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 11511abe9b8aSliubo ); 11521abe9b8aSliubo 11531abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 11541abe9b8aSliubo 11559a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11561abe9b8aSliubo 115771ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 11581abe9b8aSliubo ); 11591abe9b8aSliubo 11603f7de037SJosef Bacik TRACE_EVENT(find_free_extent, 11613f7de037SJosef Bacik 11629a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, 11639a35b637SJeff Mahoney u64 empty_size, u64 data), 11643f7de037SJosef Bacik 116571ff6437SJeff Mahoney TP_ARGS(fs_info, num_bytes, empty_size, data), 11663f7de037SJosef Bacik 1167bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11683f7de037SJosef Bacik __field( u64, num_bytes ) 11693f7de037SJosef Bacik __field( u64, empty_size ) 11703f7de037SJosef Bacik __field( u64, data ) 11713f7de037SJosef Bacik ), 11723f7de037SJosef Bacik 117371ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 11743f7de037SJosef Bacik __entry->num_bytes = num_bytes; 11753f7de037SJosef Bacik __entry->empty_size = empty_size; 11763f7de037SJosef Bacik __entry->data = data; 11773f7de037SJosef Bacik ), 11783f7de037SJosef Bacik 11795439c7f5SDavid Sterba TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)", 118071ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 11813f7de037SJosef Bacik __entry->num_bytes, __entry->empty_size, __entry->data, 11823f7de037SJosef Bacik __print_flags((unsigned long)__entry->data, "|", 11833f7de037SJosef Bacik BTRFS_GROUP_FLAGS)) 11843f7de037SJosef Bacik ); 11853f7de037SJosef Bacik 11863f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent, 11873f7de037SJosef Bacik 11883dca5c94SQu Wenruo TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 11893f7de037SJosef Bacik u64 len), 11903f7de037SJosef Bacik 11913dca5c94SQu Wenruo TP_ARGS(block_group, start, len), 11923f7de037SJosef Bacik 1193bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11943f7de037SJosef Bacik __field( u64, bg_objectid ) 11953f7de037SJosef Bacik __field( u64, flags ) 11963f7de037SJosef Bacik __field( u64, start ) 11973f7de037SJosef Bacik __field( u64, len ) 11983f7de037SJosef Bacik ), 11993f7de037SJosef Bacik 12003dca5c94SQu Wenruo TP_fast_assign_btrfs(block_group->fs_info, 12013f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12023f7de037SJosef Bacik __entry->flags = block_group->flags; 12033f7de037SJosef Bacik __entry->start = start; 12043f7de037SJosef Bacik __entry->len = len; 12053f7de037SJosef Bacik ), 12063f7de037SJosef Bacik 12075439c7f5SDavid Sterba TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) " 12085439c7f5SDavid Sterba "start=%llu len=%llu", 120971ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 121071ff6437SJeff Mahoney __entry->bg_objectid, 12113f7de037SJosef Bacik __entry->flags, __print_flags((unsigned long)__entry->flags, 12123f7de037SJosef Bacik "|", BTRFS_GROUP_FLAGS), 12133f7de037SJosef Bacik __entry->start, __entry->len) 12143f7de037SJosef Bacik ); 12153f7de037SJosef Bacik 12163f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 12173f7de037SJosef Bacik 12183dca5c94SQu Wenruo TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 12193f7de037SJosef Bacik u64 len), 12203f7de037SJosef Bacik 12213dca5c94SQu Wenruo TP_ARGS(block_group, start, len) 12223f7de037SJosef Bacik ); 12233f7de037SJosef Bacik 12243f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 12253f7de037SJosef Bacik 12263dca5c94SQu Wenruo TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 12273f7de037SJosef Bacik u64 len), 12283f7de037SJosef Bacik 12293dca5c94SQu Wenruo TP_ARGS(block_group, start, len) 12303f7de037SJosef Bacik ); 12313f7de037SJosef Bacik 12323f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster, 12333f7de037SJosef Bacik 12349a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 12353f7de037SJosef Bacik u64 bytes, u64 empty_size, u64 min_bytes), 12363f7de037SJosef Bacik 12373f7de037SJosef Bacik TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 12383f7de037SJosef Bacik 1239bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12403f7de037SJosef Bacik __field( u64, bg_objectid ) 12413f7de037SJosef Bacik __field( u64, flags ) 12423f7de037SJosef Bacik __field( u64, start ) 12433f7de037SJosef Bacik __field( u64, bytes ) 12443f7de037SJosef Bacik __field( u64, empty_size ) 12453f7de037SJosef Bacik __field( u64, min_bytes ) 12463f7de037SJosef Bacik ), 12473f7de037SJosef Bacik 1248bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 12493f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12503f7de037SJosef Bacik __entry->flags = block_group->flags; 12513f7de037SJosef Bacik __entry->start = start; 12523f7de037SJosef Bacik __entry->bytes = bytes; 12533f7de037SJosef Bacik __entry->empty_size = empty_size; 12543f7de037SJosef Bacik __entry->min_bytes = min_bytes; 12553f7de037SJosef Bacik ), 12563f7de037SJosef Bacik 12575439c7f5SDavid Sterba TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu " 12585439c7f5SDavid Sterba "empty_size=%llu min_bytes=%llu", __entry->bg_objectid, 12593f7de037SJosef Bacik __entry->flags, 12603f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 12613f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 12623f7de037SJosef Bacik __entry->bytes, __entry->empty_size, __entry->min_bytes) 12633f7de037SJosef Bacik ); 12643f7de037SJosef Bacik 12653f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup, 12663f7de037SJosef Bacik 12679a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group), 12683f7de037SJosef Bacik 12693f7de037SJosef Bacik TP_ARGS(block_group), 12703f7de037SJosef Bacik 1271bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12723f7de037SJosef Bacik __field( u64, bg_objectid ) 12733f7de037SJosef Bacik ), 12743f7de037SJosef Bacik 1275bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 12763f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12773f7de037SJosef Bacik ), 12783f7de037SJosef Bacik 12795439c7f5SDavid Sterba TP_printk_btrfs("block_group=%llu", __entry->bg_objectid) 12803f7de037SJosef Bacik ); 12813f7de037SJosef Bacik 12823f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster, 12833f7de037SJosef Bacik 12849a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group, 12859a35b637SJeff Mahoney const struct btrfs_free_cluster *cluster, 12869a35b637SJeff Mahoney u64 size, int bitmap), 12873f7de037SJosef Bacik 12883f7de037SJosef Bacik TP_ARGS(block_group, cluster, size, bitmap), 12893f7de037SJosef Bacik 1290bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12913f7de037SJosef Bacik __field( u64, bg_objectid ) 12923f7de037SJosef Bacik __field( u64, flags ) 12933f7de037SJosef Bacik __field( u64, start ) 12943f7de037SJosef Bacik __field( u64, max_size ) 12953f7de037SJosef Bacik __field( u64, size ) 12963f7de037SJosef Bacik __field( int, bitmap ) 12973f7de037SJosef Bacik ), 12983f7de037SJosef Bacik 1299bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 13003f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 13013f7de037SJosef Bacik __entry->flags = block_group->flags; 13023f7de037SJosef Bacik __entry->start = cluster->window_start; 13033f7de037SJosef Bacik __entry->max_size = cluster->max_size; 13043f7de037SJosef Bacik __entry->size = size; 13053f7de037SJosef Bacik __entry->bitmap = bitmap; 13063f7de037SJosef Bacik ), 13073f7de037SJosef Bacik 13085439c7f5SDavid Sterba TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu " 13095439c7f5SDavid Sterba "size=%llu max_size=%llu bitmap=%d", 13103f7de037SJosef Bacik __entry->bg_objectid, 13113f7de037SJosef Bacik __entry->flags, 13123f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 13133f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 13143f7de037SJosef Bacik __entry->size, __entry->max_size, __entry->bitmap) 13153f7de037SJosef Bacik ); 13163f7de037SJosef Bacik 1317143bede5SJeff Mahoney struct extent_state; 1318143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state, 1319143bede5SJeff Mahoney 13209a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, 13219a35b637SJeff Mahoney gfp_t mask, unsigned long IP), 1322143bede5SJeff Mahoney 1323143bede5SJeff Mahoney TP_ARGS(state, mask, IP), 1324143bede5SJeff Mahoney 1325143bede5SJeff Mahoney TP_STRUCT__entry( 13269a35b637SJeff Mahoney __field(const struct extent_state *, state) 1327143bede5SJeff Mahoney __field(gfp_t, mask) 1328*94c3f6c6SDavid Sterba __field(const void*, ip) 1329143bede5SJeff Mahoney ), 1330143bede5SJeff Mahoney 1331143bede5SJeff Mahoney TP_fast_assign( 1332143bede5SJeff Mahoney __entry->state = state, 1333143bede5SJeff Mahoney __entry->mask = mask, 1334*94c3f6c6SDavid Sterba __entry->ip = (const void *)IP 1335143bede5SJeff Mahoney ), 1336143bede5SJeff Mahoney 1337562a7a07SDavid Sterba TP_printk("state=%p mask=%s caller=%pS", __entry->state, 1338*94c3f6c6SDavid Sterba show_gfp_flags(__entry->mask), __entry->ip) 1339143bede5SJeff Mahoney ); 1340143bede5SJeff Mahoney 1341143bede5SJeff Mahoney TRACE_EVENT(free_extent_state, 1342143bede5SJeff Mahoney 13439a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, unsigned long IP), 1344143bede5SJeff Mahoney 1345143bede5SJeff Mahoney TP_ARGS(state, IP), 1346143bede5SJeff Mahoney 1347143bede5SJeff Mahoney TP_STRUCT__entry( 13489a35b637SJeff Mahoney __field(const struct extent_state *, state) 1349*94c3f6c6SDavid Sterba __field(const void*, ip) 1350143bede5SJeff Mahoney ), 1351143bede5SJeff Mahoney 1352143bede5SJeff Mahoney TP_fast_assign( 1353143bede5SJeff Mahoney __entry->state = state, 1354*94c3f6c6SDavid Sterba __entry->ip = (const void *)IP 1355143bede5SJeff Mahoney ), 1356143bede5SJeff Mahoney 1357*94c3f6c6SDavid Sterba TP_printk("state=%p caller=%pS", __entry->state, __entry->ip) 1358143bede5SJeff Mahoney ); 1359143bede5SJeff Mahoney 136052483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work, 136152483bc2SQu Wenruo 13629a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 136352483bc2SQu Wenruo 136452483bc2SQu Wenruo TP_ARGS(work), 136552483bc2SQu Wenruo 1366bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 13679a35b637SJeff Mahoney __field( const void *, work ) 13689a35b637SJeff Mahoney __field( const void *, wq ) 13699a35b637SJeff Mahoney __field( const void *, func ) 13709a35b637SJeff Mahoney __field( const void *, ordered_func ) 13719a35b637SJeff Mahoney __field( const void *, ordered_free ) 13729a35b637SJeff Mahoney __field( const void *, normal_work ) 137352483bc2SQu Wenruo ), 137452483bc2SQu Wenruo 1375bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_work_owner(work), 137652483bc2SQu Wenruo __entry->work = work; 137752483bc2SQu Wenruo __entry->wq = work->wq; 137852483bc2SQu Wenruo __entry->func = work->func; 137952483bc2SQu Wenruo __entry->ordered_func = work->ordered_func; 138052483bc2SQu Wenruo __entry->ordered_free = work->ordered_free; 1381b38a6258SLiu Bo __entry->normal_work = &work->normal_work; 138252483bc2SQu Wenruo ), 138352483bc2SQu Wenruo 1384d75f773cSSakari Ailus TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p " 1385b38a6258SLiu Bo "ordered_free=%p", 1386b38a6258SLiu Bo __entry->work, __entry->normal_work, __entry->wq, 1387b38a6258SLiu Bo __entry->func, __entry->ordered_func, __entry->ordered_free) 138852483bc2SQu Wenruo ); 138952483bc2SQu Wenruo 1390ac0c7cf8SDavid Sterba /* 1391c9eb55dbSOmar Sandoval * For situations when the work is freed, we pass fs_info and a tag that matches 1392c9eb55dbSOmar Sandoval * the address of the work structure so it can be paired with the scheduling 1393c9eb55dbSOmar Sandoval * event. DO NOT add anything here that dereferences wtag. 1394ac0c7cf8SDavid Sterba */ 139552483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done, 139652483bc2SQu Wenruo 13979a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 139852483bc2SQu Wenruo 1399ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag), 140052483bc2SQu Wenruo 1401bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14029a35b637SJeff Mahoney __field( const void *, wtag ) 140352483bc2SQu Wenruo ), 140452483bc2SQu Wenruo 1405ac0c7cf8SDavid Sterba TP_fast_assign_btrfs(fs_info, 1406ac0c7cf8SDavid Sterba __entry->wtag = wtag; 140752483bc2SQu Wenruo ), 140852483bc2SQu Wenruo 1409ac0c7cf8SDavid Sterba TP_printk_btrfs("work->%p", __entry->wtag) 141052483bc2SQu Wenruo ); 141152483bc2SQu Wenruo 141252483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued, 141352483bc2SQu Wenruo 14149a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 141552483bc2SQu Wenruo 141652483bc2SQu Wenruo TP_ARGS(work) 141752483bc2SQu Wenruo ); 141852483bc2SQu Wenruo 141952483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched, 142052483bc2SQu Wenruo 14219a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 142252483bc2SQu Wenruo 142352483bc2SQu Wenruo TP_ARGS(work) 142452483bc2SQu Wenruo ); 142552483bc2SQu Wenruo 142652483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 142752483bc2SQu Wenruo 14289a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 142952483bc2SQu Wenruo 1430ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag) 143152483bc2SQu Wenruo ); 143252483bc2SQu Wenruo 143352483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 143452483bc2SQu Wenruo 14359a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 143652483bc2SQu Wenruo 143752483bc2SQu Wenruo TP_ARGS(work) 143852483bc2SQu Wenruo ); 143952483bc2SQu Wenruo 1440c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue, 1441c3a46891SQu Wenruo 14429a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 14439a35b637SJeff Mahoney const char *name, int high), 1444c3a46891SQu Wenruo 1445c3a46891SQu Wenruo TP_ARGS(wq, name, high), 1446c3a46891SQu Wenruo 1447bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14489a35b637SJeff Mahoney __field( const void *, wq ) 1449c3a46891SQu Wenruo __string( name, name ) 1450c3a46891SQu Wenruo __field( int , high ) 1451c3a46891SQu Wenruo ), 1452c3a46891SQu Wenruo 1453bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1454c3a46891SQu Wenruo __entry->wq = wq; 1455c3a46891SQu Wenruo __assign_str(name, name); 1456c3a46891SQu Wenruo __entry->high = high; 1457c3a46891SQu Wenruo ), 1458c3a46891SQu Wenruo 1459562a7a07SDavid Sterba TP_printk_btrfs("name=%s%s wq=%p", __get_str(name), 1460c3a46891SQu Wenruo __print_flags(__entry->high, "", 1461c3a46891SQu Wenruo {(WQ_HIGHPRI), "-high"}), 1462c3a46891SQu Wenruo __entry->wq) 1463c3a46891SQu Wenruo ); 1464c3a46891SQu Wenruo 1465c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc, 1466c3a46891SQu Wenruo 14679a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 14689a35b637SJeff Mahoney const char *name, int high), 1469c3a46891SQu Wenruo 1470c3a46891SQu Wenruo TP_ARGS(wq, name, high) 1471c3a46891SQu Wenruo ); 1472c3a46891SQu Wenruo 1473c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue_done, 1474c3a46891SQu Wenruo 14759a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1476c3a46891SQu Wenruo 1477c3a46891SQu Wenruo TP_ARGS(wq), 1478c3a46891SQu Wenruo 1479bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14809a35b637SJeff Mahoney __field( const void *, wq ) 1481c3a46891SQu Wenruo ), 1482c3a46891SQu Wenruo 1483bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1484c3a46891SQu Wenruo __entry->wq = wq; 1485c3a46891SQu Wenruo ), 1486c3a46891SQu Wenruo 1487bc074524SJeff Mahoney TP_printk_btrfs("wq=%p", __entry->wq) 1488c3a46891SQu Wenruo ); 1489c3a46891SQu Wenruo 1490c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy, 1491c3a46891SQu Wenruo 14929a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1493c3a46891SQu Wenruo 1494c3a46891SQu Wenruo TP_ARGS(wq) 1495c3a46891SQu Wenruo ); 149652483bc2SQu Wenruo 149781fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS \ 149881fb6f77SQu Wenruo { QGROUP_RESERVE, "reserve" }, \ 149981fb6f77SQu Wenruo { QGROUP_RELEASE, "release" }, \ 150081fb6f77SQu Wenruo { QGROUP_FREE, "free" } 150181fb6f77SQu Wenruo 150281fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_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 1509bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 151081fb6f77SQu Wenruo __field( u64, rootid ) 1511f8f8e189SDavid Sterba __field( u64, ino ) 151281fb6f77SQu Wenruo __field( u64, start ) 151381fb6f77SQu Wenruo __field( u64, len ) 151481fb6f77SQu Wenruo __field( u64, reserved ) 151581fb6f77SQu Wenruo __field( int, op ) 151681fb6f77SQu Wenruo ), 151781fb6f77SQu Wenruo 1518bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 15194fd786e6SMisono Tomohiro __entry->rootid = 15204fd786e6SMisono Tomohiro BTRFS_I(inode)->root->root_key.objectid; 1521f8f8e189SDavid Sterba __entry->ino = btrfs_ino(BTRFS_I(inode)); 152281fb6f77SQu Wenruo __entry->start = start; 152381fb6f77SQu Wenruo __entry->len = len; 152481fb6f77SQu Wenruo __entry->reserved = reserved; 152581fb6f77SQu Wenruo __entry->op = op; 152681fb6f77SQu Wenruo ), 152781fb6f77SQu Wenruo 1528f8f8e189SDavid Sterba TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s", 152981fb6f77SQu Wenruo __entry->rootid, __entry->ino, __entry->start, __entry->len, 153081fb6f77SQu Wenruo __entry->reserved, 153181fb6f77SQu Wenruo __print_flags((unsigned long)__entry->op, "", 153281fb6f77SQu Wenruo BTRFS_QGROUP_OPERATIONS) 153381fb6f77SQu Wenruo ) 153481fb6f77SQu Wenruo ); 153581fb6f77SQu Wenruo 153681fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data, 153781fb6f77SQu Wenruo 15389a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 15399a35b637SJeff Mahoney u64 reserved, int op), 154081fb6f77SQu Wenruo 154181fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 154281fb6f77SQu Wenruo ); 154381fb6f77SQu Wenruo 154481fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data, 154581fb6f77SQu Wenruo 15469a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 15479a35b637SJeff Mahoney u64 reserved, int op), 154881fb6f77SQu Wenruo 154981fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 155081fb6f77SQu Wenruo ); 155181fb6f77SQu Wenruo 15520f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent, 15539a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15549a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15550f5dcf8dSMark Fasheh 1556bc074524SJeff Mahoney TP_ARGS(fs_info, rec), 15570f5dcf8dSMark Fasheh 1558bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 15590f5dcf8dSMark Fasheh __field( u64, bytenr ) 15600f5dcf8dSMark Fasheh __field( u64, num_bytes ) 15610f5dcf8dSMark Fasheh ), 15620f5dcf8dSMark Fasheh 1563bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 15640f5dcf8dSMark Fasheh __entry->bytenr = rec->bytenr, 15650f5dcf8dSMark Fasheh __entry->num_bytes = rec->num_bytes; 15660f5dcf8dSMark Fasheh ), 15670f5dcf8dSMark Fasheh 1568562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu", 1569*94c3f6c6SDavid Sterba __entry->bytenr, __entry->num_bytes) 15700f5dcf8dSMark Fasheh ); 15710f5dcf8dSMark Fasheh 15720f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents, 15730f5dcf8dSMark Fasheh 15749a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15759a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15760f5dcf8dSMark Fasheh 1577bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15780f5dcf8dSMark Fasheh ); 15790f5dcf8dSMark Fasheh 158050b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent, 15810f5dcf8dSMark Fasheh 15829a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15839a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15840f5dcf8dSMark Fasheh 1585bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15860f5dcf8dSMark Fasheh ); 15870f5dcf8dSMark Fasheh 1588c337e7b0SQu Wenruo TRACE_EVENT(qgroup_num_dirty_extents, 1589c337e7b0SQu Wenruo 1590c337e7b0SQu Wenruo TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, 1591c337e7b0SQu Wenruo u64 num_dirty_extents), 1592c337e7b0SQu Wenruo 1593c337e7b0SQu Wenruo TP_ARGS(fs_info, transid, num_dirty_extents), 1594c337e7b0SQu Wenruo 1595c337e7b0SQu Wenruo TP_STRUCT__entry_btrfs( 1596c337e7b0SQu Wenruo __field( u64, transid ) 1597c337e7b0SQu Wenruo __field( u64, num_dirty_extents ) 1598c337e7b0SQu Wenruo ), 1599c337e7b0SQu Wenruo 1600c337e7b0SQu Wenruo TP_fast_assign_btrfs(fs_info, 1601c337e7b0SQu Wenruo __entry->transid = transid; 1602c337e7b0SQu Wenruo __entry->num_dirty_extents = num_dirty_extents; 1603c337e7b0SQu Wenruo ), 1604c337e7b0SQu Wenruo 1605c337e7b0SQu Wenruo TP_printk_btrfs("transid=%llu num_dirty_extents=%llu", 1606c337e7b0SQu Wenruo __entry->transid, __entry->num_dirty_extents) 1607c337e7b0SQu Wenruo ); 1608c337e7b0SQu Wenruo 16090f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent, 16100f5dcf8dSMark Fasheh 1611c9f6f3cdSQu Wenruo TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr, 1612bc074524SJeff Mahoney u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots), 16130f5dcf8dSMark Fasheh 1614c9f6f3cdSQu Wenruo TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots, 1615c9f6f3cdSQu Wenruo nr_new_roots), 16160f5dcf8dSMark Fasheh 1617bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 1618c9f6f3cdSQu Wenruo __field( u64, transid ) 16190f5dcf8dSMark Fasheh __field( u64, bytenr ) 16200f5dcf8dSMark Fasheh __field( u64, num_bytes ) 16210f5dcf8dSMark Fasheh __field( u64, nr_old_roots ) 16220f5dcf8dSMark Fasheh __field( u64, nr_new_roots ) 16230f5dcf8dSMark Fasheh ), 16240f5dcf8dSMark Fasheh 1625bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 1626c9f6f3cdSQu Wenruo __entry->transid = transid; 16270f5dcf8dSMark Fasheh __entry->bytenr = bytenr; 16280f5dcf8dSMark Fasheh __entry->num_bytes = num_bytes; 16290f5dcf8dSMark Fasheh __entry->nr_old_roots = nr_old_roots; 16300f5dcf8dSMark Fasheh __entry->nr_new_roots = nr_new_roots; 16310f5dcf8dSMark Fasheh ), 16320f5dcf8dSMark Fasheh 1633c9f6f3cdSQu Wenruo TP_printk_btrfs( 1634c9f6f3cdSQu Wenruo "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu", 1635c9f6f3cdSQu Wenruo __entry->transid, 16360f5dcf8dSMark Fasheh __entry->bytenr, 16370f5dcf8dSMark Fasheh __entry->num_bytes, 16380f5dcf8dSMark Fasheh __entry->nr_old_roots, 16390f5dcf8dSMark Fasheh __entry->nr_new_roots) 16400f5dcf8dSMark Fasheh ); 16410f5dcf8dSMark Fasheh 16420f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters, 16430f5dcf8dSMark Fasheh 16448b317901SQu Wenruo TP_PROTO(const struct btrfs_fs_info *fs_info, 16458b317901SQu Wenruo struct btrfs_qgroup *qgroup, 1646bc074524SJeff Mahoney u64 cur_old_count, u64 cur_new_count), 16470f5dcf8dSMark Fasheh 16488b317901SQu Wenruo TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count), 16490f5dcf8dSMark Fasheh 1650bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 16510f5dcf8dSMark Fasheh __field( u64, qgid ) 16528b317901SQu Wenruo __field( u64, old_rfer ) 16538b317901SQu Wenruo __field( u64, old_excl ) 16540f5dcf8dSMark Fasheh __field( u64, cur_old_count ) 16550f5dcf8dSMark Fasheh __field( u64, cur_new_count ) 16560f5dcf8dSMark Fasheh ), 16570f5dcf8dSMark Fasheh 1658bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 16598b317901SQu Wenruo __entry->qgid = qgroup->qgroupid; 16608b317901SQu Wenruo __entry->old_rfer = qgroup->rfer; 16618b317901SQu Wenruo __entry->old_excl = qgroup->excl; 16620f5dcf8dSMark Fasheh __entry->cur_old_count = cur_old_count; 16630f5dcf8dSMark Fasheh __entry->cur_new_count = cur_new_count; 16640f5dcf8dSMark Fasheh ), 16650f5dcf8dSMark Fasheh 16668b317901SQu Wenruo TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu", 16678b317901SQu Wenruo __entry->qgid, __entry->old_rfer, __entry->old_excl, 16688b317901SQu Wenruo __entry->cur_old_count, __entry->cur_new_count) 16690f5dcf8dSMark Fasheh ); 16700f5dcf8dSMark Fasheh 16713159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve, 16723159fe7bSQu Wenruo 16733159fe7bSQu Wenruo TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup, 167464ee4e75SQu Wenruo s64 diff, int type), 16753159fe7bSQu Wenruo 167664ee4e75SQu Wenruo TP_ARGS(fs_info, qgroup, diff, type), 16773159fe7bSQu Wenruo 16783159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 16793159fe7bSQu Wenruo __field( u64, qgid ) 16803159fe7bSQu Wenruo __field( u64, cur_reserved ) 16813159fe7bSQu Wenruo __field( s64, diff ) 168264ee4e75SQu Wenruo __field( int, type ) 16833159fe7bSQu Wenruo ), 16843159fe7bSQu Wenruo 16853159fe7bSQu Wenruo TP_fast_assign_btrfs(fs_info, 16863159fe7bSQu Wenruo __entry->qgid = qgroup->qgroupid; 168764ee4e75SQu Wenruo __entry->cur_reserved = qgroup->rsv.values[type]; 16883159fe7bSQu Wenruo __entry->diff = diff; 16891b2442b4SQu Wenruo __entry->type = type; 16903159fe7bSQu Wenruo ), 16913159fe7bSQu Wenruo 169264ee4e75SQu Wenruo TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld", 169364ee4e75SQu Wenruo __entry->qgid, show_qgroup_rsv_type(__entry->type), 169464ee4e75SQu Wenruo __entry->cur_reserved, __entry->diff) 16953159fe7bSQu Wenruo ); 16963159fe7bSQu Wenruo 16973159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve, 16983159fe7bSQu Wenruo 16994ee0d883SQu Wenruo TP_PROTO(struct btrfs_root *root, s64 diff, int type), 17003159fe7bSQu Wenruo 17014ee0d883SQu Wenruo TP_ARGS(root, diff, type), 17023159fe7bSQu Wenruo 17033159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 17043159fe7bSQu Wenruo __field( u64, refroot ) 17053159fe7bSQu Wenruo __field( s64, diff ) 17064ee0d883SQu Wenruo __field( int, type ) 17073159fe7bSQu Wenruo ), 17083159fe7bSQu Wenruo 17093159fe7bSQu Wenruo TP_fast_assign_btrfs(root->fs_info, 17104fd786e6SMisono Tomohiro __entry->refroot = root->root_key.objectid; 17113159fe7bSQu Wenruo __entry->diff = diff; 17121b2442b4SQu Wenruo __entry->type = type; 17133159fe7bSQu Wenruo ), 17143159fe7bSQu Wenruo 17154ee0d883SQu Wenruo TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 17164ee0d883SQu Wenruo show_root_type(__entry->refroot), 17174ee0d883SQu Wenruo show_qgroup_rsv_type(__entry->type), __entry->diff) 17184ee0d883SQu Wenruo ); 17194ee0d883SQu Wenruo 17204ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_convert, 17214ee0d883SQu Wenruo 17224ee0d883SQu Wenruo TP_PROTO(struct btrfs_root *root, s64 diff), 17234ee0d883SQu Wenruo 17244ee0d883SQu Wenruo TP_ARGS(root, diff), 17254ee0d883SQu Wenruo 17264ee0d883SQu Wenruo TP_STRUCT__entry_btrfs( 17274ee0d883SQu Wenruo __field( u64, refroot ) 17284ee0d883SQu Wenruo __field( s64, diff ) 17294ee0d883SQu Wenruo ), 17304ee0d883SQu Wenruo 17314ee0d883SQu Wenruo TP_fast_assign_btrfs(root->fs_info, 17324fd786e6SMisono Tomohiro __entry->refroot = root->root_key.objectid; 17334ee0d883SQu Wenruo __entry->diff = diff; 17344ee0d883SQu Wenruo ), 17354ee0d883SQu Wenruo 17364ee0d883SQu Wenruo TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld", 17374ee0d883SQu Wenruo show_root_type(__entry->refroot), 17384ee0d883SQu Wenruo show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC), 17394ee0d883SQu Wenruo show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS), 17404ee0d883SQu Wenruo __entry->diff) 17414ee0d883SQu Wenruo ); 17424ee0d883SQu Wenruo 17434ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_free_all_pertrans, 17444ee0d883SQu Wenruo 17454ee0d883SQu Wenruo TP_PROTO(struct btrfs_root *root), 17464ee0d883SQu Wenruo 17474ee0d883SQu Wenruo TP_ARGS(root), 17484ee0d883SQu Wenruo 17494ee0d883SQu Wenruo TP_STRUCT__entry_btrfs( 17504ee0d883SQu Wenruo __field( u64, refroot ) 17514ee0d883SQu Wenruo __field( s64, diff ) 17524ee0d883SQu Wenruo __field( int, type ) 17534ee0d883SQu Wenruo ), 17544ee0d883SQu Wenruo 17554ee0d883SQu Wenruo TP_fast_assign_btrfs(root->fs_info, 17564fd786e6SMisono Tomohiro __entry->refroot = root->root_key.objectid; 17574ee0d883SQu Wenruo spin_lock(&root->qgroup_meta_rsv_lock); 17584ee0d883SQu Wenruo __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans; 17594ee0d883SQu Wenruo spin_unlock(&root->qgroup_meta_rsv_lock); 17604ee0d883SQu Wenruo __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS; 17614ee0d883SQu Wenruo ), 17624ee0d883SQu Wenruo 17634ee0d883SQu Wenruo TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 17644ee0d883SQu Wenruo show_root_type(__entry->refroot), 17654ee0d883SQu Wenruo show_qgroup_rsv_type(__entry->type), __entry->diff) 17663159fe7bSQu Wenruo ); 17673159fe7bSQu Wenruo 176800142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref, 176900142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 177000142756SJeff Mahoney const struct prelim_ref *oldref, 177100142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 177200142756SJeff Mahoney TP_ARGS(fs_info, newref, oldref, tree_size), 177300142756SJeff Mahoney 177400142756SJeff Mahoney TP_STRUCT__entry_btrfs( 177500142756SJeff Mahoney __field( u64, root_id ) 177600142756SJeff Mahoney __field( u64, objectid ) 177700142756SJeff Mahoney __field( u8, type ) 177800142756SJeff Mahoney __field( u64, offset ) 177900142756SJeff Mahoney __field( int, level ) 178000142756SJeff Mahoney __field( int, old_count ) 178100142756SJeff Mahoney __field( u64, parent ) 178200142756SJeff Mahoney __field( u64, bytenr ) 178300142756SJeff Mahoney __field( int, mod_count ) 178400142756SJeff Mahoney __field( u64, tree_size ) 178500142756SJeff Mahoney ), 178600142756SJeff Mahoney 178700142756SJeff Mahoney TP_fast_assign_btrfs(fs_info, 178800142756SJeff Mahoney __entry->root_id = oldref->root_id; 178900142756SJeff Mahoney __entry->objectid = oldref->key_for_search.objectid; 179000142756SJeff Mahoney __entry->type = oldref->key_for_search.type; 179100142756SJeff Mahoney __entry->offset = oldref->key_for_search.offset; 179200142756SJeff Mahoney __entry->level = oldref->level; 179300142756SJeff Mahoney __entry->old_count = oldref->count; 179400142756SJeff Mahoney __entry->parent = oldref->parent; 179500142756SJeff Mahoney __entry->bytenr = oldref->wanted_disk_byte; 179600142756SJeff Mahoney __entry->mod_count = newref ? newref->count : 0; 179700142756SJeff Mahoney __entry->tree_size = tree_size; 179800142756SJeff Mahoney ), 179900142756SJeff Mahoney 180000142756SJeff 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", 18018eec8463SDavid Sterba __entry->root_id, 18028eec8463SDavid Sterba __entry->objectid, __entry->type, 18038eec8463SDavid Sterba __entry->offset, __entry->level, 180400142756SJeff Mahoney __entry->old_count, __entry->mod_count, 180500142756SJeff Mahoney __entry->old_count + __entry->mod_count, 18068eec8463SDavid Sterba __entry->parent, 18078eec8463SDavid Sterba __entry->bytenr, 18088eec8463SDavid Sterba __entry->tree_size) 180900142756SJeff Mahoney ); 181000142756SJeff Mahoney 181100142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge, 181200142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 181300142756SJeff Mahoney const struct prelim_ref *oldref, 181400142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 181500142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 181600142756SJeff Mahoney ); 181700142756SJeff Mahoney 181800142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert, 181900142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 182000142756SJeff Mahoney const struct prelim_ref *oldref, 182100142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 182200142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 182300142756SJeff Mahoney ); 182400142756SJeff Mahoney 1825dd48d407SJosef Bacik TRACE_EVENT(btrfs_inode_mod_outstanding_extents, 1826dd48d407SJosef Bacik TP_PROTO(struct btrfs_root *root, u64 ino, int mod), 1827dd48d407SJosef Bacik 1828dd48d407SJosef Bacik TP_ARGS(root, ino, mod), 1829dd48d407SJosef Bacik 1830dd48d407SJosef Bacik TP_STRUCT__entry_btrfs( 1831dd48d407SJosef Bacik __field( u64, root_objectid ) 1832dd48d407SJosef Bacik __field( u64, ino ) 1833dd48d407SJosef Bacik __field( int, mod ) 1834dd48d407SJosef Bacik ), 1835dd48d407SJosef Bacik 1836dd48d407SJosef Bacik TP_fast_assign_btrfs(root->fs_info, 18374fd786e6SMisono Tomohiro __entry->root_objectid = root->root_key.objectid; 1838dd48d407SJosef Bacik __entry->ino = ino; 1839dd48d407SJosef Bacik __entry->mod = mod; 1840dd48d407SJosef Bacik ), 1841dd48d407SJosef Bacik 1842dd48d407SJosef Bacik TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d", 1843dd48d407SJosef Bacik show_root_type(__entry->root_objectid), 18448eec8463SDavid Sterba __entry->ino, __entry->mod) 1845dd48d407SJosef Bacik ); 18463dca5c94SQu Wenruo 18474ed0a7a3SQu Wenruo DECLARE_EVENT_CLASS(btrfs__block_group, 18484ed0a7a3SQu Wenruo TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 18494ed0a7a3SQu Wenruo 18504ed0a7a3SQu Wenruo TP_ARGS(bg_cache), 18514ed0a7a3SQu Wenruo 18524ed0a7a3SQu Wenruo TP_STRUCT__entry_btrfs( 18534ed0a7a3SQu Wenruo __field( u64, bytenr ) 18544ed0a7a3SQu Wenruo __field( u64, len ) 18554ed0a7a3SQu Wenruo __field( u64, used ) 18564ed0a7a3SQu Wenruo __field( u64, flags ) 18574ed0a7a3SQu Wenruo ), 18584ed0a7a3SQu Wenruo 18594ed0a7a3SQu Wenruo TP_fast_assign_btrfs(bg_cache->fs_info, 18604ed0a7a3SQu Wenruo __entry->bytenr = bg_cache->key.objectid, 18614ed0a7a3SQu Wenruo __entry->len = bg_cache->key.offset, 18624ed0a7a3SQu Wenruo __entry->used = btrfs_block_group_used(&bg_cache->item); 18634ed0a7a3SQu Wenruo __entry->flags = bg_cache->flags; 18644ed0a7a3SQu Wenruo ), 18654ed0a7a3SQu Wenruo 18664ed0a7a3SQu Wenruo TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)", 18674ed0a7a3SQu Wenruo __entry->bytenr, __entry->len, __entry->used, __entry->flags, 18684ed0a7a3SQu Wenruo __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS)) 18694ed0a7a3SQu Wenruo ); 18704ed0a7a3SQu Wenruo 18714ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group, 18724ed0a7a3SQu Wenruo TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 18734ed0a7a3SQu Wenruo 18744ed0a7a3SQu Wenruo TP_ARGS(bg_cache) 18754ed0a7a3SQu Wenruo ); 18764ed0a7a3SQu Wenruo 18774ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group, 18784ed0a7a3SQu Wenruo TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 18794ed0a7a3SQu Wenruo 18804ed0a7a3SQu Wenruo TP_ARGS(bg_cache) 18814ed0a7a3SQu Wenruo ); 18824ed0a7a3SQu Wenruo 18834ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group, 18844ed0a7a3SQu Wenruo TP_PROTO(const struct btrfs_block_group_cache *bg_cache), 18854ed0a7a3SQu Wenruo 18864ed0a7a3SQu Wenruo TP_ARGS(bg_cache) 18874ed0a7a3SQu Wenruo ); 18884ed0a7a3SQu Wenruo 1889a1d19847SQu Wenruo TRACE_EVENT(btrfs_set_extent_bit, 1890a1d19847SQu Wenruo TP_PROTO(const struct extent_io_tree *tree, 1891a1d19847SQu Wenruo u64 start, u64 len, unsigned set_bits), 1892a1d19847SQu Wenruo 1893a1d19847SQu Wenruo TP_ARGS(tree, start, len, set_bits), 1894a1d19847SQu Wenruo 1895a1d19847SQu Wenruo TP_STRUCT__entry_btrfs( 1896a1d19847SQu Wenruo __field( unsigned, owner ) 1897a1d19847SQu Wenruo __field( u64, ino ) 1898a1d19847SQu Wenruo __field( u64, rootid ) 1899a1d19847SQu Wenruo __field( u64, start ) 1900a1d19847SQu Wenruo __field( u64, len ) 1901a1d19847SQu Wenruo __field( unsigned, set_bits) 1902a1d19847SQu Wenruo ), 1903a1d19847SQu Wenruo 1904a1d19847SQu Wenruo TP_fast_assign_btrfs(tree->fs_info, 1905a1d19847SQu Wenruo __entry->owner = tree->owner; 1906a1d19847SQu Wenruo if (tree->private_data) { 1907a1d19847SQu Wenruo struct inode *inode = tree->private_data; 1908a1d19847SQu Wenruo 1909a1d19847SQu Wenruo __entry->ino = btrfs_ino(BTRFS_I(inode)); 1910a1d19847SQu Wenruo __entry->rootid = 1911a1d19847SQu Wenruo BTRFS_I(inode)->root->root_key.objectid; 1912a1d19847SQu Wenruo } else { 1913a1d19847SQu Wenruo __entry->ino = 0; 1914a1d19847SQu Wenruo __entry->rootid = 0; 1915a1d19847SQu Wenruo } 1916a1d19847SQu Wenruo __entry->start = start; 1917a1d19847SQu Wenruo __entry->len = len; 1918a1d19847SQu Wenruo __entry->set_bits = set_bits; 1919a1d19847SQu Wenruo ), 1920a1d19847SQu Wenruo 1921a1d19847SQu Wenruo TP_printk_btrfs( 1922a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s", 1923a1d19847SQu Wenruo show_extent_io_tree_owner(__entry->owner), __entry->ino, 1924a1d19847SQu Wenruo __entry->rootid, __entry->start, __entry->len, 1925a1d19847SQu Wenruo __print_flags(__entry->set_bits, "|", EXTENT_FLAGS)) 1926a1d19847SQu Wenruo ); 1927a1d19847SQu Wenruo 1928a1d19847SQu Wenruo TRACE_EVENT(btrfs_clear_extent_bit, 1929a1d19847SQu Wenruo TP_PROTO(const struct extent_io_tree *tree, 1930a1d19847SQu Wenruo u64 start, u64 len, unsigned clear_bits), 1931a1d19847SQu Wenruo 1932a1d19847SQu Wenruo TP_ARGS(tree, start, len, clear_bits), 1933a1d19847SQu Wenruo 1934a1d19847SQu Wenruo TP_STRUCT__entry_btrfs( 1935a1d19847SQu Wenruo __field( unsigned, owner ) 1936a1d19847SQu Wenruo __field( u64, ino ) 1937a1d19847SQu Wenruo __field( u64, rootid ) 1938a1d19847SQu Wenruo __field( u64, start ) 1939a1d19847SQu Wenruo __field( u64, len ) 1940a1d19847SQu Wenruo __field( unsigned, clear_bits) 1941a1d19847SQu Wenruo ), 1942a1d19847SQu Wenruo 1943a1d19847SQu Wenruo TP_fast_assign_btrfs(tree->fs_info, 1944a1d19847SQu Wenruo __entry->owner = tree->owner; 1945a1d19847SQu Wenruo if (tree->private_data) { 1946a1d19847SQu Wenruo struct inode *inode = tree->private_data; 1947a1d19847SQu Wenruo 1948a1d19847SQu Wenruo __entry->ino = btrfs_ino(BTRFS_I(inode)); 1949a1d19847SQu Wenruo __entry->rootid = 1950a1d19847SQu Wenruo BTRFS_I(inode)->root->root_key.objectid; 1951a1d19847SQu Wenruo } else { 1952a1d19847SQu Wenruo __entry->ino = 0; 1953a1d19847SQu Wenruo __entry->rootid = 0; 1954a1d19847SQu Wenruo } 1955a1d19847SQu Wenruo __entry->start = start; 1956a1d19847SQu Wenruo __entry->len = len; 1957a1d19847SQu Wenruo __entry->clear_bits = clear_bits; 1958a1d19847SQu Wenruo ), 1959a1d19847SQu Wenruo 1960a1d19847SQu Wenruo TP_printk_btrfs( 1961a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s", 1962a1d19847SQu Wenruo show_extent_io_tree_owner(__entry->owner), __entry->ino, 1963a1d19847SQu Wenruo __entry->rootid, __entry->start, __entry->len, 1964a1d19847SQu Wenruo __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 1965a1d19847SQu Wenruo ); 1966a1d19847SQu Wenruo 1967a1d19847SQu Wenruo TRACE_EVENT(btrfs_convert_extent_bit, 1968a1d19847SQu Wenruo TP_PROTO(const struct extent_io_tree *tree, 1969a1d19847SQu Wenruo u64 start, u64 len, unsigned set_bits, unsigned clear_bits), 1970a1d19847SQu Wenruo 1971a1d19847SQu Wenruo TP_ARGS(tree, start, len, set_bits, clear_bits), 1972a1d19847SQu Wenruo 1973a1d19847SQu Wenruo TP_STRUCT__entry_btrfs( 1974a1d19847SQu Wenruo __field( unsigned, owner ) 1975a1d19847SQu Wenruo __field( u64, ino ) 1976a1d19847SQu Wenruo __field( u64, rootid ) 1977a1d19847SQu Wenruo __field( u64, start ) 1978a1d19847SQu Wenruo __field( u64, len ) 1979a1d19847SQu Wenruo __field( unsigned, set_bits) 1980a1d19847SQu Wenruo __field( unsigned, clear_bits) 1981a1d19847SQu Wenruo ), 1982a1d19847SQu Wenruo 1983a1d19847SQu Wenruo TP_fast_assign_btrfs(tree->fs_info, 1984a1d19847SQu Wenruo __entry->owner = tree->owner; 1985a1d19847SQu Wenruo if (tree->private_data) { 1986a1d19847SQu Wenruo struct inode *inode = tree->private_data; 1987a1d19847SQu Wenruo 1988a1d19847SQu Wenruo __entry->ino = btrfs_ino(BTRFS_I(inode)); 1989a1d19847SQu Wenruo __entry->rootid = 1990a1d19847SQu Wenruo BTRFS_I(inode)->root->root_key.objectid; 1991a1d19847SQu Wenruo } else { 1992a1d19847SQu Wenruo __entry->ino = 0; 1993a1d19847SQu Wenruo __entry->rootid = 0; 1994a1d19847SQu Wenruo } 1995a1d19847SQu Wenruo __entry->start = start; 1996a1d19847SQu Wenruo __entry->len = len; 1997a1d19847SQu Wenruo __entry->set_bits = set_bits; 1998a1d19847SQu Wenruo __entry->clear_bits = clear_bits; 1999a1d19847SQu Wenruo ), 2000a1d19847SQu Wenruo 2001a1d19847SQu Wenruo TP_printk_btrfs( 2002a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s", 2003a1d19847SQu Wenruo show_extent_io_tree_owner(__entry->owner), __entry->ino, 2004a1d19847SQu Wenruo __entry->rootid, __entry->start, __entry->len, 2005a1d19847SQu Wenruo __print_flags(__entry->set_bits , "|", EXTENT_FLAGS), 2006a1d19847SQu Wenruo __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 2007a1d19847SQu Wenruo ); 2008a1d19847SQu Wenruo 200934e73cc9SQu Wenruo DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock, 201034e73cc9SQu Wenruo TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 201134e73cc9SQu Wenruo 201234e73cc9SQu Wenruo TP_ARGS(eb, start_ns), 201334e73cc9SQu Wenruo 201434e73cc9SQu Wenruo TP_STRUCT__entry_btrfs( 201534e73cc9SQu Wenruo __field( u64, block ) 201634e73cc9SQu Wenruo __field( u64, generation ) 201734e73cc9SQu Wenruo __field( u64, start_ns ) 201834e73cc9SQu Wenruo __field( u64, end_ns ) 201934e73cc9SQu Wenruo __field( u64, diff_ns ) 202034e73cc9SQu Wenruo __field( u64, owner ) 202134e73cc9SQu Wenruo __field( int, is_log_tree ) 202234e73cc9SQu Wenruo ), 202334e73cc9SQu Wenruo 202434e73cc9SQu Wenruo TP_fast_assign_btrfs(eb->fs_info, 202534e73cc9SQu Wenruo __entry->block = eb->start; 202634e73cc9SQu Wenruo __entry->generation = btrfs_header_generation(eb); 202734e73cc9SQu Wenruo __entry->start_ns = start_ns; 202834e73cc9SQu Wenruo __entry->end_ns = ktime_get_ns(); 202934e73cc9SQu Wenruo __entry->diff_ns = __entry->end_ns - start_ns; 203034e73cc9SQu Wenruo __entry->owner = btrfs_header_owner(eb); 203134e73cc9SQu Wenruo __entry->is_log_tree = (eb->log_index >= 0); 203234e73cc9SQu Wenruo ), 203334e73cc9SQu Wenruo 203434e73cc9SQu Wenruo TP_printk_btrfs( 203534e73cc9SQu Wenruo "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d", 203634e73cc9SQu Wenruo __entry->block, __entry->generation, 203734e73cc9SQu Wenruo __entry->start_ns, __entry->end_ns, __entry->diff_ns, 203834e73cc9SQu Wenruo __entry->owner, __entry->is_log_tree) 203934e73cc9SQu Wenruo ); 204034e73cc9SQu Wenruo 204134e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock, 204234e73cc9SQu Wenruo TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 204334e73cc9SQu Wenruo 204434e73cc9SQu Wenruo TP_ARGS(eb, start_ns) 204534e73cc9SQu Wenruo ); 204634e73cc9SQu Wenruo 204734e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock, 204834e73cc9SQu Wenruo TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 204934e73cc9SQu Wenruo 205034e73cc9SQu Wenruo TP_ARGS(eb, start_ns) 205134e73cc9SQu Wenruo ); 205234e73cc9SQu Wenruo 205331aab402SQu Wenruo DECLARE_EVENT_CLASS(btrfs_locking_events, 205431aab402SQu Wenruo TP_PROTO(const struct extent_buffer *eb), 205531aab402SQu Wenruo 205631aab402SQu Wenruo TP_ARGS(eb), 205731aab402SQu Wenruo 205831aab402SQu Wenruo TP_STRUCT__entry_btrfs( 205931aab402SQu Wenruo __field( u64, block ) 206031aab402SQu Wenruo __field( u64, generation ) 206131aab402SQu Wenruo __field( u64, owner ) 206231aab402SQu Wenruo __field( int, is_log_tree ) 206331aab402SQu Wenruo ), 206431aab402SQu Wenruo 206531aab402SQu Wenruo TP_fast_assign_btrfs(eb->fs_info, 206631aab402SQu Wenruo __entry->block = eb->start; 206731aab402SQu Wenruo __entry->generation = btrfs_header_generation(eb); 206831aab402SQu Wenruo __entry->owner = btrfs_header_owner(eb); 206931aab402SQu Wenruo __entry->is_log_tree = (eb->log_index >= 0); 207031aab402SQu Wenruo ), 207131aab402SQu Wenruo 207231aab402SQu Wenruo TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d", 207331aab402SQu Wenruo __entry->block, __entry->generation, 207431aab402SQu Wenruo __entry->owner, __entry->is_log_tree) 207531aab402SQu Wenruo ); 207631aab402SQu Wenruo 207731aab402SQu Wenruo #define DEFINE_BTRFS_LOCK_EVENT(name) \ 207831aab402SQu Wenruo DEFINE_EVENT(btrfs_locking_events, name, \ 207931aab402SQu Wenruo TP_PROTO(const struct extent_buffer *eb), \ 208031aab402SQu Wenruo \ 208131aab402SQu Wenruo TP_ARGS(eb) \ 208231aab402SQu Wenruo ) 208331aab402SQu Wenruo 208431aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock); 208531aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock); 208631aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking); 208731aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read); 208831aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write); 208931aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock); 209031aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock); 209131aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic); 209231aab402SQu Wenruo 2093480b9b4dSQu Wenruo DECLARE_EVENT_CLASS(btrfs__space_info_update, 2094480b9b4dSQu Wenruo 2095480b9b4dSQu Wenruo TP_PROTO(struct btrfs_fs_info *fs_info, 2096480b9b4dSQu Wenruo struct btrfs_space_info *sinfo, u64 old, s64 diff), 2097480b9b4dSQu Wenruo 2098480b9b4dSQu Wenruo TP_ARGS(fs_info, sinfo, old, diff), 2099480b9b4dSQu Wenruo 2100480b9b4dSQu Wenruo TP_STRUCT__entry_btrfs( 2101480b9b4dSQu Wenruo __field( u64, type ) 2102480b9b4dSQu Wenruo __field( u64, old ) 2103480b9b4dSQu Wenruo __field( s64, diff ) 2104480b9b4dSQu Wenruo ), 2105480b9b4dSQu Wenruo 2106480b9b4dSQu Wenruo TP_fast_assign_btrfs(fs_info, 2107480b9b4dSQu Wenruo __entry->type = sinfo->flags; 2108480b9b4dSQu Wenruo __entry->old = old; 2109480b9b4dSQu Wenruo __entry->diff = diff; 2110480b9b4dSQu Wenruo ), 2111480b9b4dSQu Wenruo TP_printk_btrfs("type=%s old=%llu diff=%lld", 2112480b9b4dSQu Wenruo __print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS), 2113480b9b4dSQu Wenruo __entry->old, __entry->diff) 2114480b9b4dSQu Wenruo ); 2115480b9b4dSQu Wenruo 2116480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use, 2117480b9b4dSQu Wenruo 2118480b9b4dSQu Wenruo TP_PROTO(struct btrfs_fs_info *fs_info, 2119480b9b4dSQu Wenruo struct btrfs_space_info *sinfo, u64 old, s64 diff), 2120480b9b4dSQu Wenruo 2121480b9b4dSQu Wenruo TP_ARGS(fs_info, sinfo, old, diff) 2122480b9b4dSQu Wenruo ); 2123480b9b4dSQu Wenruo 2124480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned, 2125480b9b4dSQu Wenruo 2126480b9b4dSQu Wenruo TP_PROTO(struct btrfs_fs_info *fs_info, 2127480b9b4dSQu Wenruo struct btrfs_space_info *sinfo, u64 old, s64 diff), 2128480b9b4dSQu Wenruo 2129480b9b4dSQu Wenruo TP_ARGS(fs_info, sinfo, old, diff) 2130480b9b4dSQu Wenruo ); 2131480b9b4dSQu Wenruo 21321abe9b8aSliubo #endif /* _TRACE_BTRFS_H */ 21331abe9b8aSliubo 21341abe9b8aSliubo /* This part must be outside protection */ 21351abe9b8aSliubo #include <trace/define_trace.h> 2136