return 0;
}
-struct xfs_buf *libxfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen,
- int flags);
+int libxfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags,
+ struct xfs_buf **bpp);
int libxfs_buf_read_uncached(struct xfs_buftarg *targ, xfs_daddr_t daddr,
size_t bblen, int flags, struct xfs_buf **bpp,
const struct xfs_buf_ops *ops);
* Allocate an uncached buffer that points nowhere. The refcount will be 1,
* and the cache node hash list will be empty to indicate that it's uncached.
*/
-struct xfs_buf *
+int
libxfs_buf_get_uncached(
struct xfs_buftarg *targ,
size_t bblen,
- int flags)
+ int flags,
+ struct xfs_buf **bpp)
{
- return libxfs_getbufr_uncached(targ, XFS_BUF_DADDR_NULL, bblen);
+ *bpp = libxfs_getbufr_uncached(targ, XFS_BUF_DADDR_NULL, bblen);
+ return *bpp != NULL ? 0 : -ENOMEM;
}
/*
#include "xfs_ag_resv.h"
#include "xfs_health.h"
-static struct xfs_buf *
+static int
xfs_get_aghdr_buf(
struct xfs_mount *mp,
xfs_daddr_t blkno,
size_t numblks,
+ struct xfs_buf **bpp,
const struct xfs_buf_ops *ops)
{
struct xfs_buf *bp;
+ int error;
- bp = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, 0);
- if (!bp)
- return NULL;
+ error = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, 0, &bp);
+ if (error)
+ return error;
xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
bp->b_bn = blkno;
bp->b_maps[0].bm_bn = blkno;
bp->b_ops = ops;
- return bp;
+ *bpp = bp;
+ return 0;
}
static inline bool is_log_ag(struct xfs_mount *mp, struct aghdr_init_data *id)
struct aghdr_init_data *id,
aghdr_init_work_f work,
const struct xfs_buf_ops *ops)
-
{
struct xfs_buf *bp;
+ int error;
- bp = xfs_get_aghdr_buf(mp, id->daddr, id->numblks, ops);
- if (!bp)
- return -ENOMEM;
+ error = xfs_get_aghdr_buf(mp, id->daddr, id->numblks, &bp, ops);
+ if (error)
+ return error;
(*work)(mp, bp, id);
* to map to a range of nbblks basic blocks at any valid (basic
* block) offset within the log.
*/
-xfs_buf_t *
+struct xfs_buf *
xlog_get_bp(
struct xlog *log,
int nbblks)
{
+ struct xfs_buf *bp;
+
if (!xlog_buf_bbcount_valid(log, nbblks)) {
xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
nbblks);
nbblks += log->l_sectBBsize;
nbblks = round_up(nbblks, log->l_sectBBsize);
- return libxfs_buf_get_uncached(log->l_dev, nbblks, 0);
+ libxfs_buf_get_uncached(log->l_dev, nbblks, 0, &bp);
+ return bp;
}
/*
int bblen)
{
struct xfs_buf *bp;
+ int error;
- bp = libxfs_buf_get_uncached(btp, bblen, 0);
+ error = -libxfs_buf_get_uncached(btp, bblen, 0, &bp);
+ if (error) {
+ fprintf(stderr, _("Could not get memory for buffer, err=%d\n"),
+ error);
+ exit(1);
+ }
bp->b_bn = daddr;
bp->b_maps[0].bm_bn = daddr;
return bp;