xfs: remove a racy if_bytes check in xfs_reflink_end_cow_extent
authorChristoph Hellwig <hch@lst.de>
Thu, 2 May 2024 07:33:54 +0000 (09:33 +0200)
committerChandan Babu R <chandanbabu@kernel.org>
Fri, 3 May 2024 05:50:06 +0000 (11:20 +0530)
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 <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
fs/xfs/xfs_reflink.c

index 93f775c13b6648ec79beb8c9a8f35e39a0396968..520f5ef3743c47dcd5d705d009d78dccaed568fe 100644 (file)
@@ -712,12 +712,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);