@@ -144,9 +144,9 @@ extern struct cache_operations libxfs_bcache_operations;
#define libxfs_buf_get(dev, daddr, len) \
libxfs_trace_getbuf(__FUNCTION__, __FILE__, __LINE__, \
(dev), (daddr), (len))
-#define libxfs_buf_get_map(dev, map, nmaps, flags) \
+#define libxfs_buf_get_map(dev, map, nmaps, flags, bpp) \
libxfs_trace_getbuf_map(__FUNCTION__, __FILE__, __LINE__, \
- (dev), (map), (nmaps), (flags))
+ (dev), (map), (nmaps), (flags), (bpp))
#define libxfs_buf_relse(buf) \
libxfs_trace_putbuf(__FUNCTION__, __FILE__, __LINE__, (buf))
@@ -161,8 +161,9 @@ void libxfs_trace_dirtybuf(const char *func, const char *file, int line,
struct xfs_buf *libxfs_trace_getbuf(const char *func, const char *file,
int line, struct xfs_buftarg *btp, xfs_daddr_t daddr,
size_t len);
-extern xfs_buf_t *libxfs_trace_getbuf_map(const char *, const char *, int,
- struct xfs_buftarg *, struct xfs_buf_map *, int, int);
+int libxfs_trace_getbuf_map(const char *func, const char *file, int line,
+ struct xfs_buftarg *btp, struct xfs_buf_map *map,
+ int nmaps, int flags, struct xfs_buf **bpp);
extern void libxfs_trace_putbuf (const char *, const char *, int,
xfs_buf_t *);
@@ -171,8 +172,8 @@ extern void libxfs_trace_putbuf (const char *, const char *, int,
extern xfs_buf_t *libxfs_buf_read_map(struct xfs_buftarg *, struct xfs_buf_map *,
int, int, const struct xfs_buf_ops *);
void libxfs_buf_dirty(struct xfs_buf *bp, int flags);
-extern xfs_buf_t *libxfs_buf_get_map(struct xfs_buftarg *,
- struct xfs_buf_map *, int, int);
+int libxfs_buf_get_map(struct xfs_buftarg *btp, struct xfs_buf_map *maps,
+ int nmaps, int flags, struct xfs_buf **bpp);
void libxfs_buf_relse(struct xfs_buf *);
static inline struct xfs_buf*
@@ -181,9 +182,14 @@ libxfs_buf_get(
xfs_daddr_t blkno,
size_t numblks)
{
+ struct xfs_buf *bp;
+ int error;
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
- return libxfs_buf_get_map(target, &map, 1, 0);
+ error = libxfs_buf_get_map(target, &map, 1, 0, &bp);
+ if (error)
+ return NULL;
+ return bp;
}
static inline struct xfs_buf*
@@ -392,10 +392,9 @@ libxfs_log_header(
xfs_buf_t *libxfs_buf_read_map(struct xfs_buftarg *, struct xfs_buf_map *,
int, int, const struct xfs_buf_ops *);
int libxfs_writebuf(xfs_buf_t *, int);
-struct xfs_buf *libxfs_buf_get(struct xfs_buftarg *btp, xfs_daddr_t daddr,
- size_t len);
-xfs_buf_t *libxfs_buf_get_map(struct xfs_buftarg *, struct xfs_buf_map *,
- int, int);
+int libxfs_buf_get_map(struct xfs_buftarg *btp,
+ struct xfs_buf_map *maps, int nmaps, int flags,
+ struct xfs_buf **bpp);
void libxfs_buf_relse(struct xfs_buf *);
#define __add_trace(bp, func, file, line) \
@@ -450,19 +449,27 @@ libxfs_trace_getbuf(
struct xfs_buf *bp;
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
- bp = libxfs_buf_get_map(target, &map, 1, 0);
+ libxfs_buf_get_map(target, &map, 1, 0, &bp);
__add_trace(bp, func, file, line);
return bp;
}
-xfs_buf_t *
-libxfs_trace_getbuf_map(const char *func, const char *file, int line,
- struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps,
- int flags)
+int
+libxfs_trace_getbuf_map(
+ const char *func,
+ const char *file,
+ int line,
+ struct xfs_buftarg *btp,
+ struct xfs_buf_map *map,
+ int nmaps,
+ int flags,
+ struct xfs_buf **bpp)
{
- xfs_buf_t *bp = libxfs_buf_get_map(btp, map, nmaps, flags);
- __add_trace(bp, func, file, line);
- return bp;
+ int error;
+
+ error = libxfs_buf_get_map(btp, map, nmaps, flags, bpp);
+ __add_trace(*bpp, func, file, line);
+ return error;
}
void
@@ -812,25 +819,20 @@ reset_buf_state(
LIBXFS_B_UPTODATE);
}
-static struct xfs_buf *
+static int
__libxfs_buf_get_map(
struct xfs_buftarg *btp,
struct xfs_buf_map *map,
int nmaps,
- int flags)
+ int flags,
+ struct xfs_buf **bpp)
{
struct xfs_bufkey key = {NULL};
- struct xfs_buf *bp;
int i;
- int error;
- if (nmaps == 1) {
- error = libxfs_getbuf_flags(btp, map[0].bm_bn, map[0].bm_len,
- flags, &bp);
- if (error)
- return NULL;
- return bp;
- }
+ if (nmaps == 1)
+ return libxfs_getbuf_flags(btp, map[0].bm_bn, map[0].bm_len,
+ flags, bpp);
key.buftarg = btp;
key.blkno = map[0].bm_bn;
@@ -840,21 +842,25 @@ __libxfs_buf_get_map(
key.map = map;
key.nmaps = nmaps;
- error = __cache_lookup(&key, flags, &bp);
- if (error)
- return NULL;
- return bp;
+ return __cache_lookup(&key, flags, bpp);
}
-struct xfs_buf *
-libxfs_buf_get_map(struct xfs_buftarg *btp, struct xfs_buf_map *map,
- int nmaps, int flags)
+int
+libxfs_buf_get_map(
+ struct xfs_buftarg *btp,
+ struct xfs_buf_map *map,
+ int nmaps,
+ int flags,
+ struct xfs_buf **bpp)
{
- struct xfs_buf *bp;
+ int error;
- bp = __libxfs_buf_get_map(btp, map, nmaps, flags);
- reset_buf_state(bp);
- return bp;
+ error = __libxfs_buf_get_map(btp, map, nmaps, flags, bpp);
+ if (error)
+ return error;
+
+ reset_buf_state(*bpp);
+ return 0;
}
void
@@ -1056,8 +1062,8 @@ libxfs_buf_read_map(struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps,
return libxfs_readbuf(btp, map[0].bm_bn, map[0].bm_len,
flags, ops);
- bp = __libxfs_buf_get_map(btp, map, nmaps, 0);
- if (!bp)
+ error = __libxfs_buf_get_map(btp, map, nmaps, 0, &bp);
+ if (error)
return NULL;
bp->b_error = 0;
@@ -423,11 +423,16 @@ libxfs_trans_get_buf_map(
int nmaps,
xfs_buf_flags_t flags)
{
- xfs_buf_t *bp;
+ struct xfs_buf *bp;
struct xfs_buf_log_item *bip;
+ int error;
- if (!tp)
- return libxfs_buf_get_map(target, map, nmaps, 0);
+ if (!tp) {
+ error = libxfs_buf_get_map(target, map, nmaps, 0, &bp);
+ if (error)
+ return NULL;
+ return bp;
+ }
/*
* If we find the buffer in the cache with this transaction
@@ -445,10 +450,9 @@ libxfs_trans_get_buf_map(
return bp;
}
- bp = libxfs_buf_get_map(target, map, nmaps, 0);
- if (bp == NULL) {
+ error = libxfs_buf_get_map(target, map, nmaps, 0, &bp);
+ if (error)
return NULL;
- }
ASSERT(!bp->b_error);
@@ -113,6 +113,7 @@ pf_queue_io(
{
struct xfs_buf *bp;
xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, map[0].bm_bn);
+ int error;
/*
* Never block on a buffer lock here, given that the actual repair
@@ -120,8 +121,9 @@ pf_queue_io(
* the lock holder is either reading it from disk himself or
* completely overwriting it this behaviour is perfectly fine.
*/
- bp = libxfs_buf_get_map(mp->m_dev, map, nmaps, LIBXFS_GETBUF_TRYLOCK);
- if (!bp)
+ error = -libxfs_buf_get_map(mp->m_dev, map, nmaps, LIBXFS_GETBUF_TRYLOCK,
+ &bp);
+ if (error)
return;
if (bp->b_flags & LIBXFS_B_UPTODATE) {