Skip to content

Commit 9676b54

Browse files
committed
xfs: make xfs_trans_get_buf_map return an error code
Convert xfs_trans_get_buf_map() to return numeric error codes like most everywhere else in xfs. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 0e3eccc commit 9676b54

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

fs/xfs/libxfs/xfs_da_btree.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,13 +2591,9 @@ xfs_da_get_buf(
25912591
if (error || nmap == 0)
25922592
goto out_free;
25932593

2594-
bp = xfs_trans_get_buf_map(tp, mp->m_ddev_targp, mapp, nmap, 0);
2595-
error = bp ? bp->b_error : -EIO;
2596-
if (error) {
2597-
if (bp)
2598-
xfs_trans_brelse(tp, bp);
2594+
error = xfs_trans_get_buf_map(tp, mp->m_ddev_targp, mapp, nmap, 0, &bp);
2595+
if (error)
25992596
goto out_free;
2600-
}
26012597

26022598
*bpp = bp;
26032599

fs/xfs/xfs_trans.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ int xfs_trans_alloc_empty(struct xfs_mount *mp,
169169
struct xfs_trans **tpp);
170170
void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
171171

172-
struct xfs_buf *xfs_trans_get_buf_map(struct xfs_trans *tp,
173-
struct xfs_buftarg *target,
174-
struct xfs_buf_map *map, int nmaps,
175-
uint flags);
172+
int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target,
173+
struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
174+
struct xfs_buf **bpp);
176175

177176
static inline struct xfs_buf *
178177
xfs_trans_get_buf(
@@ -182,8 +181,14 @@ xfs_trans_get_buf(
182181
int numblks,
183182
uint flags)
184183
{
184+
struct xfs_buf *bp;
185+
int error;
186+
185187
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
186-
return xfs_trans_get_buf_map(tp, target, &map, 1, flags);
188+
error = xfs_trans_get_buf_map(tp, target, &map, 1, flags, &bp);
189+
if (error)
190+
return NULL;
191+
return bp;
187192
}
188193

189194
int xfs_trans_read_buf_map(struct xfs_mount *mp,

fs/xfs/xfs_trans_buf.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,22 @@ xfs_trans_bjoin(
112112
* If the transaction pointer is NULL, make this just a normal
113113
* get_buf() call.
114114
*/
115-
struct xfs_buf *
115+
int
116116
xfs_trans_get_buf_map(
117117
struct xfs_trans *tp,
118118
struct xfs_buftarg *target,
119119
struct xfs_buf_map *map,
120120
int nmaps,
121-
xfs_buf_flags_t flags)
121+
xfs_buf_flags_t flags,
122+
struct xfs_buf **bpp)
122123
{
123124
xfs_buf_t *bp;
124125
struct xfs_buf_log_item *bip;
125126
int error;
126127

127-
if (!tp) {
128-
error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
129-
if (error)
130-
return NULL;
131-
return bp;
132-
}
128+
*bpp = NULL;
129+
if (!tp)
130+
return xfs_buf_get_map(target, map, nmaps, flags, bpp);
133131

134132
/*
135133
* If we find the buffer in the cache with this transaction
@@ -151,18 +149,20 @@ xfs_trans_get_buf_map(
151149
ASSERT(atomic_read(&bip->bli_refcount) > 0);
152150
bip->bli_recur++;
153151
trace_xfs_trans_get_buf_recur(bip);
154-
return bp;
152+
*bpp = bp;
153+
return 0;
155154
}
156155

157156
error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
158157
if (error)
159-
return NULL;
158+
return error;
160159

161160
ASSERT(!bp->b_error);
162161

163162
_xfs_trans_bjoin(tp, bp, 1);
164163
trace_xfs_trans_get_buf(bp->b_log_item);
165-
return bp;
164+
*bpp = bp;
165+
return 0;
166166
}
167167

168168
/*

0 commit comments

Comments
 (0)