Commit a8f3522c authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: fix endianness issue in xfs_ag_shrink_space

The AGI buffer is in big-endian format, so we must convert the
endianness to CPU format to do any comparisons.

Fixes: 46141dc8 ("xfs: introduce xfs_ag_shrink_space()")
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
parent e53d3aa0
...@@ -779,6 +779,7 @@ xfs_ag_shrink_space( ...@@ -779,6 +779,7 @@ xfs_ag_shrink_space(
struct xfs_buf *agibp, *agfbp; struct xfs_buf *agibp, *agfbp;
struct xfs_agi *agi; struct xfs_agi *agi;
struct xfs_agf *agf; struct xfs_agf *agf;
xfs_agblock_t aglen;
int error, err2; int error, err2;
ASSERT(agno == mp->m_sb.sb_agcount - 1); ASSERT(agno == mp->m_sb.sb_agcount - 1);
...@@ -793,14 +794,14 @@ xfs_ag_shrink_space( ...@@ -793,14 +794,14 @@ xfs_ag_shrink_space(
return error; return error;
agf = agfbp->b_addr; agf = agfbp->b_addr;
aglen = be32_to_cpu(agi->agi_length);
/* some extra paranoid checks before we shrink the ag */ /* some extra paranoid checks before we shrink the ag */
if (XFS_IS_CORRUPT(mp, agf->agf_length != agi->agi_length)) if (XFS_IS_CORRUPT(mp, agf->agf_length != agi->agi_length))
return -EFSCORRUPTED; return -EFSCORRUPTED;
if (delta >= agi->agi_length) if (delta >= aglen)
return -EINVAL; return -EINVAL;
args.fsbno = XFS_AGB_TO_FSB(mp, agno, args.fsbno = XFS_AGB_TO_FSB(mp, agno, aglen - delta);
be32_to_cpu(agi->agi_length) - delta);
/* /*
* Disable perag reservations so it doesn't cause the allocation request * Disable perag reservations so it doesn't cause the allocation request
......
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