Re: [PATCH RFC 28/29] xfs: add fsverity traces

Darrick J. Wong
2025-07-29T23:06:31Z

On Mon, Jul 28, 2025 at 10:30:32PM +0200, Andrey Albershteyn wrote:
> Even though fsverity has traces, debugging issues with varying block
> sizes could a bit less transparent without read/write traces.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Looks fine to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
> fs/xfs/xfs_fsverity.c | 8 ++++++++
> fs/xfs/xfs_trace.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
>
> diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c
> index dfe7b0bcd97e..4d3fd00237b1 100644
> --- a/fs/xfs/xfs_fsverity.c
> +++ b/fs/xfs/xfs_fsverity.c
> @@ -70,6 +70,8 @@ xfs_fsverity_get_descriptor(
> };
> int error = 0;
>
> + trace_xfs_fsverity_get_descriptor(ip);
> +
> /*
> * The fact that (returned attribute size) == (provided buf_size) is
> * checked by xfs_attr_copy_value() (returns -ERANGE). No descriptor
> @@ -267,6 +269,8 @@ xfs_fsverity_read_merkle(
> */
> xfs_fsverity_adjust_read(&region);
>
> + trace_xfs_fsverity_read_merkle(XFS_I(inode), region.pos, region.length);
> +
> folio = iomap_read_region(&region);
> if (IS_ERR(folio))
> return ERR_PTR(-EIO);
> @@ -297,6 +301,8 @@ xfs_fsverity_write_merkle(
> .ops = &xfs_buffered_write_iomap_ops,
> };
>
> + trace_xfs_fsverity_write_merkle(XFS_I(inode), region.pos, region.length);
> +
> if (region.pos + region.length > inode->i_sb->s_maxbytes)
> return -EFBIG;
>
> @@ -309,6 +315,8 @@ xfs_fsverity_file_corrupt(
> loff_t pos,
> size_t len)
> {
> + trace_xfs_fsverity_file_corrupt(XFS_I(inode), pos, len);
> +
> xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_DATA);
> }
>
> diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
> index 50034c059e8c..4477d5412e53 100644
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -5979,6 +5979,52 @@ DEFINE_EVENT(xfs_freeblocks_resv_class, name, \
> DEFINE_FREEBLOCKS_RESV_EVENT(xfs_freecounter_reserved);
> DEFINE_FREEBLOCKS_RESV_EVENT(xfs_freecounter_enospc);
>
> +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, unsigned int length),
> + TP_ARGS(ip, pos, length),
> + TP_STRUCT__entry(
> + __field(dev_t, dev)
> + __field(xfs_ino_t, ino)
> + __field(u64, pos)
> + __field(unsigned int, 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 %llx length %x",
> + 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, unsigned int 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.50.0
>
>