Re: [BUG] xfs: Assertion failed in xfs_iwalk_args triggered by XFS_IOC_INUMBERS

From: Darrick J. Wong
Date: Tue Jul 22 2025 - 14:35:46 EST


On Sun, Jul 20, 2025 at 11:34:06PM -0700, Christoph Hellwig wrote:
> The patch below should fix the issue. But I wonder if we should split
> the flags a bit better to make things more obvious.

We did in [1], but did you have something else in mind?

[1] https://lore.kernel.org/linux-xfs/20220321051750.400056-18-chandan.babu@xxxxxxxxxx/

> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index c8c9b8d8309f..302efe54e2af 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -457,7 +457,8 @@ xfs_inumbers(
> * locking abilities to detect cycles in the inobt without deadlocking.
> */
> tp = xfs_trans_alloc_empty(breq->mp);
> - error = xfs_inobt_walk(breq->mp, tp, breq->startino, breq->flags,
> + error = xfs_inobt_walk(breq->mp, tp, breq->startino,
> + breq->flags & XFS_IBULK_SAME_AG,

That's correct -- the only IBULK flag with meaning for xfs_inobt_walk is
SAME_AG because the others affect bulkstat output.

But it might be clearer to make this explicit the same way that
xfs_bulkstat does:

unsigned int iwalk_flags = 0;

if (breq->flags & XFS_IBULK_SAME_AG)
iwalk_flags |= XFS_IWALK_SAME_AG;

error = xfs_inobt_walk(..., iwalk_flags, ...);

This probably should have been included in [1] so:

Cc: <stable@xxxxxxxxxxxxxxx> # v5.19
Fixes: 5b35d922c52798 ("xfs: Decouple XFS_IBULK flags from XFS_IWALK flags")

--D