aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_alloc.c8
-rw-r--r--fs/xfs/xfs_alloc.h3
-rw-r--r--fs/xfs/xfs_alloc_btree.c1
-rw-r--r--fs/xfs/xfs_attr_leaf.c4
-rw-r--r--fs/xfs/xfs_bmap.c2
-rw-r--r--fs/xfs/xfs_bmap_btree.c3
-rw-r--r--fs/xfs/xfs_bmap_btree.h1
-rw-r--r--fs/xfs/xfs_btree.c1
-rw-r--r--fs/xfs/xfs_btree.h2
-rw-r--r--fs/xfs/xfs_da_btree.c3
-rw-r--r--fs/xfs/xfs_dir2_block.c2
-rw-r--r--fs/xfs/xfs_dir2_data.c11
-rw-r--r--fs/xfs/xfs_dir2_leaf.c19
-rw-r--r--fs/xfs/xfs_dir2_node.c24
-rw-r--r--fs/xfs/xfs_dir2_priv.h2
-rw-r--r--fs/xfs/xfs_dquot.c104
-rw-r--r--fs/xfs/xfs_fsops.c8
-rw-r--r--fs/xfs/xfs_ialloc.c5
-rw-r--r--fs/xfs/xfs_ialloc.h4
-rw-r--r--fs/xfs/xfs_ialloc_btree.c1
-rw-r--r--fs/xfs/xfs_inode.c14
-rw-r--r--fs/xfs/xfs_inode.h1
-rw-r--r--fs/xfs/xfs_mount.c2
-rw-r--r--fs/xfs/xfs_mount.h1
24 files changed, 137 insertions, 89 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index d12bbedf6fe5..545a6c4c2366 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -465,14 +465,14 @@ xfs_agfl_verify(
465#endif 465#endif
466} 466}
467 467
468static void 468void
469xfs_agfl_write_verify( 469xfs_agfl_write_verify(
470 struct xfs_buf *bp) 470 struct xfs_buf *bp)
471{ 471{
472 xfs_agfl_verify(bp); 472 xfs_agfl_verify(bp);
473} 473}
474 474
475void 475static void
476xfs_agfl_read_verify( 476xfs_agfl_read_verify(
477 struct xfs_buf *bp) 477 struct xfs_buf *bp)
478{ 478{
@@ -2181,14 +2181,14 @@ xfs_agf_verify(
2181 } 2181 }
2182} 2182}
2183 2183
2184static void 2184void
2185xfs_agf_write_verify( 2185xfs_agf_write_verify(
2186 struct xfs_buf *bp) 2186 struct xfs_buf *bp)
2187{ 2187{
2188 xfs_agf_verify(bp); 2188 xfs_agf_verify(bp);
2189} 2189}
2190 2190
2191void 2191static void
2192xfs_agf_read_verify( 2192xfs_agf_read_verify(
2193 struct xfs_buf *bp) 2193 struct xfs_buf *bp)
2194{ 2194{
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h
index feacb061bab7..f32811f50f43 100644
--- a/fs/xfs/xfs_alloc.h
+++ b/fs/xfs/xfs_alloc.h
@@ -231,4 +231,7 @@ xfs_alloc_get_rec(
231 xfs_extlen_t *len, /* output: length of extent */ 231 xfs_extlen_t *len, /* output: length of extent */
232 int *stat); /* output: success/failure */ 232 int *stat); /* output: success/failure */
233 233
234void xfs_agf_write_verify(struct xfs_buf *bp);
235void xfs_agfl_write_verify(struct xfs_buf *bp);
236
234#endif /* __XFS_ALLOC_H__ */ 237#endif /* __XFS_ALLOC_H__ */
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index 6e98b22ebde0..b83396524913 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -401,6 +401,7 @@ static const struct xfs_btree_ops xfs_allocbt_ops = {
401 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur, 401 .init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
402 .key_diff = xfs_allocbt_key_diff, 402 .key_diff = xfs_allocbt_key_diff,
403 .read_verify = xfs_allocbt_read_verify, 403 .read_verify = xfs_allocbt_read_verify,
404 .write_verify = xfs_allocbt_write_verify,
404#ifdef DEBUG 405#ifdef DEBUG
405 .keys_inorder = xfs_allocbt_keys_inorder, 406 .keys_inorder = xfs_allocbt_keys_inorder,
406 .recs_inorder = xfs_allocbt_recs_inorder, 407 .recs_inorder = xfs_allocbt_recs_inorder,
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 57729d71ab1a..5cd5b0c1d17a 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -924,7 +924,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
924 XFS_ATTR_FORK); 924 XFS_ATTR_FORK);
925 if (error) 925 if (error)
926 goto out; 926 goto out;
927 ASSERT(bp2 != NULL); 927 bp2->b_pre_io = bp1->b_pre_io;
928 memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(dp->i_mount)); 928 memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(dp->i_mount));
929 bp1 = NULL; 929 bp1 = NULL;
930 xfs_trans_log_buf(args->trans, bp2, 0, XFS_LBSIZE(dp->i_mount) - 1); 930 xfs_trans_log_buf(args->trans, bp2, 0, XFS_LBSIZE(dp->i_mount) - 1);
@@ -978,7 +978,7 @@ xfs_attr_leaf_create(
978 XFS_ATTR_FORK); 978 XFS_ATTR_FORK);
979 if (error) 979 if (error)
980 return(error); 980 return(error);
981 ASSERT(bp != NULL); 981 bp->b_pre_io = xfs_attr_leaf_write_verify;
982 leaf = bp->b_addr; 982 leaf = bp->b_addr;
983 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); 983 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
984 hdr = &leaf->hdr; 984 hdr = &leaf->hdr;
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 9ae7aba52e0f..6a0f3f9f39d3 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -3124,6 +3124,7 @@ xfs_bmap_extents_to_btree(
3124 /* 3124 /*
3125 * Fill in the child block. 3125 * Fill in the child block.
3126 */ 3126 */
3127 abp->b_pre_io = xfs_bmbt_write_verify;
3127 ablock = XFS_BUF_TO_BLOCK(abp); 3128 ablock = XFS_BUF_TO_BLOCK(abp);
3128 ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); 3129 ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
3129 ablock->bb_level = 0; 3130 ablock->bb_level = 0;
@@ -3270,6 +3271,7 @@ xfs_bmap_local_to_extents(
3270 ASSERT(args.len == 1); 3271 ASSERT(args.len == 1);
3271 *firstblock = args.fsbno; 3272 *firstblock = args.fsbno;
3272 bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); 3273 bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0);
3274 bp->b_pre_io = xfs_bmbt_write_verify;
3273 memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); 3275 memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes);
3274 xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); 3276 xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1);
3275 xfs_bmap_forkoff_reset(args.mp, ip, whichfork); 3277 xfs_bmap_forkoff_reset(args.mp, ip, whichfork);
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 17d7423e7503..79758e1e4f74 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -749,7 +749,7 @@ xfs_bmbt_verify(
749 } 749 }
750} 750}
751 751
752static void 752void
753xfs_bmbt_write_verify( 753xfs_bmbt_write_verify(
754 struct xfs_buf *bp) 754 struct xfs_buf *bp)
755{ 755{
@@ -806,6 +806,7 @@ static const struct xfs_btree_ops xfs_bmbt_ops = {
806 .init_ptr_from_cur = xfs_bmbt_init_ptr_from_cur, 806 .init_ptr_from_cur = xfs_bmbt_init_ptr_from_cur,
807 .key_diff = xfs_bmbt_key_diff, 807 .key_diff = xfs_bmbt_key_diff,
808 .read_verify = xfs_bmbt_read_verify, 808 .read_verify = xfs_bmbt_read_verify,
809 .write_verify = xfs_bmbt_write_verify,
809#ifdef DEBUG 810#ifdef DEBUG
810 .keys_inorder = xfs_bmbt_keys_inorder, 811 .keys_inorder = xfs_bmbt_keys_inorder,
811 .recs_inorder = xfs_bmbt_recs_inorder, 812 .recs_inorder = xfs_bmbt_recs_inorder,
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 1d00fbe9dd79..938c85986549 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -233,6 +233,7 @@ extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level);
233extern int xfs_bmdr_maxrecs(struct xfs_mount *, int blocklen, int leaf); 233extern int xfs_bmdr_maxrecs(struct xfs_mount *, int blocklen, int leaf);
234extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf); 234extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf);
235extern void xfs_bmbt_read_verify(struct xfs_buf *bp); 235extern void xfs_bmbt_read_verify(struct xfs_buf *bp);
236extern void xfs_bmbt_write_verify(struct xfs_buf *bp);
236 237
237extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *, 238extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
238 struct xfs_trans *, struct xfs_inode *, int); 239 struct xfs_trans *, struct xfs_inode *, int);
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index ef1066078c33..1e2d89eed2a4 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -996,6 +996,7 @@ xfs_btree_get_buf_block(
996 if (!*bpp) 996 if (!*bpp)
997 return ENOMEM; 997 return ENOMEM;
998 998
999 (*bpp)->b_pre_io = cur->bc_ops->write_verify;
999 *block = XFS_BUF_TO_BLOCK(*bpp); 1000 *block = XFS_BUF_TO_BLOCK(*bpp);
1000 return 0; 1001 return 0;
1001} 1002}
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 3a4c314047a0..458ab3550898 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -189,6 +189,8 @@ struct xfs_btree_ops {
189 union xfs_btree_key *key); 189 union xfs_btree_key *key);
190 190
191 void (*read_verify)(struct xfs_buf *bp); 191 void (*read_verify)(struct xfs_buf *bp);
192 void (*write_verify)(struct xfs_buf *bp);
193
192#ifdef DEBUG 194#ifdef DEBUG
193 /* check that k1 is lower than k2 */ 195 /* check that k1 is lower than k2 */
194 int (*keys_inorder)(struct xfs_btree_cur *cur, 196 int (*keys_inorder)(struct xfs_btree_cur *cur,
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 6bb0a59eaaee..087950fc2eb7 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -193,6 +193,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
193 xfs_trans_log_buf(tp, bp, 193 xfs_trans_log_buf(tp, bp,
194 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 194 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
195 195
196 bp->b_pre_io = xfs_da_node_write_verify;
196 *bpp = bp; 197 *bpp = bp;
197 return(0); 198 return(0);
198} 199}
@@ -392,6 +393,8 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
392 } 393 }
393 memcpy(node, oldroot, size); 394 memcpy(node, oldroot, size);
394 xfs_trans_log_buf(tp, bp, 0, size - 1); 395 xfs_trans_log_buf(tp, bp, 0, size - 1);
396
397 bp->b_pre_io = blk1->bp->b_pre_io;
395 blk1->bp = bp; 398 blk1->bp = bp;
396 blk1->blkno = blkno; 399 blk1->blkno = blkno;
397 400
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 0f8793c74fe2..e2fdc6f03d8a 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -1010,6 +1010,7 @@ xfs_dir2_leaf_to_block(
1010 /* 1010 /*
1011 * Start converting it to block form. 1011 * Start converting it to block form.
1012 */ 1012 */
1013 dbp->b_pre_io = xfs_dir2_block_write_verify;
1013 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); 1014 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
1014 needlog = 1; 1015 needlog = 1;
1015 needscan = 0; 1016 needscan = 0;
@@ -1139,6 +1140,7 @@ xfs_dir2_sf_to_block(
1139 kmem_free(sfp); 1140 kmem_free(sfp);
1140 return error; 1141 return error;
1141 } 1142 }
1143 bp->b_pre_io = xfs_dir2_block_write_verify;
1142 hdr = bp->b_addr; 1144 hdr = bp->b_addr;
1143 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); 1145 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
1144 /* 1146 /*
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index b555585f5ab6..dcb8a873ab92 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -185,7 +185,7 @@ __xfs_dir2_data_check(
185 return 0; 185 return 0;
186} 186}
187 187
188void 188static void
189xfs_dir2_data_verify( 189xfs_dir2_data_verify(
190 struct xfs_buf *bp) 190 struct xfs_buf *bp)
191{ 191{
@@ -202,14 +202,14 @@ xfs_dir2_data_verify(
202 } 202 }
203} 203}
204 204
205static void 205void
206xfs_dir2_data_write_verify( 206xfs_dir2_data_write_verify(
207 struct xfs_buf *bp) 207 struct xfs_buf *bp)
208{ 208{
209 xfs_dir2_data_verify(bp); 209 xfs_dir2_data_verify(bp);
210} 210}
211 211
212void 212static void
213xfs_dir2_data_read_verify( 213xfs_dir2_data_read_verify(
214 struct xfs_buf *bp) 214 struct xfs_buf *bp)
215{ 215{
@@ -482,10 +482,9 @@ xfs_dir2_data_init(
482 */ 482 */
483 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, blkno), -1, &bp, 483 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, blkno), -1, &bp,
484 XFS_DATA_FORK); 484 XFS_DATA_FORK);
485 if (error) { 485 if (error)
486 return error; 486 return error;
487 } 487 bp->b_pre_io = xfs_dir2_data_write_verify;
488 ASSERT(bp != NULL);
489 488
490 /* 489 /*
491 * Initialize the header. 490 * Initialize the header.
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 5b3bcab2a656..3002ab7d54c3 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -81,7 +81,7 @@ xfs_dir2_leaf1_read_verify(
81 xfs_buf_ioend(bp, 0); 81 xfs_buf_ioend(bp, 0);
82} 82}
83 83
84static void 84void
85xfs_dir2_leafn_write_verify( 85xfs_dir2_leafn_write_verify(
86 struct xfs_buf *bp) 86 struct xfs_buf *bp)
87{ 87{
@@ -198,6 +198,7 @@ xfs_dir2_block_to_leaf(
198 /* 198 /*
199 * Fix up the block header, make it a data block. 199 * Fix up the block header, make it a data block.
200 */ 200 */
201 dbp->b_pre_io = xfs_dir2_data_write_verify;
201 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); 202 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
202 if (needscan) 203 if (needscan)
203 xfs_dir2_data_freescan(mp, hdr, &needlog); 204 xfs_dir2_data_freescan(mp, hdr, &needlog);
@@ -1243,15 +1244,14 @@ xfs_dir2_leaf_init(
1243 * Get the buffer for the block. 1244 * Get the buffer for the block.
1244 */ 1245 */
1245 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp, 1246 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp,
1246 XFS_DATA_FORK); 1247 XFS_DATA_FORK);
1247 if (error) { 1248 if (error)
1248 return error; 1249 return error;
1249 } 1250
1250 ASSERT(bp != NULL);
1251 leaf = bp->b_addr;
1252 /* 1251 /*
1253 * Initialize the header. 1252 * Initialize the header.
1254 */ 1253 */
1254 leaf = bp->b_addr;
1255 leaf->hdr.info.magic = cpu_to_be16(magic); 1255 leaf->hdr.info.magic = cpu_to_be16(magic);
1256 leaf->hdr.info.forw = 0; 1256 leaf->hdr.info.forw = 0;
1257 leaf->hdr.info.back = 0; 1257 leaf->hdr.info.back = 0;
@@ -1264,10 +1264,12 @@ xfs_dir2_leaf_init(
1264 * the block. 1264 * the block.
1265 */ 1265 */
1266 if (magic == XFS_DIR2_LEAF1_MAGIC) { 1266 if (magic == XFS_DIR2_LEAF1_MAGIC) {
1267 bp->b_pre_io = xfs_dir2_leaf1_write_verify;
1267 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1268 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1268 ltp->bestcount = 0; 1269 ltp->bestcount = 0;
1269 xfs_dir2_leaf_log_tail(tp, bp); 1270 xfs_dir2_leaf_log_tail(tp, bp);
1270 } 1271 } else
1272 bp->b_pre_io = xfs_dir2_leafn_write_verify;
1271 *bpp = bp; 1273 *bpp = bp;
1272 return 0; 1274 return 0;
1273} 1275}
@@ -1951,7 +1953,10 @@ xfs_dir2_node_to_leaf(
1951 xfs_dir2_leaf_compact(args, lbp); 1953 xfs_dir2_leaf_compact(args, lbp);
1952 else 1954 else
1953 xfs_dir2_leaf_log_header(tp, lbp); 1955 xfs_dir2_leaf_log_header(tp, lbp);
1956
1957 lbp->b_pre_io = xfs_dir2_leaf1_write_verify;
1954 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC); 1958 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC);
1959
1955 /* 1960 /*
1956 * Set up the leaf tail from the freespace block. 1961 * Set up the leaf tail from the freespace block.
1957 */ 1962 */
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index a58abe1fc0d0..da90a91f4420 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -197,11 +197,12 @@ xfs_dir2_leaf_to_node(
197 /* 197 /*
198 * Get the buffer for the new freespace block. 198 * Get the buffer for the new freespace block.
199 */ 199 */
200 if ((error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, fdb), -1, &fbp, 200 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, fdb), -1, &fbp,
201 XFS_DATA_FORK))) { 201 XFS_DATA_FORK);
202 if (error)
202 return error; 203 return error;
203 } 204 fbp->b_pre_io = xfs_dir2_free_write_verify;
204 ASSERT(fbp != NULL); 205
205 free = fbp->b_addr; 206 free = fbp->b_addr;
206 leaf = lbp->b_addr; 207 leaf = lbp->b_addr;
207 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 208 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
@@ -223,7 +224,10 @@ xfs_dir2_leaf_to_node(
223 *to = cpu_to_be16(off); 224 *to = cpu_to_be16(off);
224 } 225 }
225 free->hdr.nused = cpu_to_be32(n); 226 free->hdr.nused = cpu_to_be32(n);
227
228 lbp->b_pre_io = xfs_dir2_leafn_write_verify;
226 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAFN_MAGIC); 229 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAFN_MAGIC);
230
227 /* 231 /*
228 * Log everything. 232 * Log everything.
229 */ 233 */
@@ -632,6 +636,7 @@ xfs_dir2_leafn_lookup_for_entry(
632 state->extrablk.index = (int)((char *)dep - 636 state->extrablk.index = (int)((char *)dep -
633 (char *)curbp->b_addr); 637 (char *)curbp->b_addr);
634 state->extrablk.magic = XFS_DIR2_DATA_MAGIC; 638 state->extrablk.magic = XFS_DIR2_DATA_MAGIC;
639 curbp->b_pre_io = xfs_dir2_data_write_verify;
635 if (cmp == XFS_CMP_EXACT) 640 if (cmp == XFS_CMP_EXACT)
636 return XFS_ERROR(EEXIST); 641 return XFS_ERROR(EEXIST);
637 } 642 }
@@ -646,6 +651,7 @@ xfs_dir2_leafn_lookup_for_entry(
646 state->extrablk.index = -1; 651 state->extrablk.index = -1;
647 state->extrablk.blkno = curdb; 652 state->extrablk.blkno = curdb;
648 state->extrablk.magic = XFS_DIR2_DATA_MAGIC; 653 state->extrablk.magic = XFS_DIR2_DATA_MAGIC;
654 curbp->b_pre_io = xfs_dir2_data_write_verify;
649 } else { 655 } else {
650 /* If the curbp is not the CI match block, drop it */ 656 /* If the curbp is not the CI match block, drop it */
651 if (state->extrablk.bp != curbp) 657 if (state->extrablk.bp != curbp)
@@ -1638,12 +1644,12 @@ xfs_dir2_node_addname_int(
1638 /* 1644 /*
1639 * Get a buffer for the new block. 1645 * Get a buffer for the new block.
1640 */ 1646 */
1641 if ((error = xfs_da_get_buf(tp, dp, 1647 error = xfs_da_get_buf(tp, dp,
1642 xfs_dir2_db_to_da(mp, fbno), 1648 xfs_dir2_db_to_da(mp, fbno),
1643 -1, &fbp, XFS_DATA_FORK))) { 1649 -1, &fbp, XFS_DATA_FORK);
1650 if (error)
1644 return error; 1651 return error;
1645 } 1652 fbp->b_pre_io = xfs_dir2_free_write_verify;
1646 ASSERT(fbp != NULL);
1647 1653
1648 /* 1654 /*
1649 * Initialize the new block to be empty, and remember 1655 * Initialize the new block to be empty, and remember
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 7ec61af8449f..01b82dcddc3e 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -45,6 +45,7 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
45#else 45#else
46#define xfs_dir2_data_check(dp,bp) 46#define xfs_dir2_data_check(dp,bp)
47#endif 47#endif
48extern void xfs_dir2_data_write_verify(struct xfs_buf *bp);
48extern int __xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_buf *bp); 49extern int __xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
49extern int xfs_dir2_data_read(struct xfs_trans *tp, struct xfs_inode *dp, 50extern int xfs_dir2_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
50 xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp); 51 xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
@@ -73,6 +74,7 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,
73 74
74/* xfs_dir2_leaf.c */ 75/* xfs_dir2_leaf.c */
75extern void xfs_dir2_leafn_read_verify(struct xfs_buf *bp); 76extern void xfs_dir2_leafn_read_verify(struct xfs_buf *bp);
77extern void xfs_dir2_leafn_write_verify(struct xfs_buf *bp);
76extern int xfs_dir2_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp, 78extern 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); 79 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
78extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, 80extern 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 b38a10e6f2e0..1b06aa051074 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -248,7 +248,57 @@ xfs_qm_init_dquot_blk(
248 xfs_trans_log_buf(tp, bp, 0, BBTOB(q->qi_dqchunklen) - 1); 248 xfs_trans_log_buf(tp, bp, 0, BBTOB(q->qi_dqchunklen) - 1);
249} 249}
250 250
251static void
252xfs_dquot_buf_verify(
253 struct xfs_buf *bp)
254{
255 struct xfs_mount *mp = bp->b_target->bt_mount;
256 struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr;
257 struct xfs_disk_dquot *ddq;
258 xfs_dqid_t id = 0;
259 int i;
260
261 /*
262 * On the first read of the buffer, verify that each dquot is valid.
263 * We don't know what the id of the dquot is supposed to be, just that
264 * they should be increasing monotonically within the buffer. If the
265 * first id is corrupt, then it will fail on the second dquot in the
266 * buffer so corruptions could point to the wrong dquot in this case.
267 */
268 for (i = 0; i < mp->m_quotainfo->qi_dqperchunk; i++) {
269 int error;
270
271 ddq = &d[i].dd_diskdq;
272
273 if (i == 0)
274 id = be32_to_cpu(ddq->d_id);
275
276 error = xfs_qm_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN,
277 "xfs_dquot_read_verify");
278 if (error) {
279 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, d);
280 xfs_buf_ioerror(bp, EFSCORRUPTED);
281 break;
282 }
283 }
284}
285
286static void
287xfs_dquot_buf_write_verify(
288 struct xfs_buf *bp)
289{
290 xfs_dquot_buf_verify(bp);
291}
251 292
293void
294xfs_dquot_buf_read_verify(
295 struct xfs_buf *bp)
296{
297 xfs_dquot_buf_verify(bp);
298 bp->b_pre_io = xfs_dquot_buf_write_verify;
299 bp->b_iodone = NULL;
300 xfs_buf_ioend(bp, 0);
301}
252 302
253/* 303/*
254 * Allocate a block and fill it with dquots. 304 * Allocate a block and fill it with dquots.
@@ -315,6 +365,7 @@ xfs_qm_dqalloc(
315 error = xfs_buf_geterror(bp); 365 error = xfs_buf_geterror(bp);
316 if (error) 366 if (error)
317 goto error1; 367 goto error1;
368 bp->b_pre_io = xfs_dquot_buf_write_verify;
318 369
319 /* 370 /*
320 * Make a chunk of dquots out of this buffer and log 371 * Make a chunk of dquots out of this buffer and log
@@ -359,59 +410,6 @@ xfs_qm_dqalloc(
359 410
360 return (error); 411 return (error);
361} 412}
362
363static void
364xfs_dquot_buf_verify(
365 struct xfs_buf *bp)
366{
367 struct xfs_mount *mp = bp->b_target->bt_mount;
368 struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr;
369 struct xfs_disk_dquot *ddq;
370 xfs_dqid_t id = 0;
371 int i;
372
373 /*
374 * On the first read of the buffer, verify that each dquot is valid.
375 * We don't know what the id of the dquot is supposed to be, just that
376 * they should be increasing monotonically within the buffer. If the
377 * first id is corrupt, then it will fail on the second dquot in the
378 * buffer so corruptions could point to the wrong dquot in this case.
379 */
380 for (i = 0; i < mp->m_quotainfo->qi_dqperchunk; i++) {
381 int error;
382
383 ddq = &d[i].dd_diskdq;
384
385 if (i == 0)
386 id = be32_to_cpu(ddq->d_id);
387
388 error = xfs_qm_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN,
389 "xfs_dquot_read_verify");
390 if (error) {
391 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, d);
392 xfs_buf_ioerror(bp, EFSCORRUPTED);
393 break;
394 }
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;
411 bp->b_iodone = NULL;
412 xfs_buf_ioend(bp, 0);
413}
414
415STATIC int 413STATIC int
416xfs_qm_dqrepair( 414xfs_qm_dqrepair(
417 struct xfs_mount *mp, 415 struct xfs_mount *mp,
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index cb65b067ed31..5d6d6b9d369d 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -222,6 +222,7 @@ xfs_growfs_data_private(
222 error = ENOMEM; 222 error = ENOMEM;
223 goto error0; 223 goto error0;
224 } 224 }
225 bp->b_pre_io = xfs_agf_write_verify;
225 226
226 agf = XFS_BUF_TO_AGF(bp); 227 agf = XFS_BUF_TO_AGF(bp);
227 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); 228 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
@@ -259,6 +260,7 @@ xfs_growfs_data_private(
259 error = ENOMEM; 260 error = ENOMEM;
260 goto error0; 261 goto error0;
261 } 262 }
263 bp->b_pre_io = xfs_agfl_write_verify;
262 264
263 agfl = XFS_BUF_TO_AGFL(bp); 265 agfl = XFS_BUF_TO_AGFL(bp);
264 for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++) 266 for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++)
@@ -279,6 +281,7 @@ xfs_growfs_data_private(
279 error = ENOMEM; 281 error = ENOMEM;
280 goto error0; 282 goto error0;
281 } 283 }
284 bp->b_pre_io = xfs_agi_write_verify;
282 285
283 agi = XFS_BUF_TO_AGI(bp); 286 agi = XFS_BUF_TO_AGI(bp);
284 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); 287 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
@@ -450,9 +453,10 @@ xfs_growfs_data_private(
450 bp = xfs_trans_get_buf(NULL, mp->m_ddev_targp, 453 bp = xfs_trans_get_buf(NULL, mp->m_ddev_targp,
451 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), 454 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
452 XFS_FSS_TO_BB(mp, 1), 0); 455 XFS_FSS_TO_BB(mp, 1), 0);
453 if (bp) 456 if (bp) {
454 xfs_buf_zero(bp, 0, BBTOB(bp->b_length)); 457 xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
455 else 458 bp->b_pre_io = xfs_sb_write_verify;
459 } else
456 error = ENOMEM; 460 error = ENOMEM;
457 } 461 }
458 462
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 070f41845572..faf68600d3a6 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -210,6 +210,7 @@ xfs_ialloc_inode_init(
210 * to log a whole cluster of inodes instead of all the 210 * to log a whole cluster of inodes instead of all the
211 * individual transactions causing a lot of log traffic. 211 * individual transactions causing a lot of log traffic.
212 */ 212 */
213 fbuf->b_pre_io = xfs_inode_buf_write_verify;
213 xfs_buf_zero(fbuf, 0, ninodes << mp->m_sb.sb_inodelog); 214 xfs_buf_zero(fbuf, 0, ninodes << mp->m_sb.sb_inodelog);
214 for (i = 0; i < ninodes; i++) { 215 for (i = 0; i < ninodes; i++) {
215 int ioffset = i << mp->m_sb.sb_inodelog; 216 int ioffset = i << mp->m_sb.sb_inodelog;
@@ -1504,14 +1505,14 @@ xfs_agi_verify(
1504 xfs_check_agi_unlinked(agi); 1505 xfs_check_agi_unlinked(agi);
1505} 1506}
1506 1507
1507static void 1508void
1508xfs_agi_write_verify( 1509xfs_agi_write_verify(
1509 struct xfs_buf *bp) 1510 struct xfs_buf *bp)
1510{ 1511{
1511 xfs_agi_verify(bp); 1512 xfs_agi_verify(bp);
1512} 1513}
1513 1514
1514void 1515static void
1515xfs_agi_read_verify( 1516xfs_agi_read_verify(
1516 struct xfs_buf *bp) 1517 struct xfs_buf *bp)
1517{ 1518{
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index 1fd6ea4e9c91..7a169e34e30e 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -147,7 +147,9 @@ int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino,
147/* 147/*
148 * Get the data from the pointed-to record. 148 * Get the data from the pointed-to record.
149 */ 149 */
150extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, 150int xfs_inobt_get_rec(struct xfs_btree_cur *cur,
151 xfs_inobt_rec_incore_t *rec, int *stat); 151 xfs_inobt_rec_incore_t *rec, int *stat);
152 152
153void xfs_agi_write_verify(struct xfs_buf *bp);
154
153#endif /* __XFS_IALLOC_H__ */ 155#endif /* __XFS_IALLOC_H__ */
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c
index 15a79f8ca03c..7761e1ebeff7 100644
--- a/fs/xfs/xfs_ialloc_btree.c
+++ b/fs/xfs/xfs_ialloc_btree.c
@@ -271,6 +271,7 @@ static const struct xfs_btree_ops xfs_inobt_ops = {
271 .init_ptr_from_cur = xfs_inobt_init_ptr_from_cur, 271 .init_ptr_from_cur = xfs_inobt_init_ptr_from_cur,
272 .key_diff = xfs_inobt_key_diff, 272 .key_diff = xfs_inobt_key_diff,
273 .read_verify = xfs_inobt_read_verify, 273 .read_verify = xfs_inobt_read_verify,
274 .write_verify = xfs_inobt_write_verify,
274#ifdef DEBUG 275#ifdef DEBUG
275 .keys_inorder = xfs_inobt_keys_inorder, 276 .keys_inorder = xfs_inobt_keys_inorder,
276 .recs_inorder = xfs_inobt_recs_inorder, 277 .recs_inorder = xfs_inobt_recs_inorder,
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 910b2da01042..dfcbe73f1db4 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -420,7 +420,7 @@ xfs_inode_buf_verify(
420 xfs_inobp_check(mp, bp); 420 xfs_inobp_check(mp, bp);
421} 421}
422 422
423static void 423void
424xfs_inode_buf_write_verify( 424xfs_inode_buf_write_verify(
425 struct xfs_buf *bp) 425 struct xfs_buf *bp)
426{ 426{
@@ -1782,6 +1782,18 @@ xfs_ifree_cluster(
1782 1782
1783 if (!bp) 1783 if (!bp)
1784 return ENOMEM; 1784 return ENOMEM;
1785
1786 /*
1787 * This buffer may not have been correctly initialised as we
1788 * didn't read it from disk. That's not important because we are
1789 * only using to mark the buffer as stale in the log, and to
1790 * attach stale cached inodes on it. That means it will never be
1791 * dispatched for IO. If it is, we want to know about it, and we
1792 * want it to fail. We can acheive this by adding a write
1793 * verifier to the buffer.
1794 */
1795 bp->b_pre_io = xfs_inode_buf_write_verify;
1796
1785 /* 1797 /*
1786 * Walk the inodes already attached to the buffer and mark them 1798 * Walk the inodes already attached to the buffer and mark them
1787 * stale. These will all have the flush locks held, so an 1799 * stale. These will all have the flush locks held, so an
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index a322c19723a3..482214d120a7 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -555,6 +555,7 @@ int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
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_read_verify(struct xfs_buf *); 557void xfs_inode_buf_read_verify(struct xfs_buf *);
558void xfs_inode_buf_write_verify(struct xfs_buf *);
558void xfs_dinode_to_disk(struct xfs_dinode *, 559void xfs_dinode_to_disk(struct xfs_dinode *,
559 struct xfs_icdinode *); 560 struct xfs_icdinode *);
560void xfs_idestroy_fork(struct xfs_inode *, int); 561void xfs_idestroy_fork(struct xfs_inode *, int);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index c85da75e4a43..152a7fc843f9 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -631,7 +631,7 @@ xfs_sb_verify(
631 xfs_buf_ioerror(bp, error); 631 xfs_buf_ioerror(bp, error);
632} 632}
633 633
634static void 634void
635xfs_sb_write_verify( 635xfs_sb_write_verify(
636 struct xfs_buf *bp) 636 struct xfs_buf *bp)
637{ 637{
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index de9089acc610..29c1b3ac920e 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -386,6 +386,7 @@ extern void xfs_set_low_space_thresholds(struct xfs_mount *);
386#endif /* __KERNEL__ */ 386#endif /* __KERNEL__ */
387 387
388extern void xfs_sb_read_verify(struct xfs_buf *); 388extern void xfs_sb_read_verify(struct xfs_buf *);
389extern void xfs_sb_write_verify(struct xfs_buf *bp);
389extern void xfs_mod_sb(struct xfs_trans *, __int64_t); 390extern void xfs_mod_sb(struct xfs_trans *, __int64_t);
390extern int xfs_initialize_perag(struct xfs_mount *, xfs_agnumber_t, 391extern int xfs_initialize_perag(struct xfs_mount *, xfs_agnumber_t,
391 xfs_agnumber_t *); 392 xfs_agnumber_t *);