Even though fsverity has traces, debugging issues with varying block
sizes could be a bit less transparent without read/write traces.

Signed-off-by: Andrey Albershteyn <[email protected]>
Reviewed-by: "Darrick J. Wong" <[email protected]>
---
 fs/xfs/xfs_fsverity.c |  6 ++++++
 fs/xfs/xfs_trace.h    | 46 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c
index ecc66ee8bac5..6db8113da52f 100644
--- a/fs/xfs/xfs_fsverity.c
+++ b/fs/xfs/xfs_fsverity.c
@@ -64,6 +64,8 @@ xfs_fsverity_get_descriptor(
        uint32_t                blocksize = i_blocksize(VFS_I(ip));
        xfs_fileoff_t           last_block_offset;
 
+       trace_xfs_fsverity_get_descriptor(ip);
+
        ASSERT(inode->i_flags & S_VERITY);
        error = xfs_bmap_last_extent(NULL, ip, XFS_DATA_FORK, &rec, &is_empty);
        if (error)
@@ -377,6 +379,7 @@ xfs_fsverity_read_merkle(
        pgoff_t                 index)
 {
        index += xfs_fsverity_metadata_offset(XFS_I(inode)) >> PAGE_SHIFT;
+       trace_xfs_fsverity_read_merkle(XFS_I(inode), index, PAGE_SIZE);
 
        return generic_read_merkle_tree_page(inode, index);
 }
@@ -391,6 +394,7 @@ xfs_fsverity_readahead_merkle_tree(
        unsigned long           nr_pages)
 {
        index += xfs_fsverity_metadata_offset(XFS_I(inode)) >> PAGE_SHIFT;
+       trace_xfs_fsverity_read_merkle(XFS_I(inode), index, PAGE_SIZE);
 
        generic_readahead_merkle_tree(inode, index, nr_pages);
 }
@@ -414,6 +418,8 @@ xfs_fsverity_write_merkle(
        const char              *p;
        unsigned int            i;
 
+       trace_xfs_fsverity_write_merkle(XFS_I(inode), position, size);
+
        if (position + size > inode->i_sb->s_maxbytes)
                return -EFBIG;
 
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 5e8190fe2be9..d05f79ec92db 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -6440,6 +6440,52 @@ TRACE_EVENT(xfs_verify_media_error,
                  __entry->error)
 );
 
+TRACE_EVENT(xfs_fsverity_get_descriptor,
+       TP_PROTO(struct xfs_inode *ip),
+       TP_ARGS(ip),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino)
+);
+
+DECLARE_EVENT_CLASS(xfs_fsverity_class,
+       TP_PROTO(struct xfs_inode *ip, u64 pos, size_t length),
+       TP_ARGS(ip, pos, length),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(u64, pos)
+               __field(size_t, length)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+               __entry->pos = pos;
+               __entry->length = length;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx pos 0x%llx length 0x%zx",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __entry->pos,
+                 __entry->length)
+)
+
+#define DEFINE_FSVERITY_EVENT(name) \
+DEFINE_EVENT(xfs_fsverity_class, name, \
+       TP_PROTO(struct xfs_inode *ip, u64 pos, size_t length), \
+       TP_ARGS(ip, pos, length))
+DEFINE_FSVERITY_EVENT(xfs_fsverity_read_merkle);
+DEFINE_FSVERITY_EVENT(xfs_fsverity_write_merkle);
+DEFINE_FSVERITY_EVENT(xfs_fsverity_file_corrupt);
+
 #endif /* _TRACE_XFS_H */
 
 #undef TRACE_INCLUDE_PATH
-- 
2.51.2



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to