Commit 3848b5f6 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: make xfs_buf_get_map return an error code

Convert xfs_buf_get_map() 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 32dff5e5
...@@ -685,53 +685,39 @@ xfs_buf_incore( ...@@ -685,53 +685,39 @@ xfs_buf_incore(
* cache hits, as metadata intensive workloads will see 3 orders of magnitude * cache hits, as metadata intensive workloads will see 3 orders of magnitude
* more hits than misses. * more hits than misses.
*/ */
struct xfs_buf * int
xfs_buf_get_map( xfs_buf_get_map(
struct xfs_buftarg *target, struct xfs_buftarg *target,
struct xfs_buf_map *map, struct xfs_buf_map *map,
int nmaps, int nmaps,
xfs_buf_flags_t flags) xfs_buf_flags_t flags,
struct xfs_buf **bpp)
{ {
struct xfs_buf *bp; struct xfs_buf *bp;
struct xfs_buf *new_bp; struct xfs_buf *new_bp;
int error = 0; int error = 0;
*bpp = NULL;
error = xfs_buf_find(target, map, nmaps, flags, NULL, &bp); error = xfs_buf_find(target, map, nmaps, flags, NULL, &bp);
if (!error)
switch (error) {
case 0:
/* cache hit */
goto found; goto found;
case -EAGAIN: if (error != -ENOENT)
/* cache hit, trylock failure, caller handles failure */ return error;
ASSERT(flags & XBF_TRYLOCK);
return NULL;
case -ENOENT:
/* cache miss, go for insert */
break;
case -EFSCORRUPTED:
default:
/*
* None of the higher layers understand failure types
* yet, so return NULL to signal a fatal lookup error.
*/
return NULL;
}
error = _xfs_buf_alloc(target, map, nmaps, flags, &new_bp); error = _xfs_buf_alloc(target, map, nmaps, flags, &new_bp);
if (error) if (error)
return NULL; return error;
error = xfs_buf_allocate_memory(new_bp, flags); error = xfs_buf_allocate_memory(new_bp, flags);
if (error) { if (error) {
xfs_buf_free(new_bp); xfs_buf_free(new_bp);
return NULL; return error;
} }
error = xfs_buf_find(target, map, nmaps, flags, new_bp, &bp); error = xfs_buf_find(target, map, nmaps, flags, new_bp, &bp);
if (error) { if (error) {
xfs_buf_free(new_bp); xfs_buf_free(new_bp);
return NULL; return error;
} }
if (bp != new_bp) if (bp != new_bp)
...@@ -744,7 +730,7 @@ xfs_buf_get_map( ...@@ -744,7 +730,7 @@ xfs_buf_get_map(
xfs_warn(target->bt_mount, xfs_warn(target->bt_mount,
"%s: failed to map pagesn", __func__); "%s: failed to map pagesn", __func__);
xfs_buf_relse(bp); xfs_buf_relse(bp);
return NULL; return error;
} }
} }
...@@ -757,7 +743,8 @@ xfs_buf_get_map( ...@@ -757,7 +743,8 @@ xfs_buf_get_map(
XFS_STATS_INC(target->bt_mount, xb_get); XFS_STATS_INC(target->bt_mount, xb_get);
trace_xfs_buf_get(bp, flags, _RET_IP_); trace_xfs_buf_get(bp, flags, _RET_IP_);
return bp; *bpp = bp;
return 0;
} }
STATIC int STATIC int
...@@ -818,11 +805,12 @@ xfs_buf_read_map( ...@@ -818,11 +805,12 @@ xfs_buf_read_map(
const struct xfs_buf_ops *ops) const struct xfs_buf_ops *ops)
{ {
struct xfs_buf *bp; struct xfs_buf *bp;
int error;
flags |= XBF_READ; flags |= XBF_READ;
bp = xfs_buf_get_map(target, map, nmaps, flags); error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
if (!bp) if (error)
return NULL; return NULL;
trace_xfs_buf_read(bp, flags, _RET_IP_); trace_xfs_buf_read(bp, flags, _RET_IP_);
......
...@@ -192,9 +192,8 @@ struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target, ...@@ -192,9 +192,8 @@ struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
xfs_daddr_t blkno, size_t numblks, xfs_daddr_t blkno, size_t numblks,
xfs_buf_flags_t flags); xfs_buf_flags_t flags);
struct xfs_buf *xfs_buf_get_map(struct xfs_buftarg *target, int xfs_buf_get_map(struct xfs_buftarg *target, struct xfs_buf_map *map,
struct xfs_buf_map *map, int nmaps, int nmaps, xfs_buf_flags_t flags, struct xfs_buf **bpp);
xfs_buf_flags_t flags);
struct xfs_buf *xfs_buf_read_map(struct xfs_buftarg *target, struct xfs_buf *xfs_buf_read_map(struct xfs_buftarg *target,
struct xfs_buf_map *map, int nmaps, struct xfs_buf_map *map, int nmaps,
xfs_buf_flags_t flags, xfs_buf_flags_t flags,
...@@ -209,8 +208,14 @@ xfs_buf_get( ...@@ -209,8 +208,14 @@ xfs_buf_get(
xfs_daddr_t blkno, xfs_daddr_t blkno,
size_t numblks) size_t numblks)
{ {
struct xfs_buf *bp;
int error;
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
return xfs_buf_get_map(target, &map, 1, 0);
error = xfs_buf_get_map(target, &map, 1, 0, &bp);
if (error)
return NULL;
return bp;
} }
static inline struct xfs_buf * static inline struct xfs_buf *
......
...@@ -122,9 +122,14 @@ xfs_trans_get_buf_map( ...@@ -122,9 +122,14 @@ xfs_trans_get_buf_map(
{ {
xfs_buf_t *bp; xfs_buf_t *bp;
struct xfs_buf_log_item *bip; struct xfs_buf_log_item *bip;
int error;
if (!tp) if (!tp) {
return xfs_buf_get_map(target, map, nmaps, flags); error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
if (error)
return NULL;
return bp;
}
/* /*
* If we find the buffer in the cache with this transaction * If we find the buffer in the cache with this transaction
...@@ -149,10 +154,9 @@ xfs_trans_get_buf_map( ...@@ -149,10 +154,9 @@ xfs_trans_get_buf_map(
return bp; return bp;
} }
bp = xfs_buf_get_map(target, map, nmaps, flags); error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
if (bp == NULL) { if (error)
return NULL; return NULL;
}
ASSERT(!bp->b_error); ASSERT(!bp->b_error);
......
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