* [PATCH 6/6] move XFS_BMAP_SANITY_CHECK out of line
@ 2008-09-15 0:47 Christoph Hellwig
2008-09-16 6:31 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2008-09-15 0:47 UTC (permalink / raw)
To: xfs
[-- Attachment #1: xfs-move-XFS_BMAP_SANITY_CHECK-out-of-line --]
[-- Type: text/plain, Size: 2628 bytes --]
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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6-xfs/fs/xfs/xfs_bmap.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_bmap.c 2008-09-15 02:39:05.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_bmap.c 2008-09-15 02:39:09.000000000 +0200
@@ -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
@@ -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;
@@ -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.
@@ -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;
Index: linux-2.6-xfs/fs/xfs/xfs_bmap_btree.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_bmap_btree.h 2008-09-15 02:39:05.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_bmap_btree.h 2008-09-15 02:39:25.000000000 +0200
@@ -213,13 +213,6 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_
*/
#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.
*/
--
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6/6] move XFS_BMAP_SANITY_CHECK out of line
2008-09-15 0:47 Christoph Hellwig
@ 2008-09-16 6:31 ` Dave Chinner
0 siblings, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2008-09-16 6:31 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Mon, Sep 15, 2008 at 02:47:03AM +0200, Christoph Hellwig wrote:
> 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.
Looks good.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 6/6] move XFS_BMAP_SANITY_CHECK out of line
@ 2008-09-22 11:06 Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2008-09-22 11:06 UTC (permalink / raw)
To: xfs
[-- Attachment #1: xfs-move-XFS_BMAP_SANITY_CHECK-out-of-line --]
[-- Type: text/plain, Size: 2628 bytes --]
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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6-xfs/fs/xfs/xfs_bmap.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_bmap.c 2008-09-15 02:39:05.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_bmap.c 2008-09-15 02:39:09.000000000 +0200
@@ -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
@@ -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;
@@ -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.
@@ -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;
Index: linux-2.6-xfs/fs/xfs/xfs_bmap_btree.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_bmap_btree.h 2008-09-15 02:39:05.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_bmap_btree.h 2008-09-15 02:39:25.000000000 +0200
@@ -213,13 +213,6 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_
*/
#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.
*/
--
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-22 11:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-22 11:06 [PATCH 6/6] move XFS_BMAP_SANITY_CHECK out of line Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2008-09-15 0:47 Christoph Hellwig
2008-09-16 6:31 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox