diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-10-30 02:14:43 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@sgi.com> | 2008-10-30 02:14:43 -0400 |
commit | 4e8938feba770b583fb13d249c17943961731a3e (patch) | |
tree | 311411b8561b8c9222996ab72ddcb4303be3d096 /fs/xfs/xfs_bmap.c | |
parent | 7cc95a821df8f09a5d37a923cf8c3a7c3ee00c29 (diff) |
[XFS] Move XFS_BMAP_SANITY_CHECK out of line.
Move the XFS_BMAP_SANITY_CHECK macro out of line and make it a properly
typed function. Also pass the xfs_buf for the btree block instead of just
the btree block header, as we will need some additional information for it
to implement CRC checking of btree blocks.
SGI-PV: 988146
SGI-Modid: xfs-linux-melb:xfs-kern:32301a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Donald Douwsma <donaldd@sgi.com>
Signed-off-by: David Chinner <david@fromorbit.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 7796a0c140eb..db289050692f 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -4524,6 +4524,22 @@ xfs_bmap_one_block( | |||
4524 | return rval; | 4524 | return rval; |
4525 | } | 4525 | } |
4526 | 4526 | ||
4527 | STATIC int | ||
4528 | xfs_bmap_sanity_check( | ||
4529 | struct xfs_mount *mp, | ||
4530 | struct xfs_buf *bp, | ||
4531 | int level) | ||
4532 | { | ||
4533 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | ||
4534 | |||
4535 | if (be32_to_cpu(block->bb_magic) != XFS_BMAP_MAGIC || | ||
4536 | be16_to_cpu(block->bb_level) != level || | ||
4537 | be16_to_cpu(block->bb_numrecs) == 0 || | ||
4538 | be16_to_cpu(block->bb_numrecs) > mp->m_bmap_dmxr[level != 0]) | ||
4539 | return 0; | ||
4540 | return 1; | ||
4541 | } | ||
4542 | |||
4527 | /* | 4543 | /* |
4528 | * Read in the extents to if_extents. | 4544 | * Read in the extents to if_extents. |
4529 | * All inode fields are set up by caller, we just traverse the btree | 4545 | * All inode fields are set up by caller, we just traverse the btree |
@@ -4575,7 +4591,7 @@ xfs_bmap_read_extents( | |||
4575 | return error; | 4591 | return error; |
4576 | block = XFS_BUF_TO_BLOCK(bp); | 4592 | block = XFS_BUF_TO_BLOCK(bp); |
4577 | XFS_WANT_CORRUPTED_GOTO( | 4593 | XFS_WANT_CORRUPTED_GOTO( |
4578 | XFS_BMAP_SANITY_CHECK(mp, block, level), | 4594 | xfs_bmap_sanity_check(mp, bp, level), |
4579 | error0); | 4595 | error0); |
4580 | if (level == 0) | 4596 | if (level == 0) |
4581 | break; | 4597 | break; |
@@ -4611,7 +4627,7 @@ xfs_bmap_read_extents( | |||
4611 | goto error0; | 4627 | goto error0; |
4612 | } | 4628 | } |
4613 | XFS_WANT_CORRUPTED_GOTO( | 4629 | XFS_WANT_CORRUPTED_GOTO( |
4614 | XFS_BMAP_SANITY_CHECK(mp, block, 0), | 4630 | xfs_bmap_sanity_check(mp, bp, 0), |
4615 | error0); | 4631 | error0); |
4616 | /* | 4632 | /* |
4617 | * Read-ahead the next leaf block, if any. | 4633 | * Read-ahead the next leaf block, if any. |
@@ -6287,7 +6303,7 @@ xfs_bmap_check_leaf_extents( | |||
6287 | goto error_norelse; | 6303 | goto error_norelse; |
6288 | block = XFS_BUF_TO_BLOCK(bp); | 6304 | block = XFS_BUF_TO_BLOCK(bp); |
6289 | XFS_WANT_CORRUPTED_GOTO( | 6305 | XFS_WANT_CORRUPTED_GOTO( |
6290 | XFS_BMAP_SANITY_CHECK(mp, block, level), | 6306 | xfs_bmap_sanity_check(mp, bp, level), |
6291 | error0); | 6307 | error0); |
6292 | if (level == 0) | 6308 | if (level == 0) |
6293 | break; | 6309 | break; |