Commit ce92464c authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: make xfs_trans_get_buf return an error code

Convert xfs_trans_get_buf() to return numeric error codes like most
everywhere else in xfs.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 9676b54e
...@@ -688,11 +688,16 @@ xfs_btree_get_bufl( ...@@ -688,11 +688,16 @@ xfs_btree_get_bufl(
xfs_trans_t *tp, /* transaction pointer */ xfs_trans_t *tp, /* transaction pointer */
xfs_fsblock_t fsbno) /* file system block number */ xfs_fsblock_t fsbno) /* file system block number */
{ {
struct xfs_buf *bp;
xfs_daddr_t d; /* real disk block address */ xfs_daddr_t d; /* real disk block address */
int error;
ASSERT(fsbno != NULLFSBLOCK); ASSERT(fsbno != NULLFSBLOCK);
d = XFS_FSB_TO_DADDR(mp, fsbno); d = XFS_FSB_TO_DADDR(mp, fsbno);
return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0); error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0, &bp);
if (error)
return NULL;
return bp;
} }
/* /*
...@@ -706,12 +711,17 @@ xfs_btree_get_bufs( ...@@ -706,12 +711,17 @@ xfs_btree_get_bufs(
xfs_agnumber_t agno, /* allocation group number */ xfs_agnumber_t agno, /* allocation group number */
xfs_agblock_t agbno) /* allocation group block number */ xfs_agblock_t agbno) /* allocation group block number */
{ {
struct xfs_buf *bp;
xfs_daddr_t d; /* real disk block address */ xfs_daddr_t d; /* real disk block address */
int error;
ASSERT(agno != NULLAGNUMBER); ASSERT(agno != NULLAGNUMBER);
ASSERT(agbno != NULLAGBLOCK); ASSERT(agbno != NULLAGBLOCK);
d = XFS_AGB_TO_DADDR(mp, agno, agbno); d = XFS_AGB_TO_DADDR(mp, agno, agbno);
return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0); error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0, &bp);
if (error)
return NULL;
return bp;
} }
/* /*
...@@ -1270,11 +1280,10 @@ xfs_btree_get_buf_block( ...@@ -1270,11 +1280,10 @@ xfs_btree_get_buf_block(
error = xfs_btree_ptr_to_daddr(cur, ptr, &d); error = xfs_btree_ptr_to_daddr(cur, ptr, &d);
if (error) if (error)
return error; return error;
*bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, error = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, mp->m_bsize,
mp->m_bsize, 0); 0, bpp);
if (error)
if (!*bpp) return error;
return -ENOMEM;
(*bpp)->b_ops = cur->bc_ops->buf_ops; (*bpp)->b_ops = cur->bc_ops->buf_ops;
*block = XFS_BUF_TO_BLOCK(*bpp); *block = XFS_BUF_TO_BLOCK(*bpp);
......
...@@ -276,6 +276,7 @@ xfs_ialloc_inode_init( ...@@ -276,6 +276,7 @@ xfs_ialloc_inode_init(
int i, j; int i, j;
xfs_daddr_t d; xfs_daddr_t d;
xfs_ino_t ino = 0; xfs_ino_t ino = 0;
int error;
/* /*
* Loop over the new block(s), filling in the inodes. For small block * Loop over the new block(s), filling in the inodes. For small block
...@@ -327,12 +328,11 @@ xfs_ialloc_inode_init( ...@@ -327,12 +328,11 @@ xfs_ialloc_inode_init(
*/ */
d = XFS_AGB_TO_DADDR(mp, agno, agbno + d = XFS_AGB_TO_DADDR(mp, agno, agbno +
(j * M_IGEO(mp)->blocks_per_cluster)); (j * M_IGEO(mp)->blocks_per_cluster));
fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
mp->m_bsize * mp->m_bsize * M_IGEO(mp)->blocks_per_cluster,
M_IGEO(mp)->blocks_per_cluster, XBF_UNMAPPED, &fbuf);
XBF_UNMAPPED); if (error)
if (!fbuf) return error;
return -ENOMEM;
/* Initialize the inode buffers and log them appropriately. */ /* Initialize the inode buffers and log them appropriately. */
fbuf->b_ops = &xfs_inode_buf_ops; fbuf->b_ops = &xfs_inode_buf_ops;
......
...@@ -1185,13 +1185,14 @@ xfs_sb_get_secondary( ...@@ -1185,13 +1185,14 @@ xfs_sb_get_secondary(
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
struct xfs_buf *bp; struct xfs_buf *bp;
int error;
ASSERT(agno != 0 && agno != NULLAGNUMBER); ASSERT(agno != 0 && agno != NULLAGNUMBER);
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)), XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
XFS_FSS_TO_BB(mp, 1), 0); XFS_FSS_TO_BB(mp, 1), 0, &bp);
if (!bp) if (error)
return -ENOMEM; return error;
bp->b_ops = &xfs_sb_buf_ops; bp->b_ops = &xfs_sb_buf_ops;
xfs_buf_oneshot(bp); xfs_buf_oneshot(bp);
*bpp = bp; *bpp = bp;
......
...@@ -341,13 +341,17 @@ xrep_init_btblock( ...@@ -341,13 +341,17 @@ xrep_init_btblock(
struct xfs_trans *tp = sc->tp; struct xfs_trans *tp = sc->tp;
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
struct xfs_buf *bp; struct xfs_buf *bp;
int error;
trace_xrep_init_btblock(mp, XFS_FSB_TO_AGNO(mp, fsb), trace_xrep_init_btblock(mp, XFS_FSB_TO_AGNO(mp, fsb),
XFS_FSB_TO_AGBNO(mp, fsb), btnum); XFS_FSB_TO_AGBNO(mp, fsb), btnum);
ASSERT(XFS_FSB_TO_AGNO(mp, fsb) == sc->sa.agno); ASSERT(XFS_FSB_TO_AGNO(mp, fsb) == sc->sa.agno);
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, XFS_FSB_TO_DADDR(mp, fsb), error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
XFS_FSB_TO_BB(mp, 1), 0); XFS_FSB_TO_DADDR(mp, fsb), XFS_FSB_TO_BB(mp, 1), 0,
&bp);
if (error)
return error;
xfs_buf_zero(bp, 0, BBTOB(bp->b_length)); xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
xfs_btree_init_block(mp, bp, btnum, 0, 0, sc->sa.agno); xfs_btree_init_block(mp, bp, btnum, 0, 0, sc->sa.agno);
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_BTREE_BUF); xfs_trans_buf_set_type(tp, bp, XFS_BLFT_BTREE_BUF);
......
...@@ -205,11 +205,12 @@ xfs_attr3_node_inactive( ...@@ -205,11 +205,12 @@ xfs_attr3_node_inactive(
/* /*
* Remove the subsidiary block from the cache and from the log. * Remove the subsidiary block from the cache and from the log.
*/ */
child_bp = xfs_trans_get_buf(*trans, mp->m_ddev_targp, error = xfs_trans_get_buf(*trans, mp->m_ddev_targp,
child_blkno, child_blkno,
XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0); XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0,
if (!child_bp) &child_bp);
return -EIO; if (error)
return error;
error = bp->b_error; error = bp->b_error;
if (error) { if (error) {
xfs_trans_brelse(*trans, child_bp); xfs_trans_brelse(*trans, child_bp);
...@@ -298,10 +299,10 @@ xfs_attr3_root_inactive( ...@@ -298,10 +299,10 @@ xfs_attr3_root_inactive(
/* /*
* Invalidate the incore copy of the root block. * Invalidate the incore copy of the root block.
*/ */
bp = xfs_trans_get_buf(*trans, mp->m_ddev_targp, blkno, error = xfs_trans_get_buf(*trans, mp->m_ddev_targp, blkno,
XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0); XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0, &bp);
if (!bp) if (error)
return -EIO; return error;
error = bp->b_error; error = bp->b_error;
if (error) { if (error) {
xfs_trans_brelse(*trans, bp); xfs_trans_brelse(*trans, bp);
......
...@@ -320,10 +320,10 @@ xfs_dquot_disk_alloc( ...@@ -320,10 +320,10 @@ xfs_dquot_disk_alloc(
dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock); dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);
/* now we can just get the buffer (there's nothing to read yet) */ /* now we can just get the buffer (there's nothing to read yet) */
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno, error = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen, 0); mp->m_quotainfo->qi_dqchunklen, 0, &bp);
if (!bp) if (error)
return -ENOMEM; return error;
bp->b_ops = &xfs_dquot_buf_ops; bp->b_ops = &xfs_dquot_buf_ops;
/* /*
......
...@@ -2546,6 +2546,7 @@ xfs_ifree_cluster( ...@@ -2546,6 +2546,7 @@ xfs_ifree_cluster(
struct xfs_perag *pag; struct xfs_perag *pag;
struct xfs_ino_geometry *igeo = M_IGEO(mp); struct xfs_ino_geometry *igeo = M_IGEO(mp);
xfs_ino_t inum; xfs_ino_t inum;
int error;
inum = xic->first_ino; inum = xic->first_ino;
pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, inum)); pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, inum));
...@@ -2574,12 +2575,11 @@ xfs_ifree_cluster( ...@@ -2574,12 +2575,11 @@ xfs_ifree_cluster(
* complete before we get a lock on it, and hence we may fail * complete before we get a lock on it, and hence we may fail
* to mark all the active inodes on the buffer stale. * to mark all the active inodes on the buffer stale.
*/ */
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno, error = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno,
mp->m_bsize * igeo->blocks_per_cluster, mp->m_bsize * igeo->blocks_per_cluster,
XBF_UNMAPPED); XBF_UNMAPPED, &bp);
if (error)
if (!bp) return error;
return -ENOMEM;
/* /*
* This buffer may not have been correctly initialised as we * This buffer may not have been correctly initialised as we
......
...@@ -826,12 +826,10 @@ xfs_growfs_rt_alloc( ...@@ -826,12 +826,10 @@ xfs_growfs_rt_alloc(
* Get a buffer for the block. * Get a buffer for the block.
*/ */
d = XFS_FSB_TO_DADDR(mp, fsbno); d = XFS_FSB_TO_DADDR(mp, fsbno);
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
mp->m_bsize, 0); mp->m_bsize, 0, &bp);
if (bp == NULL) { if (error)
error = -EIO;
goto out_trans_cancel; goto out_trans_cancel;
}
memset(bp->b_addr, 0, mp->m_sb.sb_blocksize); memset(bp->b_addr, 0, mp->m_sb.sb_blocksize);
xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
/* /*
......
...@@ -280,12 +280,10 @@ xfs_symlink( ...@@ -280,12 +280,10 @@ xfs_symlink(
d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock); d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
BTOBB(byte_cnt), 0); BTOBB(byte_cnt), 0, &bp);
if (!bp) { if (error)
error = -ENOMEM;
goto out_trans_cancel; goto out_trans_cancel;
}
bp->b_ops = &xfs_symlink_buf_ops; bp->b_ops = &xfs_symlink_buf_ops;
byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt); byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
...@@ -423,13 +421,12 @@ xfs_inactive_symlink_rmt( ...@@ -423,13 +421,12 @@ xfs_inactive_symlink_rmt(
* Invalidate the block(s). No validation is done. * Invalidate the block(s). No validation is done.
*/ */
for (i = 0; i < nmaps; i++) { for (i = 0; i < nmaps; i++) {
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
XFS_FSB_TO_DADDR(mp, mval[i].br_startblock), XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0); XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0,
if (!bp) { &bp);
error = -ENOMEM; if (error)
goto error_trans_cancel; goto error_trans_cancel;
}
xfs_trans_binval(tp, bp); xfs_trans_binval(tp, bp);
} }
/* /*
......
...@@ -173,22 +173,17 @@ int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target, ...@@ -173,22 +173,17 @@ int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target,
struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags, struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
struct xfs_buf **bpp); struct xfs_buf **bpp);
static inline struct xfs_buf * static inline int
xfs_trans_get_buf( xfs_trans_get_buf(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_buftarg *target, struct xfs_buftarg *target,
xfs_daddr_t blkno, xfs_daddr_t blkno,
int numblks, int numblks,
uint flags) uint flags,
struct xfs_buf **bpp)
{ {
struct xfs_buf *bp;
int error;
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
error = xfs_trans_get_buf_map(tp, target, &map, 1, flags, &bp); return xfs_trans_get_buf_map(tp, target, &map, 1, flags, bpp);
if (error)
return NULL;
return bp;
} }
int xfs_trans_read_buf_map(struct xfs_mount *mp, int xfs_trans_read_buf_map(struct xfs_mount *mp,
......
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