/* Waits for I/O to complete on the buffer supplied. It returns immediately if no I/O is pending. It returns the I/O error code, if any, or 0 if there was no error.  */
int xfs_buf_iowait(xfs_buf_t *bp)
/* Waits for I/O to complete on the buffer supplied. It returns immediately if no I/O is pending. It returns the I/O error code, if any, or 0 if there was no error.  */
int xfs_buf_iowait(xfs_buf_t *bp)
{
	trace_xfs_buf_iowait(bp, _RET_IP_);
	if (atomic_read(&bp->b_io_remaining))
		blk_run_address_space(bp->b_target->bt_mapping);
	wait_for_completion(&bp->b_iowait);
	trace_xfs_buf_iowait_done(bp, _RET_IP_);
	return bp->b_error;
}