• Dave Chinner's avatar
    xfs: Don't use xfs_buf_iowait in the delwri buffer code · cf53e99d
    Dave Chinner authored
    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();
    	xfs_buf_hold(bp);
    	bp->b_flags |= XBF_ASYNC;
    	xfs_buf_iosubmit(bp);
    	xfs_buf_lock(bp)
    	error = bp->b_error;
    	....
    	xfs_buf_relse(bp);
    
    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
    handled.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    cf53e99d
xfs_buf.c 43.2 KB