]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: tracepoints: add trace event for the start of a new transaction
authorFilipe Manana <fdmanana@suse.com>
Thu, 23 Apr 2026 14:56:52 +0000 (15:56 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:34 +0000 (15:53 +0200)
While tracing it's useful to know not just when a transaction is committed
or aborted, but also when a new one is started. So add a trace event for
transaction starts.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/transaction.c
include/trace/events/btrfs.h

index 277953906b913a4bf9aac333d02d904d85865867..9ff8792d71820900287793e066c410b416f9c291 100644 (file)
@@ -394,6 +394,7 @@ loop:
        cur_trans->transid = fs_info->generation;
        fs_info->running_transaction = cur_trans;
        cur_trans->aborted = 0;
+       trace_btrfs_transaction_start(cur_trans);
        spin_unlock(&fs_info->trans_lock);
 
        return 0;
index cb9b6188fcdd4408c7c13fba1f2713b6a9c7b8a5..e43528003848e7729db047166bbb97cc7faefec4 100644 (file)
@@ -32,6 +32,7 @@ struct btrfs_raid_bio;
 struct raid56_bio_trace_info;
 struct find_free_extent_ctl;
 struct btrfs_trans_handle;
+struct btrfs_transaction;
 
 #define show_ref_type(type)                                            \
        __print_symbolic(type,                                          \
@@ -181,6 +182,23 @@ FLUSH_STATES
 #define TP_printk_btrfs(fmt, args...) \
        TP_printk("%pU: " fmt, __entry->fsid, args)
 
+TRACE_EVENT(btrfs_transaction_start,
+
+       TP_PROTO(const struct btrfs_transaction *trans),
+
+       TP_ARGS(trans),
+
+       TP_STRUCT__entry_btrfs(
+               __field(        u64,  generation                )
+       ),
+
+       TP_fast_assign_btrfs(trans->fs_info,
+               __entry->generation     = trans->transid;
+       ),
+
+       TP_printk_btrfs("gen=%llu", __entry->generation)
+);
+
 TRACE_EVENT(btrfs_transaction_commit,
 
        TP_PROTO(const struct btrfs_trans_handle *trans),