Skip to content

Commit 05b5968

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: move xfs_buf_iowait out of (__)xfs_buf_submit
There is no good reason to pass a bool argument to wait for a buffer when the callers that want that can easily just wait themselves. This means the wait moves out of the extra hold of the buffer, but as the callers of synchronous buffer I/O need to hold a reference anyway that is perfectly fine. Because all async buffer submitters ignore the error return value, and the synchronous ones catch the error condition through b_error and xfs_buf_iowait this also means the new xfs_buf_submit doesn't have to return an error code. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Acked-by: Dave Chinner <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 411ff3f commit 05b5968

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

fs/xfs/xfs_buf.c

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,8 @@ struct kmem_cache *xfs_buf_cache;
5353
* b_lock (trylock due to inversion)
5454
*/
5555

56-
static int __xfs_buf_submit(struct xfs_buf *bp, bool wait);
57-
58-
static inline int
59-
xfs_buf_submit(
60-
struct xfs_buf *bp)
61-
{
62-
return __xfs_buf_submit(bp, !(bp->b_flags & XBF_ASYNC));
63-
}
56+
static void xfs_buf_submit(struct xfs_buf *bp);
57+
static int xfs_buf_iowait(struct xfs_buf *bp);
6458

6559
static inline bool xfs_buf_is_uncached(struct xfs_buf *bp)
6660
{
@@ -804,7 +798,10 @@ _xfs_buf_read(
804798
bp->b_flags &= ~(XBF_WRITE | XBF_ASYNC | XBF_READ_AHEAD | XBF_DONE);
805799
bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD);
806800

807-
return xfs_buf_submit(bp);
801+
xfs_buf_submit(bp);
802+
if (flags & XBF_ASYNC)
803+
return 0;
804+
return xfs_buf_iowait(bp);
808805
}
809806

810807
/*
@@ -980,8 +977,8 @@ xfs_buf_read_uncached(
980977
bp->b_ops = ops;
981978

982979
xfs_buf_submit(bp);
983-
if (bp->b_error) {
984-
error = bp->b_error;
980+
error = xfs_buf_iowait(bp);
981+
if (error) {
985982
xfs_buf_relse(bp);
986983
return error;
987984
}
@@ -1483,7 +1480,8 @@ xfs_bwrite(
14831480
bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q |
14841481
XBF_DONE);
14851482

1486-
error = xfs_buf_submit(bp);
1483+
xfs_buf_submit(bp);
1484+
error = xfs_buf_iowait(bp);
14871485
if (error)
14881486
xfs_force_shutdown(bp->b_mount, SHUTDOWN_META_IO_ERROR);
14891487
return error;
@@ -1698,13 +1696,10 @@ xfs_buf_iowait(
16981696
* safe to reference the buffer after a call to this function unless the caller
16991697
* holds an additional reference itself.
17001698
*/
1701-
static int
1702-
__xfs_buf_submit(
1703-
struct xfs_buf *bp,
1704-
bool wait)
1699+
static void
1700+
xfs_buf_submit(
1701+
struct xfs_buf *bp)
17051702
{
1706-
int error = 0;
1707-
17081703
trace_xfs_buf_submit(bp, _RET_IP_);
17091704

17101705
ASSERT(!(bp->b_flags & _XBF_DELWRI_Q));
@@ -1724,10 +1719,9 @@ __xfs_buf_submit(
17241719
* state here rather than mount state to avoid corrupting the log tail
17251720
* on shutdown.
17261721
*/
1727-
if (bp->b_mount->m_log &&
1728-
xlog_is_shutdown(bp->b_mount->m_log)) {
1722+
if (bp->b_mount->m_log && xlog_is_shutdown(bp->b_mount->m_log)) {
17291723
xfs_buf_ioend_fail(bp);
1730-
return -EIO;
1724+
return;
17311725
}
17321726

17331727
/*
@@ -1765,16 +1759,12 @@ __xfs_buf_submit(
17651759
xfs_buf_ioend_async(bp);
17661760
}
17671761

1768-
if (wait)
1769-
error = xfs_buf_iowait(bp);
1770-
17711762
/*
17721763
* Release the hold that keeps the buffer referenced for the entire
17731764
* I/O. Note that if the buffer is async, it is not safe to reference
17741765
* after this release.
17751766
*/
17761767
xfs_buf_rele(bp);
1777-
return error;
17781768
}
17791769

17801770
void *
@@ -2323,7 +2313,7 @@ xfs_buf_delwri_submit_buffers(
23232313
bp->b_flags |= XBF_ASYNC;
23242314
xfs_buf_list_del(bp);
23252315
}
2326-
__xfs_buf_submit(bp, false);
2316+
xfs_buf_submit(bp);
23272317
}
23282318
blk_finish_plug(&plug);
23292319

0 commit comments

Comments
 (0)