From fce74e98639a779327998695fcae1abe163ba96e Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Mon, 6 May 2019 18:00:28 -0400 Subject: [PATCH] xfs: split up allocation btree verifier Source kernel commit: 27df4f5045fc68766980c4dfba5ffc9ad1f71ebb Similar to the inode btree verifier, the same allocation btree verifier structure is shared between the by-bno (bnobt) and by-size (cntbt) btrees. This prevents the ability to distinguish magic values between them. Separate the verifier into two, one for each tree, and assign them appropriately. No functional changes. Signed-off-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- db/type.c | 8 ++++---- libxfs/xfs_ag.c | 4 ++-- libxfs/xfs_alloc_btree.c | 14 ++++++++++---- libxfs/xfs_shared.h | 3 ++- mkfs/xfs_mkfs.c | 4 ++-- repair/phase5.c | 3 ++- repair/scan.c | 4 ++-- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/db/type.c b/db/type.c index 7707f9dd4..3cb1e868b 100644 --- a/db/type.c +++ b/db/type.c @@ -82,9 +82,9 @@ static const typ_t __typtab_crc[] = { { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld, &xfs_bmbt_buf_ops, XFS_BTREE_LBLOCK_CRC_OFF }, { TYP_BNOBT, "bnobt", handle_struct, bnobt_crc_hfld, - &xfs_allocbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, + &xfs_bnobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_CNTBT, "cntbt", handle_struct, cntbt_crc_hfld, - &xfs_allocbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, + &xfs_cntbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_RMAPBT, "rmapbt", handle_struct, rmapbt_crc_hfld, &xfs_rmapbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_REFCBT, "refcntbt", handle_struct, refcbt_crc_hfld, @@ -126,9 +126,9 @@ static const typ_t __typtab_spcrc[] = { { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld, &xfs_bmbt_buf_ops, XFS_BTREE_LBLOCK_CRC_OFF }, { TYP_BNOBT, "bnobt", handle_struct, bnobt_crc_hfld, - &xfs_allocbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, + &xfs_bnobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_CNTBT, "cntbt", handle_struct, cntbt_crc_hfld, - &xfs_allocbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, + &xfs_cntbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_RMAPBT, "rmapbt", handle_struct, rmapbt_crc_hfld, &xfs_rmapbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_REFCBT, "refcntbt", handle_struct, refcbt_crc_hfld, diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 763e2fc4c..014e2ada5 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -340,14 +340,14 @@ xfs_ag_init_headers( { /* BNO root block */ .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_BNO_BLOCK(mp)), .numblks = BTOBB(mp->m_sb.sb_blocksize), - .ops = &xfs_allocbt_buf_ops, + .ops = &xfs_bnobt_buf_ops, .work = &xfs_bnoroot_init, .need_init = true }, { /* CNT root block */ .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_CNT_BLOCK(mp)), .numblks = BTOBB(mp->m_sb.sb_blocksize), - .ops = &xfs_allocbt_buf_ops, + .ops = &xfs_cntbt_buf_ops, .work = &xfs_cntroot_init, .need_init = true }, diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 87aeba8c4..30e64cc1e 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -375,13 +375,19 @@ xfs_allocbt_write_verify( } -const struct xfs_buf_ops xfs_allocbt_buf_ops = { - .name = "xfs_allocbt", +const struct xfs_buf_ops xfs_bnobt_buf_ops = { + .name = "xfs_bnobt", .verify_read = xfs_allocbt_read_verify, .verify_write = xfs_allocbt_write_verify, .verify_struct = xfs_allocbt_verify, }; +const struct xfs_buf_ops xfs_cntbt_buf_ops = { + .name = "xfs_cntbt", + .verify_read = xfs_allocbt_read_verify, + .verify_write = xfs_allocbt_write_verify, + .verify_struct = xfs_allocbt_verify, +}; STATIC int xfs_bnobt_keys_inorder( @@ -446,7 +452,7 @@ static const struct xfs_btree_ops xfs_bnobt_ops = { .init_rec_from_cur = xfs_allocbt_init_rec_from_cur, .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur, .key_diff = xfs_bnobt_key_diff, - .buf_ops = &xfs_allocbt_buf_ops, + .buf_ops = &xfs_bnobt_buf_ops, .diff_two_keys = xfs_bnobt_diff_two_keys, .keys_inorder = xfs_bnobt_keys_inorder, .recs_inorder = xfs_bnobt_recs_inorder, @@ -468,7 +474,7 @@ static const struct xfs_btree_ops xfs_cntbt_ops = { .init_rec_from_cur = xfs_allocbt_init_rec_from_cur, .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur, .key_diff = xfs_cntbt_key_diff, - .buf_ops = &xfs_allocbt_buf_ops, + .buf_ops = &xfs_cntbt_buf_ops, .diff_two_keys = xfs_cntbt_diff_two_keys, .keys_inorder = xfs_cntbt_keys_inorder, .recs_inorder = xfs_cntbt_recs_inorder, diff --git a/libxfs/xfs_shared.h b/libxfs/xfs_shared.h index 9855f4d2f..4e909791a 100644 --- a/libxfs/xfs_shared.h +++ b/libxfs/xfs_shared.h @@ -25,7 +25,8 @@ extern const struct xfs_buf_ops xfs_agf_buf_ops; extern const struct xfs_buf_ops xfs_agi_buf_ops; extern const struct xfs_buf_ops xfs_agf_buf_ops; extern const struct xfs_buf_ops xfs_agfl_buf_ops; -extern const struct xfs_buf_ops xfs_allocbt_buf_ops; +extern const struct xfs_buf_ops xfs_bnobt_buf_ops; +extern const struct xfs_buf_ops xfs_cntbt_buf_ops; extern const struct xfs_buf_ops xfs_rmapbt_buf_ops; extern const struct xfs_buf_ops xfs_refcountbt_buf_ops; extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops; diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 7229adfa7..091066485 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3556,7 +3556,7 @@ initialise_ag_headers( buf = libxfs_getbuf(mp->m_ddev_targp, XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_allocbt_buf_ops; + buf->b_ops = &xfs_bnobt_buf_ops; block = XFS_BUF_TO_BLOCK(buf); memset(block, 0, cfg->blocksize); libxfs_btree_init_block(mp, buf, XFS_BTNUM_BNO, 0, 1, agno, 0); @@ -3608,7 +3608,7 @@ initialise_ag_headers( buf = libxfs_getbuf(mp->m_ddev_targp, XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_allocbt_buf_ops; + buf->b_ops = &xfs_cntbt_buf_ops; block = XFS_BUF_TO_BLOCK(buf); memset(block, 0, cfg->blocksize); libxfs_btree_init_block(mp, buf, XFS_BTNUM_CNT, 0, 1, agno, 0); diff --git a/repair/phase5.c b/repair/phase5.c index 16472a249..0f6a83953 100644 --- a/repair/phase5.c +++ b/repair/phase5.c @@ -622,8 +622,9 @@ btnum_to_ops( { switch (btnum) { case XFS_BTNUM_BNO: + return &xfs_bnobt_buf_ops; case XFS_BTNUM_CNT: - return &xfs_allocbt_buf_ops; + return &xfs_cntbt_buf_ops; case XFS_BTNUM_INO: return &xfs_inobt_buf_ops; case XFS_BTNUM_FINO: diff --git a/repair/scan.c b/repair/scan.c index 7c410f5af..0290856e9 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -2178,7 +2178,7 @@ validate_agf( : XFS_ABTB_MAGIC; scan_sbtree(bno, be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), agno, 0, scan_allocbt, 1, magic, agcnts, - &xfs_allocbt_buf_ops); + &xfs_bnobt_buf_ops); } else { do_warn(_("bad agbno %u for btbno root, agno %d\n"), bno, agno); @@ -2190,7 +2190,7 @@ validate_agf( : XFS_ABTC_MAGIC; scan_sbtree(bno, be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), agno, 0, scan_allocbt, 1, magic, agcnts, - &xfs_allocbt_buf_ops); + &xfs_cntbt_buf_ops); } else { do_warn(_("bad agbno %u for btbcnt root, agno %d\n"), bno, agno); -- 2.47.2