aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-11-14 01:52:32 -0500
committerBen Myers <bpm@sgi.com>2012-11-15 22:35:02 -0500
commit612cfbfe174a89d565363fff7f3961a2dda5fb71 (patch)
tree46c44b5965ca17d8e47b1418158b2985ad12359e /fs/xfs
parentcfb02852226aa449fe27075caffe88726507668c (diff)
xfs: add pre-write metadata buffer verifier callbacks
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_alloc.c35
-rw-r--r--fs/xfs/xfs_alloc_btree.c21
-rw-r--r--fs/xfs/xfs_attr_leaf.c19
-rw-r--r--fs/xfs/xfs_attr_leaf.h2
-rw-r--r--fs/xfs/xfs_bmap_btree.c21
-rw-r--r--fs/xfs/xfs_da_btree.c37
-rw-r--r--fs/xfs/xfs_dir2_block.c16
-rw-r--r--fs/xfs/xfs_dir2_data.c19
-rw-r--r--fs/xfs/xfs_dir2_leaf.c31
-rw-r--r--fs/xfs/xfs_dir2_node.c17
-rw-r--r--fs/xfs/xfs_dir2_priv.h2
-rw-r--r--fs/xfs/xfs_dquot.c27
-rw-r--r--fs/xfs/xfs_dquot.h2
-rw-r--r--fs/xfs/xfs_ialloc.c17
-rw-r--r--fs/xfs/xfs_ialloc_btree.c19
-rw-r--r--fs/xfs/xfs_inode.c19
-rw-r--r--fs/xfs/xfs_inode.h2
-rw-r--r--fs/xfs/xfs_itable.c2
-rw-r--r--fs/xfs/xfs_mount.c19
-rw-r--r--fs/xfs/xfs_qm.c2
20 files changed, 273 insertions, 56 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index 38b4ab8957ff..d12bbedf6fe5 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -430,8 +430,8 @@ xfs_alloc_fixup_trees(
430 return 0; 430 return 0;
431} 431}
432 432
433void 433static void
434xfs_agfl_read_verify( 434xfs_agfl_verify(
435 struct xfs_buf *bp) 435 struct xfs_buf *bp)
436{ 436{
437#ifdef WHEN_CRCS_COME_ALONG 437#ifdef WHEN_CRCS_COME_ALONG
@@ -463,6 +463,21 @@ xfs_agfl_read_verify(
463 xfs_buf_ioerror(bp, EFSCORRUPTED); 463 xfs_buf_ioerror(bp, EFSCORRUPTED);
464 } 464 }
465#endif 465#endif
466}
467
468static void
469xfs_agfl_write_verify(
470 struct xfs_buf *bp)
471{
472 xfs_agfl_verify(bp);
473}
474
475void
476xfs_agfl_read_verify(
477 struct xfs_buf *bp)
478{
479 xfs_agfl_verify(bp);
480 bp->b_pre_io = xfs_agfl_write_verify;
466 bp->b_iodone = NULL; 481 bp->b_iodone = NULL;
467 xfs_buf_ioend(bp, 0); 482 xfs_buf_ioend(bp, 0);
468} 483}
@@ -2129,7 +2144,7 @@ xfs_alloc_put_freelist(
2129} 2144}
2130 2145
2131static void 2146static void
2132xfs_agf_read_verify( 2147xfs_agf_verify(
2133 struct xfs_buf *bp) 2148 struct xfs_buf *bp)
2134 { 2149 {
2135 struct xfs_mount *mp = bp->b_target->bt_mount; 2150 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -2164,7 +2179,21 @@ xfs_agf_read_verify(
2164 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, agf); 2179 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, agf);
2165 xfs_buf_ioerror(bp, EFSCORRUPTED); 2180 xfs_buf_ioerror(bp, EFSCORRUPTED);
2166 } 2181 }
2182}
2183
2184static void
2185xfs_agf_write_verify(
2186 struct xfs_buf *bp)
2187{
2188 xfs_agf_verify(bp);
2189}
2167 2190
2191void
2192xfs_agf_read_verify(
2193 struct xfs_buf *bp)
2194{
2195 xfs_agf_verify(bp);
2196 bp->b_pre_io = xfs_agf_write_verify;
2168 bp->b_iodone = NULL; 2197 bp->b_iodone = NULL;
2169 xfs_buf_ioend(bp, 0); 2198 xfs_buf_ioend(bp, 0);
2170} 2199}
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index 46961e52e9b8..6e98b22ebde0 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -272,8 +272,8 @@ xfs_allocbt_key_diff(
272 return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; 272 return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock;
273} 273}
274 274
275void 275static void
276xfs_allocbt_read_verify( 276xfs_allocbt_verify(
277 struct xfs_buf *bp) 277 struct xfs_buf *bp)
278{ 278{
279 struct xfs_mount *mp = bp->b_target->bt_mount; 279 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -323,11 +323,24 @@ xfs_allocbt_read_verify(
323 323
324 if (!sblock_ok) { 324 if (!sblock_ok) {
325 trace_xfs_btree_corrupt(bp, _RET_IP_); 325 trace_xfs_btree_corrupt(bp, _RET_IP_);
326 XFS_CORRUPTION_ERROR("xfs_allocbt_read_verify", 326 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
327 XFS_ERRLEVEL_LOW, mp, block);
328 xfs_buf_ioerror(bp, EFSCORRUPTED); 327 xfs_buf_ioerror(bp, EFSCORRUPTED);
329 } 328 }
329}
330 330
331static void
332xfs_allocbt_write_verify(
333 struct xfs_buf *bp)
334{
335 xfs_allocbt_verify(bp);
336}
337
338void
339xfs_allocbt_read_verify(
340 struct xfs_buf *bp)
341{
342 xfs_allocbt_verify(bp);
343 bp->b_pre_io = xfs_allocbt_write_verify;
331 bp->b_iodone = NULL; 344 bp->b_iodone = NULL;
332 xfs_buf_ioend(bp, 0); 345 xfs_buf_ioend(bp, 0);
333} 346}
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index efe170da2881..57729d71ab1a 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -88,7 +88,7 @@ STATIC void xfs_attr_leaf_moveents(xfs_attr_leafblock_t *src_leaf,
88 xfs_mount_t *mp); 88 xfs_mount_t *mp);
89STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); 89STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);
90 90
91void 91static void
92xfs_attr_leaf_verify( 92xfs_attr_leaf_verify(
93 struct xfs_buf *bp) 93 struct xfs_buf *bp)
94{ 94{
@@ -101,11 +101,26 @@ xfs_attr_leaf_verify(
101 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr); 101 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
102 xfs_buf_ioerror(bp, EFSCORRUPTED); 102 xfs_buf_ioerror(bp, EFSCORRUPTED);
103 } 103 }
104}
105
106static void
107xfs_attr_leaf_write_verify(
108 struct xfs_buf *bp)
109{
110 xfs_attr_leaf_verify(bp);
111}
104 112
113void
114xfs_attr_leaf_read_verify(
115 struct xfs_buf *bp)
116{
117 xfs_attr_leaf_verify(bp);
118 bp->b_pre_io = xfs_attr_leaf_write_verify;
105 bp->b_iodone = NULL; 119 bp->b_iodone = NULL;
106 xfs_buf_ioend(bp, 0); 120 xfs_buf_ioend(bp, 0);
107} 121}
108 122
123
109int 124int
110xfs_attr_leaf_read( 125xfs_attr_leaf_read(
111 struct xfs_trans *tp, 126 struct xfs_trans *tp,
@@ -115,7 +130,7 @@ xfs_attr_leaf_read(
115 struct xfs_buf **bpp) 130 struct xfs_buf **bpp)
116{ 131{
117 return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp, 132 return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
118 XFS_ATTR_FORK, xfs_attr_leaf_verify); 133 XFS_ATTR_FORK, xfs_attr_leaf_read_verify);
119} 134}
120 135
121/*======================================================================== 136/*========================================================================
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 098e9a58ad9f..3bbf6277e43c 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -264,6 +264,6 @@ int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
264int xfs_attr_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, 264int xfs_attr_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
265 xfs_dablk_t bno, xfs_daddr_t mappedbno, 265 xfs_dablk_t bno, xfs_daddr_t mappedbno,
266 struct xfs_buf **bpp); 266 struct xfs_buf **bpp);
267void xfs_attr_leaf_verify(struct xfs_buf *bp); 267void xfs_attr_leaf_read_verify(struct xfs_buf *bp);
268 268
269#endif /* __XFS_ATTR_LEAF_H__ */ 269#endif /* __XFS_ATTR_LEAF_H__ */
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index bddca9b92869..17d7423e7503 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -708,8 +708,8 @@ xfs_bmbt_key_diff(
708 cur->bc_rec.b.br_startoff; 708 cur->bc_rec.b.br_startoff;
709} 709}
710 710
711void 711static void
712xfs_bmbt_read_verify( 712xfs_bmbt_verify(
713 struct xfs_buf *bp) 713 struct xfs_buf *bp)
714{ 714{
715 struct xfs_mount *mp = bp->b_target->bt_mount; 715 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -744,11 +744,24 @@ xfs_bmbt_read_verify(
744 744
745 if (!lblock_ok) { 745 if (!lblock_ok) {
746 trace_xfs_btree_corrupt(bp, _RET_IP_); 746 trace_xfs_btree_corrupt(bp, _RET_IP_);
747 XFS_CORRUPTION_ERROR("xfs_bmbt_read_verify", 747 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
748 XFS_ERRLEVEL_LOW, mp, block);
749 xfs_buf_ioerror(bp, EFSCORRUPTED); 748 xfs_buf_ioerror(bp, EFSCORRUPTED);
750 } 749 }
750}
751 751
752static void
753xfs_bmbt_write_verify(
754 struct xfs_buf *bp)
755{
756 xfs_bmbt_verify(bp);
757}
758
759void
760xfs_bmbt_read_verify(
761 struct xfs_buf *bp)
762{
763 xfs_bmbt_verify(bp);
764 bp->b_pre_io = xfs_bmbt_write_verify;
752 bp->b_iodone = NULL; 765 bp->b_iodone = NULL;
753 xfs_buf_ioend(bp, 0); 766 xfs_buf_ioend(bp, 0);
754} 767}
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 93ebc0fc6dd9..6bb0a59eaaee 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -92,7 +92,7 @@ STATIC int xfs_da_blk_unlink(xfs_da_state_t *state,
92STATIC void xfs_da_state_kill_altpath(xfs_da_state_t *state); 92STATIC void xfs_da_state_kill_altpath(xfs_da_state_t *state);
93 93
94static void 94static void
95__xfs_da_node_verify( 95xfs_da_node_verify(
96 struct xfs_buf *bp) 96 struct xfs_buf *bp)
97{ 97{
98 struct xfs_mount *mp = bp->b_target->bt_mount; 98 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -108,12 +108,17 @@ __xfs_da_node_verify(
108 xfs_buf_ioerror(bp, EFSCORRUPTED); 108 xfs_buf_ioerror(bp, EFSCORRUPTED);
109 } 109 }
110 110
111 bp->b_iodone = NULL;
112 xfs_buf_ioend(bp, 0);
113} 111}
114 112
115static void 113static void
116xfs_da_node_verify( 114xfs_da_node_write_verify(
115 struct xfs_buf *bp)
116{
117 xfs_da_node_verify(bp);
118}
119
120static void
121xfs_da_node_read_verify(
117 struct xfs_buf *bp) 122 struct xfs_buf *bp)
118{ 123{
119 struct xfs_mount *mp = bp->b_target->bt_mount; 124 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -121,21 +126,22 @@ xfs_da_node_verify(
121 126
122 switch (be16_to_cpu(info->magic)) { 127 switch (be16_to_cpu(info->magic)) {
123 case XFS_DA_NODE_MAGIC: 128 case XFS_DA_NODE_MAGIC:
124 __xfs_da_node_verify(bp); 129 xfs_da_node_verify(bp);
125 return; 130 break;
126 case XFS_ATTR_LEAF_MAGIC: 131 case XFS_ATTR_LEAF_MAGIC:
127 xfs_attr_leaf_verify(bp); 132 xfs_attr_leaf_read_verify(bp);
128 return; 133 return;
129 case XFS_DIR2_LEAFN_MAGIC: 134 case XFS_DIR2_LEAFN_MAGIC:
130 xfs_dir2_leafn_verify(bp); 135 xfs_dir2_leafn_read_verify(bp);
131 return; 136 return;
132 default: 137 default:
138 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW,
139 mp, info);
140 xfs_buf_ioerror(bp, EFSCORRUPTED);
133 break; 141 break;
134 } 142 }
135 143
136 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, info); 144 bp->b_pre_io = xfs_da_node_write_verify;
137 xfs_buf_ioerror(bp, EFSCORRUPTED);
138
139 bp->b_iodone = NULL; 145 bp->b_iodone = NULL;
140 xfs_buf_ioend(bp, 0); 146 xfs_buf_ioend(bp, 0);
141} 147}
@@ -150,7 +156,7 @@ xfs_da_node_read(
150 int which_fork) 156 int which_fork)
151{ 157{
152 return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp, 158 return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
153 which_fork, xfs_da_node_verify); 159 which_fork, xfs_da_node_read_verify);
154} 160}
155 161
156/*======================================================================== 162/*========================================================================
@@ -816,7 +822,14 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
816 xfs_da_blkinfo_onlychild_validate(bp->b_addr, 822 xfs_da_blkinfo_onlychild_validate(bp->b_addr,
817 be16_to_cpu(oldroot->hdr.level)); 823 be16_to_cpu(oldroot->hdr.level));
818 824
825 /*
826 * This could be copying a leaf back into the root block in the case of
827 * there only being a single leaf block left in the tree. Hence we have
828 * to update the pre_io pointer as well to match the buffer type change
829 * that could occur.
830 */
819 memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize); 831 memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize);
832 root_blk->bp->b_pre_io = bp->b_pre_io;
820 xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); 833 xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1);
821 error = xfs_da_shrink_inode(args, child, bp); 834 error = xfs_da_shrink_inode(args, child, bp);
822 return(error); 835 return(error);
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index ca03b109772d..0f8793c74fe2 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -71,7 +71,21 @@ xfs_dir2_block_verify(
71 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr); 71 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
72 xfs_buf_ioerror(bp, EFSCORRUPTED); 72 xfs_buf_ioerror(bp, EFSCORRUPTED);
73 } 73 }
74}
74 75
76static void
77xfs_dir2_block_write_verify(
78 struct xfs_buf *bp)
79{
80 xfs_dir2_block_verify(bp);
81}
82
83void
84xfs_dir2_block_read_verify(
85 struct xfs_buf *bp)
86{
87 xfs_dir2_block_verify(bp);
88 bp->b_pre_io = xfs_dir2_block_write_verify;
75 bp->b_iodone = NULL; 89 bp->b_iodone = NULL;
76 xfs_buf_ioend(bp, 0); 90 xfs_buf_ioend(bp, 0);
77} 91}
@@ -85,7 +99,7 @@ xfs_dir2_block_read(
85 struct xfs_mount *mp = dp->i_mount; 99 struct xfs_mount *mp = dp->i_mount;
86 100
87 return xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, bpp, 101 return xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, bpp,
88 XFS_DATA_FORK, xfs_dir2_block_verify); 102 XFS_DATA_FORK, xfs_dir2_block_read_verify);
89} 103}
90 104
91static void 105static void
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 1a43c8593c00..b555585f5ab6 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -200,11 +200,26 @@ xfs_dir2_data_verify(
200 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr); 200 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
201 xfs_buf_ioerror(bp, EFSCORRUPTED); 201 xfs_buf_ioerror(bp, EFSCORRUPTED);
202 } 202 }
203}
204
205static void
206xfs_dir2_data_write_verify(
207 struct xfs_buf *bp)
208{
209 xfs_dir2_data_verify(bp);
210}
203 211
212void
213xfs_dir2_data_read_verify(
214 struct xfs_buf *bp)
215{
216 xfs_dir2_data_verify(bp);
217 bp->b_pre_io = xfs_dir2_data_write_verify;
204 bp->b_iodone = NULL; 218 bp->b_iodone = NULL;
205 xfs_buf_ioend(bp, 0); 219 xfs_buf_ioend(bp, 0);
206} 220}
207 221
222
208int 223int
209xfs_dir2_data_read( 224xfs_dir2_data_read(
210 struct xfs_trans *tp, 225 struct xfs_trans *tp,
@@ -214,7 +229,7 @@ xfs_dir2_data_read(
214 struct xfs_buf **bpp) 229 struct xfs_buf **bpp)
215{ 230{
216 return xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp, 231 return xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp,
217 XFS_DATA_FORK, xfs_dir2_data_verify); 232 XFS_DATA_FORK, xfs_dir2_data_read_verify);
218} 233}
219 234
220int 235int
@@ -225,7 +240,7 @@ xfs_dir2_data_readahead(
225 xfs_daddr_t mapped_bno) 240 xfs_daddr_t mapped_bno)
226{ 241{
227 return xfs_da_reada_buf(tp, dp, bno, mapped_bno, 242 return xfs_da_reada_buf(tp, dp, bno, mapped_bno,
228 XFS_DATA_FORK, xfs_dir2_data_verify); 243 XFS_DATA_FORK, xfs_dir2_data_read_verify);
229} 244}
230 245
231/* 246/*
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 8a95547d42ac..5b3bcab2a656 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -62,23 +62,40 @@ xfs_dir2_leaf_verify(
62 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr); 62 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
63 xfs_buf_ioerror(bp, EFSCORRUPTED); 63 xfs_buf_ioerror(bp, EFSCORRUPTED);
64 } 64 }
65}
66
67static void
68xfs_dir2_leaf1_write_verify(
69 struct xfs_buf *bp)
70{
71 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
72}
65 73
74static void
75xfs_dir2_leaf1_read_verify(
76 struct xfs_buf *bp)
77{
78 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
79 bp->b_pre_io = xfs_dir2_leaf1_write_verify;
66 bp->b_iodone = NULL; 80 bp->b_iodone = NULL;
67 xfs_buf_ioend(bp, 0); 81 xfs_buf_ioend(bp, 0);
68} 82}
69 83
70static void 84static void
71xfs_dir2_leaf1_verify( 85xfs_dir2_leafn_write_verify(
72 struct xfs_buf *bp) 86 struct xfs_buf *bp)
73{ 87{
74 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 88 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
75} 89}
76 90
77void 91void
78xfs_dir2_leafn_verify( 92xfs_dir2_leafn_read_verify(
79 struct xfs_buf *bp) 93 struct xfs_buf *bp)
80{ 94{
81 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 95 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
96 bp->b_pre_io = xfs_dir2_leafn_write_verify;
97 bp->b_iodone = NULL;
98 xfs_buf_ioend(bp, 0);
82} 99}
83 100
84static int 101static int
@@ -90,7 +107,7 @@ xfs_dir2_leaf_read(
90 struct xfs_buf **bpp) 107 struct xfs_buf **bpp)
91{ 108{
92 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, 109 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
93 XFS_DATA_FORK, xfs_dir2_leaf1_verify); 110 XFS_DATA_FORK, xfs_dir2_leaf1_read_verify);
94} 111}
95 112
96int 113int
@@ -102,7 +119,7 @@ xfs_dir2_leafn_read(
102 struct xfs_buf **bpp) 119 struct xfs_buf **bpp)
103{ 120{
104 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, 121 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
105 XFS_DATA_FORK, xfs_dir2_leafn_verify); 122 XFS_DATA_FORK, xfs_dir2_leafn_read_verify);
106} 123}
107 124
108/* 125/*
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 7c6f95697e28..a58abe1fc0d0 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -69,11 +69,26 @@ xfs_dir2_free_verify(
69 XFS_ERRLEVEL_LOW, mp, hdr); 69 XFS_ERRLEVEL_LOW, mp, hdr);
70 xfs_buf_ioerror(bp, EFSCORRUPTED); 70 xfs_buf_ioerror(bp, EFSCORRUPTED);
71 } 71 }
72}
73
74static void
75xfs_dir2_free_write_verify(
76 struct xfs_buf *bp)
77{
78 xfs_dir2_free_verify(bp);
79}
72 80
81void
82xfs_dir2_free_read_verify(
83 struct xfs_buf *bp)
84{
85 xfs_dir2_free_verify(bp);
86 bp->b_pre_io = xfs_dir2_free_write_verify;
73 bp->b_iodone = NULL; 87 bp->b_iodone = NULL;
74 xfs_buf_ioend(bp, 0); 88 xfs_buf_ioend(bp, 0);
75} 89}
76 90
91
77static int 92static int
78__xfs_dir2_free_read( 93__xfs_dir2_free_read(
79 struct xfs_trans *tp, 94 struct xfs_trans *tp,
@@ -83,7 +98,7 @@ __xfs_dir2_free_read(
83 struct xfs_buf **bpp) 98 struct xfs_buf **bpp)
84{ 99{
85 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, 100 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
86 XFS_DATA_FORK, xfs_dir2_free_verify); 101 XFS_DATA_FORK, xfs_dir2_free_read_verify);
87} 102}
88 103
89int 104int
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index daf5d0fc6165..7ec61af8449f 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -72,7 +72,7 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,
72 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp); 72 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
73 73
74/* xfs_dir2_leaf.c */ 74/* xfs_dir2_leaf.c */
75extern void xfs_dir2_leafn_verify(struct xfs_buf *bp); 75extern void xfs_dir2_leafn_read_verify(struct xfs_buf *bp);
76extern int xfs_dir2_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp, 76extern int xfs_dir2_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
77 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp); 77 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
78extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, 78extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 0ba0f0992d6e..b38a10e6f2e0 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -360,8 +360,8 @@ xfs_qm_dqalloc(
360 return (error); 360 return (error);
361} 361}
362 362
363void 363static void
364xfs_dquot_read_verify( 364xfs_dquot_buf_verify(
365 struct xfs_buf *bp) 365 struct xfs_buf *bp)
366{ 366{
367 struct xfs_mount *mp = bp->b_target->bt_mount; 367 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -388,12 +388,26 @@ xfs_dquot_read_verify(
388 error = xfs_qm_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN, 388 error = xfs_qm_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN,
389 "xfs_dquot_read_verify"); 389 "xfs_dquot_read_verify");
390 if (error) { 390 if (error) {
391 XFS_CORRUPTION_ERROR("xfs_dquot_read_verify", 391 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, d);
392 XFS_ERRLEVEL_LOW, mp, d);
393 xfs_buf_ioerror(bp, EFSCORRUPTED); 392 xfs_buf_ioerror(bp, EFSCORRUPTED);
394 break; 393 break;
395 } 394 }
396 } 395 }
396}
397
398static void
399xfs_dquot_buf_write_verify(
400 struct xfs_buf *bp)
401{
402 xfs_dquot_buf_verify(bp);
403}
404
405void
406xfs_dquot_buf_read_verify(
407 struct xfs_buf *bp)
408{
409 xfs_dquot_buf_verify(bp);
410 bp->b_pre_io = xfs_dquot_buf_write_verify;
397 bp->b_iodone = NULL; 411 bp->b_iodone = NULL;
398 xfs_buf_ioend(bp, 0); 412 xfs_buf_ioend(bp, 0);
399} 413}
@@ -413,7 +427,7 @@ xfs_qm_dqrepair(
413 427
414 /* 428 /*
415 * Read the buffer without verification so we get the corrupted 429 * Read the buffer without verification so we get the corrupted
416 * buffer returned to us. 430 * buffer returned to us. make sure we verify it on write, though.
417 */ 431 */
418 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, dqp->q_blkno, 432 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, dqp->q_blkno,
419 mp->m_quotainfo->qi_dqchunklen, 433 mp->m_quotainfo->qi_dqchunklen,
@@ -423,6 +437,7 @@ xfs_qm_dqrepair(
423 ASSERT(*bpp == NULL); 437 ASSERT(*bpp == NULL);
424 return XFS_ERROR(error); 438 return XFS_ERROR(error);
425 } 439 }
440 (*bpp)->b_pre_io = xfs_dquot_buf_write_verify;
426 441
427 ASSERT(xfs_buf_islocked(*bpp)); 442 ASSERT(xfs_buf_islocked(*bpp));
428 d = (struct xfs_dqblk *)(*bpp)->b_addr; 443 d = (struct xfs_dqblk *)(*bpp)->b_addr;
@@ -521,7 +536,7 @@ xfs_qm_dqtobp(
521 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, 536 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
522 dqp->q_blkno, 537 dqp->q_blkno,
523 mp->m_quotainfo->qi_dqchunklen, 538 mp->m_quotainfo->qi_dqchunklen,
524 0, &bp, xfs_dquot_read_verify); 539 0, &bp, xfs_dquot_buf_read_verify);
525 540
526 if (error == EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) { 541 if (error == EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) {
527 xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff * 542 xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff *
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h
index a08ba92d7da0..5438d883b628 100644
--- a/fs/xfs/xfs_dquot.h
+++ b/fs/xfs/xfs_dquot.h
@@ -140,7 +140,7 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)
140 140
141extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint, 141extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint,
142 uint, struct xfs_dquot **); 142 uint, struct xfs_dquot **);
143extern void xfs_dquot_read_verify(struct xfs_buf *bp); 143extern void xfs_dquot_buf_read_verify(struct xfs_buf *bp);
144extern void xfs_qm_dqdestroy(xfs_dquot_t *); 144extern void xfs_qm_dqdestroy(xfs_dquot_t *);
145extern int xfs_qm_dqflush(struct xfs_dquot *, struct xfs_buf **); 145extern int xfs_qm_dqflush(struct xfs_dquot *, struct xfs_buf **);
146extern void xfs_qm_dqunpin_wait(xfs_dquot_t *); 146extern void xfs_qm_dqunpin_wait(xfs_dquot_t *);
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 5bd255e5f7b8..070f41845572 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -1473,7 +1473,7 @@ xfs_check_agi_unlinked(
1473#endif 1473#endif
1474 1474
1475static void 1475static void
1476xfs_agi_read_verify( 1476xfs_agi_verify(
1477 struct xfs_buf *bp) 1477 struct xfs_buf *bp)
1478{ 1478{
1479 struct xfs_mount *mp = bp->b_target->bt_mount; 1479 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -1502,6 +1502,21 @@ xfs_agi_read_verify(
1502 xfs_buf_ioerror(bp, EFSCORRUPTED); 1502 xfs_buf_ioerror(bp, EFSCORRUPTED);
1503 } 1503 }
1504 xfs_check_agi_unlinked(agi); 1504 xfs_check_agi_unlinked(agi);
1505}
1506
1507static void
1508xfs_agi_write_verify(
1509 struct xfs_buf *bp)
1510{
1511 xfs_agi_verify(bp);
1512}
1513
1514void
1515xfs_agi_read_verify(
1516 struct xfs_buf *bp)
1517{
1518 xfs_agi_verify(bp);
1519 bp->b_pre_io = xfs_agi_write_verify;
1505 bp->b_iodone = NULL; 1520 bp->b_iodone = NULL;
1506 xfs_buf_ioend(bp, 0); 1521 xfs_buf_ioend(bp, 0);
1507} 1522}
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c
index 11306c6d61c7..15a79f8ca03c 100644
--- a/fs/xfs/xfs_ialloc_btree.c
+++ b/fs/xfs/xfs_ialloc_btree.c
@@ -183,7 +183,7 @@ xfs_inobt_key_diff(
183} 183}
184 184
185void 185void
186xfs_inobt_read_verify( 186xfs_inobt_verify(
187 struct xfs_buf *bp) 187 struct xfs_buf *bp)
188{ 188{
189 struct xfs_mount *mp = bp->b_target->bt_mount; 189 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -211,11 +211,24 @@ xfs_inobt_read_verify(
211 211
212 if (!sblock_ok) { 212 if (!sblock_ok) {
213 trace_xfs_btree_corrupt(bp, _RET_IP_); 213 trace_xfs_btree_corrupt(bp, _RET_IP_);
214 XFS_CORRUPTION_ERROR("xfs_inobt_read_verify", 214 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
215 XFS_ERRLEVEL_LOW, mp, block);
216 xfs_buf_ioerror(bp, EFSCORRUPTED); 215 xfs_buf_ioerror(bp, EFSCORRUPTED);
217 } 216 }
217}
218
219static void
220xfs_inobt_write_verify(
221 struct xfs_buf *bp)
222{
223 xfs_inobt_verify(bp);
224}
218 225
226void
227xfs_inobt_read_verify(
228 struct xfs_buf *bp)
229{
230 xfs_inobt_verify(bp);
231 bp->b_pre_io = xfs_inobt_write_verify;
219 bp->b_iodone = NULL; 232 bp->b_iodone = NULL;
220 xfs_buf_ioend(bp, 0); 233 xfs_buf_ioend(bp, 0);
221} 234}
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 3a243d076950..910b2da01042 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -382,7 +382,7 @@ xfs_inobp_check(
382} 382}
383#endif 383#endif
384 384
385void 385static void
386xfs_inode_buf_verify( 386xfs_inode_buf_verify(
387 struct xfs_buf *bp) 387 struct xfs_buf *bp)
388{ 388{
@@ -418,6 +418,21 @@ xfs_inode_buf_verify(
418 } 418 }
419 } 419 }
420 xfs_inobp_check(mp, bp); 420 xfs_inobp_check(mp, bp);
421}
422
423static void
424xfs_inode_buf_write_verify(
425 struct xfs_buf *bp)
426{
427 xfs_inode_buf_verify(bp);
428}
429
430void
431xfs_inode_buf_read_verify(
432 struct xfs_buf *bp)
433{
434 xfs_inode_buf_verify(bp);
435 bp->b_pre_io = xfs_inode_buf_write_verify;
421 bp->b_iodone = NULL; 436 bp->b_iodone = NULL;
422 xfs_buf_ioend(bp, 0); 437 xfs_buf_ioend(bp, 0);
423} 438}
@@ -447,7 +462,7 @@ xfs_imap_to_bp(
447 buf_flags |= XBF_UNMAPPED; 462 buf_flags |= XBF_UNMAPPED;
448 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, 463 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
449 (int)imap->im_len, buf_flags, &bp, 464 (int)imap->im_len, buf_flags, &bp,
450 xfs_inode_buf_verify); 465 xfs_inode_buf_read_verify);
451 if (error) { 466 if (error) {
452 if (error == EAGAIN) { 467 if (error == EAGAIN) {
453 ASSERT(buf_flags & XBF_TRYLOCK); 468 ASSERT(buf_flags & XBF_TRYLOCK);
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 1a892114792f..a322c19723a3 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -554,7 +554,7 @@ int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
554 struct xfs_buf **, uint, uint); 554 struct xfs_buf **, uint, uint);
555int xfs_iread(struct xfs_mount *, struct xfs_trans *, 555int xfs_iread(struct xfs_mount *, struct xfs_trans *,
556 struct xfs_inode *, uint); 556 struct xfs_inode *, uint);
557void xfs_inode_buf_verify(struct xfs_buf *); 557void xfs_inode_buf_read_verify(struct xfs_buf *);
558void xfs_dinode_to_disk(struct xfs_dinode *, 558void xfs_dinode_to_disk(struct xfs_dinode *,
559 struct xfs_icdinode *); 559 struct xfs_icdinode *);
560void xfs_idestroy_fork(struct xfs_inode *, int); 560void xfs_idestroy_fork(struct xfs_inode *, int);
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 0f18d412e3e8..7f86fdaab7ae 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -397,7 +397,7 @@ xfs_bulkstat(
397 & ~r.ir_free) 397 & ~r.ir_free)
398 xfs_btree_reada_bufs(mp, agno, 398 xfs_btree_reada_bufs(mp, agno,
399 agbno, nbcluster, 399 agbno, nbcluster,
400 xfs_inode_buf_verify); 400 xfs_inode_buf_read_verify);
401 } 401 }
402 irbp->ir_startino = r.ir_startino; 402 irbp->ir_startino = r.ir_startino;
403 irbp->ir_freecount = r.ir_freecount; 403 irbp->ir_freecount = r.ir_freecount;
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index bff18d73c610..c85da75e4a43 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -612,8 +612,8 @@ xfs_sb_to_disk(
612 } 612 }
613} 613}
614 614
615void 615static void
616xfs_sb_read_verify( 616xfs_sb_verify(
617 struct xfs_buf *bp) 617 struct xfs_buf *bp)
618{ 618{
619 struct xfs_mount *mp = bp->b_target->bt_mount; 619 struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -629,6 +629,21 @@ xfs_sb_read_verify(
629 error = xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR); 629 error = xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR);
630 if (error) 630 if (error)
631 xfs_buf_ioerror(bp, error); 631 xfs_buf_ioerror(bp, error);
632}
633
634static void
635xfs_sb_write_verify(
636 struct xfs_buf *bp)
637{
638 xfs_sb_verify(bp);
639}
640
641void
642xfs_sb_read_verify(
643 struct xfs_buf *bp)
644{
645 xfs_sb_verify(bp);
646 bp->b_pre_io = xfs_sb_write_verify;
632 bp->b_iodone = NULL; 647 bp->b_iodone = NULL;
633 xfs_buf_ioend(bp, 0); 648 xfs_buf_ioend(bp, 0);
634} 649}
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index a6dfb97490cc..bd40ae9624e5 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -893,7 +893,7 @@ xfs_qm_dqiter_bufs(
893 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, 893 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
894 XFS_FSB_TO_DADDR(mp, bno), 894 XFS_FSB_TO_DADDR(mp, bno),
895 mp->m_quotainfo->qi_dqchunklen, 0, &bp, 895 mp->m_quotainfo->qi_dqchunklen, 0, &bp,
896 xfs_dquot_read_verify); 896 xfs_dquot_buf_read_verify);
897 if (error) 897 if (error)
898 break; 898 break;
899 899