aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_data.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-11-12 06:54:14 -0500
committerBen Myers <bpm@sgi.com>2012-11-15 22:34:45 -0500
commite4813572640e27d3a5cce3f06751a9f54f77aaa5 (patch)
treef181db296dace8bac868f89a0a016f5973c18ba1 /fs/xfs/xfs_dir2_data.c
parent2025207ca6738a1217126ef14af9d104433f9824 (diff)
xfs: factor out dir2 data block reading
And add a verifier callback function while there. 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_dir2_data.c')
-rw-r--r--fs/xfs/xfs_dir2_data.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index cb117234e32e..0ef04f1bf511 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -185,6 +185,38 @@ __xfs_dir2_data_check(
185 return 0; 185 return 0;
186} 186}
187 187
188static void
189xfs_dir2_data_verify(
190 struct xfs_buf *bp)
191{
192 struct xfs_mount *mp = bp->b_target->bt_mount;
193 struct xfs_dir2_data_hdr *hdr = bp->b_addr;
194 int block_ok = 0;
195
196 block_ok = hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC);
197 block_ok = block_ok && __xfs_dir2_data_check(NULL, bp) == 0;
198
199 if (!block_ok) {
200 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
201 xfs_buf_ioerror(bp, EFSCORRUPTED);
202 }
203
204 bp->b_iodone = NULL;
205 xfs_buf_ioend(bp, 0);
206}
207
208int
209xfs_dir2_data_read(
210 struct xfs_trans *tp,
211 struct xfs_inode *dp,
212 xfs_dablk_t bno,
213 xfs_daddr_t mapped_bno,
214 struct xfs_buf **bpp)
215{
216 return xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp,
217 XFS_DATA_FORK, xfs_dir2_data_verify);
218}
219
188/* 220/*
189 * Given a data block and an unused entry from that block, 221 * Given a data block and an unused entry from that block,
190 * return the bestfree entry if any that corresponds to it. 222 * return the bestfree entry if any that corresponds to it.