Commit 9228d751 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: use buf ops magic to detect btree block type

Now that we encode block magic numbers in all the buffer ops, use that
for block type detection in the ag header repair code instead of
encoding magics directly in the repair code.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 4260baac
...@@ -342,22 +342,18 @@ xrep_agf( ...@@ -342,22 +342,18 @@ xrep_agf(
[XREP_AGF_BNOBT] = { [XREP_AGF_BNOBT] = {
.rmap_owner = XFS_RMAP_OWN_AG, .rmap_owner = XFS_RMAP_OWN_AG,
.buf_ops = &xfs_bnobt_buf_ops, .buf_ops = &xfs_bnobt_buf_ops,
.magic = XFS_ABTB_CRC_MAGIC,
}, },
[XREP_AGF_CNTBT] = { [XREP_AGF_CNTBT] = {
.rmap_owner = XFS_RMAP_OWN_AG, .rmap_owner = XFS_RMAP_OWN_AG,
.buf_ops = &xfs_cntbt_buf_ops, .buf_ops = &xfs_cntbt_buf_ops,
.magic = XFS_ABTC_CRC_MAGIC,
}, },
[XREP_AGF_RMAPBT] = { [XREP_AGF_RMAPBT] = {
.rmap_owner = XFS_RMAP_OWN_AG, .rmap_owner = XFS_RMAP_OWN_AG,
.buf_ops = &xfs_rmapbt_buf_ops, .buf_ops = &xfs_rmapbt_buf_ops,
.magic = XFS_RMAP_CRC_MAGIC,
}, },
[XREP_AGF_REFCOUNTBT] = { [XREP_AGF_REFCOUNTBT] = {
.rmap_owner = XFS_RMAP_OWN_REFC, .rmap_owner = XFS_RMAP_OWN_REFC,
.buf_ops = &xfs_refcountbt_buf_ops, .buf_ops = &xfs_refcountbt_buf_ops,
.magic = XFS_REFC_CRC_MAGIC,
}, },
[XREP_AGF_END] = { [XREP_AGF_END] = {
.buf_ops = NULL, .buf_ops = NULL,
...@@ -875,12 +871,10 @@ xrep_agi( ...@@ -875,12 +871,10 @@ xrep_agi(
[XREP_AGI_INOBT] = { [XREP_AGI_INOBT] = {
.rmap_owner = XFS_RMAP_OWN_INOBT, .rmap_owner = XFS_RMAP_OWN_INOBT,
.buf_ops = &xfs_inobt_buf_ops, .buf_ops = &xfs_inobt_buf_ops,
.magic = XFS_IBT_CRC_MAGIC,
}, },
[XREP_AGI_FINOBT] = { [XREP_AGI_FINOBT] = {
.rmap_owner = XFS_RMAP_OWN_INOBT, .rmap_owner = XFS_RMAP_OWN_INOBT,
.buf_ops = &xfs_finobt_buf_ops, .buf_ops = &xfs_finobt_buf_ops,
.magic = XFS_FIBT_CRC_MAGIC,
}, },
[XREP_AGI_END] = { [XREP_AGI_END] = {
.buf_ops = NULL .buf_ops = NULL
......
...@@ -743,7 +743,8 @@ xrep_findroot_block( ...@@ -743,7 +743,8 @@ xrep_findroot_block(
/* Ensure the block magic matches the btree type we're looking for. */ /* Ensure the block magic matches the btree type we're looking for. */
btblock = XFS_BUF_TO_BLOCK(bp); btblock = XFS_BUF_TO_BLOCK(bp);
if (be32_to_cpu(btblock->bb_magic) != fab->magic) ASSERT(fab->buf_ops->magic[1] != 0);
if (btblock->bb_magic != fab->buf_ops->magic[1])
goto out; goto out;
/* /*
......
...@@ -42,9 +42,6 @@ struct xrep_find_ag_btree { ...@@ -42,9 +42,6 @@ struct xrep_find_ag_btree {
/* in: buffer ops */ /* in: buffer ops */
const struct xfs_buf_ops *buf_ops; const struct xfs_buf_ops *buf_ops;
/* in: magic number of the btree */
uint32_t magic;
/* out: the highest btree block found and the tree height */ /* out: the highest btree block found and the tree height */
xfs_agblock_t root; xfs_agblock_t root;
unsigned int height; unsigned int height;
......
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