Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124825
b: refs/heads/master
c: 4e8938f
h: refs/heads/master
i:
  124823: dab78ef
v: v3
  • Loading branch information
Christoph Hellwig authored and Lachlan McIlroy committed Oct 30, 2008
1 parent d6c50b6 commit 5201483
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7cc95a821df8f09a5d37a923cf8c3a7c3ee00c29
refs/heads/master: 4e8938feba770b583fb13d249c17943961731a3e
22 changes: 19 additions & 3 deletions trunk/fs/xfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4524,6 +4524,22 @@ xfs_bmap_one_block(
return rval;
}

STATIC int
xfs_bmap_sanity_check(
struct xfs_mount *mp,
struct xfs_buf *bp,
int level)
{
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);

if (be32_to_cpu(block->bb_magic) != XFS_BMAP_MAGIC ||
be16_to_cpu(block->bb_level) != level ||
be16_to_cpu(block->bb_numrecs) == 0 ||
be16_to_cpu(block->bb_numrecs) > mp->m_bmap_dmxr[level != 0])
return 0;
return 1;
}

/*
* Read in the extents to if_extents.
* All inode fields are set up by caller, we just traverse the btree
Expand Down Expand Up @@ -4575,7 +4591,7 @@ xfs_bmap_read_extents(
return error;
block = XFS_BUF_TO_BLOCK(bp);
XFS_WANT_CORRUPTED_GOTO(
XFS_BMAP_SANITY_CHECK(mp, block, level),
xfs_bmap_sanity_check(mp, bp, level),
error0);
if (level == 0)
break;
Expand Down Expand Up @@ -4611,7 +4627,7 @@ xfs_bmap_read_extents(
goto error0;
}
XFS_WANT_CORRUPTED_GOTO(
XFS_BMAP_SANITY_CHECK(mp, block, 0),
xfs_bmap_sanity_check(mp, bp, 0),
error0);
/*
* Read-ahead the next leaf block, if any.
Expand Down Expand Up @@ -6287,7 +6303,7 @@ xfs_bmap_check_leaf_extents(
goto error_norelse;
block = XFS_BUF_TO_BLOCK(bp);
XFS_WANT_CORRUPTED_GOTO(
XFS_BMAP_SANITY_CHECK(mp, block, level),
xfs_bmap_sanity_check(mp, bp, level),
error0);
if (level == 0)
break;
Expand Down
7 changes: 0 additions & 7 deletions trunk/fs/xfs/xfs_bmap_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,6 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;
*/
#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)])

#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
(be32_to_cpu((bb)->bb_magic) == XFS_BMAP_MAGIC && \
be16_to_cpu((bb)->bb_level) == level && \
be16_to_cpu((bb)->bb_numrecs) > 0 && \
be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0])


/*
* Prototypes for xfs_bmap.c to call.
*/
Expand Down

0 comments on commit 5201483

Please sign in to comment.