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

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 b98cb7b0630a4f8e03b62d987fab5ad821b71daa..277953906b913a4bf9aac333d02d904d85865867 100644 (file)
@@ -2731,6 +2731,7 @@ void __cold __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
 
        WRITE_ONCE(trans->aborted, error);
        WRITE_ONCE(trans->transaction->aborted, error);
+       trace_btrfs_transaction_abort(trans);
        if (first_hit) {
                btrfs_err(fs_info, "Transaction %llu aborted (error %d)",
                          trans->transid, error);
index 4e077abd670440ac03859459a7971127fd296564..cb9b6188fcdd4408c7c13fba1f2713b6a9c7b8a5 100644 (file)
@@ -201,6 +201,28 @@ TRACE_EVENT(btrfs_transaction_commit,
                        __entry->in_fsync)
 );
 
+TRACE_EVENT(btrfs_transaction_abort,
+
+       TP_PROTO(const struct btrfs_trans_handle *trans),
+
+       TP_ARGS(trans),
+
+       TP_STRUCT__entry_btrfs(
+               __field(        u64,  generation                )
+               __field(        bool, in_fsync                  )
+               __field(        int,  error                     )
+       ),
+
+       TP_fast_assign_btrfs(trans->fs_info,
+               __entry->generation     = trans->transid;
+               __entry->in_fsync       = trans->in_fsync;
+               __entry->error          = trans->aborted;
+       ),
+
+       TP_printk_btrfs("gen=%llu in_fsync=%d error=%d", __entry->generation,
+                       __entry->in_fsync, __entry->error)
+);
+
 DECLARE_EVENT_CLASS(btrfs__inode,
 
        TP_PROTO(const struct inode *inode),