Re: [PATCH 04/43] xfs: skip always_cow inodes in xfs_reflink_trim_around_shared

Darrick J. Wong
2025-02-06T20:13:52Z

On Thu, Feb 06, 2025 at 07:44:20AM +0100, Christoph Hellwig wrote:
> xfs_reflink_trim_around_shared tries to find shared blocks in the
> refcount btree. Always_cow inodes don't have that tree, so don't
> bother.
>
> For the existing always_cow code this is a minor optimization. For
> the upcoming zoned code that can do COW without the rtreflink code it
> avoids triggering a NULL pointer dereference.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Hmm. So this is to support doing COW on non-reflink zoned filesystems?
How then do we protect the refcount intent log items from being replayed
on an oler kernel? Are they effectively protected by the zoned feature
bit XFS_SB_FEAT_INCOMPAT_ZONED?

If so then
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
> fs/xfs/xfs_reflink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 59f7fc16eb80..3e778e077d09 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -235,7 +235,7 @@ xfs_reflink_trim_around_shared(
> int error = 0;
>
> /* Holes, unwritten, and delalloc extents cannot be shared */
> - if (!xfs_is_cow_inode(ip) || !xfs_bmap_is_written_extent(irec)) {
> + if (!xfs_is_reflink_inode(ip) || !xfs_bmap_is_written_extent(irec)) {
> *shared = false;
> return 0;
> }
> --
> 2.45.2
>
>