Re: [PATCH v2 07/13] xfs: Introduce FORCEALIGN inode flag

Dave Chinner
2024-07-11T23:33:37Z

On Thu, Jul 11, 2024 at 08:17:26AM +0100, John Garry wrote:
> On 11/07/2024 03:59, Darrick J. Wong wrote:
> > On Fri, Jul 05, 2024 at 04:24:44PM +0000, John Garry wrote:
> > > +/* Validate the forcealign inode flag */
> > > +xfs_failaddr_t
> > > +xfs_inode_validate_forcealign(
> > > + struct xfs_mount *mp,
> > > + uint32_t extsize,
> > > + uint32_t cowextsize,
> > > + uint16_t mode,
> > > + uint16_t flags,
> > > + uint64_t flags2)
> > > +{
> > > + bool rt = flags & XFS_DIFLAG_REALTIME;
> > > +
> > > + /* superblock rocompat feature flag */
> > > + if (!xfs_has_forcealign(mp))
> > > + return __this_address;
> > > +
> > > + /* Only regular files and directories */
> > > + if (!S_ISDIR(mode) && !S_ISREG(mode))
> > > + return __this_address;
> > > +
> > > + /* We require EXTSIZE or EXTSZINHERIT */
> > > + if (!(flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT)))
> > > + return __this_address;
> > > +
> > > + /* We require a non-zero extsize */
> > > + if (!extsize)
> > > + return __this_address;
> > > +
> > > + /* Reflink'ed disallowed */
> > > + if (flags2 & XFS_DIFLAG2_REFLINK)
> > > + return __this_address;
> >
> > Hmm. If we don't support reflink + forcealign ATM, then shouldn't the
> > superblock verifier or xfs_fs_fill_super fail the mount so that old
> > kernels won't abruptly emit EFSCORRUPTED errors if a future kernel adds
> > support for forcealign'd cow and starts writing out files with both
> > iflags set?
>
> Fine, I see that we do something similar now for rtdev.
>
> However why even have the rt inode check, below, to disallow for reflink cp
> for rt inode (if we can't even mount with rt and reflink together)?

In theory we should be able to have reflink enabled on a filesystem
with an RT device right now - we just can't share extents on a rt
inode. Extent sharing should till work just fine on non-rt files,
but the overall config is disallowed at mount time because we
haven't ever tested that configuration. I'm not sure that mkfs.xfs
even allows you to make a filesystem of that config....

That said, it's good practice for the ->remap_file_range()
implementation (and anything else using shared extents) to be
explicitly checking for and preventing extent sharing on RT inodes.
THose operations don't support that config, and so should catch any
attempt that is made to do so and error out. It doesn't matter that
we have mount time checks, the checks in the extent sharing code
explicitly document that it doesn't support RT inodes right now...

-Dave.

--
Dave Chinner
david@fromorbit.com