ntfs3: add directory index tracepoints

Add ntfs3 tracepoints for directory index operations.

This adds trace events for dir_search_u(), indx_find(),
indx_insert_entry(), and indx_delete_entry() to help observe
directory index lookup, insert, and delete activity.

Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Baolin Liu 2026-08-20 17:05:01 +08:00 committed by Konstantin Komarov
parent 0dca616f46
commit 4feafef66a
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6
3 changed files with 92 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "debug.h"
#include "ntfs.h"
#include "ntfs_fs.h"
#include <trace/events/ntfs3.h>
/* Convert little endian UTF-16 to NLS string. */
int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
@ -284,6 +285,8 @@ struct inode *dir_search_flags(struct inode *dir, const struct cpu_str *uni,
struct inode *inode = NULL;
struct ntfs_fnd *fnd_a = NULL;
trace_ntfs3_dir_search_u(dir, uni ? uni->len : 0);
if (!fnd) {
fnd_a = fnd_get();
if (!fnd_a) {

View File

@ -13,6 +13,7 @@
#include "debug.h"
#include "ntfs.h"
#include "ntfs_fs.h"
#include <trace/events/ntfs3.h>
static const struct INDEX_NAMES {
const __le16 *name;
@ -1181,6 +1182,8 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,
if (!root)
root = indx_get_root(&ni->dir, ni, NULL, NULL);
trace_ntfs3_indx_find(&ni->vfs_inode, indx->type, key_len);
if (!root) {
/* Should not happen. */
return -EINVAL;
@ -2062,6 +2065,9 @@ int indx_insert_entry(struct ntfs_index *indx, struct ntfs_inode *ni,
goto out;
}
trace_ntfs3_indx_insert_entry(&ni->vfs_inode, indx->type,
le16_to_cpu(new_de->key_size), undo);
if (fnd_is_empty(fnd)) {
/*
* Find the spot the tree where we want to
@ -2420,6 +2426,8 @@ int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni,
goto out;
}
trace_ntfs3_indx_delete_entry(&ni->vfs_inode, indx->type, key_len);
/* Locate the entry to remove. */
err = indx_find(indx, ni, root, key, key_len, ctx, &diff, &e, fnd);
if (err)

View File

@ -142,6 +142,87 @@ TRACE_EVENT(ntfs3_create_inode,
__entry->parent_ino, __get_str(name))
);
TRACE_EVENT(ntfs3_dir_search_u,
TP_PROTO(struct inode *dir, unsigned int name_len),
TP_ARGS(dir, name_len),
TP_STRUCT__entry(
__field(unsigned long, dir_ino)
__field(dev_t, dev)
__field(unsigned int, name_len)
),
TP_fast_assign(
__entry->dir_ino = dir->i_ino;
__entry->dev = dir->i_sb->s_dev;
__entry->name_len = name_len;
),
TP_printk("dev=(%d,%d) dir=%lu name_len=%u",
MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->dir_ino, __entry->name_len)
);
TRACE_EVENT(ntfs3_indx_find,
TP_PROTO(struct inode *inode, u8 type, size_t key_len),
TP_ARGS(inode, type, key_len),
TP_STRUCT__entry(
__field(unsigned long, ino)
__field(size_t, key_len)
__field(dev_t, dev)
__field(u8, type)
),
TP_fast_assign(
__entry->ino = inode->i_ino;
__entry->key_len = key_len;
__entry->dev = inode->i_sb->s_dev;
__entry->type = type;
),
TP_printk("dev=(%d,%d) ino=%lu type=%u key_len=%zu",
MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino, __entry->type, __entry->key_len)
);
TRACE_EVENT(ntfs3_indx_insert_entry,
TP_PROTO(struct inode *inode, u8 type, u16 key_len, bool undo),
TP_ARGS(inode, type, key_len, undo),
TP_STRUCT__entry(
__field(unsigned long, ino)
__field(dev_t, dev)
__field(u16, key_len)
__field(u8, type)
__field(bool, undo)
),
TP_fast_assign(
__entry->ino = inode->i_ino;
__entry->dev = inode->i_sb->s_dev;
__entry->key_len = key_len;
__entry->type = type;
__entry->undo = undo;
),
TP_printk("dev=(%d,%d) ino=%lu type=%u key_len=%u undo=%d",
MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino, __entry->type, __entry->key_len,
__entry->undo)
);
TRACE_EVENT(ntfs3_indx_delete_entry,
TP_PROTO(struct inode *inode, u8 type, u32 key_len),
TP_ARGS(inode, type, key_len),
TP_STRUCT__entry(
__field(unsigned long, ino)
__field(u32, key_len)
__field(dev_t, dev)
__field(u8, type)
),
TP_fast_assign(
__entry->ino = inode->i_ino;
__entry->key_len = key_len;
__entry->dev = inode->i_sb->s_dev;
__entry->type = type;
),
TP_printk("dev=(%d,%d) ino=%lu type=%u key_len=%u",
MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino, __entry->type, __entry->key_len)
);
#endif /* _TRACE_NTFS3_H */
#include <trace/define_trace.h>