]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: tracepoints: add trace event for log_conflicting_inodes()
authorFilipe Manana <fdmanana@suse.com>
Thu, 7 May 2026 12:03:13 +0000 (13:03 +0100)
committerFilipe Manana <fdmanana@suse.com>
Tue, 9 Jun 2026 10:49:23 +0000 (11:49 +0100)
log_conflicting_inodes() is an important step called during a fsync, as
well as during rename and link operations on inodes that were previously
logged. Add trace events for when entering and exiting that function.

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/tree-log.c
include/trace/events/btrfs.h

index 63553d72ff1ab37d3245f7e6250fbecf306b0dd5..f91924372494fc7e831d54060213dcfed7228105 100644 (file)
@@ -6261,7 +6261,15 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
        if (ctx->logging_conflict_inodes)
                return 0;
 
+       /*
+        * Avoid any work if no conflicting inodes and emitting the trace event
+        * which only adds noise and it's useless if there are no inodes.
+        */
+       if (list_empty(&ctx->conflict_inodes))
+               return 0;
+
        ctx->logging_conflict_inodes = true;
+       trace_btrfs_log_conflicting_inodes_enter(trans, ctx);
 
        /*
         * New conflicting inodes may be found and added to the list while we
@@ -6355,6 +6363,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
        ctx->logging_conflict_inodes = false;
        if (ret)
                free_conflicting_inodes(ctx);
+       trace_btrfs_log_conflicting_inodes_exit(trans, ctx, ret);
 
        return ret;
 }
index ad18b09fb3cdbaf92be5b2e35070d38a4b46b43a..2eff817026a4c2de87bb04780844e1d76e87e19d 100644 (file)
@@ -1294,6 +1294,59 @@ TRACE_EVENT(btrfs_add_conflicting_inode_exit,
                        __entry->conflict_ino_parent, __entry->ret)
 );
 
+TRACE_EVENT(btrfs_log_conflicting_inodes_enter,
+
+       TP_PROTO(const struct btrfs_trans_handle *trans,
+                const struct btrfs_log_ctx *ctx),
+
+       TP_ARGS(trans, ctx),
+
+       TP_STRUCT__entry_btrfs(
+               __field(        u64,            root_objectid           )
+               __field(        u64,            transid                 )
+               __field(        u64,            ctx_ino                 )
+       ),
+
+       TP_fast_assign(
+               TP_fast_assign_fsid(trans->fs_info);
+               __entry->root_objectid          = btrfs_root_id(ctx->inode->root);
+               __entry->transid                = trans->transid;
+               __entry->ctx_ino                = btrfs_ino(ctx->inode);
+       ),
+
+       TP_printk_btrfs("root=%llu(%s) transid=%llu ctx_ino=%llu",
+                       show_root_type(__entry->root_objectid), __entry->transid,
+                       __entry->ctx_ino)
+);
+
+TRACE_EVENT(btrfs_log_conflicting_inodes_exit,
+
+       TP_PROTO(const struct btrfs_trans_handle *trans,
+                const struct btrfs_log_ctx *ctx,
+                int ret),
+
+       TP_ARGS(trans, ctx, ret),
+
+       TP_STRUCT__entry_btrfs(
+               __field(        u64,            root_objectid           )
+               __field(        u64,            transid                 )
+               __field(        u64,            ctx_ino                 )
+               __field(        int,            ret                     )
+       ),
+
+       TP_fast_assign(
+               TP_fast_assign_fsid(trans->fs_info);
+               __entry->root_objectid          = btrfs_root_id(ctx->inode->root);
+               __entry->transid                = trans->transid;
+               __entry->ctx_ino                = btrfs_ino(ctx->inode);
+               __entry->ret                    = ret;
+       ),
+
+       TP_printk_btrfs("root=%llu(%s) transid=%llu ctx_ino=%llu ret=%d",
+                       show_root_type(__entry->root_objectid), __entry->transid,
+                       __entry->ctx_ino, __entry->ret)
+);
+
 TRACE_EVENT(btrfs_sync_fs,
 
        TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),