]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: split up allocation btree verifier
authorBrian Foster <bfoster@redhat.com>
Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)
committerEric Sandeen <sandeen@redhat.com>
Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)
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 <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/type.c
libxfs/xfs_ag.c
libxfs/xfs_alloc_btree.c
libxfs/xfs_shared.h
mkfs/xfs_mkfs.c
repair/phase5.c
repair/scan.c

index 7707f9dd453efd1be6847805f21a43ab98da9bff..3cb1e868b6c6a823858957106b7f224618800210 100644 (file)
--- 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,
index 763e2fc4c21212ad615efd9654981e8accc393b3..014e2ada5fed1b0e6f4c75e53d3eed51b0a3ee46 100644 (file)
@@ -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
        },
index 87aeba8c433446ea1b3c679f9218dbbd85c60a43..30e64cc1ea245ae7e433d6cab5faa435d58a3773 100644 (file)
@@ -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,
index 9855f4d2f98fe4dcea5c36b2e3fd403c5235f9f3..4e909791aeac48a9ca82c6eb5564ca8e2cc7cadc 100644 (file)
@@ -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;
index 7229adfa79899874addcbafebb1d9aa0bb1015cd..091066485e37d80d918ce28983e7acba9b5bebee 100644 (file)
@@ -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);
index 16472a249495159d2342f00c0ed8a89a14246234..0f6a83953007261d0ec32d30272daf1ade456a9c 100644 (file)
@@ -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:
index 7c410f5af3a742ca39bfdcfa9e41bf06d09775c6..0290856e9a5c23e47dc9bd57e307eb6c2016f879 100644 (file)
@@ -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);