xfs: add pre-write metadata buffer verifier callbacks
authorDave Chinner <dchinner@redhat.com>
Wed, 14 Nov 2012 06:52:32 +0000 (17:52 +1100)
committerBen Myers <bpm@sgi.com>
Fri, 16 Nov 2012 03:35:02 +0000 (21:35 -0600)
These verifiers are essentially the same code as the read verifiers,
but do not require ioend processing. Hence factor the read verifier
functions and add a new write verifier wrapper that is used as the
callback.

This is done as one large patch for all verifiers rather than one
patch per verifier as the change is largely mechanical. This
includes hooking up the write verifier via the read verifier
function.

Hooking up the write verifier for buffers obtained via
xfs_trans_get_buf() will be done in a separate patch as that touches
code in many different places rather than just the verifier
functions.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
20 files changed:
fs/xfs/xfs_alloc.c
fs/xfs/xfs_alloc_btree.c
fs/xfs/xfs_attr_leaf.c
fs/xfs/xfs_attr_leaf.h
fs/xfs/xfs_bmap_btree.c
fs/xfs/xfs_da_btree.c
fs/xfs/xfs_dir2_block.c
fs/xfs/xfs_dir2_data.c
fs/xfs/xfs_dir2_leaf.c
fs/xfs/xfs_dir2_node.c
fs/xfs/xfs_dir2_priv.h
fs/xfs/xfs_dquot.c
fs/xfs/xfs_dquot.h
fs/xfs/xfs_ialloc.c
fs/xfs/xfs_ialloc_btree.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_itable.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_qm.c

index 38b4ab8957ff6180a04ec461eded803baba86799..d12bbedf6fe522dd51423b12b691a639e531c641 100644 (file)
@@ -430,8 +430,8 @@ xfs_alloc_fixup_trees(
        return 0;
 }
 
