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>
This commit is contained in:
Brian Foster
2019-02-07 10:45:48 -08:00
committed by Darrick J. Wong
parent 09f420197d
commit 39708c20ab
13 changed files with 57 additions and 46 deletions

View File

@@ -129,21 +129,18 @@ xfs_da3_node_verify(
ops->node_hdr_from_disk(&ichdr, hdr);
if (!xfs_verify_magic(bp, hdr->hdr.info.magic))
return __this_address;
if (xfs_sb_version_hascrc(&mp->m_sb)) {
struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
if (hdr3->info.hdr.magic != cpu_to_be16(XFS_DA3_NODE_MAGIC))
return __this_address;
if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
return __this_address;
if (be64_to_cpu(hdr3->info.blkno) != bp->b_bn)
return __this_address;
if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
return __this_address;
} else {
if (hdr->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))
return __this_address;
}
if (ichdr.level == 0)
return __this_address;
@@ -257,6 +254,8 @@ xfs_da3_node_verify_struct(
const struct xfs_buf_ops xfs_da3_node_buf_ops = {
.name = "xfs_da3_node",
.magic = { cpu_to_be16(XFS_DA_NODE_MAGIC),
cpu_to_be16(XFS_DA3_NODE_MAGIC) },
.verify_read = xfs_da3_node_read_verify,
.verify_write = xfs_da3_node_write_verify,
.verify_struct = xfs_da3_node_verify_struct,