Re: [PATCH v8 05/15] xfs: ignore HW which cannot atomic write a single block

John Garry
2025-04-23T07:16:16Z

On 23/04/2025 01:38, Darrick J. Wong wrote:
>>
>> + /*
>> + * Set atomic write unit max for mp. Ignore devices which cannot atomic
>> + * a single block, as they would be uncommon and more difficult to
>> + * support.
>> + */
>> + if (mp->m_ddev_targp->bt_bdev_awu_min <= mp->m_sb.sb_blocksize &&
>> + mp->m_ddev_targp->bt_bdev_awu_max >= mp->m_sb.sb_blocksize)
>> + mp->m_dd_awu_hw_max = mp->m_ddev_targp->bt_bdev_awu_max;
> If we don't want to use the device's atomic write capabilities due to
> fsblock alignment problems, why not just zero out bt_bdev_awu_min/max?
> That would cut down on the number of "awu" variables around the
> codebase.

Sure, I did consider this, but thought it a bit unpleasant to zero out
structure members like this.

Ideally we could have not set them in the first place, but need to know
the blocksize when xfs_alloc_buftarg() is called, but it is not yet set
for mp/sb. Is there any neat way to know the blocksize when
xfs_alloc_buftarg() is called?

>
> /*
> * Ignore hardware atomic writes if the device can't handle a single
> * fsblock for us. Most devices set the min_awu to the LBA size, but
> * the spec allows for a functionality gap.
> */
> static void

You would call this around the same point in xfs_mountfs(), right?

> xfs_buftarg_reconcile_awu(
> struct xfs_buftarg *btp)
> {
> struct xfs_mount *mp = btp->bt_mount;
>
> if (btp->bt_bdev_awu_min > mp->m_sb.sb_blocksize ||
> btp->bt_bdev_awu_max < mp->m_sb.sb_blocksize) {
> btp->bt_bdev_awu_min = 0;
> btp->bt_bdev_awu_max = 0;
> }
> }
>
> xfs_buftarg_reconcile_awu(mp->m_ddev_targp);
> if (mp->m_rtdev_targp)
> xfs_buftarg_reconcile_awu(mp->m_rtdev_targp);
>
> Hrm?

Cheers,
John