Re: [PATCH 4/5] xfs: report the correct read/write dio alignment for reflinked inodes

Darrick J. Wong
2025-01-08T17:20:27Z

On Wed, Jan 08, 2025 at 04:18:27PM +0100, Christoph Hellwig wrote:
> On Wed, Jan 08, 2025 at 10:13:02AM +0000, John Garry wrote:
> > On 08/01/2025 08:55, Christoph Hellwig wrote:
> >> @@ -580,9 +580,24 @@ xfs_report_dioalign(
> >> struct xfs_buftarg *target = xfs_inode_buftarg(ip);
> >> struct block_device *bdev = target->bt_bdev;
> >> - stat->result_mask |= STATX_DIOALIGN;
> >> + stat->result_mask |= STATX_DIOALIGN | STATX_DIO_READ_ALIGN;
> >
> > BTW, it would be a crappy userspace which can't handle fields which it did
> > not ask for, e.g. asked for STATX_DIOALIGN, but got STATX_DIOALIGN and
> > STATX_DIO_READ_ALIGN
>
> Well, the space is marked for extension. I don't think there ever
> was a requirement only fields asked for are reported, but if that
> feels safer I could switch to that.

From the "Returned information" section of the statx manpage:

"It should be noted that the kernel may return fields that weren't
requested and may fail to return fields that were requested, depending
on what the backing filesystem supports. (Fields that are given values
despite being unrequested can just be ignored.) In either case,
stx_mask will not be equal mask.

<snip>

"A filesystem may also fill in fields that the caller didn't ask for if
it has values for them available and the information is available at no
extra cost. If this happens, the corresponding bits will be set in
stx_mask."

In other words, the kernel is allowed to return information/flags that
weren't requested, and userspace can ignore it.

--D