-void
-xfs_agfl_read_verify(
+static void
+xfs_agfl_verify(
        struct xfs_buf  *bp)
 {
 #ifdef WHEN_CRCS_COME_ALONG
@@ -463,6 +463,21 @@ xfs_agfl_read_verify(
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
 #endif
+}
+
+static void
+xfs_agfl_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_agfl_verify(bp);
+}
+
+void
+xfs_agfl_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_agfl_verify(bp);
+       bp->b_pre_io = xfs_agfl_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
@@ -2129,7 +2144,7 @@ xfs_alloc_put_freelist(
 }
 
 static void
-xfs_agf_read_verify(
+xfs_agf_verify(
        struct xfs_buf  *bp)
  {
        struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -2164,7 +2179,21 @@ xfs_agf_read_verify(
                XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, agf);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
+
+static void
+xfs_agf_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_agf_verify(bp);
+}
 
+void
+xfs_agf_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_agf_verify(bp);
+       bp->b_pre_io = xfs_agf_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
index 46961e52e9b8c5dc48e522f67405b4027c02b4b1..6e98b22ebde0ab6137fdda35f4e0bcef606c16cf 100644 (file)
@@ -272,8 +272,8 @@ xfs_allocbt_key_diff(
        return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock;
 }
 
-void
-xfs_allocbt_read_verify(
+static void
+xfs_allocbt_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
@@ -323,11 +323,24 @@ xfs_allocbt_read_verify(
 
        if (!sblock_ok) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               XFS_CORRUPTION_ERROR("xfs_allocbt_read_verify",
-                                       XFS_ERRLEVEL_LOW, mp, block);
+               XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
 
+static void
+xfs_allocbt_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_allocbt_verify(bp);
+}
+
+void
+xfs_allocbt_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_allocbt_verify(bp);
+       bp->b_pre_io = xfs_allocbt_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
index efe170da288186c8b0fc9cb074fedf735f75284d..57729d71ab1a99960295cd2d2770d4656c9dc0a2 100644 (file)
@@ -88,7 +88,7 @@ STATIC void xfs_attr_leaf_moveents(xfs_attr_leafblock_t *src_leaf,
                                         xfs_mount_t *mp);
 STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);
 
-void
+static void
 xfs_attr_leaf_verify(
        struct xfs_buf          *bp)
 {
@@ -101,11 +101,26 @@ xfs_attr_leaf_verify(
                XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
+
+static void
+xfs_attr_leaf_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_attr_leaf_verify(bp);
+}
 
+void
+xfs_attr_leaf_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_attr_leaf_verify(bp);
+       bp->b_pre_io = xfs_attr_leaf_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
 
+
 int
 xfs_attr_leaf_read(
        struct xfs_trans        *tp,
@@ -115,7 +130,7 @@ xfs_attr_leaf_read(
        struct xfs_buf          **bpp)
 {
        return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
-                                       XFS_ATTR_FORK, xfs_attr_leaf_verify);
+                               XFS_ATTR_FORK, xfs_attr_leaf_read_verify);
 }
 
 /*========================================================================
index 098e9a58ad9fdaaa0498ff5711c9c8b6bbc3c649..3bbf6277e43c7dade40f007af1ddff86e34b8272 100644 (file)
@@ -264,6 +264,6 @@ int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
 int    xfs_attr_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
                        xfs_dablk_t bno, xfs_daddr_t mappedbno,
                        struct xfs_buf **bpp);
-void   xfs_attr_leaf_verify(struct xfs_buf *bp);
+void   xfs_attr_leaf_read_verify(struct xfs_buf *bp);
 
 #endif /* __XFS_ATTR_LEAF_H__ */
index bddca9b92869e1410dda11f9fd021f279e1c8b99..17d7423e7503c3d3b8fea5aa348550c113a4259f 100644 (file)
@@ -708,8 +708,8 @@ xfs_bmbt_key_diff(
                                      cur->bc_rec.b.br_startoff;
 }
 
-void
-xfs_bmbt_read_verify(
+static void
+xfs_bmbt_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
@@ -744,11 +744,24 @@ xfs_bmbt_read_verify(
 
        if (!lblock_ok) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               XFS_CORRUPTION_ERROR("xfs_bmbt_read_verify",
-                                       XFS_ERRLEVEL_LOW, mp, block);
+               XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
 
+static void
+xfs_bmbt_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_bmbt_verify(bp);
+}
+
+void
+xfs_bmbt_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_bmbt_verify(bp);
+       bp->b_pre_io = xfs_bmbt_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
index 93ebc0fc6dd9895275b0e7ee5152cf377e4723d6..6bb0a59eaaee6029231bcc1ca091f78189bac2b1 100644 (file)
@@ -92,7 +92,7 @@ STATIC int    xfs_da_blk_unlink(xfs_da_state_t *state,
 STATIC void    xfs_da_state_kill_altpath(xfs_da_state_t *state);
 
 static void
-__xfs_da_node_verify(
+xfs_da_node_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
@@ -108,12 +108,17 @@ __xfs_da_node_verify(
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
 
-       bp->b_iodone = NULL;
-       xfs_buf_ioend(bp, 0);
 }
 
 static void
-xfs_da_node_verify(
+xfs_da_node_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_da_node_verify(bp);
+}
+
+static void
+xfs_da_node_read_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
@@ -121,21 +126,22 @@ xfs_da_node_verify(
 
        switch (be16_to_cpu(info->magic)) {
                case XFS_DA_NODE_MAGIC:
-                       __xfs_da_node_verify(bp);
-                       return;
+                       xfs_da_node_verify(bp);
+                       break;
                case XFS_ATTR_LEAF_MAGIC:
-                       xfs_attr_leaf_verify(bp);
+                       xfs_attr_leaf_read_verify(bp);
                        return;
                case XFS_DIR2_LEAFN_MAGIC:
-                       xfs_dir2_leafn_verify(bp);
+                       xfs_dir2_leafn_read_verify(bp);
                        return;
                default:
+                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW,
+                                            mp, info);
+                       xfs_buf_ioerror(bp, EFSCORRUPTED);
                        break;
        }
 
-       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, info);
-       xfs_buf_ioerror(bp, EFSCORRUPTED);
-
+       bp->b_pre_io = xfs_da_node_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
@@ -150,7 +156,7 @@ xfs_da_node_read(
        int                     which_fork)
 {
        return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
-                                       which_fork, xfs_da_node_verify);
+                                       which_fork, xfs_da_node_read_verify);
 }
 
 /*========================================================================
@@ -816,7 +822,14 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
        xfs_da_blkinfo_onlychild_validate(bp->b_addr,
                                        be16_to_cpu(oldroot->hdr.level));
 
+       /*
+        * This could be copying a leaf back into the root block in the case of
+        * there only being a single leaf block left in the tree. Hence we have
+        * to update the pre_io pointer as well to match the buffer type change
+        * that could occur.
+        */
        memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize);
+       root_blk->bp->b_pre_io = bp->b_pre_io;
        xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1);
        error = xfs_da_shrink_inode(args, child, bp);
        return(error);
