btrfs: tracepoints: add trace event for btrfs_log_new_name()

btrfs_log_new_name() is an important function that affects inode logging
and is called during link and rename operations. 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>
This commit is contained in:
Filipe Manana committed 2026-06-09 11:49:25 +01:00
1 parent 4f065ebdf8
commit 8c2e738c61
2 files changed
+71 -2

No files matched your search

+5 -2
View File
@@ -8058,6 +8058,8 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
bool log_pinned = false;
int ret;
trace_btrfs_log_new_name_enter(trans, inode, old_dir, old_dir_index);
/* The inode has a new name (ref/extref), so make sure we log it. */
set_bit(BTRFS_INODE_COPY_EVERYTHING, &inode->runtime_flags);
@@ -8080,7 +8082,7 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
goto out;
} else if (ret == 0) {
if (!old_dir)
return;
goto out;
/*
* If the inode was not logged and we are doing a rename (old_dir is not
* NULL), check if old_dir was logged - if it was not we can return and
@@ -8090,7 +8092,7 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
if (ret < 0)
goto out;
else if (ret == 0)
return;
goto out;
}
ret = 0;
@@ -8189,6 +8191,7 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
btrfs_log_inode_parent(trans, inode, parent, LOG_INODE_EXISTS, &ctx);
ASSERT(list_empty(&ctx.conflict_inodes));
out:
trace_btrfs_log_new_name_exit(trans, inode, old_dir, ret);
/*
* If an error happened mark the log for a full commit because it's not
* consistent and up to date or we couldn't find out if one of the
+66
View File
@@ -1481,6 +1481,72 @@ TRACE_EVENT(btrfs_record_new_subvolume,
__entry->dir)
);
TRACE_EVENT(btrfs_log_new_name_enter,
TP_PROTO(const struct btrfs_trans_handle *trans,
const struct btrfs_inode *inode,
const struct btrfs_inode *old_dir,
u64 old_dir_index),
TP_ARGS(trans, inode, old_dir, old_dir_index),
TP_STRUCT__entry_btrfs(
__field( u64, root_objectid )
__field( u64, transid )
__field( u64, ino )
__field( umode_t, mode )
__field( u64, old_dir_ino )
__field( u64, old_dir_index )
),
TP_fast_assign(
TP_fast_assign_fsid(trans->fs_info);
__entry->root_objectid = btrfs_root_id(inode->root);
__entry->transid = trans->transid;
__entry->ino = btrfs_ino(inode);
__entry->mode = inode->vfs_inode.i_mode;
__entry->old_dir_ino = old_dir ? btrfs_ino(old_dir) : 0;
__entry->old_dir_index = old_dir_index;
),
TP_printk_btrfs("root=%llu(%s) transid=%llu ino=%llu type=%s"
" old_dir=%llu old_dir_index=%llu",
show_root_type(__entry->root_objectid), __entry->transid,
__entry->ino, show_inode_type(__entry->mode),
__entry->old_dir_ino, __entry->old_dir_index)
);
TRACE_EVENT(btrfs_log_new_name_exit,
TP_PROTO(const struct btrfs_trans_handle *trans,
const struct btrfs_inode *inode,
const struct btrfs_inode *old_dir,
int ret),
TP_ARGS(trans, inode, old_dir, ret),
TP_STRUCT__entry_btrfs(
__field( u64, root_objectid )
__field( u64, transid )
__field( u64, ino )
__field( u64, old_dir_ino )
__field( int, ret )
),
TP_fast_assign(
TP_fast_assign_fsid(trans->fs_info);
__entry->root_objectid = btrfs_root_id(inode->root);
__entry->transid = trans->transid;
__entry->ino = btrfs_ino(inode);
__entry->old_dir_ino = old_dir ? btrfs_ino(old_dir) : 0;
__entry->ret = ret;
),
TP_printk_btrfs("root=%llu(%s) transid=%llu ino=%llu old_dir=%llu ret=%d",
show_root_type(__entry->root_objectid), __entry->transid,
__entry->ino, __entry->old_dir_ino, __entry->ret)
);
TRACE_EVENT(btrfs_sync_fs,
TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),