Commit cd2c9f1b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: remove the mappedbno argument to xfs_da_read_buf

Move the code for reading an already mapped block into
xfs_da3_node_read_mapped, which is the only caller ever passing a block
number in the mappedbno argument and replace the mappedbno argument with
the simple xfs_dabuf_get flags.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 02c57f0a
...@@ -434,7 +434,7 @@ xfs_attr3_leaf_read( ...@@ -434,7 +434,7 @@ xfs_attr3_leaf_read(
{ {
int err; int err;
err = xfs_da_read_buf(tp, dp, bno, -1, bpp, XFS_ATTR_FORK, err = xfs_da_read_buf(tp, dp, bno, 0, bpp, XFS_ATTR_FORK,
&xfs_attr3_leaf_buf_ops); &xfs_attr3_leaf_buf_ops);
if (!err && tp && *bpp) if (!err && tp && *bpp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_ATTR_LEAF_BUF); xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_ATTR_LEAF_BUF);
......
...@@ -369,7 +369,7 @@ xfs_da3_node_read( ...@@ -369,7 +369,7 @@ xfs_da3_node_read(
{ {
int error; int error;
error = xfs_da_read_buf(tp, dp, bno, -1, bpp, whichfork, error = xfs_da_read_buf(tp, dp, bno, 0, bpp, whichfork,
&xfs_da3_node_buf_ops); &xfs_da3_node_buf_ops);
if (error || !*bpp || !tp) if (error || !*bpp || !tp)
return error; return error;
...@@ -384,12 +384,22 @@ xfs_da3_node_read_mapped( ...@@ -384,12 +384,22 @@ xfs_da3_node_read_mapped(
struct xfs_buf **bpp, struct xfs_buf **bpp,
int whichfork) int whichfork)
{ {
struct xfs_mount *mp = dp->i_mount;
int error; int error;
error = xfs_da_read_buf(tp, dp, 0, mappedbno, bpp, whichfork, error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, mappedbno,
&xfs_da3_node_buf_ops); XFS_FSB_TO_BB(mp, xfs_dabuf_nfsb(mp, whichfork)), 0,
if (error || !*bpp || !tp) bpp, &xfs_da3_node_buf_ops);
if (error || !*bpp)
return error; return error;
if (whichfork == XFS_ATTR_FORK)
xfs_buf_set_ref(*bpp, XFS_ATTR_BTREE_REF);
else
xfs_buf_set_ref(*bpp, XFS_DIR_BTREE_REF);
if (!tp)
return 0;
return xfs_da3_node_set_type(tp, *bpp); return xfs_da3_node_set_type(tp, *bpp);
} }
...@@ -2618,7 +2628,7 @@ xfs_da_read_buf( ...@@ -2618,7 +2628,7 @@ xfs_da_read_buf(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_inode *dp, struct xfs_inode *dp,
xfs_dablk_t bno, xfs_dablk_t bno,
xfs_daddr_t mappedbno, unsigned int flags,
struct xfs_buf **bpp, struct xfs_buf **bpp,
int whichfork, int whichfork,
const struct xfs_buf_ops *ops) const struct xfs_buf_ops *ops)
...@@ -2630,24 +2640,12 @@ xfs_da_read_buf( ...@@ -2630,24 +2640,12 @@ xfs_da_read_buf(
int error; int error;
*bpp = NULL; *bpp = NULL;
error = xfs_dabuf_map(dp, bno, flags, whichfork, &mapp, &nmap);
if (mappedbno >= 0) {
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
mappedbno, XFS_FSB_TO_BB(mp,
xfs_dabuf_nfsb(mp, whichfork)),
0, &bp, ops);
goto done;
}
error = xfs_dabuf_map(dp, bno,
mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
whichfork, &mapp, &nmap);
if (error || !nmap) if (error || !nmap)
goto out_free; goto out_free;
error = xfs_trans_read_buf_map(mp, tp, mp->m_ddev_targp, mapp, nmap, 0, error = xfs_trans_read_buf_map(mp, tp, mp->m_ddev_targp, mapp, nmap, 0,
&bp, ops); &bp, ops);
done:
if (error) if (error)
goto out_free; goto out_free;
......
...@@ -206,9 +206,8 @@ int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp, ...@@ -206,9 +206,8 @@ int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp,
xfs_dablk_t bno, xfs_daddr_t mappedbno, xfs_dablk_t bno, xfs_daddr_t mappedbno,
struct xfs_buf **bp, int whichfork); struct xfs_buf **bp, int whichfork);
int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp, int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp,
xfs_dablk_t bno, xfs_daddr_t mappedbno, xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp,
struct xfs_buf **bpp, int whichfork, int whichfork, const struct xfs_buf_ops *ops);
const struct xfs_buf_ops *ops);
int xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno, int xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno,
unsigned int flags, int whichfork, unsigned int flags, int whichfork,
const struct xfs_buf_ops *ops); const struct xfs_buf_ops *ops);
......
...@@ -123,7 +123,7 @@ xfs_dir3_block_read( ...@@ -123,7 +123,7 @@ xfs_dir3_block_read(
struct xfs_mount *mp = dp->i_mount; struct xfs_mount *mp = dp->i_mount;
int err; int err;
err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp, err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, 0, bpp,
XFS_DATA_FORK, &xfs_dir3_block_buf_ops); XFS_DATA_FORK, &xfs_dir3_block_buf_ops);
if (!err && tp && *bpp) if (!err && tp && *bpp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF); xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF);
...@@ -950,7 +950,7 @@ xfs_dir2_leaf_to_block( ...@@ -950,7 +950,7 @@ xfs_dir2_leaf_to_block(
* Read the data block if we don't already have it, give up if it fails. * Read the data block if we don't already have it, give up if it fails.
*/ */
if (!dbp) { if (!dbp) {
error = xfs_dir3_data_read(tp, dp, args->geo->datablk, -1, &dbp); error = xfs_dir3_data_read(tp, dp, args->geo->datablk, 0, &dbp);
if (error) if (error)
return error; return error;
} }
......
...@@ -400,13 +400,13 @@ xfs_dir3_data_read( ...@@ -400,13 +400,13 @@ xfs_dir3_data_read(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_inode *dp, struct xfs_inode *dp,
xfs_dablk_t bno, xfs_dablk_t bno,
xfs_daddr_t mapped_bno, unsigned int flags,
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
int err; int err;
err = xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp, err = xfs_da_read_buf(tp, dp, bno, flags, bpp, XFS_DATA_FORK,
XFS_DATA_FORK, &xfs_dir3_data_buf_ops); &xfs_dir3_data_buf_ops);
if (!err && tp && *bpp) if (!err && tp && *bpp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF); xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF);
return err; return err;
......
...@@ -266,7 +266,7 @@ xfs_dir3_leaf_read( ...@@ -266,7 +266,7 @@ xfs_dir3_leaf_read(
{ {
int err; int err;
err = xfs_da_read_buf(tp, dp, fbno, -1, bpp, XFS_DATA_FORK, err = xfs_da_read_buf(tp, dp, fbno, 0, bpp, XFS_DATA_FORK,
&xfs_dir3_leaf1_buf_ops); &xfs_dir3_leaf1_buf_ops);
if (!err && tp && *bpp) if (!err && tp && *bpp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAF1_BUF); xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAF1_BUF);
...@@ -282,7 +282,7 @@ xfs_dir3_leafn_read( ...@@ -282,7 +282,7 @@ xfs_dir3_leafn_read(
{ {
int err; int err;
err = xfs_da_read_buf(tp, dp, fbno, -1, bpp, XFS_DATA_FORK, err = xfs_da_read_buf(tp, dp, fbno, 0, bpp, XFS_DATA_FORK,
&xfs_dir3_leafn_buf_ops); &xfs_dir3_leafn_buf_ops);
if (!err && tp && *bpp) if (!err && tp && *bpp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAFN_BUF); xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAFN_BUF);
...@@ -826,7 +826,7 @@ xfs_dir2_leaf_addname( ...@@ -826,7 +826,7 @@ xfs_dir2_leaf_addname(
*/ */
error = xfs_dir3_data_read(tp, dp, error = xfs_dir3_data_read(tp, dp,
xfs_dir2_db_to_da(args->geo, use_block), xfs_dir2_db_to_da(args->geo, use_block),
-1, &dbp); 0, &dbp);
if (error) { if (error) {
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return error; return error;
...@@ -1268,7 +1268,7 @@ xfs_dir2_leaf_lookup_int( ...@@ -1268,7 +1268,7 @@ xfs_dir2_leaf_lookup_int(
xfs_trans_brelse(tp, dbp); xfs_trans_brelse(tp, dbp);
error = xfs_dir3_data_read(tp, dp, error = xfs_dir3_data_read(tp, dp,
xfs_dir2_db_to_da(args->geo, newdb), xfs_dir2_db_to_da(args->geo, newdb),
-1, &dbp); 0, &dbp);
if (error) { if (error) {
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return error; return error;
...@@ -1310,7 +1310,7 @@ xfs_dir2_leaf_lookup_int( ...@@ -1310,7 +1310,7 @@ xfs_dir2_leaf_lookup_int(
xfs_trans_brelse(tp, dbp); xfs_trans_brelse(tp, dbp);
error = xfs_dir3_data_read(tp, dp, error = xfs_dir3_data_read(tp, dp,
xfs_dir2_db_to_da(args->geo, cidb), xfs_dir2_db_to_da(args->geo, cidb),
-1, &dbp); 0, &dbp);
if (error) { if (error) {
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return error; return error;
...@@ -1602,8 +1602,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1602,8 +1602,7 @@ xfs_dir2_leaf_trim_data(
/* /*
* Read the offending data block. We need its buffer. * Read the offending data block. We need its buffer.
*/ */
error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(geo, db), -1, error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(geo, db), 0, &dbp);
&dbp);
if (error) if (error)
return error; return error;
......
...@@ -212,14 +212,14 @@ __xfs_dir3_free_read( ...@@ -212,14 +212,14 @@ __xfs_dir3_free_read(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_inode *dp, struct xfs_inode *dp,
xfs_dablk_t fbno, xfs_dablk_t fbno,
xfs_daddr_t mappedbno, unsigned int flags,
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
xfs_failaddr_t fa; xfs_failaddr_t fa;
int err; int err;
err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, err = xfs_da_read_buf(tp, dp, fbno, flags, bpp, XFS_DATA_FORK,
XFS_DATA_FORK, &xfs_dir3_free_buf_ops); &xfs_dir3_free_buf_ops);
if (err || !*bpp) if (err || !*bpp)
return err; return err;
...@@ -297,7 +297,7 @@ xfs_dir2_free_read( ...@@ -297,7 +297,7 @@ xfs_dir2_free_read(
xfs_dablk_t fbno, xfs_dablk_t fbno,
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
return __xfs_dir3_free_read(tp, dp, fbno, -1, bpp); return __xfs_dir3_free_read(tp, dp, fbno, 0, bpp);
} }
static int static int
...@@ -307,7 +307,7 @@ xfs_dir2_free_try_read( ...@@ -307,7 +307,7 @@ xfs_dir2_free_try_read(
xfs_dablk_t fbno, xfs_dablk_t fbno,
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
return __xfs_dir3_free_read(tp, dp, fbno, -2, bpp); return __xfs_dir3_free_read(tp, dp, fbno, XFS_DABUF_MAP_HOLE_OK, bpp);
} }
static int static int
...@@ -857,7 +857,7 @@ xfs_dir2_leafn_lookup_for_entry( ...@@ -857,7 +857,7 @@ xfs_dir2_leafn_lookup_for_entry(
error = xfs_dir3_data_read(tp, dp, error = xfs_dir3_data_read(tp, dp,
xfs_dir2_db_to_da(args->geo, xfs_dir2_db_to_da(args->geo,
newdb), newdb),
-1, &curbp); 0, &curbp);
if (error) if (error)
return error; return error;
} }
...@@ -1940,7 +1940,7 @@ xfs_dir2_node_addname_int( ...@@ -1940,7 +1940,7 @@ xfs_dir2_node_addname_int(
/* Read the data block in. */ /* Read the data block in. */
error = xfs_dir3_data_read(tp, dp, error = xfs_dir3_data_read(tp, dp,
xfs_dir2_db_to_da(args->geo, dbno), xfs_dir2_db_to_da(args->geo, dbno),
-1, &dbp); 0, &dbp);
} }
if (error) if (error)
return error; return error;
......
...@@ -77,8 +77,8 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp); ...@@ -77,8 +77,8 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp, extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
struct xfs_buf *bp); struct xfs_buf *bp);
extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp, int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp); xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp);
int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno, int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
unsigned int flags); unsigned int flags);
......
...@@ -331,8 +331,8 @@ xchk_da_btree_block( ...@@ -331,8 +331,8 @@ xchk_da_btree_block(
goto out_nobuf; goto out_nobuf;
/* Read the buffer. */ /* Read the buffer. */
error = xfs_da_read_buf(dargs->trans, dargs->dp, blk->blkno, -2, error = xfs_da_read_buf(dargs->trans, dargs->dp, blk->blkno,
&blk->bp, dargs->whichfork, XFS_DABUF_MAP_HOLE_OK, &blk->bp, dargs->whichfork,
&xchk_da_btree_buf_ops); &xchk_da_btree_buf_ops);
if (!xchk_da_process_error(ds, level, &error)) if (!xchk_da_process_error(ds, level, &error))
goto out_nobuf; goto out_nobuf;
......
...@@ -229,7 +229,8 @@ xchk_dir_rec( ...@@ -229,7 +229,8 @@ xchk_dir_rec(
xchk_da_set_corrupt(ds, level); xchk_da_set_corrupt(ds, level);
goto out; goto out;
} }
error = xfs_dir3_data_read(ds->dargs.trans, dp, rec_bno, -2, &bp); error = xfs_dir3_data_read(ds->dargs.trans, dp, rec_bno,
XFS_DABUF_MAP_HOLE_OK, &bp);
if (!xchk_fblock_process_error(ds->sc, XFS_DATA_FORK, rec_bno, if (!xchk_fblock_process_error(ds->sc, XFS_DATA_FORK, rec_bno,
&error)) &error))
goto out; goto out;
...@@ -346,7 +347,7 @@ xchk_directory_data_bestfree( ...@@ -346,7 +347,7 @@ xchk_directory_data_bestfree(
error = xfs_dir3_block_read(sc->tp, sc->ip, &bp); error = xfs_dir3_block_read(sc->tp, sc->ip, &bp);
} else { } else {
/* dir data format */ /* dir data format */
error = xfs_dir3_data_read(sc->tp, sc->ip, lblk, -1, &bp); error = xfs_dir3_data_read(sc->tp, sc->ip, lblk, 0, &bp);
} }
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error)) if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error))
goto out; goto out;
...@@ -557,7 +558,7 @@ xchk_directory_leaf1_bestfree( ...@@ -557,7 +558,7 @@ xchk_directory_leaf1_bestfree(
if (best == NULLDATAOFF) if (best == NULLDATAOFF)
continue; continue;
error = xfs_dir3_data_read(sc->tp, sc->ip, error = xfs_dir3_data_read(sc->tp, sc->ip,
i * args->geo->fsbcount, -1, &dbp); i * args->geo->fsbcount, 0, &dbp);
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk,
&error)) &error))
break; break;
...@@ -608,7 +609,7 @@ xchk_directory_free_bestfree( ...@@ -608,7 +609,7 @@ xchk_directory_free_bestfree(
} }
error = xfs_dir3_data_read(sc->tp, sc->ip, error = xfs_dir3_data_read(sc->tp, sc->ip,
(freehdr.firstdb + i) * args->geo->fsbcount, (freehdr.firstdb + i) * args->geo->fsbcount,
-1, &dbp); 0, &dbp);
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk,
&error)) &error))
break; break;
......
...@@ -279,7 +279,7 @@ xfs_dir2_leaf_readbuf( ...@@ -279,7 +279,7 @@ xfs_dir2_leaf_readbuf(
new_off = xfs_dir2_da_to_byte(geo, map.br_startoff); new_off = xfs_dir2_da_to_byte(geo, map.br_startoff);
if (new_off > *cur_off) if (new_off > *cur_off)
*cur_off = new_off; *cur_off = new_off;
error = xfs_dir3_data_read(args->trans, dp, map.br_startoff, -1, &bp); error = xfs_dir3_data_read(args->trans, dp, map.br_startoff, 0, &bp);
if (error) if (error)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment