2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-23 12:43:55 +08:00

xfs: buffer ->bi_end_io function requires irq-safe lock

Reports have surfaced of a lockdep splat complaining about an
irq-safe -> irq-unsafe locking order in the xfs_buf_bio_end_io() bio
completion handler. This only occurs when I/O errors are present
because bp->b_lock is only acquired in this context to protect
setting an error on the buffer. The problem is that this lock can be
acquired with the (request_queue) q->queue_lock held. See
scsi_end_request() or ata_qc_schedule_eh(), for example.

Replace the locked test/set of b_io_error with a cmpxchg() call.
This eliminates the need for the lock and thus the lock ordering
problem goes away.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Brian Foster 2016-05-18 10:56:41 +10:00 committed by Dave Chinner
parent f55532a0c0
commit 9bdd9bd69b

View File

@ -1100,22 +1100,18 @@ xfs_bwrite(
return error; return error;
} }
STATIC void static void
xfs_buf_bio_end_io( xfs_buf_bio_end_io(
struct bio *bio) struct bio *bio)
{ {
xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private; struct xfs_buf *bp = (struct xfs_buf *)bio->bi_private;
/* /*
* don't overwrite existing errors - otherwise we can lose errors on * don't overwrite existing errors - otherwise we can lose errors on
* buffers that require multiple bios to complete. * buffers that require multiple bios to complete.
*/ */
if (bio->bi_error) { if (bio->bi_error)
spin_lock(&bp->b_lock); cmpxchg(&bp->b_io_error, 0, bio->bi_error);
if (!bp->b_io_error)
bp->b_io_error = bio->bi_error;
spin_unlock(&bp->b_lock);
}
if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ))
invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp));