xfs: verifier modification series
v2 cover xfs: verifier modification series
This is a handful of changes related to the verifiers. The end goal is to differentiate CRC errors from other non-CRC verifier errors.
At this point it's somewhat RFC, if you don't like some of the changes made along the way, just speak up.
Changes from V1 noted in each patch.
Thanks,
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/7 xfs: limit superblock corruption errors to actual corruption
Today, if
xfs_sb_read_verify
xfs_sb_verify
xfs_mount_validate_sb
detects superblock corruption, it'll be extremely noisy, dumping 2 stacks, 2 hexdumps, etc.
This is because we call XFS_CORRUPTION_ERROR in xfs_mount_validate_sb as well as in xfs_sb_read_verify.
Also, *any* errors in xfs_mount_validate_sb which are not corruption per se; things like too-big-blocksize, bad version, bad magic, v1 dirs, rw-incompat etc - things which do not return EFSCORRUPTED - will still do the whole XFS_CORRUPTION_ERROR spew when xfs_sb_read_verify sees any error at all. And it suggests to the user that they should run xfs_repair, even if the root cause of the mount failure is a simple incompatibility.
I'll submit that the probably-not-corrupted errors don't warrant this much noise, so this patch removes the warning for anything other than EFSCORRUPTED returns, and replaces the lower-level XFS_CORRUPTION_ERROR with an xfs_notice().
--- fs/xfs/xfs_sb.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
Unchanged from V1
fs/xfs/xfs_sb.c +2 -3
@@ -295,8 +295,7 @@ xfs_mount_validate_sb( sbp->sb_dblocks == 0 || sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp) || sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) { -XFS_CORRUPTION_ERROR ("SB sanity check failed" , -XFS_ERRLEVEL_LOW , mp, sbp); +xfs_notice (mp,"SB sanity check failed" );return XFS_ERROR (EFSCORRUPTED ); }
@@ -625,7 +624,7 @@ xfs_sb_read_verify( out_error:if (error) { -if (error !=EWRONGFS ) +if (error ==EFSCORRUPTED )XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp, error);
-- 1.7.1
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 2/7 xfs: skip pointless CRC updates after verifier failures
In reply to Eric SandeenMost write verifiers don't update CRCs after the verifier has failed and the buffer has been marked in error. These two didn't, but should.
Add returns to the verifier failure block,
since the buffer won't be written anyway.
--- fs/xfs/xfs_alloc_btree.c | 1 + fs/xfs/xfs_ialloc_btree.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
Unchanged from V1
fs/xfs/xfs_alloc_btree.c +1 -0
@@ -373,6 +373,7 @@ xfs_allocbt_write_verify(XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , bp->b_target->bt_mount, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +return ; }xfs_btree_sblock_calc_crc (bp);
fs/xfs/xfs_ialloc_btree.c +1 -0
@@ -261,6 +261,7 @@ xfs_inobt_write_verify(XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , bp->b_target->bt_mount, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +return ; }xfs_btree_sblock_calc_crc (bp);
-- 1.7.1
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 3/7 xfs: Use defines for CRC offsets in all cases
In reply to Eric SandeenSome calls to crc functions used useful #defines,
others used awkward offsetof() constructs.
Switch them all to #define to make things a bit
cleaner.
--- fs/xfs/xfs_ag.h | 6 ++++++ fs/xfs/xfs_alloc.c | 10 ++++------ fs/xfs/xfs_dinode.h | 2 ++ fs/xfs/xfs_format.h | 2 ++ fs/xfs/xfs_ialloc.c | 5 ++--- fs/xfs/xfs_inode_buf.c | 4 ++-- fs/xfs/xfs_sb.c | 5 ++--- fs/xfs/xfs_sb.h | 2 ++ fs/xfs/xfs_symlink_remote.c | 5 ++--- 9 files changed, 24 insertions(+), 17 deletions(-)
New patch since V1
fs/xfs/xfs_ag.h +6 -0
@@ -89,6 +89,8 @@ typedef struct xfs_agf {/* structure must be padded to 64 bit alignment */ } xfs_agf_t; +#define XFS_AGF_CRC_OFF offsetof(struct xfs_agf, agf_crc) +#define XFS_AGF_MAGICNUM 0x00000001#define XFS_AGF_VERSIONNUM 0x00000002#define XFS_AGF_SEQNO 0x00000004
@@ -167,6 +169,8 @@ typedef struct xfs_agi {/* structure must be padded to 64 bit alignment */ } xfs_agi_t; +#define XFS_AGI_CRC_OFF offsetof(struct xfs_agi, agi_crc) +#define XFS_AGI_MAGICNUM 0x00000001#define XFS_AGI_VERSIONNUM 0x00000002#define XFS_AGI_SEQNO 0x00000004
@@ -222,6 +226,8 @@ typedef struct xfs_agfl {__be32 agfl_bno[];/* actually XFS_AGFL_SIZE(mp) */ } xfs_agfl_t; +#define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) +/* * tags for inode radix tree */
fs/xfs/xfs_alloc.c +4 -6
@@ -486,7 +486,7 @@ xfs_agfl_read_verify(return ; agfl_ok =xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_agfl , agfl_crc)); +XFS_AGFL_CRC_OFF ); agfl_ok = agfl_ok &&xfs_agfl_verify (bp);
@@ -516,8 +516,7 @@ xfs_agfl_write_verify(if (bip)XFS_BUF_TO_AGFL (bp)->agfl_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_agfl , agfl_crc)); +xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_AGFL_CRC_OFF ); }const struct xfs_buf_ops xfs_agfl_buf_ops = {
@@ -2242,7 +2241,7 @@ xfs_agf_read_verify(if (xfs_sb_version_hascrc (&mp->m_sb)) agf_ok =xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_agf , agf_crc)); +XFS_AGF_CRC_OFF ); agf_ok = agf_ok &&xfs_agf_verify (mp, bp);
@@ -2272,8 +2271,7 @@ xfs_agf_write_verify(if (bip)XFS_BUF_TO_AGF (bp)->agf_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_agf , agf_crc)); +xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_AGF_CRC_OFF ); }const struct xfs_buf_ops xfs_agf_buf_ops = {
fs/xfs/xfs_dinode.h +2 -0
@@ -89,6 +89,8 @@ typedef struct xfs_dinode {/* structure must be padded to 64 bit alignment */ } xfs_dinode_t; +#define XFS_DINODE_CRC_OFF offsetof(struct xfs_dinode, di_crc) +#define DI_MAX_FLUSH 0xffff/*
fs/xfs/xfs_format.h +2 -0
@@ -145,6 +145,8 @@ struct xfs_dsymlink_hdr {__be64 sl_lsn; }; +#define XFS_SYMLINK_CRC_OFF offsetof(struct xfs_dsymlink_hdr, sl_crc) +/* * The maximum pathlen is 1024 bytes. Since the minimum file system * blocksize is 512 bytes, we can get a max of 3 extents back from
fs/xfs/xfs_ialloc.c +2 -3
@@ -1572,7 +1572,7 @@ xfs_agi_read_verify(if (xfs_sb_version_hascrc (&mp->m_sb)) agi_ok =xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_agi , agi_crc)); +XFS_AGI_CRC_OFF ); agi_ok = agi_ok &&xfs_agi_verify (bp); if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
@@ -1600,8 +1600,7 @@ xfs_agi_write_verify(if (bip)XFS_BUF_TO_AGI (bp)->agi_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_agi , agi_crc)); +xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_AGI_CRC_OFF ); }const struct xfs_buf_ops xfs_agi_buf_ops = {
fs/xfs/xfs_inode_buf.c +2 -2
@@ -306,7 +306,7 @@ xfs_dinode_verify(if (!xfs_sb_version_hascrc (&mp->m_sb))return false;if (!xfs_verify_cksum ((char *)dip, mp->m_sb.sb_inodesize, - offsetof(struct xfs_dinode , di_crc))) +XFS_DINODE_CRC_OFF ))return false;if (be64_to_cpu (dip->di_ino) != ip->i_ino)return false;
@@ -327,7 +327,7 @@ xfs_dinode_calc_crc(ASSERT (xfs_sb_version_hascrc (&mp->m_sb)); crc =xfs_start_cksum ((char *)dip, mp->m_sb.sb_inodesize, - offsetof(struct xfs_dinode , di_crc)); +XFS_DINODE_CRC_OFF ); dip->di_crc =xfs_end_cksum (crc); }
fs/xfs/xfs_sb.c +2 -3
@@ -611,7 +611,7 @@ xfs_sb_read_verify( dsb->sb_crc != 0)) {if (!xfs_verify_cksum (bp->b_addr,be16_to_cpu (dsb->sb_sectsize), - offsetof(struct xfs_sb , sb_crc))) { +XFS_SB_CRC_OFF )) {/* Only fail bad secondaries on a known V5 filesystem */ if (bp->b_bn !=XFS_SB_DADDR &&xfs_sb_version_hascrc (&mp->m_sb)) {
@@ -675,8 +675,7 @@ xfs_sb_write_verify(if (bip)XFS_BUF_TO_SBP (bp)->sb_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_sb , sb_crc)); +xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_SB_CRC_OFF ); }const struct xfs_buf_ops xfs_sb_buf_ops = {
fs/xfs/xfs_sb.h +2 -0
@@ -182,6 +182,8 @@ typedef struct xfs_sb {/* must be padded to 64 bit alignment */ } xfs_sb_t; +#define XFS_SB_CRC_OFF offsetof(struct xfs_sb, sb_crc) +/* * Superblock - on disk version. Must match the in core version above. * Must be padded to 64 bit alignment.
fs/xfs/xfs_symlink_remote.c +2 -3
@@ -134,7 +134,7 @@ xfs_symlink_read_verify(return ;if (!xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_dsymlink_hdr , sl_crc)) || +XFS_SYMLINK_CRC_OFF ) || !xfs_symlink_verify (bp)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED );
@@ -162,8 +162,7 @@ xfs_symlink_write_verify(struct xfs_dsymlink_hdr *dsl = bp->b_addr; dsl->sl_lsn =cpu_to_be64 (bip->bli_item.li_lsn); } -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), - offsetof(struct xfs_dsymlink_hdr , sl_crc)); +xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_SYMLINK_CRC_OFF ); }const struct xfs_buf_ops xfs_symlink_buf_ops = {
-- 1.7.1
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 4/7 xfs: add helper for verifying checksums on xfs_bufs
In reply to Eric SandeenMany/most callers of xfs_verify_cksum() pass bp->b_addr and BBTOB(bp->b_length) as the first 2 args. Add a helper which can just accept the bp and the crc offset, and work it out on its own, for brevity.
--- fs/xfs/xfs_alloc.c | 6 ++---- fs/xfs/xfs_attr_leaf.c | 3 +-- fs/xfs/xfs_btree.c | 8 ++++---- fs/xfs/xfs_buf.h | 7 +++++++ fs/xfs/xfs_da_btree.c | 3 +-- fs/xfs/xfs_dir2_block.c | 3 +-- fs/xfs/xfs_dir2_data.c | 3 +-- fs/xfs/xfs_dir2_leaf.c | 3 +-- fs/xfs/xfs_dir2_node.c | 3 +-- fs/xfs/xfs_ialloc.c | 4 ++-- fs/xfs/xfs_linux.h | 1 + fs/xfs/xfs_symlink_remote.c | 3 +-- 12 files changed, 23 insertions(+), 24 deletions(-)
V2: move helper to xfs_buf.h
fs/xfs/xfs_alloc.c +2 -4
@@ -485,8 +485,7 @@ xfs_agfl_read_verify(if (!xfs_sb_version_hascrc (&mp->m_sb))return ; - agfl_ok =xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_AGFL_CRC_OFF ); + agfl_ok =xfs_buf_verify_cksum (bp,XFS_AGFL_CRC_OFF ); agfl_ok = agfl_ok &&xfs_agfl_verify (bp);
@@ -2240,8 +2239,7 @@ xfs_agf_read_verify(int agf_ok =1 ;if (xfs_sb_version_hascrc (&mp->m_sb)) - agf_ok =xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_AGF_CRC_OFF ); + agf_ok =xfs_buf_verify_cksum (bp,XFS_AGF_CRC_OFF ); agf_ok = agf_ok &&xfs_agf_verify (mp, bp);
fs/xfs/xfs_attr_leaf.c +1 -2
@@ -240,8 +240,7 @@ xfs_attr3_leaf_read_verify(struct xfs_mount *mp = bp->b_target->bt_mount;if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_ATTR3_LEAF_CRC_OFF )) || + !xfs_buf_verify_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF )) || !xfs_attr3_leaf_verify (bp)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED );
fs/xfs/xfs_btree.c +4 -4
@@ -243,8 +243,8 @@ xfs_btree_lblock_verify_crc( struct xfs_buf *bp) {if (xfs_sb_version_hascrc (&bp->b_target->bt_mount->m_sb)) -return xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_BTREE_LBLOCK_CRC_OFF ); +return xfs_buf_verify_cksum (bp,XFS_BTREE_LBLOCK_CRC_OFF ); +return true; }
@@ -276,8 +276,8 @@ xfs_btree_sblock_verify_crc( struct xfs_buf *bp) {if (xfs_sb_version_hascrc (&bp->b_target->bt_mount->m_sb)) -return xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_BTREE_SBLOCK_CRC_OFF ); +return xfs_buf_verify_cksum (bp,XFS_BTREE_SBLOCK_CRC_OFF ); +return true; }
fs/xfs/xfs_buf.h +7 -0
@@ -369,6 +369,13 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)xfs_buf_rele (bp); } +static inline int +xfs_buf_verify_cksum (struct xfs_buf *bp,unsigned long cksum_offset) +{ +return xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), + cksum_offset); +} +/* * Handling of buftargs. */
fs/xfs/xfs_da_btree.c +1 -2
@@ -214,8 +214,7 @@ xfs_da3_node_read_verify(switch (be16_to_cpu (info->magic)) {case XFS_DA3_NODE_MAGIC : -if (!xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_DA3_NODE_CRC_OFF )) +if (!xfs_buf_verify_cksum (bp,XFS_DA3_NODE_CRC_OFF ))break ;/* fall through */ case XFS_DA_NODE_MAGIC :
fs/xfs/xfs_dir2_block.c +1 -2
@@ -90,8 +90,7 @@ xfs_dir3_block_read_verify(struct xfs_mount *mp = bp->b_target->bt_mount;if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_DIR3_DATA_CRC_OFF )) || + !xfs_buf_verify_cksum (bp,XFS_DIR3_DATA_CRC_OFF )) || !xfs_dir3_block_verify (bp)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED );
fs/xfs/xfs_dir2_data.c +1 -2
@@ -268,8 +268,7 @@ xfs_dir3_data_read_verify(struct xfs_mount *mp = bp->b_target->bt_mount;if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_DIR3_DATA_CRC_OFF )) || + !xfs_buf_verify_cksum (bp,XFS_DIR3_DATA_CRC_OFF )) || !xfs_dir3_data_verify (bp)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED );
fs/xfs/xfs_dir2_leaf.c +1 -2
@@ -180,8 +180,7 @@ __read_verify(struct xfs_mount *mp = bp->b_target->bt_mount;if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_DIR3_LEAF_CRC_OFF )) || + !xfs_buf_verify_cksum (bp,XFS_DIR3_LEAF_CRC_OFF )) || !xfs_dir3_leaf_verify (bp, magic)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED );
fs/xfs/xfs_dir2_node.c +1 -2
@@ -116,8 +116,7 @@ xfs_dir3_free_read_verify(struct xfs_mount *mp = bp->b_target->bt_mount;if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_DIR3_FREE_CRC_OFF )) || + !xfs_buf_verify_cksum (bp,XFS_DIR3_FREE_CRC_OFF )) || !xfs_dir3_free_verify (bp)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED );
fs/xfs/xfs_ialloc.c +2 -2
@@ -1571,8 +1571,8 @@ xfs_agi_read_verify(int agi_ok =1 ;if (xfs_sb_version_hascrc (&mp->m_sb)) - agi_ok =xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_AGI_CRC_OFF ); + agi_ok =xfs_buf_verify_cksum (bp,XFS_AGI_CRC_OFF ); + agi_ok = agi_ok &&xfs_agi_verify (bp); if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
fs/xfs/xfs_linux.h +1 -0
@@ -119,6 +119,7 @@ typedef __uint64_t __psunsigned_t;#include "xfs_iops.h" #include "xfs_aops.h" #include "xfs_super.h" +#include "xfs_cksum.h" #include "xfs_buf.h" #include "xfs_message.h"
fs/xfs/xfs_symlink_remote.c +1 -2
@@ -133,8 +133,7 @@ xfs_symlink_read_verify(if (!xfs_sb_version_hascrc (&mp->m_sb))return ; -if (!xfs_verify_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_SYMLINK_CRC_OFF ) || +if (!xfs_buf_verify_cksum (bp,XFS_SYMLINK_CRC_OFF ) || !xfs_symlink_verify (bp)) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED );
-- 1.7.1
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 5/7 xfs: add helper for updating checksums on xfs_bufs
In reply to Eric SandeenMany/most callers of xfs_update_cksum() pass bp->b_addr and BBTOB(bp->b_length) as the first 2 args. Add a helper which can just accept the bp and the crc offset, and work it out on its own, for brevity.
--- fs/xfs/xfs_alloc.c | 4 ++-- fs/xfs/xfs_attr_leaf.c | 2 +- fs/xfs/xfs_btree.c | 6 ++---- fs/xfs/xfs_buf.h | 7 +++++++ fs/xfs/xfs_da_btree.c | 2 +- fs/xfs/xfs_dir2_block.c | 2 +- fs/xfs/xfs_dir2_data.c | 2 +- fs/xfs/xfs_dir2_leaf.c | 2 +- fs/xfs/xfs_dir2_node.c | 2 +- fs/xfs/xfs_ialloc.c | 2 +- fs/xfs/xfs_sb.c | 2 +- fs/xfs/xfs_symlink_remote.c | 2 +- 12 files changed, 20 insertions(+), 15 deletions(-)
V2: move helper to xfs_buf.h, fix subject
fs/xfs/xfs_alloc.c +2 -2
@@ -515,7 +515,7 @@ xfs_agfl_write_verify(if (bip)XFS_BUF_TO_AGFL (bp)->agfl_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_AGFL_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_AGFL_CRC_OFF ); }const struct xfs_buf_ops xfs_agfl_buf_ops = {
@@ -2269,7 +2269,7 @@ xfs_agf_write_verify(if (bip)XFS_BUF_TO_AGF (bp)->agf_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_AGF_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_AGF_CRC_OFF ); }const struct xfs_buf_ops xfs_agf_buf_ops = {
fs/xfs/xfs_attr_leaf.c +1 -1
@@ -224,7 +224,7 @@ xfs_attr3_leaf_write_verify(if (bip) hdr3->info.lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_ATTR3_LEAF_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF ); }/*
fs/xfs/xfs_btree.c +2 -4
@@ -234,8 +234,7 @@ xfs_btree_lblock_calc_crc(return ;if (bip) block->bb_u.l.bb_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_BTREE_LBLOCK_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_BTREE_LBLOCK_CRC_OFF ); }bool
@@ -267,8 +266,7 @@ xfs_btree_sblock_calc_crc(return ;if (bip) block->bb_u.s.bb_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), -XFS_BTREE_SBLOCK_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_BTREE_SBLOCK_CRC_OFF ); }bool
fs/xfs/xfs_buf.h +7 -0
@@ -376,6 +376,13 @@ xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset) cksum_offset); } +static inline void +xfs_buf_update_cksum (struct xfs_buf *bp,unsigned long cksum_offset) +{ +xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length), + cksum_offset); +} +/* * Handling of buftargs. */
fs/xfs/xfs_da_btree.c +1 -1
@@ -196,7 +196,7 @@ xfs_da3_node_write_verify(if (bip) hdr3->info.lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_DA3_NODE_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); }/*
fs/xfs/xfs_dir2_block.c +1 -1
@@ -117,7 +117,7 @@ xfs_dir3_block_write_verify(if (bip) hdr3->lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_DIR3_DATA_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_DIR3_DATA_CRC_OFF ); }const struct xfs_buf_ops xfs_dir3_block_buf_ops = {
fs/xfs/xfs_dir2_data.c +1 -1
@@ -295,7 +295,7 @@ xfs_dir3_data_write_verify(if (bip) hdr3->lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_DIR3_DATA_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_DIR3_DATA_CRC_OFF ); }const struct xfs_buf_ops xfs_dir3_data_buf_ops = {
fs/xfs/xfs_dir2_leaf.c +1 -1
@@ -208,7 +208,7 @@ __write_verify(if (bip) hdr3->info.lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_DIR3_LEAF_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_DIR3_LEAF_CRC_OFF ); } static void
fs/xfs/xfs_dir2_node.c +1 -1
@@ -143,7 +143,7 @@ xfs_dir3_free_write_verify(if (bip) hdr3->lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_DIR3_FREE_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_DIR3_FREE_CRC_OFF ); }const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
fs/xfs/xfs_ialloc.c +1 -1
@@ -1600,7 +1600,7 @@ xfs_agi_write_verify(if (bip)XFS_BUF_TO_AGI (bp)->agi_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_AGI_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_AGI_CRC_OFF ); }const struct xfs_buf_ops xfs_agi_buf_ops = {
fs/xfs/xfs_sb.c +1 -1
@@ -675,7 +675,7 @@ xfs_sb_write_verify(if (bip)XFS_BUF_TO_SBP (bp)->sb_lsn =cpu_to_be64 (bip->bli_item.li_lsn); -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_SB_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_SB_CRC_OFF ); }const struct xfs_buf_ops xfs_sb_buf_ops = {
fs/xfs/xfs_symlink_remote.c +1 -1
@@ -161,7 +161,7 @@ xfs_symlink_write_verify(struct xfs_dsymlink_hdr *dsl = bp->b_addr; dsl->sl_lsn =cpu_to_be64 (bip->bli_item.li_lsn); } -xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_SYMLINK_CRC_OFF ); +xfs_buf_update_cksum (bp,XFS_SYMLINK_CRC_OFF ); }const struct xfs_buf_ops xfs_symlink_buf_ops = {
-- 1.7.1
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 6/7 xfs: add xfs_verifier_error()
In reply to Eric SandeenWe want to distinguish between corruption and CRC errors. In addition, the full stack trace on verifier errors seems less than helpful; it looks more like an oops than corruption.
Create a new function to specifically alert the user to verifier errors, which can differentiate between EFSCORRUPTED and CRC mismatches. It doesn't dump stack unless the xfs error level is turned up high.
Define a new error message (EFSBADCRC) to clearly identify CRC errors. (Defined to EILSEQ, bad byte sequence)
--- fs/xfs/xfs_error.c | 22 ++++++++++++++++++++++ fs/xfs/xfs_error.h | 1 + fs/xfs/xfs_linux.h | 1 + 3 files changed, 24 insertions(+), 0 deletions(-)
V2: Use __builtin_return_address(0) to avoid the macro with __func__; this can eventually be pushed into the verifiers themselves to issue a specific warning for each failure.
fs/xfs/xfs_error.c +22 -0
@@ -178,3 +178,25 @@ xfs_corruption_error(xfs_error_report (tag, level, mp, filename, linenum, ra);xfs_alert (mp,"Corruption detected. Unmount and run xfs_repair" ); } + +/* +* Warnings specifically for verifier errors. Differentiate CRC vs. invalid +* values, and omit the stack trace unless the error level is tuned high. +*/ +void +xfs_verifier_error ( +struct xfs_buf *bp) +{ +struct xfs_mount *mp = bp->b_target->bt_mount; + +xfs_alert (mp, +"Metadata %s detected at %pF, block 0x%llx. Unmount and run xfs_repair" , + bp->b_error ==EFSBADCRC ?"CRC error" :"corruption" , +__builtin_return_address (0 ), bp->b_bn); + +if (xfs_error_level >=XFS_ERRLEVEL_LOW ) +xfs_hex_dump (bp->b_addr,64 ); + +if (xfs_error_level >=XFS_ERRLEVEL_HIGH ) +xfs_stack_trace (); +}
fs/xfs/xfs_error.h +1 -0
@@ -34,6 +34,7 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,extern void xfs_corruption_error (const char *tag,int level,struct xfs_mount *mp,void *p,const char *filename,int linenum,inst_t *ra); +extern void xfs_verifier_error (struct xfs_buf *bp);#define XFS_ERROR_REPORT (e, lvl, mp) \ xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
fs/xfs/xfs_linux.h +1 -0
@@ -179,6 +179,7 @@ typedef __uint64_t __psunsigned_t;#define ENOATTR ENODATA/* Attribute not found */ #define EWRONGFS EINVAL/* Mount with wrong filesystem type */ #define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */ +#define EFSBADCRC EILSEQ/* Bad CRC detected */ #define SYNCHRONIZE () barrier()#define __return_address __builtin_return_address(0)
-- 1.7.1
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 6/7] xfs: add xfs_verifier_error()
Quoted 5 lines · Eric Sandeen
We want to distinguish between corruption and CRC errors. In addition, the full stack trace on verifier errors seems less than helpful; it looks more like an oops than corruption.
Quoted 7 lines
Create a new function to specifically alert the user to verifier errors, which can differentiate between EFSCORRUPTED and CRC mismatches. It doesn't dump stack unless the xfs error level is turned up high.
Define a new error message (EFSBADCRC) to clearly identify CRC errors. (Defined to EILSEQ, bad byte sequence)
So, this now looks like:
[259116.148375] XFS (loop0): Metadata corruption detected at xfs_sb_read_verify+0x118/0x150 [xfs], block 0x0. Unmount and run xfs_repair [259116.160345] ffff88022bab0000: 58 46 53 42 00 00 10 00 00 00 00 00 00 04 00 00 XFSB............ [259116.169109] ffff88022bab0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [259116.177872] ffff88022bab0020: 73 df 07 64 a6 50 4d 5b 8d eb 2c 06 a1 ed e3 5c s..d.PM[..,....\ [259116.186638] ffff88022bab0030: 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 80 ................ [259116.195413] XFS (loop0): SB validate failed with error 117.
when something fails.
We should probably put a period after "xfs_repair" and also print one more line about what the hex spew means - "XFS (loop0): first 64 bytes of corrupted metadata buffer:" or something similar.
-Eric
Quoted 67 lines
Signed-off-by Eric Sandeen <[email protected]>--- fs/xfs/xfs_error.c | 22 ++++++++++++++++++++++ fs/xfs/xfs_error.h | 1 + fs/xfs/xfs_linux.h | 1 + 3 files changed, 24 insertions(+), 0 deletions(-)V2: Use
__builtin_return_address(0)to avoid the macro with__func__; this can eventually be pushed into the verifiers themselves to issue a specific warning for each failure.fs/xfs/xfs_error.c +22
-0@@ -178,3 +178,25 @@ xfs_corruption_error(xfs_error_report (tag, level, mp, filename, linenum, ra);xfs_alert (mp,"Corruption detected. Unmount and run xfs_repair" ); } + +/* +* Warnings specifically for verifier errors. Differentiate CRC vs. invalid +* values, and omit the stack trace unless the error level is tuned high. +*/ +void +xfs_verifier_error ( +struct xfs_buf *bp) +{ +struct xfs_mount *mp = bp->b_target->bt_mount; + +xfs_alert (mp, +"Metadata %s detected at %pF, block 0x%llx. Unmount and run xfs_repair" , + bp->b_error ==EFSBADCRC ?"CRC error" :"corruption" , +__builtin_return_address (0 ), bp->b_bn); + +if (xfs_error_level >=XFS_ERRLEVEL_LOW ) +xfs_hex_dump (bp->b_addr,64 ); + +if (xfs_error_level >=XFS_ERRLEVEL_HIGH ) +xfs_stack_trace (); +}fs/xfs/xfs_error.h +1
-0@@ -34,6 +34,7 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,extern void xfs_corruption_error (const char *tag,int level,struct xfs_mount *mp,void *p,const char *filename,int linenum,inst_t *ra); +extern void xfs_verifier_error (struct xfs_buf *bp);#define XFS_ERROR_REPORT (e, lvl, mp) \ xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)fs/xfs/xfs_linux.h +1
-1@@ -179,6 +179,7 @@ typedef __uint64_t __psunsigned_t;#define ENOATTR ENODATA/* Attribute not found */ #define EWRONGFS EINVAL/* Mount with wrong filesystem type */ #define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */ +#define EFSBADCRC EILSEQ/* Bad CRC detected */ #define SYNCHRONIZE () barrier()#define __return_address __builtin_return_address(0) -- 1.7.1
Quoted 5 lines
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 6/7] xfs: add xfs_verifier_error()
Quoted 23 lines · Eric Sandeen
Quoted 5 lines · Eric Sandeen
We want to distinguish between corruption and CRC errors. In addition, the full stack trace on verifier errors seems less than helpful; it looks more like an oops than corruption.
Quoted 7 lines
Create a new function to specifically alert the user to verifier errors, which can differentiate between EFSCORRUPTED and CRC mismatches. It doesn't dump stack unless the xfs error level is turned up high.
Define a new error message (EFSBADCRC) to clearly identify CRC errors. (Defined to EILSEQ, bad byte sequence)
So, this now looks like:
[259116.148375] XFS (loop0): Metadata corruption detected at xfs_sb_read_verify+0x118/0x150 [xfs], block 0x0. Unmount and run xfs_repair [259116.160345] ffff88022bab0000: 58 46 53 42 00 00 10 00 00 00 00 00 00 04 00 00 XFSB............ [259116.169109] ffff88022bab0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [259116.177872] ffff88022bab0020: 73 df 07 64 a6 50 4d 5b 8d eb 2c 06 a1 ed e3 5c s..d.PM[..,....\ [259116.186638] ffff88022bab0030: 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 80 ................ [259116.195413] XFS (loop0): SB validate failed with error 117.
Quoted 5 lines
when something fails.
We should probably put a period after "
xfs_repair" and also print one more line about what the hex spew means - "XFS (loop0): first 64 bytes of corrupted metadata buffer:" or something similar.
Yeah, I think we need to split that long line, too. i.e:
XFS (loop0): Metadata corruption detected at xfs_sb_read_verify+0x118/0x150 [xfs], block 0x0. XFS (loop0): Please unmount and run xfs_repair.
XFS (loop0): First 64 bytes of corrupted metadata buffer contains:ffff88022bab0000: 58 46 53 42 00 00 10 00 00 00 00 00 00 04 00 00 XFSB............ffff88022bab0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ffff88022bab0020: 73 df 07 64 a6 50 4d 5b 8d eb 2c 06 a1 ed e3 5c s..d.PM[..,....\ffff88022bab0030: 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 80 ................ XFS (loop0): SB validate failed with error 117.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 6/7] xfs: add xfs_verifier_error()
In reply to Eric SandeenQuoted 14 lines · Eric Sandeen
We want to distinguish between corruption and CRC errors. In addition, the full stack trace on verifier errors seems less than helpful; it looks more like an oops than corruption.
Create a new function to specifically alert the user to verifier errors, which can differentiate between EFSCORRUPTED and CRC mismatches. It doesn't dump stack unless the xfs error level is turned up high.
Define a new error message (EFSBADCRC) to clearly identify CRC errors. (Defined to EILSEQ, bad byte sequence)
Signed-off-by Eric Sandeen <[email protected]>
...
fs/xfs/xfs_error.c xfs_corruption_error( · line 198
Quoted 13 lines
fs/xfs/xfs_error.c +13
-0+void +xfs_verifier_error ( +struct xfs_buf *bp) +{ +struct xfs_mount *mp = bp->b_target->bt_mount; + +xfs_alert (mp, +"Metadata %s detected at %pF, block 0x%llx. Unmount and run xfs_repair" , + bp->b_error ==EFSBADCRC ?"CRC error" :"corruption" , +__builtin_return_address (0 ), bp->b_bn); + +if (xfs_error_level >=XFS_ERRLEVEL_LOW ) +xfs_hex_dump (bp->b_addr,64 );
This needs to handle the case where we have a page array rather than a b_addr, as well.
(The existing calls to XFS_CORRUPTION_ERROR would have oopsed on this too)
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 7/7 xfs: modify verifiers to differentiate CRC failures from other errors
In reply to Eric SandeenModify all read & write verifiers to differentiate between CRC errors and other inconsistencies.
This sets the appropriate error number on bp->b_error, and then calls xfs_verifier_error() if something went wrong. That function will issue the appropriate message to the user.
--- fs/xfs/xfs_alloc.c | 37 +++++++++++++++++-------------------- fs/xfs/xfs_alloc_btree.c | 15 ++++++++------- fs/xfs/xfs_attr_leaf.c | 14 ++++++++------ fs/xfs/xfs_attr_remote.c | 15 ++++++--------- fs/xfs/xfs_bmap_btree.c | 16 ++++++++-------- fs/xfs/xfs_da_btree.c | 14 ++++++++------ fs/xfs/xfs_dir2_block.c | 14 ++++++++------ fs/xfs/xfs_dir2_data.c | 17 +++++++++-------- fs/xfs/xfs_dir2_leaf.c | 14 ++++++++------ fs/xfs/xfs_dir2_node.c | 14 ++++++++------ fs/xfs/xfs_dquot_buf.c | 11 +++++++---- fs/xfs/xfs_ialloc.c | 12 ++++++++---- fs/xfs/xfs_ialloc_btree.c | 15 ++++++++------- fs/xfs/xfs_inode_buf.c | 3 +-- fs/xfs/xfs_sb.c | 11 ++++------- fs/xfs/xfs_symlink_remote.c | 12 +++++++----- 16 files changed, 123 insertions(+), 111 deletions(-)
V2: unchanged other than modifications to accommodate prior changes.
fs/xfs/xfs_alloc.c +17 -20
@@ -474,7 +474,6 @@ xfs_agfl_read_verify( struct xfs_buf *bp) {struct xfs_mount *mp = bp->b_target->bt_mount; -int agfl_ok =1 ;/* * There is no verification of non-crc AGFLs because mkfs does not
@@ -485,14 +484,13 @@ xfs_agfl_read_verify(if (!xfs_sb_version_hascrc (&mp->m_sb))return ; - agfl_ok =xfs_buf_verify_cksum (bp,XFS_AGFL_CRC_OFF ); - - agfl_ok = agfl_ok &&xfs_agfl_verify (bp); - -if (!agfl_ok) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (!xfs_buf_verify_cksum (bp, offsetof(struct xfs_agfl , agfl_crc))) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_agfl_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -507,8 +505,8 @@ xfs_agfl_write_verify(return ;if (!xfs_agfl_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
@@ -2236,18 +2234,17 @@ xfs_agf_read_verify( struct xfs_buf *bp) {struct xfs_mount *mp = bp->b_target->bt_mount; -int agf_ok =1 ; - -if (xfs_sb_version_hascrc (&mp->m_sb)) - agf_ok =xfs_buf_verify_cksum (bp,XFS_AGF_CRC_OFF ); - agf_ok = agf_ok &&xfs_agf_verify (mp, bp); - -if (unlikely (XFS_TEST_ERROR (!agf_ok, mp,XFS_ERRTAG_ALLOC_READ_AGF , -XFS_RANDOM_ALLOC_READ_AGF ))) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (xfs_sb_version_hascrc (&mp->m_sb) && + !xfs_buf_verify_cksum (bp, offsetof(struct xfs_agf , agf_crc))) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (XFS_TEST_ERROR (!xfs_agf_verify (mp, bp), mp, +XFS_ERRTAG_ALLOC_READ_AGF , +XFS_RANDOM_ALLOC_READ_AGF ))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -2258,8 +2255,8 @@ xfs_agf_write_verify(struct xfs_buf_log_item *bip = bp->b_fspriv;if (!xfs_agf_verify (mp, bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
fs/xfs/xfs_alloc_btree.c +8 -7
@@ -355,12 +355,14 @@ static voidxfs_allocbt_read_verify ( struct xfs_buf *bp) { -if (!(xfs_btree_sblock_verify_crc (bp) && -xfs_allocbt_verify (bp))) { -trace_xfs_btree_corrupt (bp, _RET_IP_); -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - bp->b_target->bt_mount, bp->b_addr); +if (!xfs_btree_sblock_verify_crc (bp)) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_allocbt_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); + +if (bp->b_error) { +trace_xfs_btree_corrupt (bp, _RET_IP_); +xfs_verifier_error (bp); } }
@@ -370,9 +372,8 @@ xfs_allocbt_write_verify( {if (!xfs_allocbt_verify (bp)) {trace_xfs_btree_corrupt (bp, _RET_IP_); -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - bp->b_target->bt_mount, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }xfs_btree_sblock_calc_crc (bp);
fs/xfs/xfs_attr_leaf.c +8 -6
@@ -213,8 +213,8 @@ xfs_attr3_leaf_write_verify(struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;if (!xfs_attr3_leaf_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
@@ -239,12 +239,14 @@ xfs_attr3_leaf_read_verify( {struct xfs_mount *mp = bp->b_target->bt_mount; -if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_buf_verify_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF )) || - !xfs_attr3_leaf_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (xfs_sb_version_hascrc (&mp->m_sb) && + !xfs_buf_verify_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF )) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_attr3_leaf_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); }const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
fs/xfs/xfs_attr_remote.c +6 -9
@@ -125,7 +125,6 @@ xfs_attr3_rmt_read_verify(struct xfs_mount *mp = bp->b_target->bt_mount;char *ptr;int len; -bool corrupt = false;xfs_daddr_t bno;/* no verification of non-crc buffers */
@@ -140,11 +139,11 @@ xfs_attr3_rmt_read_verify(while (len >0 ) {if (!xfs_verify_cksum (ptr,XFS_LBSIZE (mp),XFS_ATTR3_RMT_CRC_OFF )) { - corrupt = true; +xfs_buf_ioerror (bp,EFSBADCRC );break ; }if (!xfs_attr3_rmt_verify (mp, ptr,XFS_LBSIZE (mp), bno)) { - corrupt = true; +xfs_buf_ioerror (bp,EFSCORRUPTED );break ; } len -=XFS_LBSIZE (mp);
@@ -152,10 +151,9 @@ xfs_attr3_rmt_read_verify( bno += mp->m_bsize; } -if (corrupt) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); -xfs_buf_ioerror (bp,EFSCORRUPTED ); - }else +if (bp->b_error) +xfs_verifier_error (bp); +else ASSERT (len ==0 ); }
@@ -180,9 +178,8 @@ xfs_attr3_rmt_write_verify(while (len >0 ) {if (!xfs_attr3_rmt_verify (mp, ptr,XFS_LBSIZE (mp), bno)) { -XFS_CORRUPTION_ERROR (__func__, -XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }if (bip) {
fs/xfs/xfs_bmap_btree.c +8 -8
@@ -780,12 +780,14 @@ static voidxfs_bmbt_read_verify ( struct xfs_buf *bp) { -if (!(xfs_btree_lblock_verify_crc (bp) && -xfs_bmbt_verify (bp))) { -trace_xfs_btree_corrupt (bp, _RET_IP_); -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - bp->b_target->bt_mount, bp->b_addr); +if (!xfs_btree_lblock_verify_crc (bp)) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_bmbt_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); + +if (bp->b_error) { +trace_xfs_btree_corrupt (bp, _RET_IP_); +xfs_verifier_error (bp); } }
@@ -794,11 +796,9 @@ xfs_bmbt_write_verify( struct xfs_buf *bp) {if (!xfs_bmbt_verify (bp)) { -xfs_warn (bp->b_target->bt_mount,"bmbt daddr 0x%llx failed" , bp->b_bn);trace_xfs_btree_corrupt (bp, _RET_IP_); -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - bp->b_target->bt_mount, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }xfs_btree_lblock_calc_crc (bp);
fs/xfs/xfs_da_btree.c +8 -6
@@ -185,8 +185,8 @@ xfs_da3_node_write_verify(struct xfs_da3_node_hdr *hdr3 = bp->b_addr;if (!xfs_da3_node_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
@@ -209,17 +209,20 @@ static voidxfs_da3_node_read_verify ( struct xfs_buf *bp) { -struct xfs_mount *mp = bp->b_target->bt_mount;struct xfs_da_blkinfo *info = bp->b_addr;switch (be16_to_cpu (info->magic)) {case XFS_DA3_NODE_MAGIC : -if (!xfs_buf_verify_cksum (bp,XFS_DA3_NODE_CRC_OFF )) +if (!xfs_buf_verify_cksum (bp,XFS_DA3_NODE_CRC_OFF )) { +xfs_buf_ioerror (bp,EFSBADCRC );break ; + }/* fall through */ case XFS_DA_NODE_MAGIC : -if (!xfs_da3_node_verify (bp)) +if (!xfs_da3_node_verify (bp)) { +xfs_buf_ioerror (bp,EFSCORRUPTED );break ; + }return ;case XFS_ATTR_LEAF_MAGIC :case XFS_ATTR3_LEAF_MAGIC :
@@ -236,8 +239,7 @@ xfs_da3_node_read_verify( }/* corrupt block */ -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); -xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp); }const struct xfs_buf_ops xfs_da3_node_buf_ops = {
fs/xfs/xfs_dir2_block.c +8 -6
@@ -89,12 +89,14 @@ xfs_dir3_block_read_verify( {struct xfs_mount *mp = bp->b_target->bt_mount; -if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_buf_verify_cksum (bp,XFS_DIR3_DATA_CRC_OFF )) || - !xfs_dir3_block_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (xfs_sb_version_hascrc (&mp->m_sb) && + !xfs_buf_verify_cksum (bp,XFS_DIR3_DATA_CRC_OFF )) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_dir3_block_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -106,8 +108,8 @@ xfs_dir3_block_write_verify(struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;if (!xfs_dir3_block_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
fs/xfs/xfs_dir2_data.c +9 -8
@@ -241,7 +241,6 @@ static voidxfs_dir3_data_reada_verify ( struct xfs_buf *bp) { -struct xfs_mount *mp = bp->b_target->bt_mount;struct xfs_dir2_data_hdr *hdr = bp->b_addr;switch (hdr->magic) {
@@ -255,8 +254,8 @@ xfs_dir3_data_reada_verify(xfs_dir3_data_verify (bp);return ;default : -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, hdr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);break ; } }
@@ -267,12 +266,14 @@ xfs_dir3_data_read_verify( {struct xfs_mount *mp = bp->b_target->bt_mount; -if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_buf_verify_cksum (bp,XFS_DIR3_DATA_CRC_OFF )) || - !xfs_dir3_data_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (xfs_sb_version_hascrc (&mp->m_sb) && + !xfs_buf_verify_cksum (bp,XFS_DIR3_DATA_CRC_OFF )) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_dir3_data_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -284,8 +285,8 @@ xfs_dir3_data_write_verify(struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;if (!xfs_dir3_data_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
fs/xfs/xfs_dir2_leaf.c +8 -6
@@ -179,12 +179,14 @@ __read_verify( {struct xfs_mount *mp = bp->b_target->bt_mount; -if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_buf_verify_cksum (bp,XFS_DIR3_LEAF_CRC_OFF )) || - !xfs_dir3_leaf_verify (bp, magic)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (xfs_sb_version_hascrc (&mp->m_sb) && + !xfs_buf_verify_cksum (bp,XFS_DIR3_LEAF_CRC_OFF )) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_dir3_leaf_verify (bp, magic))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -197,8 +199,8 @@ __write_verify(struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;if (!xfs_dir3_leaf_verify (bp, magic)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
fs/xfs/xfs_dir2_node.c +8 -6
@@ -115,12 +115,14 @@ xfs_dir3_free_read_verify( {struct xfs_mount *mp = bp->b_target->bt_mount; -if ((xfs_sb_version_hascrc (&mp->m_sb) && - !xfs_buf_verify_cksum (bp,XFS_DIR3_FREE_CRC_OFF )) || - !xfs_dir3_free_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (xfs_sb_version_hascrc (&mp->m_sb) && + !xfs_buf_verify_cksum (bp,XFS_DIR3_FREE_CRC_OFF )) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_dir3_free_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -132,8 +134,8 @@ xfs_dir3_free_write_verify(struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;if (!xfs_dir3_free_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
fs/xfs/xfs_dquot_buf.c +7 -4
@@ -257,10 +257,13 @@ xfs_dquot_buf_read_verify( {struct xfs_mount *mp = bp->b_target->bt_mount; -if (!xfs_dquot_buf_verify_crc (mp, bp) || !xfs_dquot_buf_verify (mp, bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (!xfs_dquot_buf_verify_crc (mp, bp)) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_dquot_buf_verify (mp, bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); }/*
@@ -275,8 +278,8 @@ xfs_dquot_buf_write_verify(struct xfs_mount *mp = bp->b_target->bt_mount;if (!xfs_dquot_buf_verify (mp, bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; } }
fs/xfs/xfs_ialloc.c +8 -4
@@ -1573,13 +1573,17 @@ xfs_agi_read_verify(if (xfs_sb_version_hascrc (&mp->m_sb)) agi_ok =xfs_buf_verify_cksum (bp,XFS_AGI_CRC_OFF ); +if (!agi_ok) +xfs_buf_ioerror (bp,EFSBADCRC ); + agi_ok = agi_ok &&xfs_agi_verify (bp);if (unlikely (XFS_TEST_ERROR (!agi_ok, mp,XFS_ERRTAG_IALLOC_READ_AGI , -XFS_RANDOM_IALLOC_READ_AGI ))) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +XFS_RANDOM_IALLOC_READ_AGI )))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -1590,8 +1594,8 @@ xfs_agi_write_verify(struct xfs_buf_log_item *bip = bp->b_fspriv;if (!xfs_agi_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
fs/xfs/xfs_ialloc_btree.c +8 -7
@@ -243,12 +243,14 @@ static voidxfs_inobt_read_verify ( struct xfs_buf *bp) { -if (!(xfs_btree_sblock_verify_crc (bp) && -xfs_inobt_verify (bp))) { -trace_xfs_btree_corrupt (bp, _RET_IP_); -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - bp->b_target->bt_mount, bp->b_addr); +if (!xfs_btree_sblock_verify_crc (bp)) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_inobt_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); + +if (bp->b_error) { +trace_xfs_btree_corrupt (bp, _RET_IP_); +xfs_verifier_error (bp); } }
@@ -258,9 +260,8 @@ xfs_inobt_write_verify( {if (!xfs_inobt_verify (bp)) {trace_xfs_btree_corrupt (bp, _RET_IP_); -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - bp->b_target->bt_mount, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }xfs_btree_sblock_calc_crc (bp);
fs/xfs/xfs_inode_buf.c +1 -2
@@ -102,8 +102,7 @@ xfs_inode_buf_verify( }xfs_buf_ioerror (bp,EFSCORRUPTED ); -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_HIGH , - mp, dip); +xfs_verifier_error (bp);#ifdef DEBUG xfs_alert(mp, "bad inode magic/vsn daddr %lld #%d (magic=%x)",
fs/xfs/xfs_sb.c +4 -7
@@ -615,7 +615,7 @@ xfs_sb_read_verify(/* Only fail bad secondaries on a known V5 filesystem */ if (bp->b_bn !=XFS_SB_DADDR &&xfs_sb_version_hascrc (&mp->m_sb)) { - error =EFSCORRUPTED ; + error =EFSBADCRC ; goto out_error; } }
@@ -624,10 +624,9 @@ xfs_sb_read_verify( out_error:if (error) { -if (error ==EFSCORRUPTED ) -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - mp, bp->b_addr);xfs_buf_ioerror (bp, error); +if (error ==EFSCORRUPTED || error ==EFSBADCRC ) +xfs_verifier_error (bp); } }
@@ -643,7 +642,6 @@ xfs_sb_quiet_read_verify( {struct xfs_dsb *dsb =XFS_BUF_TO_SBP (bp); -if (dsb->sb_magicnum ==cpu_to_be32 (XFS_SB_MAGIC )) {/* XFS filesystem, verify noisily! */ xfs_sb_read_verify (bp);
@@ -663,9 +661,8 @@ xfs_sb_write_verify( error =xfs_sb_verify (bp, false);if (error) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - mp, bp->b_addr);xfs_buf_ioerror (bp, error); +xfs_verifier_error (bp);return ; }
fs/xfs/xfs_symlink_remote.c +7 -5
@@ -133,11 +133,13 @@ xfs_symlink_read_verify(if (!xfs_sb_version_hascrc (&mp->m_sb))return ; -if (!xfs_buf_verify_cksum (bp,XFS_SYMLINK_CRC_OFF ) || - !xfs_symlink_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr); +if (!xfs_buf_verify_cksum (bp,XFS_SYMLINK_CRC_OFF )) +xfs_buf_ioerror (bp,EFSBADCRC ); +else if (!xfs_symlink_verify (bp))xfs_buf_ioerror (bp,EFSCORRUPTED ); - } + +if (bp->b_error) +xfs_verifier_error (bp); } static void
@@ -152,8 +154,8 @@ xfs_symlink_write_verify(return ;if (!xfs_symlink_verify (bp)) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); +xfs_verifier_error (bp);return ; }
-- 1.7.1
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs