Commit cf53e99d authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner
Browse files

xfs: Don't use xfs_buf_iowait in the delwri buffer code

For the special case of delwri buffer submission and waiting, we
don't need to issue IO synchronously at all. The second pass to call
xfs_buf_iowait() can be replaced with  blocking on xfs_buf_lock() -
the buffer will be unlocked when the async IO is complete.

This formalises a sane the method of waiting for async IO - take an
extra reference, submit the IO, call xfs_buf_lock() when you want to
wait for IO completion. i.e.:

	bp = xfs_buf_find();
	bp->b_flags |= XBF_ASYNC;
	error = bp->b_error;

While this is somewhat racy for gathering IO errors, none of the
code that calls xfs_buf_delwri_submit() will race against other
users of the buffers being submitted. Even if they do, we don't
really care if the error is detected by the delwri code or the user
we raced against. Either way, the error will be detected and
Signed-off-by: default avatarDave Chinner <>
Reviewed-by: default avatarChristoph Hellwig <>
Signed-off-by: default avatarDave Chinner <>
parent a870fe6d
......@@ -1813,12 +1813,17 @@ __xfs_buf_delwri_submit(
list_for_each_entry_safe(bp, n, io_list, b_list) {
bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC | XBF_WRITE_FAIL);
bp->b_flags |= XBF_WRITE;
bp->b_flags |= XBF_WRITE | XBF_ASYNC;
if (!wait) {
bp->b_flags |= XBF_ASYNC;
* we do all Io submission async. This means if we need to wait
* for IO completion we need to take an extra reference so the
* buffer is still valid on the other side.
if (wait)
......@@ -1866,7 +1871,10 @@ xfs_buf_delwri_submit(
bp = list_first_entry(&io_list, struct xfs_buf, b_list);
error2 = xfs_buf_iowait(bp);
/* locking the buffer will wait for async IO completion. */
error2 = bp->b_error;
if (!error)
error = error2;
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