1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21abe9b8aSliubo #undef TRACE_SYSTEM 31abe9b8aSliubo #define TRACE_SYSTEM btrfs 41abe9b8aSliubo 51abe9b8aSliubo #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ) 61abe9b8aSliubo #define _TRACE_BTRFS_H 71abe9b8aSliubo 81abe9b8aSliubo #include <linux/writeback.h> 91abe9b8aSliubo #include <linux/tracepoint.h> 10420adbe9SVlastimil Babka #include <trace/events/mmflags.h> 111abe9b8aSliubo 121abe9b8aSliubo struct btrfs_root; 131abe9b8aSliubo struct btrfs_fs_info; 141abe9b8aSliubo struct btrfs_inode; 151abe9b8aSliubo struct extent_map; 1609ed2f16SLiu Bo struct btrfs_file_extent_item; 171abe9b8aSliubo struct btrfs_ordered_extent; 181abe9b8aSliubo struct btrfs_delayed_ref_node; 191abe9b8aSliubo struct btrfs_delayed_tree_ref; 201abe9b8aSliubo struct btrfs_delayed_data_ref; 211abe9b8aSliubo struct btrfs_delayed_ref_head; 223f7de037SJosef Bacik struct btrfs_block_group_cache; 233f7de037SJosef Bacik struct btrfs_free_cluster; 241abe9b8aSliubo struct map_lookup; 251abe9b8aSliubo struct extent_buffer; 2652483bc2SQu Wenruo struct btrfs_work; 27c3a46891SQu Wenruo struct __btrfs_workqueue; 280f5dcf8dSMark Fasheh struct btrfs_qgroup_extent_record; 293159fe7bSQu Wenruo struct btrfs_qgroup; 3000142756SJeff Mahoney struct prelim_ref; 311abe9b8aSliubo 321abe9b8aSliubo #define show_ref_type(type) \ 331abe9b8aSliubo __print_symbolic(type, \ 341abe9b8aSliubo { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ 351abe9b8aSliubo { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ 361abe9b8aSliubo { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \ 371abe9b8aSliubo { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ 381abe9b8aSliubo { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) 391abe9b8aSliubo 401abe9b8aSliubo #define __show_root_type(obj) \ 417f34b746Sliubo __print_symbolic_u64(obj, \ 421abe9b8aSliubo { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ 431abe9b8aSliubo { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ 441abe9b8aSliubo { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ 451abe9b8aSliubo { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ 461abe9b8aSliubo { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ 471abe9b8aSliubo { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ 481abe9b8aSliubo { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ 491abe9b8aSliubo { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ 50e112e2b4SLiu Bo { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \ 511abe9b8aSliubo { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ 52208acb8cSOmar Sandoval { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \ 53208acb8cSOmar Sandoval { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \ 541abe9b8aSliubo { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) 551abe9b8aSliubo 561abe9b8aSliubo #define show_root_type(obj) \ 571abe9b8aSliubo obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ 58fb57dc81SLiu Bo (obj >= BTRFS_ROOT_TREE_OBJECTID && \ 59e112e2b4SLiu Bo obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-" 601abe9b8aSliubo 6109ed2f16SLiu Bo #define show_fi_type(type) \ 6209ed2f16SLiu Bo __print_symbolic(type, \ 6309ed2f16SLiu Bo { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \ 6409ed2f16SLiu Bo { BTRFS_FILE_EXTENT_REG, "REG" }, \ 6509ed2f16SLiu Bo { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"}) 6609ed2f16SLiu Bo 673f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS \ 683f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \ 693f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 703f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 713f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \ 723f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ 733f7de037SJosef Bacik { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ 74e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 75e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ 76e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} 773f7de037SJosef Bacik 78b94417eaSAnand Jain #define BTRFS_FSID_SIZE 16 79b94417eaSAnand Jain #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE) 80bc074524SJeff Mahoney 81bc074524SJeff Mahoney #define TP_fast_assign_fsid(fs_info) \ 82b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE) 83bc074524SJeff Mahoney 84bc074524SJeff Mahoney #define TP_STRUCT__entry_btrfs(args...) \ 85bc074524SJeff Mahoney TP_STRUCT__entry( \ 86bc074524SJeff Mahoney TP_STRUCT__entry_fsid \ 87bc074524SJeff Mahoney args) 88bc074524SJeff Mahoney #define TP_fast_assign_btrfs(fs_info, args...) \ 89bc074524SJeff Mahoney TP_fast_assign( \ 90bc074524SJeff Mahoney TP_fast_assign_fsid(fs_info); \ 91bc074524SJeff Mahoney args) 92bc074524SJeff Mahoney #define TP_printk_btrfs(fmt, args...) \ 93bc074524SJeff Mahoney TP_printk("%pU: " fmt, __entry->fsid, args) 948c2a3ca2SJosef Bacik 951abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit, 961abe9b8aSliubo 979a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root), 981abe9b8aSliubo 991abe9b8aSliubo TP_ARGS(root), 1001abe9b8aSliubo 101bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 1021abe9b8aSliubo __field( u64, generation ) 1031abe9b8aSliubo __field( u64, root_objectid ) 1041abe9b8aSliubo ), 1051abe9b8aSliubo 106bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 1071abe9b8aSliubo __entry->generation = root->fs_info->generation; 1081abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 1091abe9b8aSliubo ), 1101abe9b8aSliubo 111bc074524SJeff Mahoney TP_printk_btrfs("root = %llu(%s), gen = %llu", 1121abe9b8aSliubo show_root_type(__entry->root_objectid), 1131abe9b8aSliubo (unsigned long long)__entry->generation) 1141abe9b8aSliubo ); 1151abe9b8aSliubo 1161abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode, 1171abe9b8aSliubo 1189a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1191abe9b8aSliubo 1201abe9b8aSliubo TP_ARGS(inode), 1211abe9b8aSliubo 122bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 1231abe9b8aSliubo __field( ino_t, ino ) 1241abe9b8aSliubo __field( blkcnt_t, blocks ) 1251abe9b8aSliubo __field( u64, disk_i_size ) 1261abe9b8aSliubo __field( u64, generation ) 1271abe9b8aSliubo __field( u64, last_trans ) 1281abe9b8aSliubo __field( u64, logged_trans ) 1291abe9b8aSliubo __field( u64, root_objectid ) 1301abe9b8aSliubo ), 1311abe9b8aSliubo 132bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 1331abe9b8aSliubo __entry->ino = inode->i_ino; 1341abe9b8aSliubo __entry->blocks = inode->i_blocks; 1351abe9b8aSliubo __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; 1361abe9b8aSliubo __entry->generation = BTRFS_I(inode)->generation; 1371abe9b8aSliubo __entry->last_trans = BTRFS_I(inode)->last_trans; 1381abe9b8aSliubo __entry->logged_trans = BTRFS_I(inode)->logged_trans; 1391abe9b8aSliubo __entry->root_objectid = 1401abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 1411abe9b8aSliubo ), 1421abe9b8aSliubo 143562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu " 144562a7a07SDavid Sterba "disk_i_size=%llu last_trans=%llu logged_trans=%llu", 1451abe9b8aSliubo show_root_type(__entry->root_objectid), 1461abe9b8aSliubo (unsigned long long)__entry->generation, 1471abe9b8aSliubo (unsigned long)__entry->ino, 1481abe9b8aSliubo (unsigned long long)__entry->blocks, 1491abe9b8aSliubo (unsigned long long)__entry->disk_i_size, 1501abe9b8aSliubo (unsigned long long)__entry->last_trans, 1511abe9b8aSliubo (unsigned long long)__entry->logged_trans) 1521abe9b8aSliubo ); 1531abe9b8aSliubo 1541abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new, 1551abe9b8aSliubo 1569a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1571abe9b8aSliubo 1581abe9b8aSliubo TP_ARGS(inode) 1591abe9b8aSliubo ); 1601abe9b8aSliubo 1611abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request, 1621abe9b8aSliubo 1639a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1641abe9b8aSliubo 1651abe9b8aSliubo TP_ARGS(inode) 1661abe9b8aSliubo ); 1671abe9b8aSliubo 1681abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, 1691abe9b8aSliubo 1709a35b637SJeff Mahoney TP_PROTO(const struct inode *inode), 1711abe9b8aSliubo 1721abe9b8aSliubo TP_ARGS(inode) 1731abe9b8aSliubo ); 1741abe9b8aSliubo 1751abe9b8aSliubo #define __show_map_type(type) \ 1767f34b746Sliubo __print_symbolic_u64(type, \ 1771abe9b8aSliubo { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ 1781abe9b8aSliubo { EXTENT_MAP_HOLE, "HOLE" }, \ 1791abe9b8aSliubo { EXTENT_MAP_INLINE, "INLINE" }, \ 1801abe9b8aSliubo { EXTENT_MAP_DELALLOC, "DELALLOC" }) 1811abe9b8aSliubo 1821abe9b8aSliubo #define show_map_type(type) \ 1831abe9b8aSliubo type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) 1841abe9b8aSliubo 1851abe9b8aSliubo #define show_map_flags(flag) \ 1861abe9b8aSliubo __print_flags(flag, "|", \ 187254a2d14SLiu Bo { (1 << EXTENT_FLAG_PINNED), "PINNED" },\ 188254a2d14SLiu Bo { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\ 189254a2d14SLiu Bo { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\ 190254a2d14SLiu Bo { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\ 191254a2d14SLiu Bo { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\ 192254a2d14SLiu Bo { (1 << EXTENT_FLAG_FILLING), "FILLING" },\ 193254a2d14SLiu Bo { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" }) 1941abe9b8aSliubo 1954cd8587cSSteven Rostedt TRACE_EVENT_CONDITION(btrfs_get_extent, 1961abe9b8aSliubo 1979a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode, 1989a35b637SJeff Mahoney const struct extent_map *map), 1991abe9b8aSliubo 20092a1bf76SLiu Bo TP_ARGS(root, inode, map), 2011abe9b8aSliubo 2024cd8587cSSteven Rostedt TP_CONDITION(map), 2034cd8587cSSteven Rostedt 204bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 2051abe9b8aSliubo __field( u64, root_objectid ) 20692a1bf76SLiu Bo __field( u64, ino ) 2071abe9b8aSliubo __field( u64, start ) 2081abe9b8aSliubo __field( u64, len ) 2091abe9b8aSliubo __field( u64, orig_start ) 2101abe9b8aSliubo __field( u64, block_start ) 2111abe9b8aSliubo __field( u64, block_len ) 2121abe9b8aSliubo __field( unsigned long, flags ) 2131abe9b8aSliubo __field( int, refs ) 2141abe9b8aSliubo __field( unsigned int, compress_type ) 2151abe9b8aSliubo ), 2161abe9b8aSliubo 217bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 2181abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 21992a1bf76SLiu Bo __entry->ino = btrfs_ino(inode); 2201abe9b8aSliubo __entry->start = map->start; 2211abe9b8aSliubo __entry->len = map->len; 2221abe9b8aSliubo __entry->orig_start = map->orig_start; 2231abe9b8aSliubo __entry->block_start = map->block_start; 2241abe9b8aSliubo __entry->block_len = map->block_len; 2251abe9b8aSliubo __entry->flags = map->flags; 226490b54d6SElena Reshetova __entry->refs = refcount_read(&map->refs); 2271abe9b8aSliubo __entry->compress_type = map->compress_type; 2281abe9b8aSliubo ), 2291abe9b8aSliubo 230562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu " 231562a7a07SDavid Sterba "orig_start=%llu block_start=%llu(%s) " 232562a7a07SDavid Sterba "block_len=%llu flags=%s refs=%u " 2331abe9b8aSliubo "compress_type=%u", 2341abe9b8aSliubo show_root_type(__entry->root_objectid), 23592a1bf76SLiu Bo (unsigned long long)__entry->ino, 2361abe9b8aSliubo (unsigned long long)__entry->start, 2371abe9b8aSliubo (unsigned long long)__entry->len, 2381abe9b8aSliubo (unsigned long long)__entry->orig_start, 2391abe9b8aSliubo show_map_type(__entry->block_start), 2401abe9b8aSliubo (unsigned long long)__entry->block_len, 2411abe9b8aSliubo show_map_flags(__entry->flags), 2421abe9b8aSliubo __entry->refs, __entry->compress_type) 2431abe9b8aSliubo ); 2441abe9b8aSliubo 24509ed2f16SLiu Bo /* file extent item */ 24609ed2f16SLiu Bo DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular, 24709ed2f16SLiu Bo 24809ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 24909ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 25009ed2f16SLiu Bo 25109ed2f16SLiu Bo TP_ARGS(bi, l, fi, start), 25209ed2f16SLiu Bo 25309ed2f16SLiu Bo TP_STRUCT__entry_btrfs( 25409ed2f16SLiu Bo __field( u64, root_obj ) 25509ed2f16SLiu Bo __field( u64, ino ) 25609ed2f16SLiu Bo __field( loff_t, isize ) 25709ed2f16SLiu Bo __field( u64, disk_isize ) 25809ed2f16SLiu Bo __field( u64, num_bytes ) 25909ed2f16SLiu Bo __field( u64, ram_bytes ) 26009ed2f16SLiu Bo __field( u64, disk_bytenr ) 26109ed2f16SLiu Bo __field( u64, disk_num_bytes ) 26209ed2f16SLiu Bo __field( u64, extent_offset ) 26309ed2f16SLiu Bo __field( u8, extent_type ) 26409ed2f16SLiu Bo __field( u8, compression ) 26509ed2f16SLiu Bo __field( u64, extent_start ) 26609ed2f16SLiu Bo __field( u64, extent_end ) 26709ed2f16SLiu Bo ), 26809ed2f16SLiu Bo 26909ed2f16SLiu Bo TP_fast_assign_btrfs(bi->root->fs_info, 27009ed2f16SLiu Bo __entry->root_obj = bi->root->objectid; 27109ed2f16SLiu Bo __entry->ino = btrfs_ino(bi); 27209ed2f16SLiu Bo __entry->isize = bi->vfs_inode.i_size; 27309ed2f16SLiu Bo __entry->disk_isize = bi->disk_i_size; 27409ed2f16SLiu Bo __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi); 27509ed2f16SLiu Bo __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi); 27609ed2f16SLiu Bo __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi); 27709ed2f16SLiu Bo __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi); 27809ed2f16SLiu Bo __entry->extent_offset = btrfs_file_extent_offset(l, fi); 27909ed2f16SLiu Bo __entry->extent_type = btrfs_file_extent_type(l, fi); 28009ed2f16SLiu Bo __entry->compression = btrfs_file_extent_compression(l, fi); 28109ed2f16SLiu Bo __entry->extent_start = start; 28209ed2f16SLiu Bo __entry->extent_end = (start + __entry->num_bytes); 28309ed2f16SLiu Bo ), 28409ed2f16SLiu Bo 28509ed2f16SLiu Bo TP_printk_btrfs( 28609ed2f16SLiu Bo "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 28709ed2f16SLiu Bo "file extent range=[%llu %llu] " 28809ed2f16SLiu Bo "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu " 28909ed2f16SLiu Bo "disk_num_bytes=%llu extent_offset=%llu type=%s " 29009ed2f16SLiu Bo "compression=%u", 29109ed2f16SLiu Bo show_root_type(__entry->root_obj), __entry->ino, 29209ed2f16SLiu Bo __entry->isize, 29309ed2f16SLiu Bo __entry->disk_isize, __entry->extent_start, 29409ed2f16SLiu Bo __entry->extent_end, __entry->num_bytes, __entry->ram_bytes, 29509ed2f16SLiu Bo __entry->disk_bytenr, __entry->disk_num_bytes, 29609ed2f16SLiu Bo __entry->extent_offset, show_fi_type(__entry->extent_type), 29709ed2f16SLiu Bo __entry->compression) 29809ed2f16SLiu Bo ); 29909ed2f16SLiu Bo 30009ed2f16SLiu Bo DECLARE_EVENT_CLASS( 30109ed2f16SLiu Bo btrfs__file_extent_item_inline, 30209ed2f16SLiu Bo 30309ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 30409ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 30509ed2f16SLiu Bo 30609ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start), 30709ed2f16SLiu Bo 30809ed2f16SLiu Bo TP_STRUCT__entry_btrfs( 30909ed2f16SLiu Bo __field( u64, root_obj ) 31009ed2f16SLiu Bo __field( u64, ino ) 31109ed2f16SLiu Bo __field( loff_t, isize ) 31209ed2f16SLiu Bo __field( u64, disk_isize ) 31309ed2f16SLiu Bo __field( u8, extent_type ) 31409ed2f16SLiu Bo __field( u8, compression ) 31509ed2f16SLiu Bo __field( u64, extent_start ) 31609ed2f16SLiu Bo __field( u64, extent_end ) 31709ed2f16SLiu Bo ), 31809ed2f16SLiu Bo 31909ed2f16SLiu Bo TP_fast_assign_btrfs( 32009ed2f16SLiu Bo bi->root->fs_info, 32109ed2f16SLiu Bo __entry->root_obj = bi->root->objectid; 32209ed2f16SLiu Bo __entry->ino = btrfs_ino(bi); 32309ed2f16SLiu Bo __entry->isize = bi->vfs_inode.i_size; 32409ed2f16SLiu Bo __entry->disk_isize = bi->disk_i_size; 32509ed2f16SLiu Bo __entry->extent_type = btrfs_file_extent_type(l, fi); 32609ed2f16SLiu Bo __entry->compression = btrfs_file_extent_compression(l, fi); 32709ed2f16SLiu Bo __entry->extent_start = start; 32809ed2f16SLiu Bo __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi)); 32909ed2f16SLiu Bo ), 33009ed2f16SLiu Bo 33109ed2f16SLiu Bo TP_printk_btrfs( 33209ed2f16SLiu Bo "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu " 33309ed2f16SLiu Bo "file extent range=[%llu %llu] " 33409ed2f16SLiu Bo "extent_type=%s compression=%u", 33509ed2f16SLiu Bo show_root_type(__entry->root_obj), __entry->ino, __entry->isize, 33609ed2f16SLiu Bo __entry->disk_isize, __entry->extent_start, 33709ed2f16SLiu Bo __entry->extent_end, show_fi_type(__entry->extent_type), 33809ed2f16SLiu Bo __entry->compression) 33909ed2f16SLiu Bo ); 34009ed2f16SLiu Bo 34109ed2f16SLiu Bo DEFINE_EVENT( 34209ed2f16SLiu Bo btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular, 34309ed2f16SLiu Bo 34409ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 34509ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 34609ed2f16SLiu Bo 34709ed2f16SLiu Bo TP_ARGS(bi, l, fi, start) 34809ed2f16SLiu Bo ); 34909ed2f16SLiu Bo 35009ed2f16SLiu Bo DEFINE_EVENT( 35109ed2f16SLiu Bo btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular, 35209ed2f16SLiu Bo 35309ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 35409ed2f16SLiu Bo struct btrfs_file_extent_item *fi, u64 start), 35509ed2f16SLiu Bo 35609ed2f16SLiu Bo TP_ARGS(bi, l, fi, start) 35709ed2f16SLiu Bo ); 35809ed2f16SLiu Bo 35909ed2f16SLiu Bo DEFINE_EVENT( 36009ed2f16SLiu Bo btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline, 36109ed2f16SLiu Bo 36209ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 36309ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 36409ed2f16SLiu Bo 36509ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start) 36609ed2f16SLiu Bo ); 36709ed2f16SLiu Bo 36809ed2f16SLiu Bo DEFINE_EVENT( 36909ed2f16SLiu Bo btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline, 37009ed2f16SLiu Bo 37109ed2f16SLiu Bo TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l, 37209ed2f16SLiu Bo struct btrfs_file_extent_item *fi, int slot, u64 start), 37309ed2f16SLiu Bo 37409ed2f16SLiu Bo TP_ARGS(bi, l, fi, slot, start) 37509ed2f16SLiu Bo ); 37609ed2f16SLiu Bo 3771abe9b8aSliubo #define show_ordered_flags(flags) \ 3789d04a8ceSLiu Bo __print_flags(flags, "|", \ 3799d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \ 3809d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \ 3819d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \ 3829d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \ 3839d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \ 3849d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \ 3859d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \ 3869d04a8ceSLiu Bo { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \ 387792ddef0SLiu Bo { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \ 388792ddef0SLiu Bo { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" }) 389e112e2b4SLiu Bo 3901abe9b8aSliubo 3911abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent, 3921abe9b8aSliubo 3939a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 3949a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 3951abe9b8aSliubo 3961abe9b8aSliubo TP_ARGS(inode, ordered), 3971abe9b8aSliubo 398bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 3991abe9b8aSliubo __field( ino_t, ino ) 4001abe9b8aSliubo __field( u64, file_offset ) 4011abe9b8aSliubo __field( u64, start ) 4021abe9b8aSliubo __field( u64, len ) 4031abe9b8aSliubo __field( u64, disk_len ) 4041abe9b8aSliubo __field( u64, bytes_left ) 4051abe9b8aSliubo __field( unsigned long, flags ) 4061abe9b8aSliubo __field( int, compress_type ) 4071abe9b8aSliubo __field( int, refs ) 4081abe9b8aSliubo __field( u64, root_objectid ) 40978566548SLiu Bo __field( u64, truncated_len ) 4101abe9b8aSliubo ), 4111abe9b8aSliubo 412bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 4131abe9b8aSliubo __entry->ino = inode->i_ino; 4141abe9b8aSliubo __entry->file_offset = ordered->file_offset; 4151abe9b8aSliubo __entry->start = ordered->start; 4161abe9b8aSliubo __entry->len = ordered->len; 4171abe9b8aSliubo __entry->disk_len = ordered->disk_len; 4181abe9b8aSliubo __entry->bytes_left = ordered->bytes_left; 4191abe9b8aSliubo __entry->flags = ordered->flags; 4201abe9b8aSliubo __entry->compress_type = ordered->compress_type; 421e76edab7SElena Reshetova __entry->refs = refcount_read(&ordered->refs); 4221abe9b8aSliubo __entry->root_objectid = 4231abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 42478566548SLiu Bo __entry->truncated_len = ordered->truncated_len; 4251abe9b8aSliubo ), 4261abe9b8aSliubo 427562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu " 428562a7a07SDavid Sterba "start=%llu len=%llu disk_len=%llu " 429562a7a07SDavid Sterba "truncated_len=%llu " 430562a7a07SDavid Sterba "bytes_left=%llu flags=%s compress_type=%d " 4311abe9b8aSliubo "refs=%d", 4321abe9b8aSliubo show_root_type(__entry->root_objectid), 4331abe9b8aSliubo (unsigned long long)__entry->ino, 4341abe9b8aSliubo (unsigned long long)__entry->file_offset, 4351abe9b8aSliubo (unsigned long long)__entry->start, 4361abe9b8aSliubo (unsigned long long)__entry->len, 4371abe9b8aSliubo (unsigned long long)__entry->disk_len, 43878566548SLiu Bo (unsigned long long)__entry->truncated_len, 4391abe9b8aSliubo (unsigned long long)__entry->bytes_left, 4401abe9b8aSliubo show_ordered_flags(__entry->flags), 4411abe9b8aSliubo __entry->compress_type, __entry->refs) 4421abe9b8aSliubo ); 4431abe9b8aSliubo 4441abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, 4451abe9b8aSliubo 4469a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 4479a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 4481abe9b8aSliubo 4491abe9b8aSliubo TP_ARGS(inode, ordered) 4501abe9b8aSliubo ); 4511abe9b8aSliubo 4521abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, 4531abe9b8aSliubo 4549a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 4559a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 4561abe9b8aSliubo 4571abe9b8aSliubo TP_ARGS(inode, ordered) 4581abe9b8aSliubo ); 4591abe9b8aSliubo 4601abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, 4611abe9b8aSliubo 4629a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 4639a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 4641abe9b8aSliubo 4651abe9b8aSliubo TP_ARGS(inode, ordered) 4661abe9b8aSliubo ); 4671abe9b8aSliubo 4681abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, 4691abe9b8aSliubo 4709a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, 4719a35b637SJeff Mahoney const struct btrfs_ordered_extent *ordered), 4721abe9b8aSliubo 4731abe9b8aSliubo TP_ARGS(inode, ordered) 4741abe9b8aSliubo ); 4751abe9b8aSliubo 4761abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage, 4771abe9b8aSliubo 4789a35b637SJeff Mahoney TP_PROTO(const struct page *page, const struct inode *inode, 4799a35b637SJeff Mahoney const struct writeback_control *wbc), 4801abe9b8aSliubo 4811abe9b8aSliubo TP_ARGS(page, inode, wbc), 4821abe9b8aSliubo 483bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 4841abe9b8aSliubo __field( ino_t, ino ) 4851abe9b8aSliubo __field( pgoff_t, index ) 4861abe9b8aSliubo __field( long, nr_to_write ) 4871abe9b8aSliubo __field( long, pages_skipped ) 4881abe9b8aSliubo __field( loff_t, range_start ) 4891abe9b8aSliubo __field( loff_t, range_end ) 4901abe9b8aSliubo __field( char, for_kupdate ) 4911abe9b8aSliubo __field( char, for_reclaim ) 4921abe9b8aSliubo __field( char, range_cyclic ) 4931abe9b8aSliubo __field( pgoff_t, writeback_index ) 4941abe9b8aSliubo __field( u64, root_objectid ) 4951abe9b8aSliubo ), 4961abe9b8aSliubo 497bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 4981abe9b8aSliubo __entry->ino = inode->i_ino; 4991abe9b8aSliubo __entry->index = page->index; 5001abe9b8aSliubo __entry->nr_to_write = wbc->nr_to_write; 5011abe9b8aSliubo __entry->pages_skipped = wbc->pages_skipped; 5021abe9b8aSliubo __entry->range_start = wbc->range_start; 5031abe9b8aSliubo __entry->range_end = wbc->range_end; 5041abe9b8aSliubo __entry->for_kupdate = wbc->for_kupdate; 5051abe9b8aSliubo __entry->for_reclaim = wbc->for_reclaim; 5061abe9b8aSliubo __entry->range_cyclic = wbc->range_cyclic; 5071abe9b8aSliubo __entry->writeback_index = inode->i_mapping->writeback_index; 5081abe9b8aSliubo __entry->root_objectid = 5091abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 5101abe9b8aSliubo ), 5111abe9b8aSliubo 512562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu " 513562a7a07SDavid Sterba "nr_to_write=%ld pages_skipped=%ld range_start=%llu " 514562a7a07SDavid Sterba "range_end=%llu for_kupdate=%d " 515562a7a07SDavid Sterba "for_reclaim=%d range_cyclic=%d writeback_index=%lu", 5161abe9b8aSliubo show_root_type(__entry->root_objectid), 5171abe9b8aSliubo (unsigned long)__entry->ino, __entry->index, 5181abe9b8aSliubo __entry->nr_to_write, __entry->pages_skipped, 5191abe9b8aSliubo __entry->range_start, __entry->range_end, 520846d5a09SWu Fengguang __entry->for_kupdate, 5211abe9b8aSliubo __entry->for_reclaim, __entry->range_cyclic, 5221abe9b8aSliubo (unsigned long)__entry->writeback_index) 5231abe9b8aSliubo ); 5241abe9b8aSliubo 5251abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage, 5261abe9b8aSliubo 5279a35b637SJeff Mahoney TP_PROTO(const struct page *page, const struct inode *inode, 5289a35b637SJeff Mahoney const struct writeback_control *wbc), 5291abe9b8aSliubo 5301abe9b8aSliubo TP_ARGS(page, inode, wbc) 5311abe9b8aSliubo ); 5321abe9b8aSliubo 5331abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook, 5341abe9b8aSliubo 5359a35b637SJeff Mahoney TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate), 5361abe9b8aSliubo 5371abe9b8aSliubo TP_ARGS(page, start, end, uptodate), 5381abe9b8aSliubo 539bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 5401abe9b8aSliubo __field( ino_t, ino ) 5411abe9b8aSliubo __field( pgoff_t, index ) 5421abe9b8aSliubo __field( u64, start ) 5431abe9b8aSliubo __field( u64, end ) 5441abe9b8aSliubo __field( int, uptodate ) 5451abe9b8aSliubo __field( u64, root_objectid ) 5461abe9b8aSliubo ), 5471abe9b8aSliubo 548bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb), 5491abe9b8aSliubo __entry->ino = page->mapping->host->i_ino; 5501abe9b8aSliubo __entry->index = page->index; 5511abe9b8aSliubo __entry->start = start; 5521abe9b8aSliubo __entry->end = end; 5531abe9b8aSliubo __entry->uptodate = uptodate; 5541abe9b8aSliubo __entry->root_objectid = 5551abe9b8aSliubo BTRFS_I(page->mapping->host)->root->root_key.objectid; 5561abe9b8aSliubo ), 5571abe9b8aSliubo 558562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu " 559562a7a07SDavid Sterba "end=%llu uptodate=%d", 5601abe9b8aSliubo show_root_type(__entry->root_objectid), 5611abe9b8aSliubo (unsigned long)__entry->ino, (unsigned long)__entry->index, 5621abe9b8aSliubo (unsigned long long)__entry->start, 5631abe9b8aSliubo (unsigned long long)__entry->end, __entry->uptodate) 5641abe9b8aSliubo ); 5651abe9b8aSliubo 5661abe9b8aSliubo TRACE_EVENT(btrfs_sync_file, 5671abe9b8aSliubo 5689a35b637SJeff Mahoney TP_PROTO(const struct file *file, int datasync), 5691abe9b8aSliubo 5701abe9b8aSliubo TP_ARGS(file, datasync), 5711abe9b8aSliubo 572bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 5731abe9b8aSliubo __field( ino_t, ino ) 5741abe9b8aSliubo __field( ino_t, parent ) 5751abe9b8aSliubo __field( int, datasync ) 5761abe9b8aSliubo __field( u64, root_objectid ) 5771abe9b8aSliubo ), 5781abe9b8aSliubo 5791abe9b8aSliubo TP_fast_assign( 5809a35b637SJeff Mahoney const struct dentry *dentry = file->f_path.dentry; 5819a35b637SJeff Mahoney const struct inode *inode = d_inode(dentry); 5821abe9b8aSliubo 583bc074524SJeff Mahoney TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb)); 5841abe9b8aSliubo __entry->ino = inode->i_ino; 5852b0143b5SDavid Howells __entry->parent = d_inode(dentry->d_parent)->i_ino; 5861abe9b8aSliubo __entry->datasync = datasync; 5871abe9b8aSliubo __entry->root_objectid = 5881abe9b8aSliubo BTRFS_I(inode)->root->root_key.objectid; 5891abe9b8aSliubo ), 5901abe9b8aSliubo 591562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d", 5921abe9b8aSliubo show_root_type(__entry->root_objectid), 5931abe9b8aSliubo (unsigned long)__entry->ino, (unsigned long)__entry->parent, 5941abe9b8aSliubo __entry->datasync) 5951abe9b8aSliubo ); 5961abe9b8aSliubo 5971abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs, 5981abe9b8aSliubo 5999a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, int wait), 6001abe9b8aSliubo 601bc074524SJeff Mahoney TP_ARGS(fs_info, wait), 6021abe9b8aSliubo 603bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 6041abe9b8aSliubo __field( int, wait ) 6051abe9b8aSliubo ), 6061abe9b8aSliubo 607bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 6081abe9b8aSliubo __entry->wait = wait; 6091abe9b8aSliubo ), 6101abe9b8aSliubo 611bc074524SJeff Mahoney TP_printk_btrfs("wait = %d", __entry->wait) 6121abe9b8aSliubo ); 6131abe9b8aSliubo 614c83f8effSJosef Bacik TRACE_EVENT(btrfs_add_block_group, 615c83f8effSJosef Bacik 6169a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 6179a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, int create), 618c83f8effSJosef Bacik 619c83f8effSJosef Bacik TP_ARGS(fs_info, block_group, create), 620c83f8effSJosef Bacik 621c83f8effSJosef Bacik TP_STRUCT__entry( 622b94417eaSAnand Jain __array( u8, fsid, BTRFS_FSID_SIZE ) 623c83f8effSJosef Bacik __field( u64, offset ) 624c83f8effSJosef Bacik __field( u64, size ) 625c83f8effSJosef Bacik __field( u64, flags ) 626c83f8effSJosef Bacik __field( u64, bytes_used ) 627c83f8effSJosef Bacik __field( u64, bytes_super ) 628c83f8effSJosef Bacik __field( int, create ) 629c83f8effSJosef Bacik ), 630c83f8effSJosef Bacik 631c83f8effSJosef Bacik TP_fast_assign( 632b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE); 633c83f8effSJosef Bacik __entry->offset = block_group->key.objectid; 634c83f8effSJosef Bacik __entry->size = block_group->key.offset; 635c83f8effSJosef Bacik __entry->flags = block_group->flags; 636c83f8effSJosef Bacik __entry->bytes_used = 637c83f8effSJosef Bacik btrfs_block_group_used(&block_group->item); 638c83f8effSJosef Bacik __entry->bytes_super = block_group->bytes_super; 639c83f8effSJosef Bacik __entry->create = create; 640c83f8effSJosef Bacik ), 641c83f8effSJosef Bacik 642562a7a07SDavid Sterba TP_printk("%pU: block_group offset=%llu size=%llu " 643562a7a07SDavid Sterba "flags=%llu(%s) bytes_used=%llu bytes_super=%llu " 644c83f8effSJosef Bacik "create=%d", __entry->fsid, 645c83f8effSJosef Bacik (unsigned long long)__entry->offset, 646c83f8effSJosef Bacik (unsigned long long)__entry->size, 647c83f8effSJosef Bacik (unsigned long long)__entry->flags, 648c83f8effSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 649c83f8effSJosef Bacik BTRFS_GROUP_FLAGS), 650c83f8effSJosef Bacik (unsigned long long)__entry->bytes_used, 651c83f8effSJosef Bacik (unsigned long long)__entry->bytes_super, __entry->create) 652c83f8effSJosef Bacik ); 653c83f8effSJosef Bacik 6541abe9b8aSliubo #define show_ref_action(action) \ 6551abe9b8aSliubo __print_symbolic(action, \ 6561abe9b8aSliubo { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ 6571abe9b8aSliubo { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ 6581abe9b8aSliubo { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ 6591abe9b8aSliubo { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) 6601abe9b8aSliubo 6611abe9b8aSliubo 662599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref, 6631abe9b8aSliubo 6649a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 6659a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 6669a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 6671abe9b8aSliubo int action), 6681abe9b8aSliubo 669bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 6701abe9b8aSliubo 671bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 6721abe9b8aSliubo __field( u64, bytenr ) 6731abe9b8aSliubo __field( u64, num_bytes ) 6741abe9b8aSliubo __field( int, action ) 6751abe9b8aSliubo __field( u64, parent ) 6761abe9b8aSliubo __field( u64, ref_root ) 6771abe9b8aSliubo __field( int, level ) 6781abe9b8aSliubo __field( int, type ) 679dea7d76eSLiu Bo __field( u64, seq ) 6801abe9b8aSliubo ), 6811abe9b8aSliubo 682bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 6831abe9b8aSliubo __entry->bytenr = ref->bytenr; 6841abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 6851abe9b8aSliubo __entry->action = action; 6861abe9b8aSliubo __entry->parent = full_ref->parent; 6871abe9b8aSliubo __entry->ref_root = full_ref->root; 6881abe9b8aSliubo __entry->level = full_ref->level; 6891abe9b8aSliubo __entry->type = ref->type; 690dea7d76eSLiu Bo __entry->seq = ref->seq; 6911abe9b8aSliubo ), 6921abe9b8aSliubo 693562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 694562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) level=%d " 695562a7a07SDavid Sterba "type=%s seq=%llu", 6961abe9b8aSliubo (unsigned long long)__entry->bytenr, 6971abe9b8aSliubo (unsigned long long)__entry->num_bytes, 6981abe9b8aSliubo show_ref_action(__entry->action), 6991abe9b8aSliubo show_root_type(__entry->parent), 7001abe9b8aSliubo show_root_type(__entry->ref_root), 701dea7d76eSLiu Bo __entry->level, show_ref_type(__entry->type), 702dea7d76eSLiu Bo (unsigned long long)__entry->seq) 7031abe9b8aSliubo ); 7041abe9b8aSliubo 705599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref, 706599c75ecSLiu Bo 7079a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7089a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7099a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 710599c75ecSLiu Bo int action), 711599c75ecSLiu Bo 712bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 713599c75ecSLiu Bo ); 714599c75ecSLiu Bo 715599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref, 716599c75ecSLiu Bo 7179a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7189a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7199a35b637SJeff Mahoney const struct btrfs_delayed_tree_ref *full_ref, 720599c75ecSLiu Bo int action), 721599c75ecSLiu Bo 722bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 723599c75ecSLiu Bo ); 724599c75ecSLiu Bo 725599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref, 7261abe9b8aSliubo 7279a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7289a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7299a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 7301abe9b8aSliubo int action), 7311abe9b8aSliubo 732bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action), 7331abe9b8aSliubo 734bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 7351abe9b8aSliubo __field( u64, bytenr ) 7361abe9b8aSliubo __field( u64, num_bytes ) 7371abe9b8aSliubo __field( int, action ) 7381abe9b8aSliubo __field( u64, parent ) 7391abe9b8aSliubo __field( u64, ref_root ) 7401abe9b8aSliubo __field( u64, owner ) 7411abe9b8aSliubo __field( u64, offset ) 7421abe9b8aSliubo __field( int, type ) 743dea7d76eSLiu Bo __field( u64, seq ) 7441abe9b8aSliubo ), 7451abe9b8aSliubo 746bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 7471abe9b8aSliubo __entry->bytenr = ref->bytenr; 7481abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 7491abe9b8aSliubo __entry->action = action; 7501abe9b8aSliubo __entry->parent = full_ref->parent; 7511abe9b8aSliubo __entry->ref_root = full_ref->root; 7521abe9b8aSliubo __entry->owner = full_ref->objectid; 7531abe9b8aSliubo __entry->offset = full_ref->offset; 7541abe9b8aSliubo __entry->type = ref->type; 755dea7d76eSLiu Bo __entry->seq = ref->seq; 7561abe9b8aSliubo ), 7571abe9b8aSliubo 758562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s " 759562a7a07SDavid Sterba "parent=%llu(%s) ref_root=%llu(%s) owner=%llu " 760562a7a07SDavid Sterba "offset=%llu type=%s seq=%llu", 7611abe9b8aSliubo (unsigned long long)__entry->bytenr, 7621abe9b8aSliubo (unsigned long long)__entry->num_bytes, 7631abe9b8aSliubo show_ref_action(__entry->action), 7641abe9b8aSliubo show_root_type(__entry->parent), 7651abe9b8aSliubo show_root_type(__entry->ref_root), 7661abe9b8aSliubo (unsigned long long)__entry->owner, 7671abe9b8aSliubo (unsigned long long)__entry->offset, 768dea7d76eSLiu Bo show_ref_type(__entry->type), 769dea7d76eSLiu Bo (unsigned long long)__entry->seq) 7701abe9b8aSliubo ); 7711abe9b8aSliubo 772599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref, 773599c75ecSLiu Bo 7749a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7759a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7769a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 777599c75ecSLiu Bo int action), 778599c75ecSLiu Bo 779bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 780599c75ecSLiu Bo ); 781599c75ecSLiu Bo 782599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref, 783599c75ecSLiu Bo 7849a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7859a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7869a35b637SJeff Mahoney const struct btrfs_delayed_data_ref *full_ref, 787599c75ecSLiu Bo int action), 788599c75ecSLiu Bo 789bc074524SJeff Mahoney TP_ARGS(fs_info, ref, full_ref, action) 790599c75ecSLiu Bo ); 791599c75ecSLiu Bo 792599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head, 7931abe9b8aSliubo 7949a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 7959a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 7969a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 7971abe9b8aSliubo int action), 7981abe9b8aSliubo 799bc074524SJeff Mahoney TP_ARGS(fs_info, ref, head_ref, action), 8001abe9b8aSliubo 801bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 8021abe9b8aSliubo __field( u64, bytenr ) 8031abe9b8aSliubo __field( u64, num_bytes ) 8041abe9b8aSliubo __field( int, action ) 8051abe9b8aSliubo __field( int, is_data ) 8061abe9b8aSliubo ), 8071abe9b8aSliubo 808bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 8091abe9b8aSliubo __entry->bytenr = ref->bytenr; 8101abe9b8aSliubo __entry->num_bytes = ref->num_bytes; 8111abe9b8aSliubo __entry->action = action; 8121abe9b8aSliubo __entry->is_data = head_ref->is_data; 8131abe9b8aSliubo ), 8141abe9b8aSliubo 815562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d", 8161abe9b8aSliubo (unsigned long long)__entry->bytenr, 8171abe9b8aSliubo (unsigned long long)__entry->num_bytes, 8181abe9b8aSliubo show_ref_action(__entry->action), 8191abe9b8aSliubo __entry->is_data) 8201abe9b8aSliubo ); 8211abe9b8aSliubo 822599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head, 823599c75ecSLiu Bo 8249a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8259a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8269a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 827599c75ecSLiu Bo int action), 828599c75ecSLiu Bo 829bc074524SJeff Mahoney TP_ARGS(fs_info, ref, head_ref, action) 830599c75ecSLiu Bo ); 831599c75ecSLiu Bo 832599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, 833599c75ecSLiu Bo 8349a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8359a35b637SJeff Mahoney const struct btrfs_delayed_ref_node *ref, 8369a35b637SJeff Mahoney const struct btrfs_delayed_ref_head *head_ref, 837599c75ecSLiu Bo int action), 838599c75ecSLiu Bo 839bc074524SJeff Mahoney TP_ARGS(fs_info, ref, head_ref, action) 840599c75ecSLiu Bo ); 841599c75ecSLiu Bo 8421abe9b8aSliubo #define show_chunk_type(type) \ 8431abe9b8aSliubo __print_flags(type, "|", \ 8441abe9b8aSliubo { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ 8451abe9b8aSliubo { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ 8461abe9b8aSliubo { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ 8471abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ 8481abe9b8aSliubo { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ 8491abe9b8aSliubo { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ 850e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ 851e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ 852e112e2b4SLiu Bo { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) 8531abe9b8aSliubo 8541abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk, 8551abe9b8aSliubo 8569a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8579a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 8581abe9b8aSliubo 8596bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size), 8601abe9b8aSliubo 861bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 8621abe9b8aSliubo __field( int, num_stripes ) 8631abe9b8aSliubo __field( u64, type ) 8641abe9b8aSliubo __field( int, sub_stripes ) 8651abe9b8aSliubo __field( u64, offset ) 8661abe9b8aSliubo __field( u64, size ) 8671abe9b8aSliubo __field( u64, root_objectid ) 8681abe9b8aSliubo ), 8691abe9b8aSliubo 8706bccf3abSJeff Mahoney TP_fast_assign_btrfs(fs_info, 8711abe9b8aSliubo __entry->num_stripes = map->num_stripes; 8721abe9b8aSliubo __entry->type = map->type; 8731abe9b8aSliubo __entry->sub_stripes = map->sub_stripes; 8741abe9b8aSliubo __entry->offset = offset; 8751abe9b8aSliubo __entry->size = size; 8766bccf3abSJeff Mahoney __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 8771abe9b8aSliubo ), 8781abe9b8aSliubo 879562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu " 880562a7a07SDavid Sterba "num_stripes=%d sub_stripes=%d type=%s", 8811abe9b8aSliubo show_root_type(__entry->root_objectid), 8821abe9b8aSliubo (unsigned long long)__entry->offset, 8831abe9b8aSliubo (unsigned long long)__entry->size, 8841abe9b8aSliubo __entry->num_stripes, __entry->sub_stripes, 8851abe9b8aSliubo show_chunk_type(__entry->type)) 8861abe9b8aSliubo ); 8871abe9b8aSliubo 8881abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, 8891abe9b8aSliubo 8909a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8919a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 8921abe9b8aSliubo 8936bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 8941abe9b8aSliubo ); 8951abe9b8aSliubo 8961abe9b8aSliubo DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, 8971abe9b8aSliubo 8989a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 8999a35b637SJeff Mahoney const struct map_lookup *map, u64 offset, u64 size), 9001abe9b8aSliubo 9016bccf3abSJeff Mahoney TP_ARGS(fs_info, map, offset, size) 9021abe9b8aSliubo ); 9031abe9b8aSliubo 9041abe9b8aSliubo TRACE_EVENT(btrfs_cow_block, 9051abe9b8aSliubo 9069a35b637SJeff Mahoney TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf, 9079a35b637SJeff Mahoney const struct extent_buffer *cow), 9081abe9b8aSliubo 9091abe9b8aSliubo TP_ARGS(root, buf, cow), 9101abe9b8aSliubo 911bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9121abe9b8aSliubo __field( u64, root_objectid ) 9131abe9b8aSliubo __field( u64, buf_start ) 9141abe9b8aSliubo __field( int, refs ) 9151abe9b8aSliubo __field( u64, cow_start ) 9161abe9b8aSliubo __field( int, buf_level ) 9171abe9b8aSliubo __field( int, cow_level ) 9181abe9b8aSliubo ), 9191abe9b8aSliubo 920bc074524SJeff Mahoney TP_fast_assign_btrfs(root->fs_info, 9211abe9b8aSliubo __entry->root_objectid = root->root_key.objectid; 9221abe9b8aSliubo __entry->buf_start = buf->start; 9231abe9b8aSliubo __entry->refs = atomic_read(&buf->refs); 9241abe9b8aSliubo __entry->cow_start = cow->start; 9251abe9b8aSliubo __entry->buf_level = btrfs_header_level(buf); 9261abe9b8aSliubo __entry->cow_level = btrfs_header_level(cow); 9271abe9b8aSliubo ), 9281abe9b8aSliubo 929562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu " 930562a7a07SDavid Sterba "(orig_level=%d) cow_buf=%llu (cow_level=%d)", 9311abe9b8aSliubo show_root_type(__entry->root_objectid), 9321abe9b8aSliubo __entry->refs, 9331abe9b8aSliubo (unsigned long long)__entry->buf_start, 9341abe9b8aSliubo __entry->buf_level, 9351abe9b8aSliubo (unsigned long long)__entry->cow_start, 9361abe9b8aSliubo __entry->cow_level) 9371abe9b8aSliubo ); 9381abe9b8aSliubo 9398c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation, 9408c2a3ca2SJosef Bacik 9419a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val, 9428c2a3ca2SJosef Bacik u64 bytes, int reserve), 9438c2a3ca2SJosef Bacik 9448c2a3ca2SJosef Bacik TP_ARGS(fs_info, type, val, bytes, reserve), 9458c2a3ca2SJosef Bacik 946bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 9478c2a3ca2SJosef Bacik __string( type, type ) 9488c2a3ca2SJosef Bacik __field( u64, val ) 9498c2a3ca2SJosef Bacik __field( u64, bytes ) 9508c2a3ca2SJosef Bacik __field( int, reserve ) 9518c2a3ca2SJosef Bacik ), 9528c2a3ca2SJosef Bacik 953bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 9548c2a3ca2SJosef Bacik __assign_str(type, type); 9558c2a3ca2SJosef Bacik __entry->val = val; 9568c2a3ca2SJosef Bacik __entry->bytes = bytes; 9578c2a3ca2SJosef Bacik __entry->reserve = reserve; 9588c2a3ca2SJosef Bacik ), 9598c2a3ca2SJosef Bacik 960bc074524SJeff Mahoney TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val, 961bc074524SJeff Mahoney __entry->reserve ? "reserve" : "release", 9628c2a3ca2SJosef Bacik __entry->bytes) 9638c2a3ca2SJosef Bacik ); 9648c2a3ca2SJosef Bacik 965f376df2bSJosef Bacik #define show_flush_action(action) \ 966f376df2bSJosef Bacik __print_symbolic(action, \ 967f376df2bSJosef Bacik { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ 968f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ 969f376df2bSJosef Bacik { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) 970f376df2bSJosef Bacik 971f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush, 972f376df2bSJosef Bacik 9739a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, 974f376df2bSJosef Bacik int flush, char *reason), 975f376df2bSJosef Bacik 976f376df2bSJosef Bacik TP_ARGS(fs_info, flags, bytes, flush, reason), 977f376df2bSJosef Bacik 978f376df2bSJosef Bacik TP_STRUCT__entry( 979b94417eaSAnand Jain __array( u8, fsid, BTRFS_FSID_SIZE ) 980f376df2bSJosef Bacik __field( u64, flags ) 981f376df2bSJosef Bacik __field( u64, bytes ) 982f376df2bSJosef Bacik __field( int, flush ) 983f376df2bSJosef Bacik __string( reason, reason ) 984f376df2bSJosef Bacik ), 985f376df2bSJosef Bacik 986f376df2bSJosef Bacik TP_fast_assign( 987b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE); 988f376df2bSJosef Bacik __entry->flags = flags; 989f376df2bSJosef Bacik __entry->bytes = bytes; 990f376df2bSJosef Bacik __entry->flush = flush; 991f376df2bSJosef Bacik __assign_str(reason, reason) 992f376df2bSJosef Bacik ), 993f376df2bSJosef Bacik 994562a7a07SDavid Sterba TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu", 995f376df2bSJosef Bacik __entry->fsid, __get_str(reason), __entry->flush, 996f376df2bSJosef Bacik show_flush_action(__entry->flush), 997f376df2bSJosef Bacik (unsigned long long)__entry->flags, 998f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 999f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 1000f376df2bSJosef Bacik (unsigned long long)__entry->bytes) 1001f376df2bSJosef Bacik ); 1002f376df2bSJosef Bacik 1003f376df2bSJosef Bacik #define show_flush_state(state) \ 1004f376df2bSJosef Bacik __print_symbolic(state, \ 1005f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ 1006f376df2bSJosef Bacik { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ 1007f376df2bSJosef Bacik { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ 1008f376df2bSJosef Bacik { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ 1009f376df2bSJosef Bacik { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ 1010f376df2bSJosef Bacik { COMMIT_TRANS, "COMMIT_TRANS"}) 1011f376df2bSJosef Bacik 1012f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space, 1013f376df2bSJosef Bacik 10149a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, 10157bdd6277SNikolay Borisov int state, int ret), 1016f376df2bSJosef Bacik 10177bdd6277SNikolay Borisov TP_ARGS(fs_info, flags, num_bytes, state, ret), 1018f376df2bSJosef Bacik 1019f376df2bSJosef Bacik TP_STRUCT__entry( 1020b94417eaSAnand Jain __array( u8, fsid, BTRFS_FSID_SIZE ) 1021f376df2bSJosef Bacik __field( u64, flags ) 1022f376df2bSJosef Bacik __field( u64, num_bytes ) 1023f376df2bSJosef Bacik __field( int, state ) 1024f376df2bSJosef Bacik __field( int, ret ) 1025f376df2bSJosef Bacik ), 1026f376df2bSJosef Bacik 1027f376df2bSJosef Bacik TP_fast_assign( 1028b94417eaSAnand Jain memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE); 1029f376df2bSJosef Bacik __entry->flags = flags; 1030f376df2bSJosef Bacik __entry->num_bytes = num_bytes; 1031f376df2bSJosef Bacik __entry->state = state; 1032f376df2bSJosef Bacik __entry->ret = ret; 1033f376df2bSJosef Bacik ), 1034f376df2bSJosef Bacik 10357bdd6277SNikolay Borisov TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d", 10367bdd6277SNikolay Borisov __entry->fsid, __entry->state, 1037f376df2bSJosef Bacik show_flush_state(__entry->state), 1038f376df2bSJosef Bacik (unsigned long long)__entry->flags, 1039f376df2bSJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 1040f376df2bSJosef Bacik BTRFS_GROUP_FLAGS), 10417bdd6277SNikolay Borisov (unsigned long long)__entry->num_bytes, __entry->ret) 1042f376df2bSJosef Bacik ); 1043f376df2bSJosef Bacik 10441abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent, 10451abe9b8aSliubo 10469a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 10471abe9b8aSliubo 104871ff6437SJeff Mahoney TP_ARGS(fs_info, start, len), 10491abe9b8aSliubo 1050bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 10511abe9b8aSliubo __field( u64, start ) 10521abe9b8aSliubo __field( u64, len ) 10531abe9b8aSliubo ), 10541abe9b8aSliubo 105571ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 10561abe9b8aSliubo __entry->start = start; 10571abe9b8aSliubo __entry->len = len; 10581abe9b8aSliubo ), 10591abe9b8aSliubo 1060562a7a07SDavid Sterba TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu", 106171ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 10621abe9b8aSliubo (unsigned long long)__entry->start, 10631abe9b8aSliubo (unsigned long long)__entry->len) 10641abe9b8aSliubo ); 10651abe9b8aSliubo 10661abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, 10671abe9b8aSliubo 10689a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 10691abe9b8aSliubo 107071ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 10711abe9b8aSliubo ); 10721abe9b8aSliubo 10731abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, 10741abe9b8aSliubo 10759a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), 10761abe9b8aSliubo 107771ff6437SJeff Mahoney TP_ARGS(fs_info, start, len) 10781abe9b8aSliubo ); 10791abe9b8aSliubo 10803f7de037SJosef Bacik TRACE_EVENT(find_free_extent, 10813f7de037SJosef Bacik 10829a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, 10839a35b637SJeff Mahoney u64 empty_size, u64 data), 10843f7de037SJosef Bacik 108571ff6437SJeff Mahoney TP_ARGS(fs_info, num_bytes, empty_size, data), 10863f7de037SJosef Bacik 1087bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 10883f7de037SJosef Bacik __field( u64, num_bytes ) 10893f7de037SJosef Bacik __field( u64, empty_size ) 10903f7de037SJosef Bacik __field( u64, data ) 10913f7de037SJosef Bacik ), 10923f7de037SJosef Bacik 109371ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 10943f7de037SJosef Bacik __entry->num_bytes = num_bytes; 10953f7de037SJosef Bacik __entry->empty_size = empty_size; 10963f7de037SJosef Bacik __entry->data = data; 10973f7de037SJosef Bacik ), 10983f7de037SJosef Bacik 1099562a7a07SDavid Sterba TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)", 110071ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 11013f7de037SJosef Bacik __entry->num_bytes, __entry->empty_size, __entry->data, 11023f7de037SJosef Bacik __print_flags((unsigned long)__entry->data, "|", 11033f7de037SJosef Bacik BTRFS_GROUP_FLAGS)) 11043f7de037SJosef Bacik ); 11053f7de037SJosef Bacik 11063f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent, 11073f7de037SJosef Bacik 11089a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 11099a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, u64 start, 11103f7de037SJosef Bacik u64 len), 11113f7de037SJosef Bacik 111271ff6437SJeff Mahoney TP_ARGS(fs_info, block_group, start, len), 11133f7de037SJosef Bacik 1114bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11153f7de037SJosef Bacik __field( u64, bg_objectid ) 11163f7de037SJosef Bacik __field( u64, flags ) 11173f7de037SJosef Bacik __field( u64, start ) 11183f7de037SJosef Bacik __field( u64, len ) 11193f7de037SJosef Bacik ), 11203f7de037SJosef Bacik 112171ff6437SJeff Mahoney TP_fast_assign_btrfs(fs_info, 11223f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 11233f7de037SJosef Bacik __entry->flags = block_group->flags; 11243f7de037SJosef Bacik __entry->start = start; 11253f7de037SJosef Bacik __entry->len = len; 11263f7de037SJosef Bacik ), 11273f7de037SJosef Bacik 1128562a7a07SDavid Sterba TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) " 1129562a7a07SDavid Sterba "start=%Lu len=%Lu", 113071ff6437SJeff Mahoney show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 113171ff6437SJeff Mahoney __entry->bg_objectid, 11323f7de037SJosef Bacik __entry->flags, __print_flags((unsigned long)__entry->flags, 11333f7de037SJosef Bacik "|", BTRFS_GROUP_FLAGS), 11343f7de037SJosef Bacik __entry->start, __entry->len) 11353f7de037SJosef Bacik ); 11363f7de037SJosef Bacik 11373f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent, 11383f7de037SJosef Bacik 11399a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 11409a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, u64 start, 11413f7de037SJosef Bacik u64 len), 11423f7de037SJosef Bacik 114371ff6437SJeff Mahoney TP_ARGS(fs_info, block_group, start, len) 11443f7de037SJosef Bacik ); 11453f7de037SJosef Bacik 11463f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster, 11473f7de037SJosef Bacik 11489a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 11499a35b637SJeff Mahoney const struct btrfs_block_group_cache *block_group, u64 start, 11503f7de037SJosef Bacik u64 len), 11513f7de037SJosef Bacik 115271ff6437SJeff Mahoney TP_ARGS(fs_info, block_group, start, len) 11533f7de037SJosef Bacik ); 11543f7de037SJosef Bacik 11553f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster, 11563f7de037SJosef Bacik 11579a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start, 11583f7de037SJosef Bacik u64 bytes, u64 empty_size, u64 min_bytes), 11593f7de037SJosef Bacik 11603f7de037SJosef Bacik TP_ARGS(block_group, start, bytes, empty_size, min_bytes), 11613f7de037SJosef Bacik 1162bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11633f7de037SJosef Bacik __field( u64, bg_objectid ) 11643f7de037SJosef Bacik __field( u64, flags ) 11653f7de037SJosef Bacik __field( u64, start ) 11663f7de037SJosef Bacik __field( u64, bytes ) 11673f7de037SJosef Bacik __field( u64, empty_size ) 11683f7de037SJosef Bacik __field( u64, min_bytes ) 11693f7de037SJosef Bacik ), 11703f7de037SJosef Bacik 1171bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 11723f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 11733f7de037SJosef Bacik __entry->flags = block_group->flags; 11743f7de037SJosef Bacik __entry->start = start; 11753f7de037SJosef Bacik __entry->bytes = bytes; 11763f7de037SJosef Bacik __entry->empty_size = empty_size; 11773f7de037SJosef Bacik __entry->min_bytes = min_bytes; 11783f7de037SJosef Bacik ), 11793f7de037SJosef Bacik 1180562a7a07SDavid Sterba TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu " 1181562a7a07SDavid Sterba "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid, 11823f7de037SJosef Bacik __entry->flags, 11833f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 11843f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 11853f7de037SJosef Bacik __entry->bytes, __entry->empty_size, __entry->min_bytes) 11863f7de037SJosef Bacik ); 11873f7de037SJosef Bacik 11883f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup, 11893f7de037SJosef Bacik 11909a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group), 11913f7de037SJosef Bacik 11923f7de037SJosef Bacik TP_ARGS(block_group), 11933f7de037SJosef Bacik 1194bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 11953f7de037SJosef Bacik __field( u64, bg_objectid ) 11963f7de037SJosef Bacik ), 11973f7de037SJosef Bacik 1198bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 11993f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12003f7de037SJosef Bacik ), 12013f7de037SJosef Bacik 1202bc074524SJeff Mahoney TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid) 12033f7de037SJosef Bacik ); 12043f7de037SJosef Bacik 12053f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster, 12063f7de037SJosef Bacik 12079a35b637SJeff Mahoney TP_PROTO(const struct btrfs_block_group_cache *block_group, 12089a35b637SJeff Mahoney const struct btrfs_free_cluster *cluster, 12099a35b637SJeff Mahoney u64 size, int bitmap), 12103f7de037SJosef Bacik 12113f7de037SJosef Bacik TP_ARGS(block_group, cluster, size, bitmap), 12123f7de037SJosef Bacik 1213bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12143f7de037SJosef Bacik __field( u64, bg_objectid ) 12153f7de037SJosef Bacik __field( u64, flags ) 12163f7de037SJosef Bacik __field( u64, start ) 12173f7de037SJosef Bacik __field( u64, max_size ) 12183f7de037SJosef Bacik __field( u64, size ) 12193f7de037SJosef Bacik __field( int, bitmap ) 12203f7de037SJosef Bacik ), 12213f7de037SJosef Bacik 1222bc074524SJeff Mahoney TP_fast_assign_btrfs(block_group->fs_info, 12233f7de037SJosef Bacik __entry->bg_objectid = block_group->key.objectid; 12243f7de037SJosef Bacik __entry->flags = block_group->flags; 12253f7de037SJosef Bacik __entry->start = cluster->window_start; 12263f7de037SJosef Bacik __entry->max_size = cluster->max_size; 12273f7de037SJosef Bacik __entry->size = size; 12283f7de037SJosef Bacik __entry->bitmap = bitmap; 12293f7de037SJosef Bacik ), 12303f7de037SJosef Bacik 1231562a7a07SDavid Sterba TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu " 1232562a7a07SDavid Sterba "size=%Lu max_size=%Lu bitmap=%d", 12333f7de037SJosef Bacik __entry->bg_objectid, 12343f7de037SJosef Bacik __entry->flags, 12353f7de037SJosef Bacik __print_flags((unsigned long)__entry->flags, "|", 12363f7de037SJosef Bacik BTRFS_GROUP_FLAGS), __entry->start, 12373f7de037SJosef Bacik __entry->size, __entry->max_size, __entry->bitmap) 12383f7de037SJosef Bacik ); 12393f7de037SJosef Bacik 1240143bede5SJeff Mahoney struct extent_state; 1241143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state, 1242143bede5SJeff Mahoney 12439a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, 12449a35b637SJeff Mahoney gfp_t mask, unsigned long IP), 1245143bede5SJeff Mahoney 1246143bede5SJeff Mahoney TP_ARGS(state, mask, IP), 1247143bede5SJeff Mahoney 1248143bede5SJeff Mahoney TP_STRUCT__entry( 12499a35b637SJeff Mahoney __field(const struct extent_state *, state) 1250143bede5SJeff Mahoney __field(gfp_t, mask) 1251143bede5SJeff Mahoney __field(unsigned long, ip) 1252143bede5SJeff Mahoney ), 1253143bede5SJeff Mahoney 1254143bede5SJeff Mahoney TP_fast_assign( 1255143bede5SJeff Mahoney __entry->state = state, 1256143bede5SJeff Mahoney __entry->mask = mask, 1257143bede5SJeff Mahoney __entry->ip = IP 1258143bede5SJeff Mahoney ), 1259143bede5SJeff Mahoney 1260562a7a07SDavid Sterba TP_printk("state=%p mask=%s caller=%pS", __entry->state, 12619a35b637SJeff Mahoney show_gfp_flags(__entry->mask), (const void *)__entry->ip) 1262143bede5SJeff Mahoney ); 1263143bede5SJeff Mahoney 1264143bede5SJeff Mahoney TRACE_EVENT(free_extent_state, 1265143bede5SJeff Mahoney 12669a35b637SJeff Mahoney TP_PROTO(const struct extent_state *state, unsigned long IP), 1267143bede5SJeff Mahoney 1268143bede5SJeff Mahoney TP_ARGS(state, IP), 1269143bede5SJeff Mahoney 1270143bede5SJeff Mahoney TP_STRUCT__entry( 12719a35b637SJeff Mahoney __field(const struct extent_state *, state) 1272143bede5SJeff Mahoney __field(unsigned long, ip) 1273143bede5SJeff Mahoney ), 1274143bede5SJeff Mahoney 1275143bede5SJeff Mahoney TP_fast_assign( 1276143bede5SJeff Mahoney __entry->state = state, 1277143bede5SJeff Mahoney __entry->ip = IP 1278143bede5SJeff Mahoney ), 1279143bede5SJeff Mahoney 1280562a7a07SDavid Sterba TP_printk("state=%p caller=%pS", __entry->state, 12819a35b637SJeff Mahoney (const void *)__entry->ip) 1282143bede5SJeff Mahoney ); 1283143bede5SJeff Mahoney 128452483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work, 128552483bc2SQu Wenruo 12869a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 128752483bc2SQu Wenruo 128852483bc2SQu Wenruo TP_ARGS(work), 128952483bc2SQu Wenruo 1290bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 12919a35b637SJeff Mahoney __field( const void *, work ) 12929a35b637SJeff Mahoney __field( const void *, wq ) 12939a35b637SJeff Mahoney __field( const void *, func ) 12949a35b637SJeff Mahoney __field( const void *, ordered_func ) 12959a35b637SJeff Mahoney __field( const void *, ordered_free ) 12969a35b637SJeff Mahoney __field( const void *, normal_work ) 129752483bc2SQu Wenruo ), 129852483bc2SQu Wenruo 1299bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_work_owner(work), 130052483bc2SQu Wenruo __entry->work = work; 130152483bc2SQu Wenruo __entry->wq = work->wq; 130252483bc2SQu Wenruo __entry->func = work->func; 130352483bc2SQu Wenruo __entry->ordered_func = work->ordered_func; 130452483bc2SQu Wenruo __entry->ordered_free = work->ordered_free; 1305b38a6258SLiu Bo __entry->normal_work = &work->normal_work; 130652483bc2SQu Wenruo ), 130752483bc2SQu Wenruo 1308562a7a07SDavid Sterba TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p " 1309b38a6258SLiu Bo "ordered_free=%p", 1310b38a6258SLiu Bo __entry->work, __entry->normal_work, __entry->wq, 1311b38a6258SLiu Bo __entry->func, __entry->ordered_func, __entry->ordered_free) 131252483bc2SQu Wenruo ); 131352483bc2SQu Wenruo 1314ac0c7cf8SDavid Sterba /* 1315ac0c7cf8SDavid Sterba * For situiations when the work is freed, we pass fs_info and a tag that that 1316ac0c7cf8SDavid Sterba * matches address of the work structure so it can be paired with the 1317ac0c7cf8SDavid Sterba * scheduling event. 1318ac0c7cf8SDavid Sterba */ 131952483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done, 132052483bc2SQu Wenruo 13219a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 132252483bc2SQu Wenruo 1323ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag), 132452483bc2SQu Wenruo 1325bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 13269a35b637SJeff Mahoney __field( const void *, wtag ) 132752483bc2SQu Wenruo ), 132852483bc2SQu Wenruo 1329ac0c7cf8SDavid Sterba TP_fast_assign_btrfs(fs_info, 1330ac0c7cf8SDavid Sterba __entry->wtag = wtag; 133152483bc2SQu Wenruo ), 133252483bc2SQu Wenruo 1333ac0c7cf8SDavid Sterba TP_printk_btrfs("work->%p", __entry->wtag) 133452483bc2SQu Wenruo ); 133552483bc2SQu Wenruo 133652483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued, 133752483bc2SQu Wenruo 13389a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 133952483bc2SQu Wenruo 134052483bc2SQu Wenruo TP_ARGS(work) 134152483bc2SQu Wenruo ); 134252483bc2SQu Wenruo 134352483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched, 134452483bc2SQu Wenruo 13459a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 134652483bc2SQu Wenruo 134752483bc2SQu Wenruo TP_ARGS(work) 134852483bc2SQu Wenruo ); 134952483bc2SQu Wenruo 135052483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 135152483bc2SQu Wenruo 13529a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag), 135352483bc2SQu Wenruo 1354ac0c7cf8SDavid Sterba TP_ARGS(fs_info, wtag) 135552483bc2SQu Wenruo ); 135652483bc2SQu Wenruo 135752483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 135852483bc2SQu Wenruo 13599a35b637SJeff Mahoney TP_PROTO(const struct btrfs_work *work), 136052483bc2SQu Wenruo 136152483bc2SQu Wenruo TP_ARGS(work) 136252483bc2SQu Wenruo ); 136352483bc2SQu Wenruo 1364c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue, 1365c3a46891SQu Wenruo 13669a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 13679a35b637SJeff Mahoney const char *name, int high), 1368c3a46891SQu Wenruo 1369c3a46891SQu Wenruo TP_ARGS(wq, name, high), 1370c3a46891SQu Wenruo 1371bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 13729a35b637SJeff Mahoney __field( const void *, wq ) 1373c3a46891SQu Wenruo __string( name, name ) 1374c3a46891SQu Wenruo __field( int , high ) 1375c3a46891SQu Wenruo ), 1376c3a46891SQu Wenruo 1377bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1378c3a46891SQu Wenruo __entry->wq = wq; 1379c3a46891SQu Wenruo __assign_str(name, name); 1380c3a46891SQu Wenruo __entry->high = high; 1381c3a46891SQu Wenruo ), 1382c3a46891SQu Wenruo 1383562a7a07SDavid Sterba TP_printk_btrfs("name=%s%s wq=%p", __get_str(name), 1384c3a46891SQu Wenruo __print_flags(__entry->high, "", 1385c3a46891SQu Wenruo {(WQ_HIGHPRI), "-high"}), 1386c3a46891SQu Wenruo __entry->wq) 1387c3a46891SQu Wenruo ); 1388c3a46891SQu Wenruo 1389c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc, 1390c3a46891SQu Wenruo 13919a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq, 13929a35b637SJeff Mahoney const char *name, int high), 1393c3a46891SQu Wenruo 1394c3a46891SQu Wenruo TP_ARGS(wq, name, high) 1395c3a46891SQu Wenruo ); 1396c3a46891SQu Wenruo 1397c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue_done, 1398c3a46891SQu Wenruo 13999a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1400c3a46891SQu Wenruo 1401c3a46891SQu Wenruo TP_ARGS(wq), 1402c3a46891SQu Wenruo 1403bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 14049a35b637SJeff Mahoney __field( const void *, wq ) 1405c3a46891SQu Wenruo ), 1406c3a46891SQu Wenruo 1407bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_workqueue_owner(wq), 1408c3a46891SQu Wenruo __entry->wq = wq; 1409c3a46891SQu Wenruo ), 1410c3a46891SQu Wenruo 1411bc074524SJeff Mahoney TP_printk_btrfs("wq=%p", __entry->wq) 1412c3a46891SQu Wenruo ); 1413c3a46891SQu Wenruo 1414c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy, 1415c3a46891SQu Wenruo 14169a35b637SJeff Mahoney TP_PROTO(const struct __btrfs_workqueue *wq), 1417c3a46891SQu Wenruo 1418c3a46891SQu Wenruo TP_ARGS(wq) 1419c3a46891SQu Wenruo ); 142052483bc2SQu Wenruo 142181fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS \ 142281fb6f77SQu Wenruo { QGROUP_RESERVE, "reserve" }, \ 142381fb6f77SQu Wenruo { QGROUP_RELEASE, "release" }, \ 142481fb6f77SQu Wenruo { QGROUP_FREE, "free" } 142581fb6f77SQu Wenruo 142681fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data, 142781fb6f77SQu Wenruo 14289a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 14299a35b637SJeff Mahoney u64 reserved, int op), 143081fb6f77SQu Wenruo 143181fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op), 143281fb6f77SQu Wenruo 1433bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 143481fb6f77SQu Wenruo __field( u64, rootid ) 143581fb6f77SQu Wenruo __field( unsigned long, ino ) 143681fb6f77SQu Wenruo __field( u64, start ) 143781fb6f77SQu Wenruo __field( u64, len ) 143881fb6f77SQu Wenruo __field( u64, reserved ) 143981fb6f77SQu Wenruo __field( int, op ) 144081fb6f77SQu Wenruo ), 144181fb6f77SQu Wenruo 1442bc074524SJeff Mahoney TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 144381fb6f77SQu Wenruo __entry->rootid = BTRFS_I(inode)->root->objectid; 144481fb6f77SQu Wenruo __entry->ino = inode->i_ino; 144581fb6f77SQu Wenruo __entry->start = start; 144681fb6f77SQu Wenruo __entry->len = len; 144781fb6f77SQu Wenruo __entry->reserved = reserved; 144881fb6f77SQu Wenruo __entry->op = op; 144981fb6f77SQu Wenruo ), 145081fb6f77SQu Wenruo 1451562a7a07SDavid Sterba TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s", 145281fb6f77SQu Wenruo __entry->rootid, __entry->ino, __entry->start, __entry->len, 145381fb6f77SQu Wenruo __entry->reserved, 145481fb6f77SQu Wenruo __print_flags((unsigned long)__entry->op, "", 145581fb6f77SQu Wenruo BTRFS_QGROUP_OPERATIONS) 145681fb6f77SQu Wenruo ) 145781fb6f77SQu Wenruo ); 145881fb6f77SQu Wenruo 145981fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data, 146081fb6f77SQu Wenruo 14619a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 14629a35b637SJeff Mahoney u64 reserved, int op), 146381fb6f77SQu Wenruo 146481fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 146581fb6f77SQu Wenruo ); 146681fb6f77SQu Wenruo 146781fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data, 146881fb6f77SQu Wenruo 14699a35b637SJeff Mahoney TP_PROTO(const struct inode *inode, u64 start, u64 len, 14709a35b637SJeff Mahoney u64 reserved, int op), 147181fb6f77SQu Wenruo 147281fb6f77SQu Wenruo TP_ARGS(inode, start, len, reserved, op) 147381fb6f77SQu Wenruo ); 147481fb6f77SQu Wenruo 147581fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref, 147681fb6f77SQu Wenruo 14779a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 14789a35b637SJeff Mahoney u64 ref_root, u64 reserved), 147981fb6f77SQu Wenruo 1480bc074524SJeff Mahoney TP_ARGS(fs_info, ref_root, reserved), 148181fb6f77SQu Wenruo 1482bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 148381fb6f77SQu Wenruo __field( u64, ref_root ) 148481fb6f77SQu Wenruo __field( u64, reserved ) 148581fb6f77SQu Wenruo ), 148681fb6f77SQu Wenruo 1487bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 148881fb6f77SQu Wenruo __entry->ref_root = ref_root; 148981fb6f77SQu Wenruo __entry->reserved = reserved; 149081fb6f77SQu Wenruo ), 149181fb6f77SQu Wenruo 1492562a7a07SDavid Sterba TP_printk_btrfs("root=%llu reserved=%llu op=free", 149381fb6f77SQu Wenruo __entry->ref_root, __entry->reserved) 149481fb6f77SQu Wenruo ); 149581fb6f77SQu Wenruo 149681fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref, 149781fb6f77SQu Wenruo 14989a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 14999a35b637SJeff Mahoney u64 ref_root, u64 reserved), 150081fb6f77SQu Wenruo 1501bc074524SJeff Mahoney TP_ARGS(fs_info, ref_root, reserved) 150281fb6f77SQu Wenruo ); 15030f5dcf8dSMark Fasheh 15040f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent, 15059a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15069a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15070f5dcf8dSMark Fasheh 1508bc074524SJeff Mahoney TP_ARGS(fs_info, rec), 15090f5dcf8dSMark Fasheh 1510bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 15110f5dcf8dSMark Fasheh __field( u64, bytenr ) 15120f5dcf8dSMark Fasheh __field( u64, num_bytes ) 15130f5dcf8dSMark Fasheh ), 15140f5dcf8dSMark Fasheh 1515bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 15160f5dcf8dSMark Fasheh __entry->bytenr = rec->bytenr, 15170f5dcf8dSMark Fasheh __entry->num_bytes = rec->num_bytes; 15180f5dcf8dSMark Fasheh ), 15190f5dcf8dSMark Fasheh 1520562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu", 15210f5dcf8dSMark Fasheh (unsigned long long)__entry->bytenr, 15220f5dcf8dSMark Fasheh (unsigned long long)__entry->num_bytes) 15230f5dcf8dSMark Fasheh ); 15240f5dcf8dSMark Fasheh 15250f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents, 15260f5dcf8dSMark Fasheh 15279a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15289a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15290f5dcf8dSMark Fasheh 1530bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15310f5dcf8dSMark Fasheh ); 15320f5dcf8dSMark Fasheh 153350b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent, 15340f5dcf8dSMark Fasheh 15359a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 15369a35b637SJeff Mahoney const struct btrfs_qgroup_extent_record *rec), 15370f5dcf8dSMark Fasheh 1538bc074524SJeff Mahoney TP_ARGS(fs_info, rec) 15390f5dcf8dSMark Fasheh ); 15400f5dcf8dSMark Fasheh 15410f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent, 15420f5dcf8dSMark Fasheh 15439a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr, 1544bc074524SJeff Mahoney u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots), 15450f5dcf8dSMark Fasheh 1546bc074524SJeff Mahoney TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots), 15470f5dcf8dSMark Fasheh 1548bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 15490f5dcf8dSMark Fasheh __field( u64, bytenr ) 15500f5dcf8dSMark Fasheh __field( u64, num_bytes ) 15510f5dcf8dSMark Fasheh __field( u64, nr_old_roots ) 15520f5dcf8dSMark Fasheh __field( u64, nr_new_roots ) 15530f5dcf8dSMark Fasheh ), 15540f5dcf8dSMark Fasheh 1555bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 15560f5dcf8dSMark Fasheh __entry->bytenr = bytenr; 15570f5dcf8dSMark Fasheh __entry->num_bytes = num_bytes; 15580f5dcf8dSMark Fasheh __entry->nr_old_roots = nr_old_roots; 15590f5dcf8dSMark Fasheh __entry->nr_new_roots = nr_new_roots; 15600f5dcf8dSMark Fasheh ), 15610f5dcf8dSMark Fasheh 1562562a7a07SDavid Sterba TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu " 15630f5dcf8dSMark Fasheh "nr_new_roots=%llu", 15640f5dcf8dSMark Fasheh __entry->bytenr, 15650f5dcf8dSMark Fasheh __entry->num_bytes, 15660f5dcf8dSMark Fasheh __entry->nr_old_roots, 15670f5dcf8dSMark Fasheh __entry->nr_new_roots) 15680f5dcf8dSMark Fasheh ); 15690f5dcf8dSMark Fasheh 15700f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters, 15710f5dcf8dSMark Fasheh 15729a35b637SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid, 1573bc074524SJeff Mahoney u64 cur_old_count, u64 cur_new_count), 15740f5dcf8dSMark Fasheh 1575bc074524SJeff Mahoney TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count), 15760f5dcf8dSMark Fasheh 1577bc074524SJeff Mahoney TP_STRUCT__entry_btrfs( 15780f5dcf8dSMark Fasheh __field( u64, qgid ) 15790f5dcf8dSMark Fasheh __field( u64, cur_old_count ) 15800f5dcf8dSMark Fasheh __field( u64, cur_new_count ) 15810f5dcf8dSMark Fasheh ), 15820f5dcf8dSMark Fasheh 1583bc074524SJeff Mahoney TP_fast_assign_btrfs(fs_info, 15840f5dcf8dSMark Fasheh __entry->qgid = qgid; 15850f5dcf8dSMark Fasheh __entry->cur_old_count = cur_old_count; 15860f5dcf8dSMark Fasheh __entry->cur_new_count = cur_new_count; 15870f5dcf8dSMark Fasheh ), 15880f5dcf8dSMark Fasheh 1589562a7a07SDavid Sterba TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu", 15900f5dcf8dSMark Fasheh __entry->qgid, 15910f5dcf8dSMark Fasheh __entry->cur_old_count, 15920f5dcf8dSMark Fasheh __entry->cur_new_count) 15930f5dcf8dSMark Fasheh ); 15940f5dcf8dSMark Fasheh 15953159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve, 15963159fe7bSQu Wenruo 15973159fe7bSQu Wenruo TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup, 15983159fe7bSQu Wenruo s64 diff), 15993159fe7bSQu Wenruo 16003159fe7bSQu Wenruo TP_ARGS(fs_info, qgroup, diff), 16013159fe7bSQu Wenruo 16023159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 16033159fe7bSQu Wenruo __field( u64, qgid ) 16043159fe7bSQu Wenruo __field( u64, cur_reserved ) 16053159fe7bSQu Wenruo __field( s64, diff ) 16063159fe7bSQu Wenruo ), 16073159fe7bSQu Wenruo 16083159fe7bSQu Wenruo TP_fast_assign_btrfs(fs_info, 16093159fe7bSQu Wenruo __entry->qgid = qgroup->qgroupid; 16103159fe7bSQu Wenruo __entry->cur_reserved = qgroup->reserved; 16113159fe7bSQu Wenruo __entry->diff = diff; 16123159fe7bSQu Wenruo ), 16133159fe7bSQu Wenruo 16143159fe7bSQu Wenruo TP_printk_btrfs("qgid=%llu cur_reserved=%llu diff=%lld", 16153159fe7bSQu Wenruo __entry->qgid, __entry->cur_reserved, __entry->diff) 16163159fe7bSQu Wenruo ); 16173159fe7bSQu Wenruo 16183159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve, 16193159fe7bSQu Wenruo 16203159fe7bSQu Wenruo TP_PROTO(struct btrfs_root *root, s64 diff), 16213159fe7bSQu Wenruo 16223159fe7bSQu Wenruo TP_ARGS(root, diff), 16233159fe7bSQu Wenruo 16243159fe7bSQu Wenruo TP_STRUCT__entry_btrfs( 16253159fe7bSQu Wenruo __field( u64, refroot ) 16263159fe7bSQu Wenruo __field( s64, diff ) 16273159fe7bSQu Wenruo ), 16283159fe7bSQu Wenruo 16293159fe7bSQu Wenruo TP_fast_assign_btrfs(root->fs_info, 16303159fe7bSQu Wenruo __entry->refroot = root->objectid; 16313159fe7bSQu Wenruo __entry->diff = diff; 16323159fe7bSQu Wenruo ), 16333159fe7bSQu Wenruo 16343159fe7bSQu Wenruo TP_printk_btrfs("refroot=%llu(%s) diff=%lld", 16353159fe7bSQu Wenruo show_root_type(__entry->refroot), __entry->diff) 16363159fe7bSQu Wenruo ); 16373159fe7bSQu Wenruo 163800142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref, 163900142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 164000142756SJeff Mahoney const struct prelim_ref *oldref, 164100142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 164200142756SJeff Mahoney TP_ARGS(fs_info, newref, oldref, tree_size), 164300142756SJeff Mahoney 164400142756SJeff Mahoney TP_STRUCT__entry_btrfs( 164500142756SJeff Mahoney __field( u64, root_id ) 164600142756SJeff Mahoney __field( u64, objectid ) 164700142756SJeff Mahoney __field( u8, type ) 164800142756SJeff Mahoney __field( u64, offset ) 164900142756SJeff Mahoney __field( int, level ) 165000142756SJeff Mahoney __field( int, old_count ) 165100142756SJeff Mahoney __field( u64, parent ) 165200142756SJeff Mahoney __field( u64, bytenr ) 165300142756SJeff Mahoney __field( int, mod_count ) 165400142756SJeff Mahoney __field( u64, tree_size ) 165500142756SJeff Mahoney ), 165600142756SJeff Mahoney 165700142756SJeff Mahoney TP_fast_assign_btrfs(fs_info, 165800142756SJeff Mahoney __entry->root_id = oldref->root_id; 165900142756SJeff Mahoney __entry->objectid = oldref->key_for_search.objectid; 166000142756SJeff Mahoney __entry->type = oldref->key_for_search.type; 166100142756SJeff Mahoney __entry->offset = oldref->key_for_search.offset; 166200142756SJeff Mahoney __entry->level = oldref->level; 166300142756SJeff Mahoney __entry->old_count = oldref->count; 166400142756SJeff Mahoney __entry->parent = oldref->parent; 166500142756SJeff Mahoney __entry->bytenr = oldref->wanted_disk_byte; 166600142756SJeff Mahoney __entry->mod_count = newref ? newref->count : 0; 166700142756SJeff Mahoney __entry->tree_size = tree_size; 166800142756SJeff Mahoney ), 166900142756SJeff Mahoney 167000142756SJeff 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", 167100142756SJeff Mahoney (unsigned long long)__entry->root_id, 167200142756SJeff Mahoney (unsigned long long)__entry->objectid, __entry->type, 167300142756SJeff Mahoney (unsigned long long)__entry->offset, __entry->level, 167400142756SJeff Mahoney __entry->old_count, __entry->mod_count, 167500142756SJeff Mahoney __entry->old_count + __entry->mod_count, 167600142756SJeff Mahoney (unsigned long long)__entry->parent, 167700142756SJeff Mahoney (unsigned long long)__entry->bytenr, 167800142756SJeff Mahoney (unsigned long long)__entry->tree_size) 167900142756SJeff Mahoney ); 168000142756SJeff Mahoney 168100142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge, 168200142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 168300142756SJeff Mahoney const struct prelim_ref *oldref, 168400142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 168500142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 168600142756SJeff Mahoney ); 168700142756SJeff Mahoney 168800142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert, 168900142756SJeff Mahoney TP_PROTO(const struct btrfs_fs_info *fs_info, 169000142756SJeff Mahoney const struct prelim_ref *oldref, 169100142756SJeff Mahoney const struct prelim_ref *newref, u64 tree_size), 169200142756SJeff Mahoney TP_ARGS(fs_info, oldref, newref, tree_size) 169300142756SJeff Mahoney ); 169400142756SJeff Mahoney 16951abe9b8aSliubo #endif /* _TRACE_BTRFS_H */ 16961abe9b8aSliubo 16971abe9b8aSliubo /* This part must be outside protection */ 16981abe9b8aSliubo #include <trace/define_trace.h> 1699