Commit 0d79781a authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: improve the code that checks recovered refcount intent items

The code that validates recovered refcount 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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent ed64f834
...@@ -423,27 +423,26 @@ xfs_cui_validate_phys( ...@@ -423,27 +423,26 @@ xfs_cui_validate_phys(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_phys_extent *refc) struct xfs_phys_extent *refc)
{ {
xfs_fsblock_t startblock_fsb; if (refc->pe_flags & ~XFS_REFCOUNT_EXTENT_FLAGS)
bool op_ok; return false;
startblock_fsb = XFS_BB_TO_FSB(mp,
XFS_FSB_TO_DADDR(mp, refc->pe_startblock));
switch (refc->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK) { switch (refc->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK) {
case XFS_REFCOUNT_INCREASE: case XFS_REFCOUNT_INCREASE:
case XFS_REFCOUNT_DECREASE: case XFS_REFCOUNT_DECREASE:
case XFS_REFCOUNT_ALLOC_COW: case XFS_REFCOUNT_ALLOC_COW:
case XFS_REFCOUNT_FREE_COW: case XFS_REFCOUNT_FREE_COW:
op_ok = true;
break; break;
default: default:
op_ok = false; return false;
break;
} }
if (!op_ok || startblock_fsb == 0 ||
refc->pe_len == 0 || if (refc->pe_startblock + refc->pe_len <= refc->pe_startblock)
startblock_fsb >= mp->m_sb.sb_dblocks || return false;
refc->pe_len >= mp->m_sb.sb_agblocks ||
(refc->pe_flags & ~XFS_REFCOUNT_EXTENT_FLAGS)) if (!xfs_verify_fsbno(mp, refc->pe_startblock))
return false;
if (!xfs_verify_fsbno(mp, refc->pe_startblock + refc->pe_len - 1))
return false; return false;
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment