xfs: split up allocation btree verifier
authorBrian Foster <bfoster@redhat.com>
Thu, 7 Feb 2019 18:45:47 +0000 (10:45 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 12 Feb 2019 00:07:01 +0000 (16:07 -0800)
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>
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_alloc_btree.c
fs/xfs/libxfs/xfs_shared.h
fs/xfs/scrub/agheader_repair.c
fs/xfs/xfs_log_recover.c

index bde67ef3ff436a33e2ea6bc8eba202c853223c0d..1ef8acf35e7d8f33aea4ed771dd8e9aaf23eedd8 100644 (file)
@@ -339,14 +339,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 4e59cc8a280221973279f262e2ee613ba61a5b3d..480d0f52da64851edadd92f44343448c1f47690c 100644 (file)
@@ -377,13 +377,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(
@@ -448,7 +454,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,
@@ -470,7 +476,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 673be3cf7b8d53b52d5109a1fed8ceca4ec43fe5..2799d1531639136b06cdf70019654918fa612d8d 100644 (file)
@@ -341,12 +341,12 @@ xrep_agf(
        struct xrep_find_ag_btree       fab[XREP_AGF_MAX] = {
                [XREP_AGF_BNOBT] = {
                        .rmap_owner = XFS_RMAP_OWN_AG,
-                       .buf_ops = &xfs_allocbt_buf_ops,
+                       .buf_ops = &xfs_bnobt_buf_ops,
                        .magic = XFS_ABTB_CRC_MAGIC,
                },
                [XREP_AGF_CNTBT] = {
                        .rmap_owner = XFS_RMAP_OWN_AG,
-                       .buf_ops = &xfs_allocbt_buf_ops,
+                       .buf_ops = &xfs_cntbt_buf_ops,
                        .magic = XFS_ABTC_CRC_MAGIC,
                },
                [XREP_AGF_RMAPBT] = {
index 228c754bb13736645fa33ab1b539d98d59cc6826..5ad42d598333a4f0b499ab41720caf5a30cf45e3 100644 (file)
@@ -2439,10 +2439,12 @@ xlog_recover_validate_buf_type(
        case XFS_BLFT_BTREE_BUF:
                switch (magic32) {
                case XFS_ABTB_CRC_MAGIC:
-               case XFS_ABTC_CRC_MAGIC:
                case XFS_ABTB_MAGIC:
+                       bp->b_ops = &xfs_bnobt_buf_ops;
+                       break;
+               case XFS_ABTC_CRC_MAGIC:
                case XFS_ABTC_MAGIC:
-                       bp->b_ops = &xfs_allocbt_buf_ops;
+                       bp->b_ops = &xfs_cntbt_buf_ops;
                        break;
                case XFS_IBT_CRC_MAGIC:
                case XFS_IBT_MAGIC: