Skip to content

Commit

Permalink
xfs: add verifier callback to directory read code
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Phil White <pwhite@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
  • Loading branch information
Dave Chinner authored and Ben Myers committed Nov 16, 2012
1 parent c631919 commit 4bb20a8
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 91 deletions.
23 changes: 12 additions & 11 deletions fs/xfs/xfs_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
dp = args->dp;
args->blkno = 0;
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -1032,7 +1032,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
* remove the "old" attr from that block (neat, huh!)
*/
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1,
&bp, XFS_ATTR_FORK);
&bp, XFS_ATTR_FORK, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -1101,7 +1101,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
dp = args->dp;
args->blkno = 0;
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error) {
return(error);
}
Expand Down Expand Up @@ -1159,7 +1159,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args)

args->blkno = 0;
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -1190,7 +1190,8 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
trace_xfs_attr_leaf_list(context);

context->cursor->blkno = 0;
error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK);
error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK,
NULL);
if (error)
return XFS_ERROR(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -1605,7 +1606,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
state->path.blk[0].bp = NULL;

error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error)
goto out;
ASSERT((((xfs_attr_leafblock_t *)bp->b_addr)->hdr.info.magic) ==
Expand Down Expand Up @@ -1718,7 +1719,7 @@ xfs_attr_refillstate(xfs_da_state_t *state)
error = xfs_da_read_buf(state->args->trans,
state->args->dp,
blk->blkno, blk->disk_blkno,
&blk->bp, XFS_ATTR_FORK);
&blk->bp, XFS_ATTR_FORK, NULL);
if (error)
return(error);
} else {
Expand All @@ -1737,7 +1738,7 @@ xfs_attr_refillstate(xfs_da_state_t *state)
error = xfs_da_read_buf(state->args->trans,
state->args->dp,
blk->blkno, blk->disk_blkno,
&blk->bp, XFS_ATTR_FORK);
&blk->bp, XFS_ATTR_FORK, NULL);
if (error)
return(error);
} else {
Expand Down Expand Up @@ -1827,7 +1828,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
bp = NULL;
if (cursor->blkno > 0) {
error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
&bp, XFS_ATTR_FORK);
&bp, XFS_ATTR_FORK, NULL);
if ((error != 0) && (error != EFSCORRUPTED))
return(error);
if (bp) {
Expand Down Expand Up @@ -1870,7 +1871,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
for (;;) {
error = xfs_da_read_buf(NULL, context->dp,
cursor->blkno, -1, &bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error)
return(error);
if (unlikely(bp == NULL)) {
Expand Down Expand Up @@ -1937,7 +1938,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
xfs_trans_brelse(NULL, bp);
error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
&bp, XFS_ATTR_FORK);
&bp, XFS_ATTR_FORK, NULL);
if (error)
return(error);
if (unlikely((bp == NULL))) {
Expand Down
18 changes: 9 additions & 9 deletions fs/xfs/xfs_attr_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
if (error)
goto out;
error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp1,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error)
goto out;
ASSERT(bp1 != NULL);
Expand Down Expand Up @@ -1642,7 +1642,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
if (blkno == 0)
continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp,
blkno, -1, &bp, XFS_ATTR_FORK);
blkno, -1, &bp, XFS_ATTR_FORK, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -2519,7 +2519,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
* Set up the operation.
*/
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error) {
return(error);
}
Expand Down Expand Up @@ -2584,7 +2584,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
* Set up the operation.
*/
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error) {
return(error);
}
Expand Down Expand Up @@ -2641,7 +2641,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
* Read the block containing the "old" attr
*/
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp1,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error) {
return(error);
}
Expand All @@ -2652,7 +2652,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
*/
if (args->blkno2 != args->blkno) {
error = xfs_da_read_buf(args->trans, args->dp, args->blkno2,
-1, &bp2, XFS_ATTR_FORK);
-1, &bp2, XFS_ATTR_FORK, NULL);
if (error) {
return(error);
}
Expand Down Expand Up @@ -2753,7 +2753,7 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
* the extents in reverse order the extent containing
* block 0 must still be there.
*/
error = xfs_da_read_buf(*trans, dp, 0, -1, &bp, XFS_ATTR_FORK);
error = xfs_da_read_buf(*trans, dp, 0, -1, &bp, XFS_ATTR_FORK, NULL);
if (error)
return(error);
blkno = XFS_BUF_ADDR(bp);
Expand Down Expand Up @@ -2839,7 +2839,7 @@ xfs_attr_node_inactive(
* before we come back to this one.
*/
error = xfs_da_read_buf(*trans, dp, child_fsb, -2, &child_bp,
XFS_ATTR_FORK);
XFS_ATTR_FORK, NULL);
if (error)
return(error);
if (child_bp) {
Expand Down Expand Up @@ -2880,7 +2880,7 @@ xfs_attr_node_inactive(
*/
if ((i+1) < count) {
error = xfs_da_read_buf(*trans, dp, 0, parent_blkno,
&bp, XFS_ATTR_FORK);
&bp, XFS_ATTR_FORK, NULL);
if (error)
return(error);
child_fsb = be32_to_cpu(node->btree[i+1].before);
Expand Down
44 changes: 28 additions & 16 deletions fs/xfs/xfs_da_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
child = be32_to_cpu(oldroot->btree[0].before);
ASSERT(child != 0);
error = xfs_da_read_buf(args->trans, args->dp, child, -1, &bp,
args->whichfork);
args->whichfork, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -838,7 +838,8 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
if (blkno == 0)
continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp,
blkno, -1, &bp, state->args->whichfork);
blkno, -1, &bp, state->args->whichfork,
NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -1084,7 +1085,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
*/
blk->blkno = blkno;
error = xfs_da_read_buf(args->trans, args->dp, blkno,
-1, &blk->bp, args->whichfork);
-1, &blk->bp, args->whichfork, NULL);
if (error) {
blk->blkno = 0;
state->path.active--;
Expand Down Expand Up @@ -1247,7 +1248,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
if (old_info->back) {
error = xfs_da_read_buf(args->trans, args->dp,
be32_to_cpu(old_info->back),
-1, &bp, args->whichfork);
-1, &bp, args->whichfork, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand All @@ -1268,7 +1269,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
if (old_info->forw) {
error = xfs_da_read_buf(args->trans, args->dp,
be32_to_cpu(old_info->forw),
-1, &bp, args->whichfork);
-1, &bp, args->whichfork, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -1368,7 +1369,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
if (drop_info->back) {
error = xfs_da_read_buf(args->trans, args->dp,
be32_to_cpu(drop_info->back),
-1, &bp, args->whichfork);
-1, &bp, args->whichfork, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand All @@ -1385,7 +1386,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
if (drop_info->forw) {
error = xfs_da_read_buf(args->trans, args->dp,
be32_to_cpu(drop_info->forw),
-1, &bp, args->whichfork);
-1, &bp, args->whichfork, NULL);
if (error)
return(error);
ASSERT(bp != NULL);
Expand Down Expand Up @@ -1470,7 +1471,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
*/
blk->blkno = blkno;
error = xfs_da_read_buf(args->trans, args->dp, blkno, -1,
&blk->bp, args->whichfork);
&blk->bp, args->whichfork, NULL);
if (error)
return(error);
ASSERT(blk->bp != NULL);
Expand Down Expand Up @@ -1733,7 +1734,8 @@ xfs_da_swap_lastblock(
* Read the last block in the btree space.
*/
last_blkno = (xfs_dablk_t)lastoff - mp->m_dirblkfsbs;
if ((error = xfs_da_read_buf(tp, ip, last_blkno, -1, &last_buf, w)))
error = xfs_da_read_buf(tp, ip, last_blkno, -1, &last_buf, w, NULL);
if (error)
return error;
/*
* Copy the last block into the dead buffer and log it.
Expand All @@ -1759,7 +1761,9 @@ xfs_da_swap_lastblock(
* If the moved block has a left sibling, fix up the pointers.
*/
if ((sib_blkno = be32_to_cpu(dead_info->back))) {
if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w,
NULL);
if (error)
goto done;
sib_info = sib_buf->b_addr;
if (unlikely(
Expand All @@ -1780,7 +1784,9 @@ xfs_da_swap_lastblock(
* If the moved block has a right sibling, fix up the pointers.
*/
if ((sib_blkno = be32_to_cpu(dead_info->forw))) {
if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w,
NULL);
if (error)
goto done;
sib_info = sib_buf->b_addr;
if (unlikely(
Expand All @@ -1803,7 +1809,9 @@ xfs_da_swap_lastblock(
* Walk down the tree looking for the parent of the moved block.
*/
for (;;) {
if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w)))
error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w,
NULL);
if (error)
goto done;
par_node = par_buf->b_addr;
if (unlikely(par_node->hdr.info.magic !=
Expand Down Expand Up @@ -1853,7 +1861,9 @@ xfs_da_swap_lastblock(
error = XFS_ERROR(EFSCORRUPTED);
goto done;
}
if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w)))
error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w,
NULL);
if (error)
goto done;
par_node = par_buf->b_addr;
if (unlikely(
Expand Down Expand Up @@ -2139,7 +2149,8 @@ xfs_da_read_buf(
xfs_dablk_t bno,
xfs_daddr_t mappedbno,
struct xfs_buf **bpp,
int whichfork)
int whichfork,
xfs_buf_iodone_t verifier)
{
struct xfs_buf *bp;
struct xfs_buf_map map;
Expand All @@ -2161,7 +2172,7 @@ xfs_da_read_buf(

error = xfs_trans_read_buf_map(dp->i_mount, trans,
dp->i_mount->m_ddev_targp,
mapp, nmap, 0, &bp, NULL);
mapp, nmap, 0, &bp, verifier);
if (error)
goto out_free;

Expand Down Expand Up @@ -2217,7 +2228,8 @@ xfs_da_reada_buf(
struct xfs_trans *trans,
struct xfs_inode *dp,
xfs_dablk_t bno,
int whichfork)
int whichfork,
xfs_buf_iodone_t verifier)
{
xfs_daddr_t mappedbno = -1;
struct xfs_buf_map map;
Expand Down
7 changes: 4 additions & 3 deletions fs/xfs/xfs_da_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef __XFS_DA_BTREE_H__
#define __XFS_DA_BTREE_H__

struct xfs_buf;
struct xfs_bmap_free;
struct xfs_inode;
struct xfs_mount;
Expand Down Expand Up @@ -226,9 +225,11 @@ int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp,
struct xfs_buf **bp, int whichfork);
int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp,
xfs_dablk_t bno, xfs_daddr_t mappedbno,
struct xfs_buf **bpp, int whichfork);
struct xfs_buf **bpp, int whichfork,
xfs_buf_iodone_t verifier);
xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp,
xfs_dablk_t bno, int whichfork);
xfs_dablk_t bno, int whichfork,
xfs_buf_iodone_t verifier);
int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
struct xfs_buf *dead_buf);

Expand Down
Loading

0 comments on commit 4bb20a8

Please sign in to comment.