index ca03b109772d9b121b4198306afba61c47af6936..0f8793c74fe2608e0fbc7bc0cc799410986ce580 100644 (file)
@@ -71,7 +71,21 @@ xfs_dir2_block_verify(
                XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
 
+static void
+xfs_dir2_block_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_block_verify(bp);
+}
+
+void
+xfs_dir2_block_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_block_verify(bp);
+       bp->b_pre_io = xfs_dir2_block_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
@@ -85,7 +99,7 @@ xfs_dir2_block_read(
        struct xfs_mount        *mp = dp->i_mount;
 
        return xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, bpp,
-                                       XFS_DATA_FORK, xfs_dir2_block_verify);
+                               XFS_DATA_FORK, xfs_dir2_block_read_verify);
 }
 
 static void
index 1a43c8593c0077787781f73a8df28c8479fec1c8..b555585f5ab65cfdbe93f5a61bbeb4f3be11f710 100644 (file)
@@ -200,11 +200,26 @@ xfs_dir2_data_verify(
                XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
+
+static void
+xfs_dir2_data_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_data_verify(bp);
+}
 
+void
+xfs_dir2_data_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_data_verify(bp);
+       bp->b_pre_io = xfs_dir2_data_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
 
+
 int
 xfs_dir2_data_read(
        struct xfs_trans        *tp,
@@ -214,7 +229,7 @@ xfs_dir2_data_read(
        struct xfs_buf          **bpp)
 {
        return xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp,
-                                       XFS_DATA_FORK, xfs_dir2_data_verify);
+                               XFS_DATA_FORK, xfs_dir2_data_read_verify);
 }
 
 int
@@ -225,7 +240,7 @@ xfs_dir2_data_readahead(
        xfs_daddr_t             mapped_bno)
 {
        return xfs_da_reada_buf(tp, dp, bno, mapped_bno,
-                                       XFS_DATA_FORK, xfs_dir2_data_verify);
+                               XFS_DATA_FORK, xfs_dir2_data_read_verify);
 }
 
 /*
index 8a95547d42ac7b72a8dbca3fcea0cf1b7e224b29..5b3bcab2a656ab998e2e920829c9a081826be2c6 100644 (file)
@@ -62,23 +62,40 @@ xfs_dir2_leaf_verify(
                XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
+
+static void
+xfs_dir2_leaf1_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
+}
 
+static void
+xfs_dir2_leaf1_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
+       bp->b_pre_io = xfs_dir2_leaf1_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
 
 static void
-xfs_dir2_leaf1_verify(
-       struct xfs_buf          *bp)
+xfs_dir2_leafn_write_verify(
+       struct xfs_buf  *bp)
 {
-       xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
+       xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
 }
 
 void
-xfs_dir2_leafn_verify(
-       struct xfs_buf          *bp)
+xfs_dir2_leafn_read_verify(
+       struct xfs_buf  *bp)
 {
        xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
+       bp->b_pre_io = xfs_dir2_leafn_write_verify;
+       bp->b_iodone = NULL;
+       xfs_buf_ioend(bp, 0);
 }
 
 static int
@@ -90,7 +107,7 @@ xfs_dir2_leaf_read(
        struct xfs_buf          **bpp)
 {
        return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
-                                       XFS_DATA_FORK, xfs_dir2_leaf1_verify);
+                               XFS_DATA_FORK, xfs_dir2_leaf1_read_verify);
 }
 
 int
@@ -102,7 +119,7 @@ xfs_dir2_leafn_read(
        struct xfs_buf          **bpp)
 {
        return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
-                                       XFS_DATA_FORK, xfs_dir2_leafn_verify);
+                               XFS_DATA_FORK, xfs_dir2_leafn_read_verify);
 }
 
 /*
index 7c6f95697e28e645b0410a50bc2f904a725b5b94..a58abe1fc0d075ed7a79a8cee20021e232b33792 100644 (file)
@@ -69,11 +69,26 @@ xfs_dir2_free_verify(
                                     XFS_ERRLEVEL_LOW, mp, hdr);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
+
+static void
+xfs_dir2_free_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_free_verify(bp);
+}
 
+void
+xfs_dir2_free_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dir2_free_verify(bp);
+       bp->b_pre_io = xfs_dir2_free_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
 
+
 static int
 __xfs_dir2_free_read(
        struct xfs_trans        *tp,
@@ -83,7 +98,7 @@ __xfs_dir2_free_read(
        struct xfs_buf          **bpp)
 {
        return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
-                                       XFS_DATA_FORK, xfs_dir2_free_verify);
+                               XFS_DATA_FORK, xfs_dir2_free_read_verify);
 }
 
 int
index daf5d0fc6165a939915d068460226d4ca2327360..7ec61af8449f927ddd6ac9053a1eeb8aaf20074b 100644 (file)
@@ -72,7 +72,7 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,
                xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
 
 /* xfs_dir2_leaf.c */
