aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_alloc.c
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2019-02-07 13:45:48 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2019-02-11 19:07:01 -0500
commit39708c20ab51337c3eb282a824eb0aaff7ebe2e1 (patch)
treead3e741a8fbafdfa13531f9efdf91557daada42d /fs/xfs/libxfs/xfs_alloc.c
parent09f420197d7ced360b4809606efd7a65f842c2c0 (diff)
xfs: miscellaneous verifier magic value fixups
Most buffer verifiers have hardcoded magic value checks conditionalized on the version of the filesystem. The magic value field of the verifier structure facilitates abstraction of some of this code. Populate the ->magic field of various verifiers to take advantage of this abstraction. 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>
Diffstat (limited to 'fs/xfs/libxfs/xfs_alloc.c')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 48aab07e7138..bc3367b8b7bb 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -568,9 +568,9 @@ xfs_agfl_verify(
568 if (!xfs_sb_version_hascrc(&mp->m_sb)) 568 if (!xfs_sb_version_hascrc(&mp->m_sb))
569 return NULL; 569 return NULL;
570 570
571 if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid)) 571 if (!xfs_verify_magic(bp, agfl->agfl_magicnum))
572 return __this_address; 572 return __this_address;
573 if (agfl->agfl_magicnum != cpu_to_be32(XFS_AGFL_MAGIC)) 573 if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
574 return __this_address; 574 return __this_address;
575 /* 575 /*
576 * during growfs operations, the perag is not fully initialised, 576 * during growfs operations, the perag is not fully initialised,
@@ -643,6 +643,7 @@ xfs_agfl_write_verify(
643 643
644const struct xfs_buf_ops xfs_agfl_buf_ops = { 644const struct xfs_buf_ops xfs_agfl_buf_ops = {
645 .name = "xfs_agfl", 645 .name = "xfs_agfl",
646 .magic = { cpu_to_be32(XFS_AGFL_MAGIC), cpu_to_be32(XFS_AGFL_MAGIC) },
646 .verify_read = xfs_agfl_read_verify, 647 .verify_read = xfs_agfl_read_verify,
647 .verify_write = xfs_agfl_write_verify, 648 .verify_write = xfs_agfl_write_verify,
648 .verify_struct = xfs_agfl_verify, 649 .verify_struct = xfs_agfl_verify,
@@ -2587,8 +2588,10 @@ xfs_agf_verify(
2587 return __this_address; 2588 return __this_address;
2588 } 2589 }
2589 2590
2590 if (!(agf->agf_magicnum == cpu_to_be32(XFS_AGF_MAGIC) && 2591 if (!xfs_verify_magic(bp, agf->agf_magicnum))
2591 XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) && 2592 return __this_address;
2593
2594 if (!(XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
2592 be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) && 2595 be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) &&
2593 be32_to_cpu(agf->agf_flfirst) < xfs_agfl_size(mp) && 2596 be32_to_cpu(agf->agf_flfirst) < xfs_agfl_size(mp) &&
2594 be32_to_cpu(agf->agf_fllast) < xfs_agfl_size(mp) && 2597 be32_to_cpu(agf->agf_fllast) < xfs_agfl_size(mp) &&
@@ -2670,6 +2673,7 @@ xfs_agf_write_verify(
2670 2673
2671const struct xfs_buf_ops xfs_agf_buf_ops = { 2674const struct xfs_buf_ops xfs_agf_buf_ops = {
2672 .name = "xfs_agf", 2675 .name = "xfs_agf",
2676 .magic = { cpu_to_be32(XFS_AGF_MAGIC), cpu_to_be32(XFS_AGF_MAGIC) },
2673 .verify_read = xfs_agf_read_verify, 2677 .verify_read = xfs_agf_read_verify,
2674 .verify_write = xfs_agf_write_verify, 2678 .verify_write = xfs_agf_write_verify,
2675 .verify_struct = xfs_agf_verify, 2679 .verify_struct = xfs_agf_verify,