diff mbox series

[11/43] xfs: skip always_cow inodes in xfs_reflink_trim_around_shared

Message ID 20241211085636.1380516-12-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/43] xfs: constify feature checks | expand

Commit Message

Christoph Hellwig Dec. 11, 2024, 8:54 a.m. UTC
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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_reflink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Darrick J. Wong Dec. 12, 2024, 9:38 p.m. UTC | #1
On Wed, Dec 11, 2024 at 09:54:36AM +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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Is this a bug fix?

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
> 
>
Christoph Hellwig Dec. 13, 2024, 5:12 a.m. UTC | #2
On Thu, Dec 12, 2024 at 01:38:57PM -0800, Darrick J. Wong wrote:
> On Wed, Dec 11, 2024 at 09:54:36AM +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.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Is this a bug fix?

For the existing always_cow code it is a minor optimization.  For
the zoned code that can do COW without the rtreflink code it avoids
triggering a NULL pointer dereference.
diff mbox series

Patch

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;
 	}