]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: tracepoints: pass a transaction handle to transaction commit event
authorFilipe Manana <fdmanana@suse.com>
Fri, 17 Apr 2026 16:43:19 +0000 (17:43 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:33 +0000 (15:53 +0200)
The transaction commit tracepoint prints fs_info->generation as if it
were the ID of the committed transaction but this does not always match
that ID. This is because the trace point is called in the transaction
commit path after the transaction is in the TRANS_STATE_COMPLETED state,
which means another transaction may have already started (which can happen
as soon as the transaction state was set to TRANS_STATE_UNBLOCKED), in
which case fs_info->generation was incremented and does not correspond
to the committed transaction anymore.

So fix this by passing a transaction handle to the trace event instead of
fs_info. This will also allow later for the trace event to dump other
useful information about the transaction.

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 0fd596e2c65b84b6dc681d81cc9f7629ec466394..b98cb7b0630a4f8e03b62d987fab5ad821b71daa 100644 (file)
@@ -2114,7 +2114,7 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans, int err)
        btrfs_put_transaction(cur_trans);
        btrfs_put_transaction(cur_trans);
 
-       trace_btrfs_transaction_commit(fs_info);
+       trace_btrfs_transaction_commit(trans);
 
        if (current->journal_info == trans)
                current->journal_info = NULL;
@@ -2632,7 +2632,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
        if (trans->type & __TRANS_FREEZABLE)
                sb_end_intwrite(fs_info->sb);
 
-       trace_btrfs_transaction_commit(fs_info);
+       trace_btrfs_transaction_commit(trans);
 
        btrfs_scrub_continue(fs_info);
 
index a8cdc50677a5f6f92169bba3d199b63479305f5a..4cec2f8838f59cdbbe947f06c19cd803739218b2 100644 (file)
@@ -31,6 +31,7 @@ struct btrfs_space_info;
 struct btrfs_raid_bio;
 struct raid56_bio_trace_info;
 struct find_free_extent_ctl;
+struct btrfs_trans_handle;
 
 #define show_ref_type(type)                                            \
        __print_symbolic(type,                                          \
@@ -182,16 +183,16 @@ FLUSH_STATES
 
 TRACE_EVENT(btrfs_transaction_commit,
 
-       TP_PROTO(const struct btrfs_fs_info *fs_info),
+       TP_PROTO(const struct btrfs_trans_handle *trans),
 
-       TP_ARGS(fs_info),
+       TP_ARGS(trans),
 
        TP_STRUCT__entry_btrfs(
                __field(        u64,  generation                )
        ),
 
-       TP_fast_assign_btrfs(fs_info,
-               __entry->generation     = fs_info->generation;
+       TP_fast_assign_btrfs(trans->fs_info,
+               __entry->generation     = trans->transid;
        ),
 
        TP_printk_btrfs("gen=%llu", __entry->generation)