Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Brian Foster and committed by
Darrick J. Wong
27df4f50 8473fee3

+20 -11
+2 -2
fs/xfs/libxfs/xfs_ag.c
··· 339 339 { /* BNO root block */ 340 340 .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_BNO_BLOCK(mp)), 341 341 .numblks = BTOBB(mp->m_sb.sb_blocksize), 342 - .ops = &xfs_allocbt_buf_ops, 342 + .ops = &xfs_bnobt_buf_ops, 343 343 .work = &xfs_bnoroot_init, 344 344 .need_init = true 345 345 }, 346 346 { /* CNT root block */ 347 347 .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_CNT_BLOCK(mp)), 348 348 .numblks = BTOBB(mp->m_sb.sb_blocksize), 349 - .ops = &xfs_allocbt_buf_ops, 349 + .ops = &xfs_cntbt_buf_ops, 350 350 .work = &xfs_cntroot_init, 351 351 .need_init = true 352 352 },
+10 -4
fs/xfs/libxfs/xfs_alloc_btree.c
··· 377 377 378 378 } 379 379 380 - const struct xfs_buf_ops xfs_allocbt_buf_ops = { 381 - .name = "xfs_allocbt", 380 + const struct xfs_buf_ops xfs_bnobt_buf_ops = { 381 + .name = "xfs_bnobt", 382 382 .verify_read = xfs_allocbt_read_verify, 383 383 .verify_write = xfs_allocbt_write_verify, 384 384 .verify_struct = xfs_allocbt_verify, 385 385 }; 386 386 387 + const 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 388 394 STATIC int 389 395 xfs_bnobt_keys_inorder( ··· 454 448 .init_rec_from_cur = xfs_allocbt_init_rec_from_cur, 455 449 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur, 456 450 .key_diff = xfs_bnobt_key_diff, 457 - .buf_ops = &xfs_allocbt_buf_ops, 451 + .buf_ops = &xfs_bnobt_buf_ops, 458 452 .diff_two_keys = xfs_bnobt_diff_two_keys, 459 453 .keys_inorder = xfs_bnobt_keys_inorder, 460 454 .recs_inorder = xfs_bnobt_recs_inorder, ··· 476 470 .init_rec_from_cur = xfs_allocbt_init_rec_from_cur, 477 471 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur, 478 472 .key_diff = xfs_cntbt_key_diff, 479 - .buf_ops = &xfs_allocbt_buf_ops, 473 + .buf_ops = &xfs_cntbt_buf_ops, 480 474 .diff_two_keys = xfs_cntbt_diff_two_keys, 481 475 .keys_inorder = xfs_cntbt_keys_inorder, 482 476 .recs_inorder = xfs_cntbt_recs_inorder,
+2 -1
fs/xfs/libxfs/xfs_shared.h
··· 25 25 extern const struct xfs_buf_ops xfs_agi_buf_ops; 26 26 extern const struct xfs_buf_ops xfs_agf_buf_ops; 27 27 extern const struct xfs_buf_ops xfs_agfl_buf_ops; 28 - extern const struct xfs_buf_ops xfs_allocbt_buf_ops; 28 + extern const struct xfs_buf_ops xfs_bnobt_buf_ops; 29 + extern const struct xfs_buf_ops xfs_cntbt_buf_ops; 29 30 extern const struct xfs_buf_ops xfs_rmapbt_buf_ops; 30 31 extern const struct xfs_buf_ops xfs_refcountbt_buf_ops; 31 32 extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
+2 -2
fs/xfs/scrub/agheader_repair.c
··· 341 341 struct xrep_find_ag_btree fab[XREP_AGF_MAX] = { 342 342 [XREP_AGF_BNOBT] = { 343 343 .rmap_owner = XFS_RMAP_OWN_AG, 344 - .buf_ops = &xfs_allocbt_buf_ops, 344 + .buf_ops = &xfs_bnobt_buf_ops, 345 345 .magic = XFS_ABTB_CRC_MAGIC, 346 346 }, 347 347 [XREP_AGF_CNTBT] = { 348 348 .rmap_owner = XFS_RMAP_OWN_AG, 349 - .buf_ops = &xfs_allocbt_buf_ops, 349 + .buf_ops = &xfs_cntbt_buf_ops, 350 350 .magic = XFS_ABTC_CRC_MAGIC, 351 351 }, 352 352 [XREP_AGF_RMAPBT] = {
+4 -2
fs/xfs/xfs_log_recover.c
··· 2439 2439 case XFS_BLFT_BTREE_BUF: 2440 2440 switch (magic32) { 2441 2441 case XFS_ABTB_CRC_MAGIC: 2442 - case XFS_ABTC_CRC_MAGIC: 2443 2442 case XFS_ABTB_MAGIC: 2443 + bp->b_ops = &xfs_bnobt_buf_ops; 2444 + break; 2445 + case XFS_ABTC_CRC_MAGIC: 2444 2446 case XFS_ABTC_MAGIC: 2445 - bp->b_ops = &xfs_allocbt_buf_ops; 2447 + bp->b_ops = &xfs_cntbt_buf_ops; 2446 2448 break; 2447 2449 case XFS_IBT_CRC_MAGIC: 2448 2450 case XFS_IBT_MAGIC: