Skip to content

Commit 04c609e

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: lift a xfs_valid_startblock into xfs_bmapi_allocate
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 <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent b11ed35 commit 04c609e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4221,6 +4221,11 @@ xfs_bmapi_allocate(
42214221
if (bma->blkno == NULLFSBLOCK)
42224222
return -ENOSPC;
42234223

4224+
if (WARN_ON_ONCE(!xfs_valid_startblock(bma->ip, bma->blkno))) {
4225+
xfs_bmap_mark_sick(bma->ip, whichfork);
4226+
return -EFSCORRUPTED;
4227+
}
4228+
42244229
if (bma->flags & XFS_BMAPI_ZERO) {
42254230
error = xfs_zero_extent(bma->ip, bma->blkno, bma->length);
42264231
if (error)
@@ -4713,12 +4718,6 @@ xfs_bmapi_convert_one_delalloc(
47134718
if (error)
47144719
goto out_finish;
47154720

4716-
if (WARN_ON_ONCE(!xfs_valid_startblock(ip, bma.got.br_startblock))) {
4717-
xfs_bmap_mark_sick(ip, whichfork);
4718-
error = -EFSCORRUPTED;
4719-
goto out_finish;
4720-
}
4721-
47224721
XFS_STATS_ADD(mp, xs_xstrat_bytes, XFS_FSB_TO_B(mp, bma.length));
47234722
XFS_STATS_INC(mp, xs_xstrat_quick);
47244723

0 commit comments

Comments
 (0)