aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-11-12 06:54:08 -0500
committerBen Myers <bpm@sgi.com>2012-11-15 22:34:31 -0500
commit3d3e6f64e22c94115d47de670611bcd3ecda3796 (patch)
treeec97be647a06d5aef171333624b370cf482285b4 /fs/xfs/xfs_bmap.c
parentaf133e8606d32c2aed43870491ebbdc56feec8a8 (diff)
xfs: verify btree blocks as they are read from disk
Add an btree block verify callback function and pass it into the buffer read functions. Because each different btree block type requires different verification, add a function to the ops structure that is called from the generic code. Also, propagate the verification callback functions through the readahead functions, and into the external bmap and bulkstat inode readahead code that uses the generic btree buffer read functions. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Phil White <pwhite@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r--fs/xfs/xfs_bmap.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index a60f3d1f151c..9ae7aba52e0f 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -2662,8 +2662,9 @@ xfs_bmap_btree_to_extents(
2662 if ((error = xfs_btree_check_lptr(cur, cbno, 1))) 2662 if ((error = xfs_btree_check_lptr(cur, cbno, 1)))
2663 return error; 2663 return error;
2664#endif 2664#endif
2665 if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, 2665 error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, XFS_BMAP_BTREE_REF,
2666 XFS_BMAP_BTREE_REF))) 2666 xfs_bmbt_read_verify);
2667 if (error)
2667 return error; 2668 return error;
2668 cblock = XFS_BUF_TO_BLOCK(cbp); 2669 cblock = XFS_BUF_TO_BLOCK(cbp);
2669 if ((error = xfs_btree_check_block(cur, cblock, 0, cbp))) 2670 if ((error = xfs_btree_check_block(cur, cblock, 0, cbp)))
@@ -4078,8 +4079,9 @@ xfs_bmap_read_extents(
4078 * pointer (leftmost) at each level. 4079 * pointer (leftmost) at each level.
4079 */ 4080 */
4080 while (level-- > 0) { 4081 while (level-- > 0) {
4081 if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, 4082 error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp,
4082 XFS_BMAP_BTREE_REF))) 4083 XFS_BMAP_BTREE_REF, xfs_bmbt_read_verify);
4084 if (error)
4083 return error; 4085 return error;
4084 block = XFS_BUF_TO_BLOCK(bp); 4086 block = XFS_BUF_TO_BLOCK(bp);
4085 XFS_WANT_CORRUPTED_GOTO( 4087 XFS_WANT_CORRUPTED_GOTO(
@@ -4124,7 +4126,8 @@ xfs_bmap_read_extents(
4124 */ 4126 */
4125 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); 4127 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib);
4126 if (nextbno != NULLFSBLOCK) 4128 if (nextbno != NULLFSBLOCK)
4127 xfs_btree_reada_bufl(mp, nextbno, 1); 4129 xfs_btree_reada_bufl(mp, nextbno, 1,
4130 xfs_bmbt_read_verify);
4128 /* 4131 /*
4129 * Copy records into the extent records. 4132 * Copy records into the extent records.
4130 */ 4133 */
@@ -4156,8 +4159,9 @@ xfs_bmap_read_extents(
4156 */ 4159 */
4157 if (bno == NULLFSBLOCK) 4160 if (bno == NULLFSBLOCK)
4158 break; 4161 break;
4159 if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, 4162 error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp,
4160 XFS_BMAP_BTREE_REF))) 4163 XFS_BMAP_BTREE_REF, xfs_bmbt_read_verify);
4164 if (error)
4161 return error; 4165 return error;
4162 block = XFS_BUF_TO_BLOCK(bp); 4166 block = XFS_BUF_TO_BLOCK(bp);
4163 } 4167 }
@@ -5868,15 +5872,16 @@ xfs_bmap_check_leaf_extents(
5868 */ 5872 */
5869 while (level-- > 0) { 5873 while (level-- > 0) {
5870 /* See if buf is in cur first */ 5874 /* See if buf is in cur first */
5875 bp_release = 0;
5871 bp = xfs_bmap_get_bp(cur, XFS_FSB_TO_DADDR(mp, bno)); 5876 bp = xfs_bmap_get_bp(cur, XFS_FSB_TO_DADDR(mp, bno));
5872 if (bp) { 5877 if (!bp) {
5873 bp_release = 0;
5874 } else {
5875 bp_release = 1; 5878 bp_release = 1;
5879 error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp,
5880 XFS_BMAP_BTREE_REF,
5881 xfs_bmbt_read_verify);
5882 if (error)
5883 goto error_norelse;
5876 } 5884 }
5877 if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp,
5878 XFS_BMAP_BTREE_REF)))
5879 goto error_norelse;
5880 block = XFS_BUF_TO_BLOCK(bp); 5885 block = XFS_BUF_TO_BLOCK(bp);
5881 XFS_WANT_CORRUPTED_GOTO( 5886 XFS_WANT_CORRUPTED_GOTO(
5882 xfs_bmap_sanity_check(mp, bp, level), 5887 xfs_bmap_sanity_check(mp, bp, level),
@@ -5953,15 +5958,16 @@ xfs_bmap_check_leaf_extents(
5953 if (bno == NULLFSBLOCK) 5958 if (bno == NULLFSBLOCK)
5954 break; 5959 break;
5955 5960
5961 bp_release = 0;
5956 bp = xfs_bmap_get_bp(cur, XFS_FSB_TO_DADDR(mp, bno)); 5962 bp = xfs_bmap_get_bp(cur, XFS_FSB_TO_DADDR(mp, bno));
5957 if (bp) { 5963 if (!bp) {
5958 bp_release = 0;
5959 } else {
5960 bp_release = 1; 5964 bp_release = 1;
5965 error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp,
5966 XFS_BMAP_BTREE_REF,
5967 xfs_bmbt_read_verify);
5968 if (error)
5969 goto error_norelse;
5961 } 5970 }
5962 if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp,
5963 XFS_BMAP_BTREE_REF)))
5964 goto error_norelse;
5965 block = XFS_BUF_TO_BLOCK(bp); 5971 block = XFS_BUF_TO_BLOCK(bp);
5966 } 5972 }
5967 if (bp_release) { 5973 if (bp_release) {
@@ -6052,7 +6058,9 @@ xfs_bmap_count_tree(
6052 struct xfs_btree_block *block, *nextblock; 6058 struct xfs_btree_block *block, *nextblock;
6053 int numrecs; 6059 int numrecs;
6054 6060
6055 if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF))) 6061 error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF,
6062 xfs_bmbt_read_verify);
6063 if (error)
6056 return error; 6064 return error;
6057 *count += 1; 6065 *count += 1;
6058 block = XFS_BUF_TO_BLOCK(bp); 6066 block = XFS_BUF_TO_BLOCK(bp);
@@ -6061,8 +6069,10 @@ xfs_bmap_count_tree(
6061 /* Not at node above leaves, count this level of nodes */ 6069 /* Not at node above leaves, count this level of nodes */
6062 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); 6070 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib);
6063 while (nextbno != NULLFSBLOCK) { 6071 while (nextbno != NULLFSBLOCK) {
6064 if ((error = xfs_btree_read_bufl(mp, tp, nextbno, 6072 error = xfs_btree_read_bufl(mp, tp, nextbno, 0, &nbp,
6065 0, &nbp, XFS_BMAP_BTREE_REF))) 6073 XFS_BMAP_BTREE_REF,
6074 xfs_bmbt_read_verify);
6075 if (error)
6066 return error; 6076 return error;
6067 *count += 1; 6077 *count += 1;
6068 nextblock = XFS_BUF_TO_BLOCK(nbp); 6078 nextblock = XFS_BUF_TO_BLOCK(nbp);
@@ -6091,8 +6101,10 @@ xfs_bmap_count_tree(
6091 if (nextbno == NULLFSBLOCK) 6101 if (nextbno == NULLFSBLOCK)
6092 break; 6102 break;
6093 bno = nextbno; 6103 bno = nextbno;
6094 if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, 6104 error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp,
6095 XFS_BMAP_BTREE_REF))) 6105 XFS_BMAP_BTREE_REF,
6106 xfs_bmbt_read_verify);
6107 if (error)
6096 return error; 6108 return error;
6097 *count += 1; 6109 *count += 1;
6098 block = XFS_BUF_TO_BLOCK(bp); 6110 block = XFS_BUF_TO_BLOCK(bp);