aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_dir2_data.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_dir2_data.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_dir2_data.c')
-rw-r--r--fs/xfs/libxfs/xfs_dir2_data.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 01162c62ec8f..b7b9ce002cb9 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -252,18 +252,16 @@ xfs_dir3_data_verify(
252 struct xfs_mount *mp = bp->b_target->bt_mount; 252 struct xfs_mount *mp = bp->b_target->bt_mount;
253 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; 253 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
254 254
255 if (!xfs_verify_magic(bp, hdr3->magic))
256 return __this_address;
257
255 if (xfs_sb_version_hascrc(&mp->m_sb)) { 258 if (xfs_sb_version_hascrc(&mp->m_sb)) {
256 if (hdr3->magic != cpu_to_be32(XFS_DIR3_DATA_MAGIC))
257 return __this_address;
258 if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) 259 if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
259 return __this_address; 260 return __this_address;
260 if (be64_to_cpu(hdr3->blkno) != bp->b_bn) 261 if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
261 return __this_address; 262 return __this_address;
262 if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn))) 263 if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn)))
263 return __this_address; 264 return __this_address;
264 } else {
265 if (hdr3->magic != cpu_to_be32(XFS_DIR2_DATA_MAGIC))
266 return __this_address;
267 } 265 }
268 return __xfs_dir3_data_check(NULL, bp); 266 return __xfs_dir3_data_check(NULL, bp);
269} 267}
@@ -339,6 +337,8 @@ xfs_dir3_data_write_verify(
339 337
340const struct xfs_buf_ops xfs_dir3_data_buf_ops = { 338const struct xfs_buf_ops xfs_dir3_data_buf_ops = {
341 .name = "xfs_dir3_data", 339 .name = "xfs_dir3_data",
340 .magic = { cpu_to_be32(XFS_DIR2_DATA_MAGIC),
341 cpu_to_be32(XFS_DIR3_DATA_MAGIC) },
342 .verify_read = xfs_dir3_data_read_verify, 342 .verify_read = xfs_dir3_data_read_verify,
343 .verify_write = xfs_dir3_data_write_verify, 343 .verify_write = xfs_dir3_data_write_verify,
344 .verify_struct = xfs_dir3_data_verify, 344 .verify_struct = xfs_dir3_data_verify,
@@ -346,6 +346,8 @@ const struct xfs_buf_ops xfs_dir3_data_buf_ops = {
346 346
347static const struct xfs_buf_ops xfs_dir3_data_reada_buf_ops = { 347static const struct xfs_buf_ops xfs_dir3_data_reada_buf_ops = {
348 .name = "xfs_dir3_data_reada", 348 .name = "xfs_dir3_data_reada",
349 .magic = { cpu_to_be32(XFS_DIR2_DATA_MAGIC),
350 cpu_to_be32(XFS_DIR3_DATA_MAGIC) },
349 .verify_read = xfs_dir3_data_reada_verify, 351 .verify_read = xfs_dir3_data_reada_verify,
350 .verify_write = xfs_dir3_data_write_verify, 352 .verify_write = xfs_dir3_data_write_verify,
351}; 353};