Re: [PATCH 07/27] xfs_db: display the realtime rmap btree contents

Christoph Hellwig
2025-02-07T05:16:51Z

On Thu, Feb 06, 2025 at 02:51:33PM -0800, Darrick J. Wong wrote:
> +static int
> +rtrmaproot_rec_count(
> + void *obj,
> + int startoff)
> +{
> + struct xfs_rtrmap_root *block;
> +#ifdef DEBUG
> + struct xfs_dinode *dip = obj;
> +#endif
> +
> + ASSERT(bitoffs(startoff) == 0);
> + ASSERT(obj == iocur_top->data);
> + block = (struct xfs_rtrmap_root *)((char *)obj + byteize(startoff));
> + ASSERT((char *)block == XFS_DFORK_DPTR(dip));

Hmm, wouldn't this be cleaner by turning the logic around:

struct xfs_dinode *dip = obj;
struct xfs_rtrmap_root *block = XFS_DFORK_DPTR(dip);

...

ASSERT(block == obj + byteize(startoff));

Same for the other uses of this pattern.

Otherwise looks good (as good as xfs_db can look like anyway..)