-extern void xfs_dir2_leafn_verify(struct xfs_buf *bp);
+extern void xfs_dir2_leafn_read_verify(struct xfs_buf *bp);
 extern int xfs_dir2_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
                xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
 extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
index 0ba0f0992d6e0730f6a4ec0a01c4eb4420ce02cd..b38a10e6f2e09c3782c4e66faa8f843d8f7c12c1 100644 (file)
@@ -360,8 +360,8 @@ xfs_qm_dqalloc(
        return (error);
 }
 
-void
-xfs_dquot_read_verify(
+static void
+xfs_dquot_buf_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
@@ -388,12 +388,26 @@ xfs_dquot_read_verify(
                error = xfs_qm_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN,
                                        "xfs_dquot_read_verify");
                if (error) {
-                       XFS_CORRUPTION_ERROR("xfs_dquot_read_verify",
-                                            XFS_ERRLEVEL_LOW, mp, d);
+                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, d);
                        xfs_buf_ioerror(bp, EFSCORRUPTED);
                        break;
                }
        }
+}
+
+static void
+xfs_dquot_buf_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dquot_buf_verify(bp);
+}
+
+void
+xfs_dquot_buf_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_dquot_buf_verify(bp);
+       bp->b_pre_io = xfs_dquot_buf_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
@@ -413,7 +427,7 @@ xfs_qm_dqrepair(
 
        /*
         * Read the buffer without verification so we get the corrupted
-        * buffer returned to us.
+        * buffer returned to us. make sure we verify it on write, though.
         */
        error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, dqp->q_blkno,
                                   mp->m_quotainfo->qi_dqchunklen,
@@ -423,6 +437,7 @@ xfs_qm_dqrepair(
                ASSERT(*bpp == NULL);
                return XFS_ERROR(error);
        }
+       (*bpp)->b_pre_io = xfs_dquot_buf_write_verify;
 
        ASSERT(xfs_buf_islocked(*bpp));
        d = (struct xfs_dqblk *)(*bpp)->b_addr;
@@ -521,7 +536,7 @@ xfs_qm_dqtobp(
                error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
                                           dqp->q_blkno,
                                           mp->m_quotainfo->qi_dqchunklen,
-                                          0, &bp, xfs_dquot_read_verify);
+                                          0, &bp, xfs_dquot_buf_read_verify);
 
                if (error == EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) {
                        xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff *
index a08ba92d7da008d36656cd4817846fedb37d72b1..5438d883b628d156448ccc0187edc3aa6766d925 100644 (file)
@@ -140,7 +140,7 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)
 
 extern int             xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint,
                                        uint, struct xfs_dquot  **);
-extern void            xfs_dquot_read_verify(struct xfs_buf *bp);
+extern void            xfs_dquot_buf_read_verify(struct xfs_buf *bp);
 extern void            xfs_qm_dqdestroy(xfs_dquot_t *);
 extern int             xfs_qm_dqflush(struct xfs_dquot *, struct xfs_buf **);
 extern void            xfs_qm_dqunpin_wait(xfs_dquot_t *);
index 5bd255e5f7b84e6ac86eae1fdeb4d0e163e685b3..070f41845572c55f5b48ee84d38f63895a2cbdbd 100644 (file)
@@ -1473,7 +1473,7 @@ xfs_check_agi_unlinked(
 #endif
 
 static void
-xfs_agi_read_verify(
+xfs_agi_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -1502,6 +1502,21 @@ xfs_agi_read_verify(
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
        xfs_check_agi_unlinked(agi);
+}
+
+static void
+xfs_agi_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_agi_verify(bp);
+}
+
+void
+xfs_agi_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_agi_verify(bp);
+       bp->b_pre_io = xfs_agi_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
index 11306c6d61c7382c44a4bb2a1468380dc1cdc959..15a79f8ca03c9a26d0293004ba9db481a026e2c9 100644 (file)
@@ -183,7 +183,7 @@ xfs_inobt_key_diff(
 }
 
 void
-xfs_inobt_read_verify(
+xfs_inobt_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
@@ -211,11 +211,24 @@ xfs_inobt_read_verify(
 
        if (!sblock_ok) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               XFS_CORRUPTION_ERROR("xfs_inobt_read_verify",
-                                       XFS_ERRLEVEL_LOW, mp, block);
+               XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
                xfs_buf_ioerror(bp, EFSCORRUPTED);
        }
+}
+
+static void
+xfs_inobt_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_inobt_verify(bp);
+}
 
