extern void libxfs_putbufr(xfs_buf_t *);
extern int libxfs_writebuf_int(xfs_buf_t *, int);
+extern int libxfs_writebufr(struct xfs_buf *);
extern int libxfs_readbufr(struct xfs_buftarg *, xfs_daddr_t, xfs_buf_t *, int, int);
+extern int libxfs_readbufr_map(struct xfs_buftarg *, struct xfs_buf *,
+ struct xfs_buf_map *, int, int);
extern int libxfs_bhash_size;
return bp;
}
-struct xfs_buf *
-libxfs_readbuf_map(struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps,
- int flags, const struct xfs_buf_ops *ops)
+int
+libxfs_readbufr_map(struct xfs_buftarg *btp, struct xfs_buf *bp,
+ struct xfs_buf_map *map, int nmaps, int flags)
{
- xfs_buf_t *bp;
- int error = 0;
- int fd;
- int i;
- char *buf;
-
- if (nmaps == 1)
- return libxfs_readbuf(btp, map[0].bm_bn, map[0].bm_len,
- flags, ops);
-
- bp = libxfs_getbuf_map(btp, map, nmaps);
- if (!bp)
- return NULL;
+ int fd = libxfs_device_to_fd(btp->dev);
+ int error = 0;
+ char *buf;
+ int i;
- bp->b_error = 0;
- bp->b_ops = ops;
- if ((bp->b_flags & (LIBXFS_B_UPTODATE|LIBXFS_B_DIRTY)))
- return bp;
+ ASSERT(BBTOB(len) <= bp->b_bcount);
- ASSERT(bp->b_nmaps = nmaps);
+ ASSERT(bp->b_nmaps == nmaps);
fd = libxfs_device_to_fd(btp->dev);
buf = bp->b_addr;
offset += len;
}
+ if (!error);
+ bp->b_flags |= LIBXFS_B_UPTODATE;
+#ifdef IO_DEBUG
+ printf("%lx: %s: read %u bytes, error %d, blkno=0x%llx(0x%llx), %p\n",
+ pthread_self(), __FUNCTION__, , error,
+ (long long)LIBXFS_BBTOOFF64(blkno), (long long)blkno, bp);
+#endif
+ return error;
+}
+
+struct xfs_buf *
+libxfs_readbuf_map(struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps,
+ int flags, const struct xfs_buf_ops *ops)
+{
+ struct xfs_buf *bp;
+ int error = 0;
+
+ if (nmaps == 1)
+ return libxfs_readbuf(btp, map[0].bm_bn, map[0].bm_len,
+ flags, ops);
+
+ bp = libxfs_getbuf_map(btp, map, nmaps);
+ if (!bp)
+ return NULL;
+
+ bp->b_error = 0;
+ bp->b_ops = ops;
+ if ((bp->b_flags & (LIBXFS_B_UPTODATE|LIBXFS_B_DIRTY)))
+ return bp;
+
+ error = libxfs_readbufr_map(btp, bp, map, nmaps, flags);
if (!error) {
bp->b_flags |= LIBXFS_B_UPTODATE;
if (bp->b_ops)