summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-10-25 17:16:16 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2020-10-26 18:32:35 -0700
commit9a9d4c9e55072c8188537e18ba3e0888546e534e (patch)
treec854cfba131d38920a17ccaa35c87f62b6107c08
parent63bb34a171cd87759f17d37cac7f6a178ab23d63 (diff)
xfs: improve the code that checks recovered extent-free intent items
The code that validates recovered extent-free intent items is kind of a mess -- it doesn't use the standard xfs type validators, and it doesn't check for things that it should. Fix the validator function to use the standard validation helpers and look for more types of obvious errors. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/xfs/xfs_extfree_item.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index efafa311b2b6..3226714572b2 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -582,14 +582,14 @@ xfs_efi_validate_ext(
struct xfs_mount *mp,
struct xfs_extent *extp)
{
- xfs_fsblock_t startblock_fsb;
-
- startblock_fsb = XFS_BB_TO_FSB(mp,
- XFS_FSB_TO_DADDR(mp, extp->ext_start));
- if (startblock_fsb == 0 ||
- extp->ext_len == 0 ||
- startblock_fsb >= mp->m_sb.sb_dblocks ||
- extp->ext_len >= mp->m_sb.sb_agblocks)
+ xfs_fsblock_t end;
+
+ if (extp->ext_start + extp->ext_len <= extp->ext_start)
+ return false;
+
+ end = extp->ext_start + extp->ext_len - 1;
+ if (!xfs_verify_fsbno(mp, extp->ext_start) ||
+ !xfs_verify_fsbno(mp, end))
return false;
return true;