+void
+xfs_inobt_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_inobt_verify(bp);
+       bp->b_pre_io = xfs_inobt_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
index 3a243d07695068c03697209ac349c2eb406cf717..910b2da01042eec1f5811a6e5d47325e3df0e9d4 100644 (file)
@@ -382,7 +382,7 @@ xfs_inobp_check(
 }
 #endif
 
-void
+static void
 xfs_inode_buf_verify(
        struct xfs_buf  *bp)
 {
@@ -418,6 +418,21 @@ xfs_inode_buf_verify(
                }
        }
        xfs_inobp_check(mp, bp);
+}
+
+static void
+xfs_inode_buf_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_inode_buf_verify(bp);
+}
+
+void
+xfs_inode_buf_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_inode_buf_verify(bp);
+       bp->b_pre_io = xfs_inode_buf_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
@@ -447,7 +462,7 @@ xfs_imap_to_bp(
        buf_flags |= XBF_UNMAPPED;
        error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
                                   (int)imap->im_len, buf_flags, &bp,
-                                  xfs_inode_buf_verify);
+                                  xfs_inode_buf_read_verify);
        if (error) {
                if (error == EAGAIN) {
                        ASSERT(buf_flags & XBF_TRYLOCK);
index 1a892114792fb2b53cab66f939861100810374b7..a322c19723a3ebf1fca098894328bac80ad115d3 100644 (file)
@@ -554,7 +554,7 @@ int         xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
                               struct xfs_buf **, uint, uint);
 int            xfs_iread(struct xfs_mount *, struct xfs_trans *,
                          struct xfs_inode *, uint);
-void           xfs_inode_buf_verify(struct xfs_buf *);
+void           xfs_inode_buf_read_verify(struct xfs_buf *);
 void           xfs_dinode_to_disk(struct xfs_dinode *,
                                   struct xfs_icdinode *);
 void           xfs_idestroy_fork(struct xfs_inode *, int);
index 0f18d412e3e8313666d8477d72afaea59ea85216..7f86fdaab7ae13c77838e278298e611327e3f054 100644 (file)
@@ -397,7 +397,7 @@ xfs_bulkstat(
                                                        & ~r.ir_free)
                                                xfs_btree_reada_bufs(mp, agno,
                                                        agbno, nbcluster,
-                                                       xfs_inode_buf_verify);
+                                                       xfs_inode_buf_read_verify);
                                }
                                irbp->ir_startino = r.ir_startino;
                                irbp->ir_freecount = r.ir_freecount;
index bff18d73c6105deb3d38054301fc9b8158da62a6..c85da75e4a43006480979a73cb5ee7f3e4b57cf3 100644 (file)
@@ -612,8 +612,8 @@ xfs_sb_to_disk(
        }
 }
 
-void
-xfs_sb_read_verify(
+static void
+xfs_sb_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -629,6 +629,21 @@ xfs_sb_read_verify(
        error = xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR);
        if (error)
                xfs_buf_ioerror(bp, error);
+}
+
+static void
+xfs_sb_write_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_sb_verify(bp);
+}
+
+void
+xfs_sb_read_verify(
+       struct xfs_buf  *bp)
+{
+       xfs_sb_verify(bp);
+       bp->b_pre_io = xfs_sb_write_verify;
        bp->b_iodone = NULL;
        xfs_buf_ioend(bp, 0);
 }
index a6dfb97490cc95ce6ce867382e309f60f99859fd..bd40ae9624e54b26240e5f9af6a48d7a2540c566 100644 (file)
@@ -893,7 +893,7 @@ xfs_qm_dqiter_bufs(
                error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
                              XFS_FSB_TO_DADDR(mp, bno),
                              mp->m_quotainfo->qi_dqchunklen, 0, &bp,
-                             xfs_dquot_read_verify);
+                             xfs_dquot_buf_read_verify);
                if (error)
                        break;