aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-11-12 06:54:15 -0500
committerBen Myers <bpm@sgi.com>2012-11-15 22:34:48 -0500
commite6f7667c4eef42b6f5bc6cdeb31d0bab62fe5f79 (patch)
tree945a1c7b6b60172b41385f2777375ec2ed9eecf7 /fs/xfs
parente4813572640e27d3a5cce3f06751a9f54f77aaa5 (diff)
xfs: factor dir2 leaf read
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')
-rw-r--r--fs/xfs/xfs_dir2_leaf.c73
-rw-r--r--fs/xfs/xfs_dir2_node.c6
-rw-r--r--fs/xfs/xfs_dir2_priv.h2
3 files changed, 67 insertions, 14 deletions
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 0fdf765c917f..97408e3287ed 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -48,6 +48,62 @@ static void xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_buf *bp,
48 int first, int last); 48 int first, int last);
49static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_buf *bp); 49static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_buf *bp);
50 50
51static void
52xfs_dir2_leaf_verify(
53 struct xfs_buf *bp,
54 __be16 magic)
55{
56 struct xfs_mount *mp = bp->b_target->bt_mount;
57 struct xfs_dir2_leaf_hdr *hdr = bp->b_addr;
58 int block_ok = 0;
59
60 block_ok = hdr->info.magic == magic;
61 if (!block_ok) {
62 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
63 xfs_buf_ioerror(bp, EFSCORRUPTED);
64 }
65
66 bp->b_iodone = NULL;
67 xfs_buf_ioend(bp, 0);
68}
69
70static void
71xfs_dir2_leaf1_verify(
72 struct xfs_buf *bp)
73{
74 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
75}
76
77static void
78xfs_dir2_leafn_verify(
79 struct xfs_buf *bp)
80{
81 xfs_dir2_leaf_verify(bp, cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
82}
83
84static int
85xfs_dir2_leaf_read(
86 struct xfs_trans *tp,
87 struct xfs_inode *dp,
88 xfs_dablk_t fbno,
89 xfs_daddr_t mappedbno,
90 struct xfs_buf **bpp)
91{
92 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
93 XFS_DATA_FORK, xfs_dir2_leaf1_verify);
94}
95
96int
97xfs_dir2_leafn_read(
98 struct xfs_trans *tp,
99 struct xfs_inode *dp,
100 xfs_dablk_t fbno,
101 xfs_daddr_t mappedbno,
102 struct xfs_buf **bpp)
103{
104 return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
105 XFS_DATA_FORK, xfs_dir2_leafn_verify);
106}
51 107
52/* 108/*
53 * Convert a block form directory to a leaf form directory. 109 * Convert a block form directory to a leaf form directory.
@@ -311,14 +367,11 @@ xfs_dir2_leaf_addname(
311 dp = args->dp; 367 dp = args->dp;
312 tp = args->trans; 368 tp = args->trans;
313 mp = dp->i_mount; 369 mp = dp->i_mount;
314 /* 370
315 * Read the leaf block. 371 error = xfs_dir2_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp);
316 */
317 error = xfs_da_read_buf(tp, dp, mp->m_dirleafblk, -1, &lbp,
318 XFS_DATA_FORK, NULL);
319 if (error) 372 if (error)
320 return error; 373 return error;
321 ASSERT(lbp != NULL); 374
322 /* 375 /*
323 * Look up the entry by hash value and name. 376 * Look up the entry by hash value and name.
324 * We know it's not there, our caller has already done a lookup. 377 * We know it's not there, our caller has already done a lookup.
@@ -1369,13 +1422,11 @@ xfs_dir2_leaf_lookup_int(
1369 dp = args->dp; 1422 dp = args->dp;
1370 tp = args->trans; 1423 tp = args->trans;
1371 mp = dp->i_mount; 1424 mp = dp->i_mount;
1372 /* 1425
1373 * Read the leaf block into the buffer. 1426 error = xfs_dir2_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp);
1374 */
1375 error = xfs_da_read_buf(tp, dp, mp->m_dirleafblk, -1, &lbp,
1376 XFS_DATA_FORK, NULL);
1377 if (error) 1427 if (error)
1378 return error; 1428 return error;
1429
1379 *lbpp = lbp; 1430 *lbpp = lbp;
1380 leaf = lbp->b_addr; 1431 leaf = lbp->b_addr;
1381 xfs_dir2_leaf_check(dp, lbp); 1432 xfs_dir2_leaf_check(dp, lbp);
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 67b811c17eaa..7c6f95697e28 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -1232,11 +1232,11 @@ xfs_dir2_leafn_toosmall(
1232 /* 1232 /*
1233 * Read the sibling leaf block. 1233 * Read the sibling leaf block.
1234 */ 1234 */
1235 error = xfs_da_read_buf(state->args->trans, state->args->dp, 1235 error = xfs_dir2_leafn_read(state->args->trans, state->args->dp,
1236 blkno, -1, &bp, XFS_DATA_FORK, NULL); 1236 blkno, -1, &bp);
1237 if (error) 1237 if (error)
1238 return error; 1238 return error;
1239 ASSERT(bp != NULL); 1239
1240 /* 1240 /*
1241 * Count bytes in the two blocks combined. 1241 * Count bytes in the two blocks combined.
1242 */ 1242 */
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 71ec82839107..4560825d099c 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -70,6 +70,8 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,
70 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp); 70 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
71 71
72/* xfs_dir2_leaf.c */ 72/* xfs_dir2_leaf.c */
73extern int xfs_dir2_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
74 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
73extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, 75extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
74 struct xfs_buf *dbp); 76 struct xfs_buf *dbp);
75extern int xfs_dir2_leaf_addname(struct xfs_da_args *args); 77extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);