aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_da_btree.c
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/xfs_da_btree.c
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/xfs_da_btree.c')
-rw-r--r--fs/xfs/xfs_da_btree.c37
1 files changed, 25 insertions, 12 deletions
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);