@@ -114,22 +114,18 @@ int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_buf_map *map, int nmaps,
xfs_buf_flags_t flags, struct xfs_buf **bpp,
const struct xfs_buf_ops *ops);
-static inline struct xfs_buf *
+static inline int
libxfs_trans_get_buf(
struct xfs_trans *tp,
struct xfs_buftarg *btp,
xfs_daddr_t blkno,
int numblks,
- uint flags)
+ uint flags,
+ struct xfs_buf **bpp)
{
- struct xfs_buf *bp;
- int error;
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
- error = libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, &bp);
- if (error)
- return NULL;
- return bp;
+ return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, bpp);
}
static inline int
@@ -685,11 +685,16 @@ xfs_btree_get_bufl(
xfs_trans_t *tp, /* transaction pointer */
xfs_fsblock_t fsbno) /* file system block number */
{
+ struct xfs_buf *bp;
xfs_daddr_t d; /* real disk block address */
+ int error;
ASSERT(fsbno != NULLFSBLOCK);
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;
}
/*
@@ -703,12 +708,17 @@ xfs_btree_get_bufs(
xfs_agnumber_t agno, /* allocation group number */
xfs_agblock_t agbno) /* allocation group block number */
{
+ struct xfs_buf *bp;
xfs_daddr_t d; /* real disk block address */
+ int error;
ASSERT(agno != NULLAGNUMBER);
ASSERT(agbno != NULLAGBLOCK);
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;
}
/*
@@ -1267,11 +1277,10 @@ xfs_btree_get_buf_block(
error = xfs_btree_ptr_to_daddr(cur, ptr, &d);
if (error)
return error;
- *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d,
- mp->m_bsize, 0);
-
- if (!*bpp)
- return -ENOMEM;
+ error = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, mp->m_bsize,
+ 0, bpp);
+ if (error)
+ return error;
(*bpp)->b_ops = cur->bc_ops->buf_ops;
*block = XFS_BUF_TO_BLOCK(*bpp);
@@ -271,6 +271,7 @@ xfs_ialloc_inode_init(
int i, j;
xfs_daddr_t d;
xfs_ino_t ino = 0;
+ int error;
/*
* Loop over the new block(s), filling in the inodes. For small block
@@ -322,12 +323,11 @@ xfs_ialloc_inode_init(
*/
d = XFS_AGB_TO_DADDR(mp, agno, agbno +
(j * M_IGEO(mp)->blocks_per_cluster));
- fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
- mp->m_bsize *
- M_IGEO(mp)->blocks_per_cluster,
- XBF_UNMAPPED);
- if (!fbuf)
- return -ENOMEM;
+ error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
+ mp->m_bsize * M_IGEO(mp)->blocks_per_cluster,
+ XBF_UNMAPPED, &fbuf);
+ if (error)
+ return error;
/* Initialize the inode buffers and log them appropriately. */
fbuf->b_ops = &xfs_inode_buf_ops;
@@ -1162,13 +1162,14 @@ xfs_sb_get_secondary(
struct xfs_buf **bpp)
{
struct xfs_buf *bp;
+ int error;
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_FSS_TO_BB(mp, 1), 0);
- if (!bp)
- return -ENOMEM;
+ XFS_FSS_TO_BB(mp, 1), 0, &bp);
+ if (error)
+ return error;
bp->b_ops = &xfs_sb_buf_ops;
xfs_buf_oneshot(bp);
*bpp = bp;
@@ -254,8 +254,14 @@ newfile(
exit(1);
}
d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
- bp = libxfs_trans_get_buf(logit ? tp : NULL, mp->m_dev, d,
- nb << mp->m_blkbb_log, 0);
+ error = -libxfs_trans_get_buf(logit ? tp : NULL, mp->m_dev, d,
+ nb << mp->m_blkbb_log, 0, &bp);
+ if (error) {
+ fprintf(stderr,
+ _("%s: cannot allocate buffer for file\n"),
+ progname);
+ exit(1);
+ }
memmove(bp->b_addr, buf, len);
if (len < bp->b_bcount)
memset((char *)bp->b_addr + len, 0, bp->b_bcount - len);