Re: [PATCH 6/6] xfs: refactor xfs_file_fallocate

Christoph Hellwig
2024-08-29T03:56:31Z

On Thu, Aug 29, 2024 at 01:11:11PM +1000, Dave Chinner wrote:
> > +xfs_falloc_allocate_range(
> > + struct file *file,
> > + int mode,
> > + loff_t offset,
> > + loff_t len)
> > +{
> > + struct inode *inode = file_inode(file);
> > + loff_t new_size = 0;
> > + int error;
> > +
> > + /*
> > + * If always_cow mode we can't use preallocations and thus should not
> > + * create them.
> > + */
> > + if (xfs_is_always_cow_inode(XFS_I(inode)))
> > + return -EOPNOTSUPP;
>
> ... our preallocation operation always returns -EOPNOTSUPP for
> COW mode.
>
> Should the zeroing code also have this COW mode check in it after
> the hole punch has run so we don't do unnecessary prealloc there?

The low-level block allocation helper just returns early without
doing work (move a bit, but not changed in behavior earlier in the
series). So it won't actually do the prealloc.

>
> -Dave.
> --
> Dave Chinner
> david@fromorbit.com
---end quoted text---