summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2019-02-07 13:45:47 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2019-02-11 19:07:01 -0500
commit27df4f5045fc68766980c4dfba5ffc9ad1f71ebb (patch)
treee3a9f981dda44a14ced4f7e7287f2bd70091ab39
parent8473fee340e37711b9ac6a5cc591305ccaaa4778 (diff)
xfs: split up allocation btree verifier
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>
-rw-r--r--fs/xfs/libxfs/xfs_ag.c4
-rw-r--r--fs/xfs/libxfs/xfs_alloc_btree.c14
-rw-r--r--fs/xfs/libxfs/xfs_shared.h3
-rw-r--r--fs/xfs/scrub/agheader_repair.c4
-rw-r--r--fs/xfs/xfs_log_recover.c6
5 files changed, 20 insertions, 11 deletions
diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
index bde67ef3ff43..1ef8acf35e7d 100644
--- a/fs/xfs/libxfs/xfs_ag.c
+++ b/fs/xfs/libxfs/xfs_ag.c
@@ -339,14 +339,14 @@ xfs_ag_init_headers(
339 { /* BNO root block */ 339 { /* BNO root block */
340 .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_BNO_BLOCK(mp)), 340 .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_BNO_BLOCK(mp)),
341 .numblks = BTOBB(mp->m_sb.sb_blocksize), 341 .numblks = BTOBB(mp->m_sb.sb_blocksize),
342 .ops = &xfs_allocbt_buf_ops, 342 .ops = &xfs_bnobt_buf_ops,
343 .work = &xfs_bnoroot_init, 343 .work = &xfs_bnoroot_init,
344 .need_init = true 344 .need_init = true
345 }, 345 },
346 { /* CNT root block */ 346 { /* CNT root block */
347 .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_CNT_BLOCK(mp)), 347 .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_CNT_BLOCK(mp)),
348 .numblks = BTOBB(mp->m_sb.sb_blocksize), 348 .numblks = BTOBB(mp->m_sb.sb_blocksize),
349 .ops = &xfs_allocbt_buf_ops, 349 .ops = &xfs_cntbt_buf_ops,
350 .work = &xfs_cntroot_init, 350 .work = &xfs_cntroot_init,
351 .need_init = true 351 .need_init = true
352 }, 352 },
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 4e59cc8a2802..480d0f52da64 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -377,13 +377,19 @@ xfs_allocbt_write_verify(
377 377
378} 378}
379 379
380const struct xfs_buf_ops xfs_allocbt_buf_ops = { 380const struct xfs_buf_ops xfs_bnobt_buf_ops = {
381 .name = "xfs_allocbt", 381 .name = "xfs_bnobt",
382 .verify_read = xfs_allocbt_read_verify, 382 .verify_read = xfs_allocbt_read_verify,
383 .verify_write = xfs_allocbt_write_verify, 383 .verify_write = xfs_allocbt_write_verify,
384 .verify_struct = xfs_allocbt_verify, 384 .verify_struct = xfs_allocbt_verify,
385}; 385};
386 386
387const struct xfs_buf_ops xfs_cntbt_buf_ops = {
388 .name = "xfs_cntbt",
389 .verify_read = xfs_allocbt_read_verify,
390 .verify_write = xfs_allocbt_write_verify,
391 .verify_struct = xfs_allocbt_verify,
392};
387 393
388STATIC int 394STATIC int
389xfs_bnobt_keys_inorder( 395xfs_bnobt_keys_inorder(
@@ -448,7 +454,7 @@ static const struct xfs_btree_ops xfs_bnobt_ops = {
448 .init_rec_from_cur = xfs_allocbt_init_rec_from_cur, 454 .init_rec_from_cur = xfs_allocbt_init_rec_from_cur,
449 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur, 455 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
450 .key_diff = xfs_bnobt_key_diff, 456 .key_diff = xfs_bnobt_key_diff,
451 .buf_ops = &xfs_allocbt_buf_ops, 457 .buf_ops = &xfs_bnobt_buf_ops,
452 .diff_two_keys = xfs_bnobt_diff_two_keys, 458 .diff_two_keys = xfs_bnobt_diff_two_keys,
453 .keys_inorder = xfs_bnobt_keys_inorder, 459 .keys_inorder = xfs_bnobt_keys_inorder,
454 .recs_inorder = xfs_bnobt_recs_inorder, 460 .recs_inorder = xfs_bnobt_recs_inorder,
@@ -470,7 +476,7 @@ static const struct xfs_btree_ops xfs_cntbt_ops = {
470 .init_rec_from_cur = xfs_allocbt_init_rec_from_cur, 476 .init_rec_from_cur = xfs_allocbt_init_rec_from_cur,
471 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur, 477 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
472 .key_diff = xfs_cntbt_key_diff, 478 .key_diff = xfs_cntbt_key_diff,
473 .buf_ops = &xfs_allocbt_buf_ops, 479 .buf_ops = &xfs_cntbt_buf_ops,
474 .diff_two_keys = xfs_cntbt_diff_two_keys, 480 .diff_two_keys = xfs_cntbt_diff_two_keys,
475 .keys_inorder = xfs_cntbt_keys_inorder, 481 .keys_inorder = xfs_cntbt_keys_inorder,
476 .recs_inorder = xfs_cntbt_recs_inorder, 482 .recs_inorder = xfs_cntbt_recs_inorder,
diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
index 9855f4d2f98f..4e909791aeac 100644
--- a/fs/xfs/libxfs/xfs_shared.h
+++ b/fs/xfs/libxfs/xfs_shared.h
@@ -25,7 +25,8 @@ extern const struct xfs_buf_ops xfs_agf_buf_ops;
25extern const struct xfs_buf_ops xfs_agi_buf_ops; 25extern const struct xfs_buf_ops xfs_agi_buf_ops;
26extern const struct xfs_buf_ops xfs_agf_buf_ops; 26extern const struct xfs_buf_ops xfs_agf_buf_ops;
27extern const struct xfs_buf_ops xfs_agfl_buf_ops; 27extern const struct xfs_buf_ops xfs_agfl_buf_ops;
28extern const struct xfs_buf_ops xfs_allocbt_buf_ops; 28extern const struct xfs_buf_ops xfs_bnobt_buf_ops;
29extern const struct xfs_buf_ops xfs_cntbt_buf_ops;
29extern const struct xfs_buf_ops xfs_rmapbt_buf_ops; 30extern const struct xfs_buf_ops xfs_rmapbt_buf_ops;
30extern const struct xfs_buf_ops xfs_refcountbt_buf_ops; 31extern const struct xfs_buf_ops xfs_refcountbt_buf_ops;
31extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops; 32extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
index 673be3cf7b8d..2799d1531639 100644
--- a/fs/xfs/scrub/agheader_repair.c
+++ b/fs/xfs/scrub/agheader_repair.c
@@ -341,12 +341,12 @@ xrep_agf(
341 struct xrep_find_ag_btree fab[XREP_AGF_MAX] = { 341 struct xrep_find_ag_btree fab[XREP_AGF_MAX] = {
342 [XREP_AGF_BNOBT] = { 342 [XREP_AGF_BNOBT] = {
343 .rmap_owner = XFS_RMAP_OWN_AG, 343 .rmap_owner = XFS_RMAP_OWN_AG,
344 .buf_ops = &xfs_allocbt_buf_ops, 344 .buf_ops = &xfs_bnobt_buf_ops,
345 .magic = XFS_ABTB_CRC_MAGIC, 345 .magic = XFS_ABTB_CRC_MAGIC,
346 }, 346 },
347 [XREP_AGF_CNTBT] = { 347 [XREP_AGF_CNTBT] = {
348 .rmap_owner = XFS_RMAP_OWN_AG, 348 .rmap_owner = XFS_RMAP_OWN_AG,
349 .buf_ops = &xfs_allocbt_buf_ops, 349 .buf_ops = &xfs_cntbt_buf_ops,
350 .magic = XFS_ABTC_CRC_MAGIC, 350 .magic = XFS_ABTC_CRC_MAGIC,
351 }, 351 },
352 [XREP_AGF_RMAPBT] = { 352 [XREP_AGF_RMAPBT] = {
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 228c754bb137..5ad42d598333 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2439,10 +2439,12 @@ xlog_recover_validate_buf_type(
2439 case XFS_BLFT_BTREE_BUF: 2439 case XFS_BLFT_BTREE_BUF:
2440 switch (magic32) { 2440 switch (magic32) {
2441 case XFS_ABTB_CRC_MAGIC: 2441 case XFS_ABTB_CRC_MAGIC:
2442 case XFS_ABTC_CRC_MAGIC:
2443 case XFS_ABTB_MAGIC: 2442 case XFS_ABTB_MAGIC:
2443 bp->b_ops = &xfs_bnobt_buf_ops;
2444 break;
2445 case XFS_ABTC_CRC_MAGIC:
2444 case XFS_ABTC_MAGIC: 2446 case XFS_ABTC_MAGIC:
2445 bp->b_ops = &xfs_allocbt_buf_ops; 2447 bp->b_ops = &xfs_cntbt_buf_ops;
2446 break; 2448 break;
2447 case XFS_IBT_CRC_MAGIC: 2449 case XFS_IBT_CRC_MAGIC:
2448 case XFS_IBT_MAGIC: 2450 case XFS_IBT_MAGIC: