Skip to content

Commit 0e3eccc

Browse files
committed
xfs: make xfs_buf_read return an error code
Convert xfs_buf_read() 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 2842b6d commit 0e3eccc

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

fs/xfs/libxfs/xfs_attr_remote.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,10 @@ xfs_attr_rmtval_get(
418418
(map[i].br_startblock != HOLESTARTBLOCK));
419419
dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
420420
dblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
421-
bp = xfs_buf_read(mp->m_ddev_targp, dblkno, dblkcnt, 0,
422-
&xfs_attr3_rmt_buf_ops);
423-
if (!bp)
424-
return -ENOMEM;
421+
error = xfs_buf_read(mp->m_ddev_targp, dblkno, dblkcnt,
422+
0, &bp, &xfs_attr3_rmt_buf_ops);
423+
if (error)
424+
return error;
425425

426426
error = xfs_attr_rmtval_copyout(mp, bp, args->dp->i_ino,
427427
&offset, &valuelen,

fs/xfs/xfs_buf.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,18 @@ xfs_buf_get(
213213
return xfs_buf_get_map(target, &map, 1, 0, bpp);
214214
}
215215

216-
static inline struct xfs_buf *
216+
static inline int
217217
xfs_buf_read(
218218
struct xfs_buftarg *target,
219219
xfs_daddr_t blkno,
220220
size_t numblks,
221221
xfs_buf_flags_t flags,
222+
struct xfs_buf **bpp,
222223
const struct xfs_buf_ops *ops)
223224
{
224-
struct xfs_buf *bp;
225-
int error;
226225
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
227226

228-
error = xfs_buf_read_map(target, &map, 1, flags, &bp, ops);
229-
if (error)
230-
return NULL;
231-
return bp;
227+
return xfs_buf_read_map(target, &map, 1, flags, bpp, ops);
232228
}
233229

234230
static inline void

fs/xfs/xfs_log_recover.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,10 +2745,10 @@ xlog_recover_buffer_pass2(
27452745
if (buf_f->blf_flags & XFS_BLF_INODE_BUF)
27462746
buf_flags |= XBF_UNMAPPED;
27472747

2748-
bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
2749-
buf_flags, NULL);
2750-
if (!bp)
2751-
return -ENOMEM;
2748+
error = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
2749+
buf_flags, &bp, NULL);
2750+
if (error)
2751+
return error;
27522752

27532753
/*
27542754
* Recover the buffer only if we get an LSN from it and it's less than
@@ -2945,12 +2945,10 @@ xlog_recover_inode_pass2(
29452945
}
29462946
trace_xfs_log_recover_inode_recover(log, in_f);
29472947

2948-
bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0,
2949-
&xfs_inode_buf_ops);
2950-
if (!bp) {
2951-
error = -ENOMEM;
2948+
error = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len,
2949+
0, &bp, &xfs_inode_buf_ops);
2950+
if (error)
29522951
goto error;
2953-
}
29542952
ASSERT(in_f->ilf_fields & XFS_ILOG_CORE);
29552953
dip = xfs_buf_offset(bp, in_f->ilf_boffset);
29562954

fs/xfs/xfs_symlink.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ xfs_readlink_bmap_ilocked(
5353
d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
5454
byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
5555

56-
bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0,
57-
&xfs_symlink_buf_ops);
58-
if (!bp)
59-
return -ENOMEM;
56+
error = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0,
57+
&bp, &xfs_symlink_buf_ops);
58+
if (error)
59+
return error;
6060
byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
6161
if (pathlen < byte_cnt)
6262
byte_cnt = pathlen;

0 commit comments

Comments
 (0)