From: Christoph Hellwig Date: Wed, 30 Apr 2025 21:26:50 +0000 (-0700) Subject: xfs: remove a racy if_bytes check in xfs_reflink_end_cow_extent X-Git-Tag: v6.1.138~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2edfd2c87c56a231f1c617703511c47065a3f39b;p=thirdparty%2Fkernel%2Fstable.git xfs: remove a racy if_bytes check in xfs_reflink_end_cow_extent [ Upstream commit 86de848403abda05bf9c16dcdb6bef65a8d88c41 ] Accessing if_bytes without the ilock is racy. Remove the initial if_bytes == 0 check in xfs_reflink_end_cow_extent and let ext_iext_lookup_extent fail for this case after we've taken the ilock. Signed-off-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Leah Rumancik Acked-by: "Darrick J. Wong" Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 0405226fb74c8..d539487eaf1a7 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -718,12 +718,6 @@ xfs_reflink_end_cow_extent( int nmaps; int error; - /* No COW extents? That's easy! */ - if (ifp->if_bytes == 0) { - *offset_fsb = end_fsb; - return 0; - } - resblks = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, XFS_TRANS_RESERVE, &tp);