]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: lift a xfs_valid_startblock into xfs_bmapi_allocate
authorChristoph Hellwig <hch@lst.de>
Mon, 29 Jul 2024 23:22:55 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:04 +0000 (17:01 -0700)
Source kernel commit: 04c609e6e5066294b60329420d3711e990c47abf

xfs_bmapi_convert_delalloc has a xfs_valid_startblock check on the block
allocated by xfs_bmapi_allocate.  Lift it into xfs_bmapi_allocate as
we should assert the same for xfs_bmapi_write.

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>
libxfs/xfs_bmap.c

index f236e40d1c7db3125ebb384cbcbc9e5ffc7e6919..5b1c305ec26714ba5ba45a3661034f9ac05d3109 100644 (file)
@@ -4215,6 +4215,11 @@ xfs_bmapi_allocate(
        if (bma->blkno == NULLFSBLOCK)
                return -ENOSPC;
 
+       if (WARN_ON_ONCE(!xfs_valid_startblock(bma->ip, bma->blkno))) {
+               xfs_bmap_mark_sick(bma->ip, whichfork);
+               return -EFSCORRUPTED;
+       }
+
        if (bma->flags & XFS_BMAPI_ZERO) {
                error = xfs_zero_extent(bma->ip, bma->blkno, bma->length);
                if (error)
@@ -4707,12 +4712,6 @@ xfs_bmapi_convert_one_delalloc(
        if (error)
                goto out_finish;
 
-       if (WARN_ON_ONCE(!xfs_valid_startblock(ip, bma.got.br_startblock))) {
-               xfs_bmap_mark_sick(ip, whichfork);
-               error = -EFSCORRUPTED;
-               goto out_finish;
-       }
-
        XFS_STATS_ADD(mp, xs_xstrat_bytes, XFS_FSB_TO_B(mp, bma.length));
        XFS_STATS_INC(mp, xs_xstrat_quick);