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; 22*32da5386SDavid Sterba struct btrfs_block_group; 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 ) 17394c3f6c6SDavid 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, 19794c3f6c6SDavid 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 2951d2e7c7cSDavid Sterba TP_PROTO(const 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 3331d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 3341d2e7c7cSDavid Sterba const 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 3881d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 3891d2e7c7cSDavid Sterba const 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 4291d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 4301d2e7c7cSDavid Sterba const 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 4381d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 4391d2e7c7cSDavid Sterba const 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 4471d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 4481d2e7c7cSDavid Sterba const 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 4561d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l, 4571d2e7c7cSDavid Sterba const 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 ) 57794c3f6c6SDavid 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, 60694c3f6c6SDavid 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 ) 62594c3f6c6SDavid 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), 64594c3f6c6SDavid 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, 702*32da5386SDavid Sterba const struct btrfs_block_group *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, 716b3470b5dSDavid Sterba __entry->offset = block_group->start; 717b3470b5dSDavid Sterba __entry->size = block_group->length; 718c83f8effSJosef Bacik __entry->flags = block_group->flags; 719bf38be65SDavid Sterba __entry->bytes_used = block_group->used; 720c83f8effSJosef Bacik __entry->bytes_super = block_group->bytes_super; 721c83f8effSJosef Bacik __entry->create = create; 722c83f8effSJosef Bacik ), 723c83f8effSJosef Bacik 7242e63e62dSDavid Sterba TP_printk_btrfs("block_group offset=%llu size=%llu " 725562a7a07SDavid Sterba "flags=%llu(%s) bytes_used=%llu bytes_super=%llu " 7262e63e62dSDavid Sterba "create=%d", 7278eec8463SDavid Sterba __entry->offset, 7288eec8463SDavid Sterba __entry->size, 7298eec8463SDavid Sterba __entry->flags, 730c83f8effSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 731c83f8effSJosef Bacik BTRFS_GROUP_FLAGS), 7328eec8463SDavid Sterba __entry->bytes_used, 7338eec8463SDavid Sterba __entry->bytes_super, __entry->create) 734c83f8effSJosef Bacik ); 735c83f8effSJosef Bacik 7361abe9b8aSliubo #define show_ref_action(action) \ 7371abe9b8aSliubo __print_symbolic(action, \ 7381abe9b8aSliubo { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 7391abe9b8aSliubo { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 7401abe9b8aSliubo { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 7411abe9b8aSliubo { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 7421abe9b8aSliubo 7431abe9b8aSliubo 744599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 7451abe9b8aSliubo 7469a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7479a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7489a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 7491abe9b8aSliubo int action), 7501abe9b8aSliubo 751bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 7521abe9b8aSliubo 753bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 7541abe9b8aSliubo __field( u64, bytenr ) 7551abe9b8aSliubo __field( u64, num_bytes ) 7561abe9b8aSliubo __field( int, action ) 7571abe9b8aSliubo __field( u64, parent ) 7581abe9b8aSliubo __field( u64, ref_root ) 7591abe9b8aSliubo __field( int, level ) 7601abe9b8aSliubo __field( int, type ) 761dea7d76eSLiu Bo __field( u64, seq ) 7621abe9b8aSliubo ), 7631abe9b8aSliubo 764bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 7651abe9b8aSliubo __entry->bytenr = ref->bytenr; 7661abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 7671abe9b8aSliubo __entry->action = action; 7681abe9b8aSliubo __entry->parent = full_ref->parent; 7691abe9b8aSliubo __entry->ref_root = full_ref->root; 7701abe9b8aSliubo __entry->level = full_ref->level; 7711abe9b8aSliubo __entry->type = ref->type; 772dea7d76eSLiu Bo __entry->seq = ref->seq; 7731abe9b8aSliubo ), 7741abe9b8aSliubo 775562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 776562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) level=%d " 777562a7a07SDavid Sterba "type=%s seq=%llu", 7788eec8463SDavid Sterba __entry->bytenr, 7798eec8463SDavid Sterba __entry->num_bytes, 7801abe9b8aSliubo show_ref_action(__entry->action), 7811abe9b8aSliubo show_root_type(__entry->parent), 7821abe9b8aSliubo show_root_type(__entry->ref_root), 783dea7d76eSLiu Bo __entry->level, show_ref_type(__entry->type), 7848eec8463SDavid Sterba __entry->seq) 7851abe9b8aSliubo ); 7861abe9b8aSliubo 787599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 788599c75ecSLiu Bo 7899a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7909a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7919a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 792599c75ecSLiu Bo int action), 793599c75ecSLiu Bo 794bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 795599c75ecSLiu Bo ); 796599c75ecSLiu Bo 797599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 798599c75ecSLiu Bo 7999a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8009a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8019a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 802599c75ecSLiu Bo int action), 803599c75ecSLiu Bo 804bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 805599c75ecSLiu Bo ); 806599c75ecSLiu Bo 807599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 8081abe9b8aSliubo 8099a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8109a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8119a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 8121abe9b8aSliubo int action), 8131abe9b8aSliubo 814bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 8151abe9b8aSliubo 816bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 8171abe9b8aSliubo __field( u64, bytenr ) 8181abe9b8aSliubo __field( u64, num_bytes ) 8191abe9b8aSliubo __field( int, action ) 8201abe9b8aSliubo __field( u64, parent ) 8211abe9b8aSliubo __field( u64, ref_root ) 8221abe9b8aSliubo __field( u64, owner ) 8231abe9b8aSliubo __field( u64, offset ) 8241abe9b8aSliubo __field( int, type ) 825dea7d76eSLiu Bo __field( u64, seq ) 8261abe9b8aSliubo ), 8271abe9b8aSliubo 828bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 8291abe9b8aSliubo __entry->bytenr = ref->bytenr; 8301abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 8311abe9b8aSliubo __entry->action = action; 8321abe9b8aSliubo __entry->parent = full_ref->parent; 8331abe9b8aSliubo __entry->ref_root = full_ref->root; 8341abe9b8aSliubo __entry->owner = full_ref->objectid; 8351abe9b8aSliubo __entry->offset = full_ref->offset; 8361abe9b8aSliubo __entry->type = ref->type; 837dea7d76eSLiu Bo __entry->seq = ref->seq; 8381abe9b8aSliubo ), 8391abe9b8aSliubo 840562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 841562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) owner=%llu " 842562a7a07SDavid Sterba "offset=%llu type=%s seq=%llu", 8438eec8463SDavid Sterba __entry->bytenr, 8448eec8463SDavid Sterba __entry->num_bytes, 8451abe9b8aSliubo show_ref_action(__entry->action), 8461abe9b8aSliubo show_root_type(__entry->parent), 8471abe9b8aSliubo show_root_type(__entry->ref_root), 8488eec8463SDavid Sterba __entry->owner, 8498eec8463SDavid Sterba __entry->offset, 850dea7d76eSLiu Bo show_ref_type(__entry->type), 8518eec8463SDavid Sterba __entry->seq) 8521abe9b8aSliubo ); 8531abe9b8aSliubo 854599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 855599c75ecSLiu Bo 8569a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8579a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8589a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 859599c75ecSLiu Bo int action), 860599c75ecSLiu Bo 861bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 862599c75ecSLiu Bo ); 863599c75ecSLiu Bo 864599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 865599c75ecSLiu Bo 8669a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8679a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8689a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 869599c75ecSLiu Bo int action), 870599c75ecSLiu Bo 871bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 872599c75ecSLiu Bo ); 873599c75ecSLiu Bo 874599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 8751abe9b8aSliubo 8769a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8779a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 8781abe9b8aSliubo int action), 8791abe9b8aSliubo 880d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action), 8811abe9b8aSliubo 882bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 8831abe9b8aSliubo __field( u64, bytenr ) 8841abe9b8aSliubo __field( u64, num_bytes ) 8851abe9b8aSliubo __field( int, action ) 8861abe9b8aSliubo __field( int, is_data ) 8871abe9b8aSliubo ), 8881abe9b8aSliubo 889bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 890d278850eSJosef Bacik __entry->bytenr = head_ref->bytenr; 891d278850eSJosef Bacik __entry->num_bytes = head_ref->num_bytes; 8921abe9b8aSliubo __entry->action = action; 8931abe9b8aSliubo __entry->is_data = head_ref->is_data; 8941abe9b8aSliubo ), 8951abe9b8aSliubo 896562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d", 8978eec8463SDavid Sterba __entry->bytenr, 8988eec8463SDavid Sterba __entry->num_bytes, 8991abe9b8aSliubo show_ref_action(__entry->action), 9001abe9b8aSliubo __entry->is_data) 9011abe9b8aSliubo ); 9021abe9b8aSliubo 903599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 904599c75ecSLiu Bo 9059a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9069a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 907599c75ecSLiu Bo int action), 908599c75ecSLiu Bo 909d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action) 910599c75ecSLiu Bo ); 911599c75ecSLiu Bo 912599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 913599c75ecSLiu Bo 9149a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9159a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 916599c75ecSLiu Bo int action), 917599c75ecSLiu Bo 918d278850eSJosef Bacik TP_ARGS(fs_info, head_ref, action) 919599c75ecSLiu Bo ); 920599c75ecSLiu Bo 9211abe9b8aSliubo #define show_chunk_type(type) \ 9221abe9b8aSliubo __print_flags(type, "|", \ 9231abe9b8aSliubo { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 9241abe9b8aSliubo { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 9251abe9b8aSliubo { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 9261abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 9271abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 9281abe9b8aSliubo { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 929e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 930e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 931e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 9321abe9b8aSliubo 9331abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk, 9341abe9b8aSliubo 9359a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9369a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9371abe9b8aSliubo 9386bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size), 9391abe9b8aSliubo 940bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9411abe9b8aSliubo __field( int, num_stripes ) 9421abe9b8aSliubo __field( u64, type ) 9431abe9b8aSliubo __field( int, sub_stripes ) 9441abe9b8aSliubo __field( u64, offset ) 9451abe9b8aSliubo __field( u64, size ) 9461abe9b8aSliubo __field( u64, root_objectid ) 9471abe9b8aSliubo ), 9481abe9b8aSliubo 9496bccf3abSJeff Mahoney TP_fast_assign_btrfs(fs_info, 9501abe9b8aSliubo __entry->num_stripes = map->num_stripes; 9511abe9b8aSliubo __entry->type = map->type; 9521abe9b8aSliubo __entry->sub_stripes = map->sub_stripes; 9531abe9b8aSliubo __entry->offset = offset; 9541abe9b8aSliubo __entry->size = size; 9556bccf3abSJeff Mahoney __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 9561abe9b8aSliubo ), 9571abe9b8aSliubo 958562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu " 959562a7a07SDavid Sterba "num_stripes=%d sub_stripes=%d type=%s", 9601abe9b8aSliubo show_root_type(__entry->root_objectid), 9618eec8463SDavid Sterba __entry->offset, 9628eec8463SDavid Sterba __entry->size, 9631abe9b8aSliubo __entry->num_stripes, __entry->sub_stripes, 9641abe9b8aSliubo show_chunk_type(__entry->type)) 9651abe9b8aSliubo ); 9661abe9b8aSliubo 9671abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 9681abe9b8aSliubo 9699a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9709a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9711abe9b8aSliubo 9726bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 9731abe9b8aSliubo ); 9741abe9b8aSliubo 9751abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 9761abe9b8aSliubo 9779a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 9789a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9791abe9b8aSliubo 9806bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 9811abe9b8aSliubo ); 9821abe9b8aSliubo 9831abe9b8aSliubo TRACE_EVENT(btrfs_cow_block, 9841abe9b8aSliubo 9859a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf, 9869a35b637SJeff Mahoney const struct extent_buffer *cow), 9871abe9b8aSliubo 9881abe9b8aSliubo TP_ARGS(root, buf, cow), 9891abe9b8aSliubo 990bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9911abe9b8aSliubo __field( u64, root_objectid ) 9921abe9b8aSliubo __field( u64, buf_start ) 9931abe9b8aSliubo __field( int, refs ) 9941abe9b8aSliubo __field( u64, cow_start ) 9951abe9b8aSliubo __field( int, buf_level ) 9961abe9b8aSliubo __field( int, cow_level ) 9971abe9b8aSliubo ), 9981abe9b8aSliubo 999bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 10001abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 10011abe9b8aSliubo __entry->buf_start = buf->start; 10021abe9b8aSliubo __entry->refs = atomic_read(&buf->refs); 10031abe9b8aSliubo __entry->cow_start = cow->start; 10041abe9b8aSliubo __entry->buf_level = btrfs_header_level(buf); 10051abe9b8aSliubo __entry->cow_level = btrfs_header_level(cow); 10061abe9b8aSliubo ), 10071abe9b8aSliubo 1008562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu " 1009562a7a07SDavid Sterba "(orig_level=%d) cow_buf=%llu (cow_level=%d)", 10101abe9b8aSliubo show_root_type(__entry->root_objectid), 10111abe9b8aSliubo __entry->refs, 10128eec8463SDavid Sterba __entry->buf_start, 10131abe9b8aSliubo __entry->buf_level, 10148eec8463SDavid Sterba __entry->cow_start, 10151abe9b8aSliubo __entry->cow_level) 10161abe9b8aSliubo ); 10171abe9b8aSliubo 10188c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation, 10198c2a3ca2SJosef Bacik 10201d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_fs_info *fs_info, const char *type, u64 val, 10218c2a3ca2SJosef Bacik u64 bytes, int reserve), 10228c2a3ca2SJosef Bacik 10238c2a3ca2SJosef Bacik TP_ARGS(fs_info, type, val, bytes, reserve), 10248c2a3ca2SJosef Bacik 1025bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 10268c2a3ca2SJosef Bacik __string( type, type ) 10278c2a3ca2SJosef Bacik __field( u64, val ) 10288c2a3ca2SJosef Bacik __field( u64, bytes ) 10298c2a3ca2SJosef Bacik __field( int, reserve ) 10308c2a3ca2SJosef Bacik ), 10318c2a3ca2SJosef Bacik 1032bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 10338c2a3ca2SJosef Bacik __assign_str(type, type); 10348c2a3ca2SJosef Bacik __entry->val = val; 10358c2a3ca2SJosef Bacik __entry->bytes = bytes; 10368c2a3ca2SJosef Bacik __entry->reserve = reserve; 10378c2a3ca2SJosef Bacik ), 10388c2a3ca2SJosef Bacik 10395439c7f5SDavid Sterba TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val, 1040bc074524SJeff Mahoney __entry->reserve ? "reserve" : "release", 10418c2a3ca2SJosef Bacik __entry->bytes) 10428c2a3ca2SJosef Bacik ); 10438c2a3ca2SJosef Bacik 1044f376df2bSJosef Bacik #define show_flush_action(action) \ 1045f376df2bSJosef Bacik __print_symbolic(action, \ 1046f376df2bSJosef Bacik { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ 1047f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ 1048f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) 1049f376df2bSJosef Bacik 1050f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush, 1051f376df2bSJosef Bacik 10529a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 10531d2e7c7cSDavid Sterba int flush, const char *reason), 1054f376df2bSJosef Bacik 1055f376df2bSJosef Bacik TP_ARGS(fs_info, flags, bytes, flush, reason), 1056f376df2bSJosef Bacik 10572e63e62dSDavid Sterba TP_STRUCT__entry_btrfs( 1058f376df2bSJosef Bacik __field( u64, flags ) 1059f376df2bSJosef Bacik __field( u64, bytes ) 1060f376df2bSJosef Bacik __field( int, flush ) 1061f376df2bSJosef Bacik __string( reason, reason ) 1062f376df2bSJosef Bacik ), 1063f376df2bSJosef Bacik 10642e63e62dSDavid Sterba TP_fast_assign_btrfs(fs_info, 1065f376df2bSJosef Bacik __entry->flags = flags; 1066f376df2bSJosef Bacik __entry->bytes = bytes; 1067f376df2bSJosef Bacik __entry->flush = flush; 1068f376df2bSJosef Bacik __assign_str(reason, reason) 1069f376df2bSJosef Bacik ), 1070f376df2bSJosef Bacik 10712e63e62dSDavid Sterba TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu", 10722e63e62dSDavid Sterba __get_str(reason), __entry->flush, 1073f376df2bSJosef Bacik show_flush_action(__entry->flush), 10748eec8463SDavid Sterba __entry->flags, 1075f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 1076f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 10778eec8463SDavid Sterba __entry->bytes) 1078f376df2bSJosef Bacik ); 1079f376df2bSJosef Bacik 1080f376df2bSJosef Bacik #define show_flush_state(state) \ 1081f376df2bSJosef Bacik __print_symbolic(state, \ 1082f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ 1083f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ 1084f376df2bSJosef Bacik { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ 1085f376df2bSJosef Bacik { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ 1086413df725SJosef Bacik { FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR"}, \ 1087413df725SJosef Bacik { FLUSH_DELAYED_REFS, "FLUSH_ELAYED_REFS"}, \ 1088f376df2bSJosef Bacik { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ 1089450114fcSJosef Bacik { ALLOC_CHUNK_FORCE, "ALLOC_CHUNK_FORCE"}, \ 1090844245b4SJosef Bacik { RUN_DELAYED_IPUTS, "RUN_DELAYED_IPUTS"}, \ 1091f376df2bSJosef Bacik { COMMIT_TRANS, "COMMIT_TRANS"}) 1092f376df2bSJosef Bacik 1093f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space, 1094f376df2bSJosef Bacik 10959a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, 10967bdd6277SNikolay Borisov int state, int ret), 1097f376df2bSJosef Bacik 10987bdd6277SNikolay Borisov TP_ARGS(fs_info, flags, num_bytes, state, ret), 1099f376df2bSJosef Bacik 11002e63e62dSDavid Sterba TP_STRUCT__entry_btrfs( 1101f376df2bSJosef Bacik __field( u64, flags ) 1102f376df2bSJosef Bacik __field( u64, num_bytes ) 1103f376df2bSJosef Bacik __field( int, state ) 1104f376df2bSJosef Bacik __field( int, ret ) 1105f376df2bSJosef Bacik ), 1106f376df2bSJosef Bacik 11072e63e62dSDavid Sterba TP_fast_assign_btrfs(fs_info, 1108f376df2bSJosef Bacik __entry->flags = flags; 1109f376df2bSJosef Bacik __entry->num_bytes = num_bytes; 1110f376df2bSJosef Bacik __entry->state = state; 1111f376df2bSJosef Bacik __entry->ret = ret; 1112f376df2bSJosef Bacik ), 1113f376df2bSJosef Bacik 11142e63e62dSDavid Sterba TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d", 11152e63e62dSDavid Sterba __entry->state, 1116f376df2bSJosef Bacik show_flush_state(__entry->state), 11178eec8463SDavid Sterba __entry->flags, 1118f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 1119f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 11208eec8463SDavid Sterba __entry->num_bytes, __entry->ret) 1121f376df2bSJosef Bacik ); 1122f376df2bSJosef Bacik 11231abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent, 11241abe9b8aSliubo 11259a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11261abe9b8aSliubo 112771ff6437SJeff Mahoney TP_ARGS(fs_info, start, len), 11281abe9b8aSliubo 1129bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11301abe9b8aSliubo __field( u64, start ) 11311abe9b8aSliubo __field( u64, len ) 11321abe9b8aSliubo ), 11331abe9b8aSliubo 113471ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 11351abe9b8aSliubo __entry->start = start; 11361abe9b8aSliubo __entry->len = len; 11371abe9b8aSliubo ), 11381abe9b8aSliubo 1139562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu", 114071ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 11418eec8463SDavid Sterba __entry->start, 11428eec8463SDavid Sterba __entry->len) 11431abe9b8aSliubo ); 11441abe9b8aSliubo 11451abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 11461abe9b8aSliubo 11479a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11481abe9b8aSliubo 114971ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 11501abe9b8aSliubo ); 11511abe9b8aSliubo 11521abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 11531abe9b8aSliubo 11549a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 11551abe9b8aSliubo 115671ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 11571abe9b8aSliubo ); 11581abe9b8aSliubo 11593f7de037SJosef Bacik TRACE_EVENT(find_free_extent, 11603f7de037SJosef Bacik 11619a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, 11629a35b637SJeff Mahoney u64 empty_size, u64 data), 11633f7de037SJosef Bacik 116471ff6437SJeff Mahoney TP_ARGS(fs_info, num_bytes, empty_size, data), 11653f7de037SJosef Bacik 1166bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11673f7de037SJosef Bacik __field( u64, num_bytes ) 11683f7de037SJosef Bacik __field( u64, empty_size ) 11693f7de037SJosef Bacik __field( u64, data ) 11703f7de037SJosef Bacik ), 11713f7de037SJosef Bacik 117271ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 11733f7de037SJosef Bacik __entry->num_bytes = num_bytes; 11743f7de037SJosef Bacik __entry->empty_size = empty_size; 11753f7de037SJosef Bacik __entry->data = data; 11763f7de037SJosef Bacik ), 11773f7de037SJosef Bacik 11785439c7f5SDavid Sterba TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)", 117971ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 11803f7de037SJosef Bacik __entry->num_bytes, __entry->empty_size, __entry->data, 11813f7de037SJosef Bacik __print_flags((unsigned long)__entry->data, "|", 11823f7de037SJosef Bacik BTRFS_GROUP_FLAGS)) 11833f7de037SJosef Bacik ); 11843f7de037SJosef Bacik 11853f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent, 11863f7de037SJosef Bacik 1187*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *block_group, u64 start, 11883f7de037SJosef Bacik u64 len), 11893f7de037SJosef Bacik 11903dca5c94SQu Wenruo TP_ARGS(block_group, start, len), 11913f7de037SJosef Bacik 1192bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11933f7de037SJosef Bacik __field( u64, bg_objectid ) 11943f7de037SJosef Bacik __field( u64, flags ) 11953f7de037SJosef Bacik __field( u64, start ) 11963f7de037SJosef Bacik __field( u64, len ) 11973f7de037SJosef Bacik ), 11983f7de037SJosef Bacik 11993dca5c94SQu Wenruo TP_fast_assign_btrfs(block_group->fs_info, 1200b3470b5dSDavid Sterba __entry->bg_objectid = block_group->start; 12013f7de037SJosef Bacik __entry->flags = block_group->flags; 12023f7de037SJosef Bacik __entry->start = start; 12033f7de037SJosef Bacik __entry->len = len; 12043f7de037SJosef Bacik ), 12053f7de037SJosef Bacik 12065439c7f5SDavid Sterba TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) " 12075439c7f5SDavid Sterba "start=%llu len=%llu", 120871ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 120971ff6437SJeff Mahoney __entry->bg_objectid, 12103f7de037SJosef Bacik __entry->flags, __print_flags((unsigned long)__entry->flags, 12113f7de037SJosef Bacik "|", BTRFS_GROUP_FLAGS), 12123f7de037SJosef Bacik __entry->start, __entry->len) 12133f7de037SJosef Bacik ); 12143f7de037SJosef Bacik 12153f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 12163f7de037SJosef Bacik 1217*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *block_group, u64 start, 12183f7de037SJosef Bacik u64 len), 12193f7de037SJosef Bacik 12203dca5c94SQu Wenruo TP_ARGS(block_group, start, len) 12213f7de037SJosef Bacik ); 12223f7de037SJosef Bacik 12233f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 12243f7de037SJosef Bacik 1225*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *block_group, u64 start, 12263f7de037SJosef Bacik u64 len), 12273f7de037SJosef Bacik 12283dca5c94SQu Wenruo TP_ARGS(block_group, start, len) 12293f7de037SJosef Bacik ); 12303f7de037SJosef Bacik 12313f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster, 12323f7de037SJosef Bacik 1233*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *block_group, u64 start, 12343f7de037SJosef Bacik u64 bytes, u64 empty_size, u64 min_bytes), 12353f7de037SJosef Bacik 12363f7de037SJosef Bacik TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 12373f7de037SJosef Bacik 1238bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12393f7de037SJosef Bacik __field( u64, bg_objectid ) 12403f7de037SJosef Bacik __field( u64, flags ) 12413f7de037SJosef Bacik __field( u64, start ) 12423f7de037SJosef Bacik __field( u64, bytes ) 12433f7de037SJosef Bacik __field( u64, empty_size ) 12443f7de037SJosef Bacik __field( u64, min_bytes ) 12453f7de037SJosef Bacik ), 12463f7de037SJosef Bacik 1247bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 1248b3470b5dSDavid Sterba __entry->bg_objectid = block_group->start; 12493f7de037SJosef Bacik __entry->flags = block_group->flags; 12503f7de037SJosef Bacik __entry->start = start; 12513f7de037SJosef Bacik __entry->bytes = bytes; 12523f7de037SJosef Bacik __entry->empty_size = empty_size; 12533f7de037SJosef Bacik __entry->min_bytes = min_bytes; 12543f7de037SJosef Bacik ), 12553f7de037SJosef Bacik 12565439c7f5SDavid Sterba TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu " 12575439c7f5SDavid Sterba "empty_size=%llu min_bytes=%llu", __entry->bg_objectid, 12583f7de037SJosef Bacik __entry->flags, 12593f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 12603f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 12613f7de037SJosef Bacik __entry->bytes, __entry->empty_size, __entry->min_bytes) 12623f7de037SJosef Bacik ); 12633f7de037SJosef Bacik 12643f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup, 12653f7de037SJosef Bacik 1266*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *block_group), 12673f7de037SJosef Bacik 12683f7de037SJosef Bacik TP_ARGS(block_group), 12693f7de037SJosef Bacik 1270bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12713f7de037SJosef Bacik __field( u64, bg_objectid ) 12723f7de037SJosef Bacik ), 12733f7de037SJosef Bacik 1274bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 1275b3470b5dSDavid Sterba __entry->bg_objectid = block_group->start; 12763f7de037SJosef Bacik ), 12773f7de037SJosef Bacik 12785439c7f5SDavid Sterba TP_printk_btrfs("block_group=%llu", __entry->bg_objectid) 12793f7de037SJosef Bacik ); 12803f7de037SJosef Bacik 12813f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster, 12823f7de037SJosef Bacik 1283*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *block_group, 12849a35b637SJeff Mahoney const struct btrfs_free_cluster *cluster, 12859a35b637SJeff Mahoney u64 size, int bitmap), 12863f7de037SJosef Bacik 12873f7de037SJosef Bacik TP_ARGS(block_group, cluster, size, bitmap), 12883f7de037SJosef Bacik 1289bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12903f7de037SJosef Bacik __field( u64, bg_objectid ) 12913f7de037SJosef Bacik __field( u64, flags ) 12923f7de037SJosef Bacik __field( u64, start ) 12933f7de037SJosef Bacik __field( u64, max_size ) 12943f7de037SJosef Bacik __field( u64, size ) 12953f7de037SJosef Bacik __field( int, bitmap ) 12963f7de037SJosef Bacik ), 12973f7de037SJosef Bacik 1298bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 1299b3470b5dSDavid Sterba __entry->bg_objectid = block_group->start; 13003f7de037SJosef Bacik __entry->flags = block_group->flags; 13013f7de037SJosef Bacik __entry->start = cluster->window_start; 13023f7de037SJosef Bacik __entry->max_size = cluster->max_size; 13033f7de037SJosef Bacik __entry->size = size; 13043f7de037SJosef Bacik __entry->bitmap = bitmap; 13053f7de037SJosef Bacik ), 13063f7de037SJosef Bacik 13075439c7f5SDavid Sterba TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu " 13085439c7f5SDavid Sterba "size=%llu max_size=%llu bitmap=%d", 13093f7de037SJosef Bacik __entry->bg_objectid, 13103f7de037SJosef Bacik __entry->flags, 13113f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 13123f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 13133f7de037SJosef Bacik __entry->size, __entry->max_size, __entry->bitmap) 13143f7de037SJosef Bacik ); 13153f7de037SJosef Bacik 1316143bede5SJeff Mahoney struct extent_state; 1317143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state, 1318143bede5SJeff Mahoney 13199a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, 13209a35b637SJeff Mahoney gfp_t mask, unsigned long IP), 1321143bede5SJeff Mahoney 1322143bede5SJeff Mahoney TP_ARGS(state, mask, IP), 1323143bede5SJeff Mahoney 1324143bede5SJeff Mahoney TP_STRUCT__entry( 13259a35b637SJeff Mahoney __field(const struct extent_state *, state) 1326143bede5SJeff Mahoney __field(gfp_t, mask) 132794c3f6c6SDavid Sterba __field(const void*, ip) 1328143bede5SJeff Mahoney ), 1329143bede5SJeff Mahoney 1330143bede5SJeff Mahoney TP_fast_assign( 1331143bede5SJeff Mahoney __entry->state = state, 1332143bede5SJeff Mahoney __entry->mask = mask, 133394c3f6c6SDavid Sterba __entry->ip = (const void *)IP 1334143bede5SJeff Mahoney ), 1335143bede5SJeff Mahoney 1336562a7a07SDavid Sterba TP_printk("state=%p mask=%s caller=%pS", __entry->state, 133794c3f6c6SDavid Sterba show_gfp_flags(__entry->mask), __entry->ip) 1338143bede5SJeff Mahoney ); 1339143bede5SJeff Mahoney 1340143bede5SJeff Mahoney TRACE_EVENT(free_extent_state, 1341143bede5SJeff Mahoney 13429a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, unsigned long IP), 1343143bede5SJeff Mahoney 1344143bede5SJeff Mahoney TP_ARGS(state, IP), 1345143bede5SJeff Mahoney 1346143bede5SJeff Mahoney TP_STRUCT__entry( 13479a35b637SJeff Mahoney __field(const struct extent_state *, state) 134894c3f6c6SDavid Sterba __field(const void*, ip) 1349143bede5SJeff Mahoney ), 1350143bede5SJeff Mahoney 1351143bede5SJeff Mahoney TP_fast_assign( 1352143bede5SJeff Mahoney __entry->state = state, 135394c3f6c6SDavid Sterba __entry->ip = (const void *)IP 1354143bede5SJeff Mahoney ), 1355143bede5SJeff Mahoney 135694c3f6c6SDavid Sterba TP_printk("state=%p caller=%pS", __entry->state, __entry->ip) 1357143bede5SJeff Mahoney ); 1358143bede5SJeff Mahoney 135952483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work, 136052483bc2SQu Wenruo 13619a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 136252483bc2SQu Wenruo 136352483bc2SQu Wenruo TP_ARGS(work), 136452483bc2SQu Wenruo 1365bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 13669a35b637SJeff Mahoney __field( const void *, work ) 13679a35b637SJeff Mahoney __field( const void *, wq ) 13689a35b637SJeff Mahoney __field( const void *, func ) 13699a35b637SJeff Mahoney __field( const void *, ordered_func ) 13709a35b637SJeff Mahoney __field( const void *, ordered_free ) 13719a35b637SJeff Mahoney __field( const void *, normal_work ) 137252483bc2SQu Wenruo ), 137352483bc2SQu Wenruo 1374bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_work_owner(work), 137552483bc2SQu Wenruo __entry->work = work; 137652483bc2SQu Wenruo __entry->wq = work->wq; 137752483bc2SQu Wenruo __entry->func = work->func; 137852483bc2SQu Wenruo __entry->ordered_func = work->ordered_func; 137952483bc2SQu Wenruo __entry->ordered_free = work->ordered_free; 1380b38a6258SLiu Bo __entry->normal_work = &work->normal_work; 138152483bc2SQu Wenruo ), 138252483bc2SQu Wenruo 1383d75f773cSSakari Ailus TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p " 1384b38a6258SLiu Bo "ordered_free=%p", 1385b38a6258SLiu Bo __entry->work, __entry->normal_work, __entry->wq, 1386b38a6258SLiu Bo __entry->func, __entry->ordered_func, __entry->ordered_free) 138752483bc2SQu Wenruo ); 138852483bc2SQu Wenruo 1389ac0c7cf8SDavid Sterba /* 1390c9eb55dbSOmar Sandoval * For situations when the work is freed, we pass fs_info and a tag that matches 1391c9eb55dbSOmar Sandoval * the address of the work structure so it can be paired with the scheduling 1392c9eb55dbSOmar Sandoval * event. DO NOT add anything here that dereferences wtag. 1393ac0c7cf8SDavid Sterba */ 139452483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done, 139552483bc2SQu Wenruo 13969a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 139752483bc2SQu Wenruo 1398ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag), 139952483bc2SQu Wenruo 1400bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14019a35b637SJeff Mahoney __field( const void *, wtag ) 140252483bc2SQu Wenruo ), 140352483bc2SQu Wenruo 1404ac0c7cf8SDavid Sterba TP_fast_assign_btrfs(fs_info, 1405ac0c7cf8SDavid Sterba __entry->wtag = wtag; 140652483bc2SQu Wenruo ), 140752483bc2SQu Wenruo 1408ac0c7cf8SDavid Sterba TP_printk_btrfs("work->%p", __entry->wtag) 140952483bc2SQu Wenruo ); 141052483bc2SQu Wenruo 141152483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued, 141252483bc2SQu Wenruo 14139a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 141452483bc2SQu Wenruo 141552483bc2SQu Wenruo TP_ARGS(work) 141652483bc2SQu Wenruo ); 141752483bc2SQu Wenruo 141852483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched, 141952483bc2SQu Wenruo 14209a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 142152483bc2SQu Wenruo 142252483bc2SQu Wenruo TP_ARGS(work) 142352483bc2SQu Wenruo ); 142452483bc2SQu Wenruo 142552483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 142652483bc2SQu Wenruo 14279a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 142852483bc2SQu Wenruo 1429ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag) 143052483bc2SQu Wenruo ); 143152483bc2SQu Wenruo 143252483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 143352483bc2SQu Wenruo 14349a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 143552483bc2SQu Wenruo 143652483bc2SQu Wenruo TP_ARGS(work) 143752483bc2SQu Wenruo ); 143852483bc2SQu Wenruo 1439c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue, 1440c3a46891SQu Wenruo 14419a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 14429a35b637SJeff Mahoney const char *name, int high), 1443c3a46891SQu Wenruo 1444c3a46891SQu Wenruo TP_ARGS(wq, name, high), 1445c3a46891SQu Wenruo 1446bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14479a35b637SJeff Mahoney __field( const void *, wq ) 1448c3a46891SQu Wenruo __string( name, name ) 1449c3a46891SQu Wenruo __field( int , high ) 1450c3a46891SQu Wenruo ), 1451c3a46891SQu Wenruo 1452bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1453c3a46891SQu Wenruo __entry->wq = wq; 1454c3a46891SQu Wenruo __assign_str(name, name); 1455c3a46891SQu Wenruo __entry->high = high; 1456c3a46891SQu Wenruo ), 1457c3a46891SQu Wenruo 1458562a7a07SDavid Sterba TP_printk_btrfs("name=%s%s wq=%p", __get_str(name), 1459c3a46891SQu Wenruo __print_flags(__entry->high, "", 1460c3a46891SQu Wenruo {(WQ_HIGHPRI), "-high"}), 1461c3a46891SQu Wenruo __entry->wq) 1462c3a46891SQu Wenruo ); 1463c3a46891SQu Wenruo 1464c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc, 1465c3a46891SQu Wenruo 14669a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 14679a35b637SJeff Mahoney const char *name, int high), 1468c3a46891SQu Wenruo 1469c3a46891SQu Wenruo TP_ARGS(wq, name, high) 1470c3a46891SQu Wenruo ); 1471c3a46891SQu Wenruo 1472c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue_done, 1473c3a46891SQu Wenruo 14749a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1475c3a46891SQu Wenruo 1476c3a46891SQu Wenruo TP_ARGS(wq), 1477c3a46891SQu Wenruo 1478bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14799a35b637SJeff Mahoney __field( const void *, wq ) 1480c3a46891SQu Wenruo ), 1481c3a46891SQu Wenruo 1482bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1483c3a46891SQu Wenruo __entry->wq = wq; 1484c3a46891SQu Wenruo ), 1485c3a46891SQu Wenruo 1486bc074524SJeff Mahoney TP_printk_btrfs("wq=%p", __entry->wq) 1487c3a46891SQu Wenruo ); 1488c3a46891SQu Wenruo 1489c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy, 1490c3a46891SQu Wenruo 14919a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1492c3a46891SQu Wenruo 1493c3a46891SQu Wenruo TP_ARGS(wq) 1494c3a46891SQu Wenruo ); 149552483bc2SQu Wenruo 149681fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS \ 149781fb6f77SQu Wenruo { QGROUP_RESERVE, "reserve" }, \ 149881fb6f77SQu Wenruo { QGROUP_RELEASE, "release" }, \ 149981fb6f77SQu Wenruo { QGROUP_FREE, "free" } 150081fb6f77SQu Wenruo 150181fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data, 150281fb6f77SQu Wenruo 15039a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 15049a35b637SJeff Mahoney u64 reserved, int op), 150581fb6f77SQu Wenruo 150681fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op), 150781fb6f77SQu Wenruo 1508bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 150981fb6f77SQu Wenruo __field( u64, rootid ) 1510f8f8e189SDavid Sterba __field( u64, ino ) 151181fb6f77SQu Wenruo __field( u64, start ) 151281fb6f77SQu Wenruo __field( u64, len ) 151381fb6f77SQu Wenruo __field( u64, reserved ) 151481fb6f77SQu Wenruo __field( int, op ) 151581fb6f77SQu Wenruo ), 151681fb6f77SQu Wenruo 1517bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 15184fd786e6SMisono Tomohiro __entry->rootid = 15194fd786e6SMisono Tomohiro BTRFS_I(inode)->root->root_key.objectid; 1520f8f8e189SDavid Sterba __entry->ino = btrfs_ino(BTRFS_I(inode)); 152181fb6f77SQu Wenruo __entry->start = start; 152281fb6f77SQu Wenruo __entry->len = len; 152381fb6f77SQu Wenruo __entry->reserved = reserved; 152481fb6f77SQu Wenruo __entry->op = op; 152581fb6f77SQu Wenruo ), 152681fb6f77SQu Wenruo 1527f8f8e189SDavid Sterba TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s", 152881fb6f77SQu Wenruo __entry->rootid, __entry->ino, __entry->start, __entry->len, 152981fb6f77SQu Wenruo __entry->reserved, 153081fb6f77SQu Wenruo __print_flags((unsigned long)__entry->op, "", 153181fb6f77SQu Wenruo BTRFS_QGROUP_OPERATIONS) 153281fb6f77SQu Wenruo ) 153381fb6f77SQu Wenruo ); 153481fb6f77SQu Wenruo 153581fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data, 153681fb6f77SQu Wenruo 15379a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 15389a35b637SJeff Mahoney u64 reserved, int op), 153981fb6f77SQu Wenruo 154081fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 154181fb6f77SQu Wenruo ); 154281fb6f77SQu Wenruo 154381fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data, 154481fb6f77SQu Wenruo 15459a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 15469a35b637SJeff Mahoney u64 reserved, int op), 154781fb6f77SQu Wenruo 154881fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 154981fb6f77SQu Wenruo ); 155081fb6f77SQu Wenruo 15510f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent, 15529a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15539a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15540f5dcf8dSMark Fasheh 1555bc074524SJeff Mahoney TP_ARGS(fs_info, rec), 15560f5dcf8dSMark Fasheh 1557bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 15580f5dcf8dSMark Fasheh __field( u64, bytenr ) 15590f5dcf8dSMark Fasheh __field( u64, num_bytes ) 15600f5dcf8dSMark Fasheh ), 15610f5dcf8dSMark Fasheh 1562bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 15630f5dcf8dSMark Fasheh __entry->bytenr = rec->bytenr, 15640f5dcf8dSMark Fasheh __entry->num_bytes = rec->num_bytes; 15650f5dcf8dSMark Fasheh ), 15660f5dcf8dSMark Fasheh 1567562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu", 156894c3f6c6SDavid Sterba __entry->bytenr, __entry->num_bytes) 15690f5dcf8dSMark Fasheh ); 15700f5dcf8dSMark Fasheh 15710f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents, 15720f5dcf8dSMark Fasheh 15739a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15749a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15750f5dcf8dSMark Fasheh 1576bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15770f5dcf8dSMark Fasheh ); 15780f5dcf8dSMark Fasheh 157950b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent, 15800f5dcf8dSMark Fasheh 15819a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15829a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15830f5dcf8dSMark Fasheh 1584bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15850f5dcf8dSMark Fasheh ); 15860f5dcf8dSMark Fasheh 1587c337e7b0SQu Wenruo TRACE_EVENT(qgroup_num_dirty_extents, 1588c337e7b0SQu Wenruo 1589c337e7b0SQu Wenruo TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, 1590c337e7b0SQu Wenruo u64 num_dirty_extents), 1591c337e7b0SQu Wenruo 1592c337e7b0SQu Wenruo TP_ARGS(fs_info, transid, num_dirty_extents), 1593c337e7b0SQu Wenruo 1594c337e7b0SQu Wenruo TP_STRUCT__entry_btrfs( 1595c337e7b0SQu Wenruo __field( u64, transid ) 1596c337e7b0SQu Wenruo __field( u64, num_dirty_extents ) 1597c337e7b0SQu Wenruo ), 1598c337e7b0SQu Wenruo 1599c337e7b0SQu Wenruo TP_fast_assign_btrfs(fs_info, 1600c337e7b0SQu Wenruo __entry->transid = transid; 1601c337e7b0SQu Wenruo __entry->num_dirty_extents = num_dirty_extents; 1602c337e7b0SQu Wenruo ), 1603c337e7b0SQu Wenruo 1604c337e7b0SQu Wenruo TP_printk_btrfs("transid=%llu num_dirty_extents=%llu", 1605c337e7b0SQu Wenruo __entry->transid, __entry->num_dirty_extents) 1606c337e7b0SQu Wenruo ); 1607c337e7b0SQu Wenruo 16080f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent, 16090f5dcf8dSMark Fasheh 1610c9f6f3cdSQu Wenruo TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr, 1611bc074524SJeff Mahoney u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots), 16120f5dcf8dSMark Fasheh 1613c9f6f3cdSQu Wenruo TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots, 1614c9f6f3cdSQu Wenruo nr_new_roots), 16150f5dcf8dSMark Fasheh 1616bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 1617c9f6f3cdSQu Wenruo __field( u64, transid ) 16180f5dcf8dSMark Fasheh __field( u64, bytenr ) 16190f5dcf8dSMark Fasheh __field( u64, num_bytes ) 16200f5dcf8dSMark Fasheh __field( u64, nr_old_roots ) 16210f5dcf8dSMark Fasheh __field( u64, nr_new_roots ) 16220f5dcf8dSMark Fasheh ), 16230f5dcf8dSMark Fasheh 1624bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 1625c9f6f3cdSQu Wenruo __entry->transid = transid; 16260f5dcf8dSMark Fasheh __entry->bytenr = bytenr; 16270f5dcf8dSMark Fasheh __entry->num_bytes = num_bytes; 16280f5dcf8dSMark Fasheh __entry->nr_old_roots = nr_old_roots; 16290f5dcf8dSMark Fasheh __entry->nr_new_roots = nr_new_roots; 16300f5dcf8dSMark Fasheh ), 16310f5dcf8dSMark Fasheh 1632c9f6f3cdSQu Wenruo TP_printk_btrfs( 1633c9f6f3cdSQu Wenruo "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu", 1634c9f6f3cdSQu Wenruo __entry->transid, 16350f5dcf8dSMark Fasheh __entry->bytenr, 16360f5dcf8dSMark Fasheh __entry->num_bytes, 16370f5dcf8dSMark Fasheh __entry->nr_old_roots, 16380f5dcf8dSMark Fasheh __entry->nr_new_roots) 16390f5dcf8dSMark Fasheh ); 16400f5dcf8dSMark Fasheh 16410f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters, 16420f5dcf8dSMark Fasheh 16438b317901SQu Wenruo TP_PROTO(const struct btrfs_fs_info *fs_info, 16441d2e7c7cSDavid Sterba const struct btrfs_qgroup *qgroup, 1645bc074524SJeff Mahoney u64 cur_old_count, u64 cur_new_count), 16460f5dcf8dSMark Fasheh 16478b317901SQu Wenruo TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count), 16480f5dcf8dSMark Fasheh 1649bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 16500f5dcf8dSMark Fasheh __field( u64, qgid ) 16518b317901SQu Wenruo __field( u64, old_rfer ) 16528b317901SQu Wenruo __field( u64, old_excl ) 16530f5dcf8dSMark Fasheh __field( u64, cur_old_count ) 16540f5dcf8dSMark Fasheh __field( u64, cur_new_count ) 16550f5dcf8dSMark Fasheh ), 16560f5dcf8dSMark Fasheh 1657bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 16588b317901SQu Wenruo __entry->qgid = qgroup->qgroupid; 16598b317901SQu Wenruo __entry->old_rfer = qgroup->rfer; 16608b317901SQu Wenruo __entry->old_excl = qgroup->excl; 16610f5dcf8dSMark Fasheh __entry->cur_old_count = cur_old_count; 16620f5dcf8dSMark Fasheh __entry->cur_new_count = cur_new_count; 16630f5dcf8dSMark Fasheh ), 16640f5dcf8dSMark Fasheh 16658b317901SQu Wenruo TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu", 16668b317901SQu Wenruo __entry->qgid, __entry->old_rfer, __entry->old_excl, 16678b317901SQu Wenruo __entry->cur_old_count, __entry->cur_new_count) 16680f5dcf8dSMark Fasheh ); 16690f5dcf8dSMark Fasheh 16703159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve, 16713159fe7bSQu Wenruo 16723159fe7bSQu Wenruo TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup, 167364ee4e75SQu Wenruo s64 diff, int type), 16743159fe7bSQu Wenruo 167564ee4e75SQu Wenruo TP_ARGS(fs_info, qgroup, diff, type), 16763159fe7bSQu Wenruo 16773159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 16783159fe7bSQu Wenruo __field( u64, qgid ) 16793159fe7bSQu Wenruo __field( u64, cur_reserved ) 16803159fe7bSQu Wenruo __field( s64, diff ) 168164ee4e75SQu Wenruo __field( int, type ) 16823159fe7bSQu Wenruo ), 16833159fe7bSQu Wenruo 16843159fe7bSQu Wenruo TP_fast_assign_btrfs(fs_info, 16853159fe7bSQu Wenruo __entry->qgid = qgroup->qgroupid; 168664ee4e75SQu Wenruo __entry->cur_reserved = qgroup->rsv.values[type]; 16873159fe7bSQu Wenruo __entry->diff = diff; 16881b2442b4SQu Wenruo __entry->type = type; 16893159fe7bSQu Wenruo ), 16903159fe7bSQu Wenruo 169164ee4e75SQu Wenruo TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld", 169264ee4e75SQu Wenruo __entry->qgid, show_qgroup_rsv_type(__entry->type), 169364ee4e75SQu Wenruo __entry->cur_reserved, __entry->diff) 16943159fe7bSQu Wenruo ); 16953159fe7bSQu Wenruo 16963159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve, 16973159fe7bSQu Wenruo 16984ee0d883SQu Wenruo TP_PROTO(struct btrfs_root *root, s64 diff, int type), 16993159fe7bSQu Wenruo 17004ee0d883SQu Wenruo TP_ARGS(root, diff, type), 17013159fe7bSQu Wenruo 17023159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 17033159fe7bSQu Wenruo __field( u64, refroot ) 17043159fe7bSQu Wenruo __field( s64, diff ) 17054ee0d883SQu Wenruo __field( int, type ) 17063159fe7bSQu Wenruo ), 17073159fe7bSQu Wenruo 17083159fe7bSQu Wenruo TP_fast_assign_btrfs(root->fs_info, 17094fd786e6SMisono Tomohiro __entry->refroot = root->root_key.objectid; 17103159fe7bSQu Wenruo __entry->diff = diff; 17111b2442b4SQu Wenruo __entry->type = type; 17123159fe7bSQu Wenruo ), 17133159fe7bSQu Wenruo 17144ee0d883SQu Wenruo TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 17154ee0d883SQu Wenruo show_root_type(__entry->refroot), 17164ee0d883SQu Wenruo show_qgroup_rsv_type(__entry->type), __entry->diff) 17174ee0d883SQu Wenruo ); 17184ee0d883SQu Wenruo 17194ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_convert, 17204ee0d883SQu Wenruo 17214ee0d883SQu Wenruo TP_PROTO(struct btrfs_root *root, s64 diff), 17224ee0d883SQu Wenruo 17234ee0d883SQu Wenruo TP_ARGS(root, diff), 17244ee0d883SQu Wenruo 17254ee0d883SQu Wenruo TP_STRUCT__entry_btrfs( 17264ee0d883SQu Wenruo __field( u64, refroot ) 17274ee0d883SQu Wenruo __field( s64, diff ) 17284ee0d883SQu Wenruo ), 17294ee0d883SQu Wenruo 17304ee0d883SQu Wenruo TP_fast_assign_btrfs(root->fs_info, 17314fd786e6SMisono Tomohiro __entry->refroot = root->root_key.objectid; 17324ee0d883SQu Wenruo __entry->diff = diff; 17334ee0d883SQu Wenruo ), 17344ee0d883SQu Wenruo 17354ee0d883SQu Wenruo TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld", 17364ee0d883SQu Wenruo show_root_type(__entry->refroot), 17374ee0d883SQu Wenruo show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC), 17384ee0d883SQu Wenruo show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS), 17394ee0d883SQu Wenruo __entry->diff) 17404ee0d883SQu Wenruo ); 17414ee0d883SQu Wenruo 17424ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_free_all_pertrans, 17434ee0d883SQu Wenruo 17444ee0d883SQu Wenruo TP_PROTO(struct btrfs_root *root), 17454ee0d883SQu Wenruo 17464ee0d883SQu Wenruo TP_ARGS(root), 17474ee0d883SQu Wenruo 17484ee0d883SQu Wenruo TP_STRUCT__entry_btrfs( 17494ee0d883SQu Wenruo __field( u64, refroot ) 17504ee0d883SQu Wenruo __field( s64, diff ) 17514ee0d883SQu Wenruo __field( int, type ) 17524ee0d883SQu Wenruo ), 17534ee0d883SQu Wenruo 17544ee0d883SQu Wenruo TP_fast_assign_btrfs(root->fs_info, 17554fd786e6SMisono Tomohiro __entry->refroot = root->root_key.objectid; 17564ee0d883SQu Wenruo spin_lock(&root->qgroup_meta_rsv_lock); 17574ee0d883SQu Wenruo __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans; 17584ee0d883SQu Wenruo spin_unlock(&root->qgroup_meta_rsv_lock); 17594ee0d883SQu Wenruo __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS; 17604ee0d883SQu Wenruo ), 17614ee0d883SQu Wenruo 17624ee0d883SQu Wenruo TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld", 17634ee0d883SQu Wenruo show_root_type(__entry->refroot), 17644ee0d883SQu Wenruo show_qgroup_rsv_type(__entry->type), __entry->diff) 17653159fe7bSQu Wenruo ); 17663159fe7bSQu Wenruo 176700142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref, 176800142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 176900142756SJeff Mahoney const struct prelim_ref *oldref, 177000142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 177100142756SJeff Mahoney TP_ARGS(fs_info, newref, oldref, tree_size), 177200142756SJeff Mahoney 177300142756SJeff Mahoney TP_STRUCT__entry_btrfs( 177400142756SJeff Mahoney __field( u64, root_id ) 177500142756SJeff Mahoney __field( u64, objectid ) 177600142756SJeff Mahoney __field( u8, type ) 177700142756SJeff Mahoney __field( u64, offset ) 177800142756SJeff Mahoney __field( int, level ) 177900142756SJeff Mahoney __field( int, old_count ) 178000142756SJeff Mahoney __field( u64, parent ) 178100142756SJeff Mahoney __field( u64, bytenr ) 178200142756SJeff Mahoney __field( int, mod_count ) 178300142756SJeff Mahoney __field( u64, tree_size ) 178400142756SJeff Mahoney ), 178500142756SJeff Mahoney 178600142756SJeff Mahoney TP_fast_assign_btrfs(fs_info, 178700142756SJeff Mahoney __entry->root_id = oldref->root_id; 178800142756SJeff Mahoney __entry->objectid = oldref->key_for_search.objectid; 178900142756SJeff Mahoney __entry->type = oldref->key_for_search.type; 179000142756SJeff Mahoney __entry->offset = oldref->key_for_search.offset; 179100142756SJeff Mahoney __entry->level = oldref->level; 179200142756SJeff Mahoney __entry->old_count = oldref->count; 179300142756SJeff Mahoney __entry->parent = oldref->parent; 179400142756SJeff Mahoney __entry->bytenr = oldref->wanted_disk_byte; 179500142756SJeff Mahoney __entry->mod_count = newref ? newref->count : 0; 179600142756SJeff Mahoney __entry->tree_size = tree_size; 179700142756SJeff Mahoney ), 179800142756SJeff Mahoney 179900142756SJeff 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", 18008eec8463SDavid Sterba __entry->root_id, 18018eec8463SDavid Sterba __entry->objectid, __entry->type, 18028eec8463SDavid Sterba __entry->offset, __entry->level, 180300142756SJeff Mahoney __entry->old_count, __entry->mod_count, 180400142756SJeff Mahoney __entry->old_count + __entry->mod_count, 18058eec8463SDavid Sterba __entry->parent, 18068eec8463SDavid Sterba __entry->bytenr, 18078eec8463SDavid Sterba __entry->tree_size) 180800142756SJeff Mahoney ); 180900142756SJeff Mahoney 181000142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge, 181100142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 181200142756SJeff Mahoney const struct prelim_ref *oldref, 181300142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 181400142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 181500142756SJeff Mahoney ); 181600142756SJeff Mahoney 181700142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert, 181800142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 181900142756SJeff Mahoney const struct prelim_ref *oldref, 182000142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 182100142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 182200142756SJeff Mahoney ); 182300142756SJeff Mahoney 1824dd48d407SJosef Bacik TRACE_EVENT(btrfs_inode_mod_outstanding_extents, 18251d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_root *root, u64 ino, int mod), 1826dd48d407SJosef Bacik 1827dd48d407SJosef Bacik TP_ARGS(root, ino, mod), 1828dd48d407SJosef Bacik 1829dd48d407SJosef Bacik TP_STRUCT__entry_btrfs( 1830dd48d407SJosef Bacik __field( u64, root_objectid ) 1831dd48d407SJosef Bacik __field( u64, ino ) 1832dd48d407SJosef Bacik __field( int, mod ) 1833dd48d407SJosef Bacik ), 1834dd48d407SJosef Bacik 1835dd48d407SJosef Bacik TP_fast_assign_btrfs(root->fs_info, 18364fd786e6SMisono Tomohiro __entry->root_objectid = root->root_key.objectid; 1837dd48d407SJosef Bacik __entry->ino = ino; 1838dd48d407SJosef Bacik __entry->mod = mod; 1839dd48d407SJosef Bacik ), 1840dd48d407SJosef Bacik 1841dd48d407SJosef Bacik TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d", 1842dd48d407SJosef Bacik show_root_type(__entry->root_objectid), 18438eec8463SDavid Sterba __entry->ino, __entry->mod) 1844dd48d407SJosef Bacik ); 18453dca5c94SQu Wenruo 18464ed0a7a3SQu Wenruo DECLARE_EVENT_CLASS(btrfs__block_group, 1847*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *bg_cache), 18484ed0a7a3SQu Wenruo 18494ed0a7a3SQu Wenruo TP_ARGS(bg_cache), 18504ed0a7a3SQu Wenruo 18514ed0a7a3SQu Wenruo TP_STRUCT__entry_btrfs( 18524ed0a7a3SQu Wenruo __field( u64, bytenr ) 18534ed0a7a3SQu Wenruo __field( u64, len ) 18544ed0a7a3SQu Wenruo __field( u64, used ) 18554ed0a7a3SQu Wenruo __field( u64, flags ) 18564ed0a7a3SQu Wenruo ), 18574ed0a7a3SQu Wenruo 18584ed0a7a3SQu Wenruo TP_fast_assign_btrfs(bg_cache->fs_info, 1859b3470b5dSDavid Sterba __entry->bytenr = bg_cache->start, 1860b3470b5dSDavid Sterba __entry->len = bg_cache->length, 1861bf38be65SDavid Sterba __entry->used = bg_cache->used; 18624ed0a7a3SQu Wenruo __entry->flags = bg_cache->flags; 18634ed0a7a3SQu Wenruo ), 18644ed0a7a3SQu Wenruo 18654ed0a7a3SQu Wenruo TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)", 18664ed0a7a3SQu Wenruo __entry->bytenr, __entry->len, __entry->used, __entry->flags, 18674ed0a7a3SQu Wenruo __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS)) 18684ed0a7a3SQu Wenruo ); 18694ed0a7a3SQu Wenruo 18704ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group, 1871*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *bg_cache), 18724ed0a7a3SQu Wenruo 18734ed0a7a3SQu Wenruo TP_ARGS(bg_cache) 18744ed0a7a3SQu Wenruo ); 18754ed0a7a3SQu Wenruo 18764ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group, 1877*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *bg_cache), 18784ed0a7a3SQu Wenruo 18794ed0a7a3SQu Wenruo TP_ARGS(bg_cache) 18804ed0a7a3SQu Wenruo ); 18814ed0a7a3SQu Wenruo 18824ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group, 1883*32da5386SDavid Sterba TP_PROTO(const struct btrfs_block_group *bg_cache), 18844ed0a7a3SQu Wenruo 18854ed0a7a3SQu Wenruo TP_ARGS(bg_cache) 18864ed0a7a3SQu Wenruo ); 18874ed0a7a3SQu Wenruo 1888a1d19847SQu Wenruo TRACE_EVENT(btrfs_set_extent_bit, 1889a1d19847SQu Wenruo TP_PROTO(const struct extent_io_tree *tree, 1890a1d19847SQu Wenruo u64 start, u64 len, unsigned set_bits), 1891a1d19847SQu Wenruo 1892a1d19847SQu Wenruo TP_ARGS(tree, start, len, set_bits), 1893a1d19847SQu Wenruo 1894a1d19847SQu Wenruo TP_STRUCT__entry_btrfs( 1895a1d19847SQu Wenruo __field( unsigned, owner ) 1896a1d19847SQu Wenruo __field( u64, ino ) 1897a1d19847SQu Wenruo __field( u64, rootid ) 1898a1d19847SQu Wenruo __field( u64, start ) 1899a1d19847SQu Wenruo __field( u64, len ) 1900a1d19847SQu Wenruo __field( unsigned, set_bits) 1901a1d19847SQu Wenruo ), 1902a1d19847SQu Wenruo 1903a1d19847SQu Wenruo TP_fast_assign_btrfs(tree->fs_info, 1904a1d19847SQu Wenruo __entry->owner = tree->owner; 1905a1d19847SQu Wenruo if (tree->private_data) { 19061d2e7c7cSDavid Sterba const struct inode *inode = tree->private_data; 1907a1d19847SQu Wenruo 1908a1d19847SQu Wenruo __entry->ino = btrfs_ino(BTRFS_I(inode)); 1909a1d19847SQu Wenruo __entry->rootid = 1910a1d19847SQu Wenruo BTRFS_I(inode)->root->root_key.objectid; 1911a1d19847SQu Wenruo } else { 1912a1d19847SQu Wenruo __entry->ino = 0; 1913a1d19847SQu Wenruo __entry->rootid = 0; 1914a1d19847SQu Wenruo } 1915a1d19847SQu Wenruo __entry->start = start; 1916a1d19847SQu Wenruo __entry->len = len; 1917a1d19847SQu Wenruo __entry->set_bits = set_bits; 1918a1d19847SQu Wenruo ), 1919a1d19847SQu Wenruo 1920a1d19847SQu Wenruo TP_printk_btrfs( 1921a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s", 1922a1d19847SQu Wenruo show_extent_io_tree_owner(__entry->owner), __entry->ino, 1923a1d19847SQu Wenruo __entry->rootid, __entry->start, __entry->len, 1924a1d19847SQu Wenruo __print_flags(__entry->set_bits, "|", EXTENT_FLAGS)) 1925a1d19847SQu Wenruo ); 1926a1d19847SQu Wenruo 1927a1d19847SQu Wenruo TRACE_EVENT(btrfs_clear_extent_bit, 1928a1d19847SQu Wenruo TP_PROTO(const struct extent_io_tree *tree, 1929a1d19847SQu Wenruo u64 start, u64 len, unsigned clear_bits), 1930a1d19847SQu Wenruo 1931a1d19847SQu Wenruo TP_ARGS(tree, start, len, clear_bits), 1932a1d19847SQu Wenruo 1933a1d19847SQu Wenruo TP_STRUCT__entry_btrfs( 1934a1d19847SQu Wenruo __field( unsigned, owner ) 1935a1d19847SQu Wenruo __field( u64, ino ) 1936a1d19847SQu Wenruo __field( u64, rootid ) 1937a1d19847SQu Wenruo __field( u64, start ) 1938a1d19847SQu Wenruo __field( u64, len ) 1939a1d19847SQu Wenruo __field( unsigned, clear_bits) 1940a1d19847SQu Wenruo ), 1941a1d19847SQu Wenruo 1942a1d19847SQu Wenruo TP_fast_assign_btrfs(tree->fs_info, 1943a1d19847SQu Wenruo __entry->owner = tree->owner; 1944a1d19847SQu Wenruo if (tree->private_data) { 19451d2e7c7cSDavid Sterba const struct inode *inode = tree->private_data; 1946a1d19847SQu Wenruo 1947a1d19847SQu Wenruo __entry->ino = btrfs_ino(BTRFS_I(inode)); 1948a1d19847SQu Wenruo __entry->rootid = 1949a1d19847SQu Wenruo BTRFS_I(inode)->root->root_key.objectid; 1950a1d19847SQu Wenruo } else { 1951a1d19847SQu Wenruo __entry->ino = 0; 1952a1d19847SQu Wenruo __entry->rootid = 0; 1953a1d19847SQu Wenruo } 1954a1d19847SQu Wenruo __entry->start = start; 1955a1d19847SQu Wenruo __entry->len = len; 1956a1d19847SQu Wenruo __entry->clear_bits = clear_bits; 1957a1d19847SQu Wenruo ), 1958a1d19847SQu Wenruo 1959a1d19847SQu Wenruo TP_printk_btrfs( 1960a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s", 1961a1d19847SQu Wenruo show_extent_io_tree_owner(__entry->owner), __entry->ino, 1962a1d19847SQu Wenruo __entry->rootid, __entry->start, __entry->len, 1963a1d19847SQu Wenruo __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 1964a1d19847SQu Wenruo ); 1965a1d19847SQu Wenruo 1966a1d19847SQu Wenruo TRACE_EVENT(btrfs_convert_extent_bit, 1967a1d19847SQu Wenruo TP_PROTO(const struct extent_io_tree *tree, 1968a1d19847SQu Wenruo u64 start, u64 len, unsigned set_bits, unsigned clear_bits), 1969a1d19847SQu Wenruo 1970a1d19847SQu Wenruo TP_ARGS(tree, start, len, set_bits, clear_bits), 1971a1d19847SQu Wenruo 1972a1d19847SQu Wenruo TP_STRUCT__entry_btrfs( 1973a1d19847SQu Wenruo __field( unsigned, owner ) 1974a1d19847SQu Wenruo __field( u64, ino ) 1975a1d19847SQu Wenruo __field( u64, rootid ) 1976a1d19847SQu Wenruo __field( u64, start ) 1977a1d19847SQu Wenruo __field( u64, len ) 1978a1d19847SQu Wenruo __field( unsigned, set_bits) 1979a1d19847SQu Wenruo __field( unsigned, clear_bits) 1980a1d19847SQu Wenruo ), 1981a1d19847SQu Wenruo 1982a1d19847SQu Wenruo TP_fast_assign_btrfs(tree->fs_info, 1983a1d19847SQu Wenruo __entry->owner = tree->owner; 1984a1d19847SQu Wenruo if (tree->private_data) { 19851d2e7c7cSDavid Sterba const struct inode *inode = tree->private_data; 1986a1d19847SQu Wenruo 1987a1d19847SQu Wenruo __entry->ino = btrfs_ino(BTRFS_I(inode)); 1988a1d19847SQu Wenruo __entry->rootid = 1989a1d19847SQu Wenruo BTRFS_I(inode)->root->root_key.objectid; 1990a1d19847SQu Wenruo } else { 1991a1d19847SQu Wenruo __entry->ino = 0; 1992a1d19847SQu Wenruo __entry->rootid = 0; 1993a1d19847SQu Wenruo } 1994a1d19847SQu Wenruo __entry->start = start; 1995a1d19847SQu Wenruo __entry->len = len; 1996a1d19847SQu Wenruo __entry->set_bits = set_bits; 1997a1d19847SQu Wenruo __entry->clear_bits = clear_bits; 1998a1d19847SQu Wenruo ), 1999a1d19847SQu Wenruo 2000a1d19847SQu Wenruo TP_printk_btrfs( 2001a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s", 2002a1d19847SQu Wenruo show_extent_io_tree_owner(__entry->owner), __entry->ino, 2003a1d19847SQu Wenruo __entry->rootid, __entry->start, __entry->len, 2004a1d19847SQu Wenruo __print_flags(__entry->set_bits , "|", EXTENT_FLAGS), 2005a1d19847SQu Wenruo __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS)) 2006a1d19847SQu Wenruo ); 2007a1d19847SQu Wenruo 200834e73cc9SQu Wenruo DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock, 200934e73cc9SQu Wenruo TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 201034e73cc9SQu Wenruo 201134e73cc9SQu Wenruo TP_ARGS(eb, start_ns), 201234e73cc9SQu Wenruo 201334e73cc9SQu Wenruo TP_STRUCT__entry_btrfs( 201434e73cc9SQu Wenruo __field( u64, block ) 201534e73cc9SQu Wenruo __field( u64, generation ) 201634e73cc9SQu Wenruo __field( u64, start_ns ) 201734e73cc9SQu Wenruo __field( u64, end_ns ) 201834e73cc9SQu Wenruo __field( u64, diff_ns ) 201934e73cc9SQu Wenruo __field( u64, owner ) 202034e73cc9SQu Wenruo __field( int, is_log_tree ) 202134e73cc9SQu Wenruo ), 202234e73cc9SQu Wenruo 202334e73cc9SQu Wenruo TP_fast_assign_btrfs(eb->fs_info, 202434e73cc9SQu Wenruo __entry->block = eb->start; 202534e73cc9SQu Wenruo __entry->generation = btrfs_header_generation(eb); 202634e73cc9SQu Wenruo __entry->start_ns = start_ns; 202734e73cc9SQu Wenruo __entry->end_ns = ktime_get_ns(); 202834e73cc9SQu Wenruo __entry->diff_ns = __entry->end_ns - start_ns; 202934e73cc9SQu Wenruo __entry->owner = btrfs_header_owner(eb); 203034e73cc9SQu Wenruo __entry->is_log_tree = (eb->log_index >= 0); 203134e73cc9SQu Wenruo ), 203234e73cc9SQu Wenruo 203334e73cc9SQu Wenruo TP_printk_btrfs( 203434e73cc9SQu Wenruo "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d", 203534e73cc9SQu Wenruo __entry->block, __entry->generation, 203634e73cc9SQu Wenruo __entry->start_ns, __entry->end_ns, __entry->diff_ns, 203734e73cc9SQu Wenruo __entry->owner, __entry->is_log_tree) 203834e73cc9SQu Wenruo ); 203934e73cc9SQu Wenruo 204034e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock, 204134e73cc9SQu Wenruo TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 204234e73cc9SQu Wenruo 204334e73cc9SQu Wenruo TP_ARGS(eb, start_ns) 204434e73cc9SQu Wenruo ); 204534e73cc9SQu Wenruo 204634e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock, 204734e73cc9SQu Wenruo TP_PROTO(const struct extent_buffer *eb, u64 start_ns), 204834e73cc9SQu Wenruo 204934e73cc9SQu Wenruo TP_ARGS(eb, start_ns) 205034e73cc9SQu Wenruo ); 205134e73cc9SQu Wenruo 205231aab402SQu Wenruo DECLARE_EVENT_CLASS(btrfs_locking_events, 205331aab402SQu Wenruo TP_PROTO(const struct extent_buffer *eb), 205431aab402SQu Wenruo 205531aab402SQu Wenruo TP_ARGS(eb), 205631aab402SQu Wenruo 205731aab402SQu Wenruo TP_STRUCT__entry_btrfs( 205831aab402SQu Wenruo __field( u64, block ) 205931aab402SQu Wenruo __field( u64, generation ) 206031aab402SQu Wenruo __field( u64, owner ) 206131aab402SQu Wenruo __field( int, is_log_tree ) 206231aab402SQu Wenruo ), 206331aab402SQu Wenruo 206431aab402SQu Wenruo TP_fast_assign_btrfs(eb->fs_info, 206531aab402SQu Wenruo __entry->block = eb->start; 206631aab402SQu Wenruo __entry->generation = btrfs_header_generation(eb); 206731aab402SQu Wenruo __entry->owner = btrfs_header_owner(eb); 206831aab402SQu Wenruo __entry->is_log_tree = (eb->log_index >= 0); 206931aab402SQu Wenruo ), 207031aab402SQu Wenruo 207131aab402SQu Wenruo TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d", 207231aab402SQu Wenruo __entry->block, __entry->generation, 207331aab402SQu Wenruo __entry->owner, __entry->is_log_tree) 207431aab402SQu Wenruo ); 207531aab402SQu Wenruo 207631aab402SQu Wenruo #define DEFINE_BTRFS_LOCK_EVENT(name) \ 207731aab402SQu Wenruo DEFINE_EVENT(btrfs_locking_events, name, \ 207831aab402SQu Wenruo TP_PROTO(const struct extent_buffer *eb), \ 207931aab402SQu Wenruo \ 208031aab402SQu Wenruo TP_ARGS(eb) \ 208131aab402SQu Wenruo ) 208231aab402SQu Wenruo 208331aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock); 208431aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock); 208531aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking); 208631aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read); 208731aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write); 208831aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock); 208931aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock); 209031aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic); 209131aab402SQu Wenruo 2092480b9b4dSQu Wenruo DECLARE_EVENT_CLASS(btrfs__space_info_update, 2093480b9b4dSQu Wenruo 20941d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_fs_info *fs_info, 20951d2e7c7cSDavid Sterba const struct btrfs_space_info *sinfo, u64 old, s64 diff), 2096480b9b4dSQu Wenruo 2097480b9b4dSQu Wenruo TP_ARGS(fs_info, sinfo, old, diff), 2098480b9b4dSQu Wenruo 2099480b9b4dSQu Wenruo TP_STRUCT__entry_btrfs( 2100480b9b4dSQu Wenruo __field( u64, type ) 2101480b9b4dSQu Wenruo __field( u64, old ) 2102480b9b4dSQu Wenruo __field( s64, diff ) 2103480b9b4dSQu Wenruo ), 2104480b9b4dSQu Wenruo 2105480b9b4dSQu Wenruo TP_fast_assign_btrfs(fs_info, 2106480b9b4dSQu Wenruo __entry->type = sinfo->flags; 2107480b9b4dSQu Wenruo __entry->old = old; 2108480b9b4dSQu Wenruo __entry->diff = diff; 2109480b9b4dSQu Wenruo ), 2110480b9b4dSQu Wenruo TP_printk_btrfs("type=%s old=%llu diff=%lld", 2111480b9b4dSQu Wenruo __print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS), 2112480b9b4dSQu Wenruo __entry->old, __entry->diff) 2113480b9b4dSQu Wenruo ); 2114480b9b4dSQu Wenruo 2115480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use, 2116480b9b4dSQu Wenruo 21171d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_fs_info *fs_info, 21181d2e7c7cSDavid Sterba const struct btrfs_space_info *sinfo, u64 old, s64 diff), 2119480b9b4dSQu Wenruo 2120480b9b4dSQu Wenruo TP_ARGS(fs_info, sinfo, old, diff) 2121480b9b4dSQu Wenruo ); 2122480b9b4dSQu Wenruo 2123480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned, 2124480b9b4dSQu Wenruo 21251d2e7c7cSDavid Sterba TP_PROTO(const struct btrfs_fs_info *fs_info, 21261d2e7c7cSDavid Sterba const struct btrfs_space_info *sinfo, u64 old, s64 diff), 2127480b9b4dSQu Wenruo 2128480b9b4dSQu Wenruo TP_ARGS(fs_info, sinfo, old, diff) 2129480b9b4dSQu Wenruo ); 2130480b9b4dSQu Wenruo 21311abe9b8aSliubo #endif /* _TRACE_BTRFS_H */ 21321abe9b8aSliubo 21331abe9b8aSliubo /* This part must be outside protection */ 21341abe9b8aSliubo #include <trace/define_trace.h> 2135